req_bstatus command to request status through binary req

This commit is contained in:
Florent 2025-08-29 20:19:25 +02:00
parent 36bc91798c
commit d2103bef25
2 changed files with 18 additions and 5 deletions

View file

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

View file

@ -8,7 +8,7 @@ import time, datetime
import getopt, json, shlex, re
import logging
import requests
from bleak import BleakScanner
from bleak import BleakScanner, BleakClient
import serial.tools.list_ports
from pathlib import Path
import traceback
@ -19,12 +19,11 @@ from prompt_toolkit.history import FileHistory
from prompt_toolkit.formatted_text import ANSI
from prompt_toolkit.key_binding import KeyBindings
from prompt_toolkit.shortcuts import radiolist_dialog
from bleak import BleakClient
from meshcore import MeshCore, EventType, logger
# Version
VERSION = "v1.1.17"
VERSION = "v1.1.18"
# default ble address is stored in a config file
MCCLI_CONFIG_DIR = str(Path.home()) + "/.config/meshcore/"
@ -1567,7 +1566,7 @@ async def next_cmd(mc, cmds, json_output=False):
inp = inp if inp != "" else "direct"
print(f"Path for {contact['adv_name']}: out {outp}, in {inp}")
case "req_tele2" :
case "req_btele" :
argnum = 1
await mc.ensure_contacts()
contact = mc.get_contact_by_name(cmds[1])
@ -1581,6 +1580,20 @@ async def next_cmd(mc, cmds, json_output=False):
else :
print(json.dumps(res))
case "req_bstatus" :
argnum = 1
await mc.ensure_contacts()
contact = mc.get_contact_by_name(cmds[1])
timeout = 0 if not "timeout" in contact else contact["timeout"]
res = await mc.commands.req_status(contact, timeout)
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_mma" | "rm":
argnum = 3
await mc.ensure_contacts()