Contact Settings: add Hop limit
Sets the companion firmware's autoadd_max_hops (optional third byte of CMD_SET_AUTOADD_CONFIG). The radio only auto-adds contacts heard in fewer hops than the limit; 0 means no limit. Shown only when the radio reports the value. Review mode stores it like the firmware. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
fc7bbe9e02
commit
6a5d15209b
46 files changed
+628
-1
No files matched your search
@@ -0,0 +1,33 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:meshcore_open/connector/meshcore_protocol.dart';
|
||||
|
||||
void main() {
|
||||
// CMD_SET_AUTOADD_CONFIG: [cmd][flags][autoadd_max_hops?]. Firmware stores
|
||||
// the third byte (capped at 64) only when it is present.
|
||||
group('buildSetAutoAddConfigFrame', () {
|
||||
Iterable<int> frame({int? maxHops}) => buildSetAutoAddConfigFrame(
|
||||
autoAddChat: true,
|
||||
autoAddRepeater: false,
|
||||
autoAddRoomServer: true,
|
||||
autoAddSensor: false,
|
||||
overwriteOldest: true,
|
||||
maxHops: maxHops,
|
||||
);
|
||||
|
||||
const flags =
|
||||
autoAddChatFlag | autoAddRoomServerFlag | autoAddOverwriteOldestFlag;
|
||||
|
||||
test('omits the hop limit when not given', () {
|
||||
expect(frame(), [cmdSetAutoAddConfig, flags]);
|
||||
});
|
||||
|
||||
test('appends the hop limit, including 0 (no limit)', () {
|
||||
expect(frame(maxHops: 8), [cmdSetAutoAddConfig, flags, 8]);
|
||||
expect(frame(maxHops: 0), [cmdSetAutoAddConfig, flags, 0]);
|
||||
});
|
||||
|
||||
test('caps the hop limit at 64', () {
|
||||
expect(frame(maxHops: 200), [cmdSetAutoAddConfig, flags, 64]);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user