fix(#970): act on the adversarial review, cite the merged firmware

No preview is sent while a slot transfer runs, so neither can take the other's refusal. A final SLOT_SET reply that is not 0 is no longer read as a commit. Back during a read or save now says why it is held. Comments now cite meshcore-firmware f3d30a88 on firmware-base, which merged 3e788e2a with the contract files unchanged. The wider attribution fix is #991.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
feat/975-settings-restructure
diffwireauto 1 month ago
parent 89548d30af
commit ed96ffa3e8

@ -1225,6 +1225,9 @@ class MeshCoreConnector extends ChangeNotifier {
/// refused the id (the refusal is then shown like any other).
Future<TunePlayResult?> playTune(int tuneId) async {
if (!_deviceUiGateOpen('play', advertised: supportsTunes)) return null;
// A refusal names no sub-code, so a preview sent mid-transfer could take
// the transfer's refusal, or hand it one.
if (_tuneSlotTransferActive) return null;
_appDebugLogService?.info('play -> $tuneId [0xC5][0x11]', tag: 'DeviceUI');
final reply = await _sendDeviceUiAndAwait(
buildTunePlayFrame(tuneId),
@ -1388,6 +1391,14 @@ class MeshCoreConnector extends ChangeNotifier {
if (more && reply.slotAccepted!.accepted != end) {
return _SlotPush.displaced;
}
// A commit answers 0. Anything else is not a commit, whatever it is.
if (!more && reply.slotAccepted!.accepted != 0) {
_setDeviceUiError(
DeviceUiSurface.tuneSlot,
'The radio did not confirm saving this tune. Nothing was changed.',
);
return _SlotPush.failed;
}
offset = end;
onProgress?.call(offset, bytes.length);
} while (offset < bytes.length);

@ -606,7 +606,7 @@ bool firmwareSupportsNotifyScope(int? offbandCaps2) =>
/// 0x12), channel tune (0x0B, 0x0C), event tones (0x0F, 0x10) and preview
/// (0x11). Firmware sets it where the UI plays every sound through its tune
/// engine, which needs a buzzer but is not implied by one, so a radio can
/// advertise the scope bit without this (meshcore-firmware `3e788e2a`).
/// advertise the scope bit without this (meshcore-firmware `f3d30a88`).
const int offbandCap2Tunes = 0x10;
/// GPS mode and Power-save interval over `0xC5` sub-codes 0x0D / 0x0E (#969).

@ -4,7 +4,7 @@ import 'offband_device_ui.dart';
/// The badge's own display and battery settings over `0xC5` (#987): both
/// text sizes, Screen off, time zone and the battery full point. Gated on caps
/// byte 2 `0x40` SCREEN_SETTINGS (meshcore-firmware `3e788e2a`).
/// byte 2 `0x40` SCREEN_SETTINGS (meshcore-firmware `f3d30a88`).
///
/// Every reply, GET or SET, is the whole set re-read after the write:
/// `[0xC5][sub][nav][msg][scr_stored:2][scr_secs:2][tz][batt_stored:2]

@ -5,7 +5,7 @@ import 'offband_device_ui.dart';
/// The radio's tune system over `0xC5` (#970, #971, #986): the built-in tune
/// table, the eight custom RTTTL slots, the six event tones and preview.
///
/// Gated on caps byte 2 `0x10` TUNES (meshcore-firmware `3e788e2a`). The
/// Gated on caps byte 2 `0x10` TUNES (meshcore-firmware `f3d30a88`). The
/// contract lives in firmware's `OffbandConfigProtocol.h`; the tables and the
/// validator below are ports of `Tunes.h` and `TuneSlots.h` at that commit.
@ -336,7 +336,7 @@ bool _isDefaultsSep(int c) => c == 0x2C || c == 0x3A;
const int _colon = 0x3A;
/// Port of firmware `rtttlProblem()` (`Tunes.h`, `3e788e2a`), step for step.
/// Port of firmware `rtttlProblem()` (`Tunes.h`, `f3d30a88`), step for step.
RtttlProblem rtttlProblem(String rtttl) {
final s = rtttl.codeUnits;
if (s.isEmpty) return RtttlProblem.empty;

@ -1,5 +1,5 @@
/// The badge's time zone table, a copy of firmware `src/helpers/TimeZones.h`
/// at meshcore-firmware `3e788e2a` (#987).
/// on meshcore-firmware `firmware-base` at `f3d30a88` (#987).
///
/// The radio stores a zone as an index into this list, so the order is the
/// contract. Firmware keeps it append-only ("Append only; never reorder"), so

@ -202,7 +202,15 @@ class _TuneSlotEditorScreenState extends State<TuneSlotEditorScreen> {
// halfway, and the radio would keep the old tune.
canPop: !_dirty && !_busy,
onPopInvokedWithResult: (didPop, _) async {
if (didPop || _busy) return;
if (didPop) return;
if (_busy) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Wait for the radio to finish, then go back.'),
),
);
return;
}
final navigator = Navigator.of(context);
if (await _confirmDiscard()) navigator.pop();
},

@ -212,7 +212,7 @@ void main() {
test('the new bits collide with no allocated caps-byte-2 bit', () {
// Firmware allocates 0x01 scope, 0x02 matrix, 0x04 indicators, 0x08
// packet hash (OffbandConfigProtocol.h on firmware-base), and
// 3e788e2a adds 0x10 TUNES, 0x20 GPS mode, 0x40 SCREEN_SETTINGS.
// f3d30a88 adds 0x10 TUNES, 0x20 GPS mode, 0x40 SCREEN_SETTINGS.
const allocated = 0x01 | 0x02 | 0x04 | 0x08;
const added = [
offbandCap2Tunes,

@ -1,5 +1,5 @@
// #987: the badge's screen and battery settings over 0xC5 0x13 to 0x17, and
// the time zone table, against meshcore-firmware 3e788e2a.
// the time zone table, against meshcore-firmware f3d30a88.
import 'dart:typed_data';

@ -1,5 +1,5 @@
// #970, #986: the tune codec over 0xC5, against the contract in
// meshcore-firmware 3e788e2a OffbandConfigProtocol.h, and the ports of its
// meshcore-firmware f3d30a88 OffbandConfigProtocol.h, and the ports of its
// RTTTL validator and slot-name rule.
import 'dart:typed_data';

@ -277,6 +277,29 @@ void main() {
expect(sent.first, equals([0xC5, 0x0A, 3, 0, 0]));
});
test('a final reply that is not 0 is not a commit', () async {
connector.handleFrameForTest(deviceInfo(caps2: 0x10));
radio = (f) => f[1] == 0x0A
? [
[0xC5, 0x0A, f[2], 5],
]
: const [];
expect(await connector.saveTuneSlot(0, 'x:d=4:c'), isFalse);
expect(connector.deviceUiErrorSurface, DeviceUiSurface.tuneSlot);
});
test('no preview is sent while a slot transfer is running', () async {
connector.handleFrameForTest(deviceInfo(caps2: 0x10));
sent.clear();
final read = connector.readTuneSlot(0);
await Future<void>.delayed(Duration.zero);
expect(connector.tuneSlotTransferActive, isTrue);
expect(await connector.playTune(3), isNull);
expect(sentSub({0x11}), isFalse);
connector.handleFrameForTest([0xC5, 0x12, 0, 0, 0]);
expect(await read, '');
});
test('a tune over 240 characters is never sent', () async {
connector.handleFrameForTest(deviceInfo(caps2: 0x10));
sent.clear();

Loading…
Cancel
Save

Powered by TurnKey Linux.