add clock sync to repeater serial

This commit is contained in:
Florent 2026-01-27 09:19:19 -04:00
parent 92af5f7479
commit 246a84ee05
2 changed files with 9 additions and 2 deletions

View file

@ -4,7 +4,7 @@ build-backend = "hatchling.build"
[project]
name = "meshcore-cli"
version = "1.3.15"
version = "1.3.16"
authors = [
{ name="Florent de Lamotte", email="florent@frizoncorrea.fr" },
]

View file

@ -32,7 +32,7 @@ import re
from meshcore import MeshCore, EventType, logger
# Version
VERSION = "v1.3.15"
VERSION = "v1.3.16"
# default ble address is stored in a config file
MCCLI_CONFIG_DIR = str(Path.home()) + "/.config/meshcore/"
@ -3829,6 +3829,13 @@ async def repeater_loop(port, baudrate):
print(REPEATER_HELP)
continue
if cmd.lower() == "clock sync" or cmd.lower() == "st" or cmd.lower() == "sync_time":
cur_time = int(time.time())
print(f'{ANSI_GREEN}Syncing clock to'
f' {datetime.datetime.fromtimestamp(cur_time).strftime("%Y-%m-%d %H:%M:%S")}'
f' ({cur_time}){ANSI_END}')
cmd = f"time {cur_time}"
# Send command with CR terminator
ser.write(f"{cmd}\r".encode())
await asyncio.sleep(0.3)