From 637d28e1adb79ecd4718ff6a54ffbf5d156fb3e6 Mon Sep 17 00:00:00 2001 From: Florent Date: Fri, 18 Apr 2025 11:45:32 +0200 Subject: [PATCH] add something to the payload of clock sync --- src/meshcore_cli/meshcore_cli.py | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/src/meshcore_cli/meshcore_cli.py b/src/meshcore_cli/meshcore_cli.py index a62d95b..fa14bf3 100644 --- a/src/meshcore_cli/meshcore_cli.py +++ b/src/meshcore_cli/meshcore_cli.py @@ -3,26 +3,16 @@ mccli.py : CLI interface to MeschCore BLE companion app """ import asyncio -import os -import sys -import getopt -import json -import datetime -import time -import shlex +import os, sys +import time, datetime +import getopt, json, shlex import logging from pathlib import Path -from meshcore import TCPConnection -from meshcore import BLEConnection -from meshcore import SerialConnection -from meshcore import MeshCore -from meshcore import EventType -from meshcore import logger +from meshcore import TCPConnection, BLEConnection, SerialConnection +from meshcore import MeshCore, EventType, logger -#logger.setLevel(logging.DEBUG) - -# default address is stored in a config file +# default ble address is stored in a config file MCCLI_CONFIG_DIR = str(Path.home()) + "/.config/meshcore/" MCCLI_ADDRESS = MCCLI_CONFIG_DIR + "default_address" @@ -271,7 +261,7 @@ async def next_cmd(mc, cmds, json_output=False): case "help" : command_help() - case "ver" | "v" : + case "ver" | "query" | "v" | "q": res = await mc.commands.send_device_query() logger.debug(res) if res.type == EventType.ERROR : @@ -298,6 +288,7 @@ async def next_cmd(mc, cmds, json_output=False): else: print(f"Error setting time: {res}") elif json_output : + res.payload["ok"] = "time synced" print(json.dumps(res.payload, indent=4)) else : print("Time synced") @@ -322,6 +313,7 @@ async def next_cmd(mc, cmds, json_output=False): else: print(f"Error syncing time: {res}") elif json_output : + res.payload["ok"] = "time synced" print(json.dumps(res.payload, indent=4)) else: print("Time synced")