add something to the payload of clock sync

This commit is contained in:
Florent 2025-04-18 11:45:32 +02:00
parent 07a1fbc319
commit 637d28e1ad

View file

@ -3,26 +3,16 @@
mccli.py : CLI interface to MeschCore BLE companion app mccli.py : CLI interface to MeschCore BLE companion app
""" """
import asyncio import asyncio
import os import os, sys
import sys import time, datetime
import getopt import getopt, json, shlex
import json
import datetime
import time
import shlex
import logging import logging
from pathlib import Path from pathlib import Path
from meshcore import TCPConnection from meshcore import TCPConnection, BLEConnection, SerialConnection
from meshcore import BLEConnection from meshcore import MeshCore, EventType, logger
from meshcore import SerialConnection
from meshcore import MeshCore
from meshcore import EventType
from meshcore import logger
#logger.setLevel(logging.DEBUG) # default ble address is stored in a config file
# default address is stored in a config file
MCCLI_CONFIG_DIR = str(Path.home()) + "/.config/meshcore/" MCCLI_CONFIG_DIR = str(Path.home()) + "/.config/meshcore/"
MCCLI_ADDRESS = MCCLI_CONFIG_DIR + "default_address" MCCLI_ADDRESS = MCCLI_CONFIG_DIR + "default_address"
@ -271,7 +261,7 @@ async def next_cmd(mc, cmds, json_output=False):
case "help" : case "help" :
command_help() command_help()
case "ver" | "v" : case "ver" | "query" | "v" | "q":
res = await mc.commands.send_device_query() res = await mc.commands.send_device_query()
logger.debug(res) logger.debug(res)
if res.type == EventType.ERROR : if res.type == EventType.ERROR :
@ -298,6 +288,7 @@ async def next_cmd(mc, cmds, json_output=False):
else: else:
print(f"Error setting time: {res}") print(f"Error setting time: {res}")
elif json_output : elif json_output :
res.payload["ok"] = "time synced"
print(json.dumps(res.payload, indent=4)) print(json.dumps(res.payload, indent=4))
else : else :
print("Time synced") print("Time synced")
@ -322,6 +313,7 @@ async def next_cmd(mc, cmds, json_output=False):
else: else:
print(f"Error syncing time: {res}") print(f"Error syncing time: {res}")
elif json_output : elif json_output :
res.payload["ok"] = "time synced"
print(json.dumps(res.payload, indent=4)) print(json.dumps(res.payload, indent=4))
else: else:
print("Time synced") print("Time synced")