Merge pull request #548 from hdhog/dev

fix: use explicit time <epoch> for repeater clock sync
This commit is contained in:
zjs81 authored and GitHub committed 2026-09-20 23:10:23 -07:00
commit 8fd67cfe48
3 files changed
+61 -1

No files matched your search

@@ -4,6 +4,18 @@ import '../models/path_selection.dart';
import '../connector/meshcore_connector.dart';
import '../connector/meshcore_protocol.dart';
/// 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 a
/// plain "clock sync" sets the repeater clock to the node clock. The official
/// meshcore-cli translates it to an explicit `time <epoch>` command instead;
/// do the same so the repeater always gets the phone's time.
String normalizeRepeaterClockSyncCommand(String command, {int? nowSeconds}) {
final epoch = nowSeconds ?? DateTime.now().millisecondsSinceEpoch ~/ 1000;
return command.trim().toLowerCase() == 'clock sync'
? 'time $epoch'
: command;
}
class RepeaterCommandService {
final MeshCoreConnector _connector;
final Map<String, Completer<String>> _pendingCommands = {};
@@ -25,6 +37,7 @@ class RepeaterCommandService {
Function(int)? onAttempt,
int retries = maxRetries,
}) async {
command = normalizeRepeaterClockSyncCommand(command);
final attemptCount = retries < 1 ? 1 : retries;
final selection = await _connector.preparePathForContactSend(repeater);
+5 -1
View File
@@ -7,6 +7,7 @@ import '../l10n/l10n.dart';
import '../models/contact.dart';
import '../l10n/contact_localization.dart';
import '../services/storage_service.dart';
import '../services/repeater_command_service.dart';
import '../connector/meshcore_connector.dart';
import '../connector/meshcore_protocol.dart';
import '../theme/mesh_theme.dart';
@@ -201,7 +202,10 @@ class _RepeaterLoginDialogState extends State<RepeaterLoginDialog> {
await _connector.sendFrame(
buildSendCliCommandFrame(
repeater.publicKey,
'clock sync',
normalizeRepeaterClockSyncCommand(
'clock sync',
nowSeconds: timestampSeconds,
),
timestampSeconds: timestampSeconds,
),
);