Companion firmware (MeshCore commit 4a869163, 2025-12-30) replaces the CLI frame timestamp with the companion node's RTC for TXT_TYPE_CLI_DATA, so "clock sync" sets the repeater clock to the node RTC. Nodes with a wrong RTC push repeater clocks years into the future; firmware cannot set the clock backwards without clkreboot. - RepeaterCommandService: translate "clock sync" to "time <phone epoch>" before sending, matching official meshcore-cli behavior - repeater login dialog: send "time <epoch>" for auto clock sync after login (this path bypasses RepeaterCommandService) - add unit tests for the command translation Ref: https://github.com/zjs81/meshcore-open/issues/464
44 lines
1.4 KiB
Dart
44 lines
1.4 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:meshcore_open/services/repeater_command_service.dart';
|
|
|
|
void main() {
|
|
group('normalizeRepeaterClockSyncCommand', () {
|
|
test('translates "clock sync" to explicit time command', () {
|
|
final result = normalizeRepeaterClockSyncCommand(
|
|
'clock sync',
|
|
nowSeconds: 1787900000,
|
|
);
|
|
expect(result, 'time 1787900000');
|
|
});
|
|
|
|
test('is case-insensitive and tolerates surrounding whitespace', () {
|
|
expect(
|
|
normalizeRepeaterClockSyncCommand(' Clock Sync ', nowSeconds: 1),
|
|
'time 1',
|
|
);
|
|
});
|
|
|
|
test('passes other commands through unchanged', () {
|
|
expect(normalizeRepeaterClockSyncCommand('clock', nowSeconds: 1), 'clock');
|
|
expect(
|
|
normalizeRepeaterClockSyncCommand('get radio', nowSeconds: 1),
|
|
'get radio',
|
|
);
|
|
expect(
|
|
normalizeRepeaterClockSyncCommand('time 123', nowSeconds: 1),
|
|
'time 123',
|
|
);
|
|
});
|
|
|
|
test('uses current time when nowSeconds is omitted', () {
|
|
final before = DateTime.now().millisecondsSinceEpoch ~/ 1000;
|
|
final result = normalizeRepeaterClockSyncCommand('clock sync');
|
|
final after = DateTime.now().millisecondsSinceEpoch ~/ 1000;
|
|
|
|
expect(result, startsWith('time '));
|
|
final epoch = int.parse(result.substring('time '.length));
|
|
expect(epoch, inInclusiveRange(before, after));
|
|
});
|
|
});
|
|
}
|