From 492254deb9461ed3350f2f0f402db55037a919ba Mon Sep 17 00:00:00 2001 From: Florent Date: Tue, 15 Jul 2025 16:47:53 +0200 Subject: [PATCH] req_amm --- src/meshcore_cli/meshcore_cli.py | 34 +++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/meshcore_cli/meshcore_cli.py b/src/meshcore_cli/meshcore_cli.py index 9b75acd..b4b6ae9 100644 --- a/src/meshcore_cli/meshcore_cli.py +++ b/src/meshcore_cli/meshcore_cli.py @@ -10,6 +10,7 @@ import logging import requests from bleak import BleakScanner from pathlib import Path +import traceback from prompt_toolkit.shortcuts import PromptSession from prompt_toolkit.shortcuts import CompleteStyle from prompt_toolkit.completion import NestedCompleter @@ -657,6 +658,11 @@ Line starting with \"$\" or \".\" will issue a meshcli command. args = [cmds[0], contact['adv_name'], cmds[1]] await process_cmds(mc, args) + elif contact["type"] > 3 and (line.startswith("req_amm ")) : + cmds = line.split(" ", 3) + args = [cmds[0], contact['adv_name'], cmds[1], cmds[2]] + await process_cmds(mc, args) + elif line.startswith(":") : # : will send a command to current recipient args=["cmd", contact['adv_name'], line[1:]] await process_cmds(mc, args) @@ -1361,6 +1367,32 @@ async def next_cmd(mc, cmds, json_output=False): else : print(json.dumps(res.payload, indent=4)) + case "req_tele2" : + argnum = 1 + await mc.ensure_contacts() + contact = mc.get_contact_by_name(cmds[1]) + res = await mc.commands.binary.req_telemetry(contact) + if res is None : + if json_output : + print(json.dumps({"error" : "Getting data"})) + else: + print("Error getting data") + else : + print(json.dumps(res)) + + case "req_amm" : + argnum = 3 + await mc.ensure_contacts() + contact = mc.get_contact_by_name(cmds[1]) + res = await mc.commands.binary.req_amm(contact, int(cmds[2]), int(cmds[3])) + if res is None : + if json_output : + print(json.dumps({"error" : "Getting data"})) + else: + print("Error getting data") + else : + print(json.dumps(res, indent=4)) + case "req_binary" : argnum = 2 await mc.ensure_contacts() @@ -1374,7 +1406,6 @@ async def next_cmd(mc, cmds, json_output=False): else : print(json.dumps(res)) - case "contacts" | "list" | "lc": await mc.ensure_contacts(follow=True) res = mc.contacts @@ -1988,6 +2019,7 @@ def cli(): print("\nExited cleanly") except Exception as e: print(f"Error: {e}") + traceback.print_exc() if __name__ == '__main__': cli()