From bf2f95a63ac4bc593be295d1bcc2cdcb467bd49a Mon Sep 17 00:00:00 2001 From: Florent Date: Fri, 3 Oct 2025 13:25:42 +0200 Subject: [PATCH] autoupdate on by default, -P option for pairing --- pyproject.toml | 4 ++-- src/meshcore_cli/meshcore_cli.py | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 55319d1..61c3471 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "meshcore-cli" -version = "1.1.23" +version = "1.1.24" authors = [ { name="Florent de Lamotte", email="florent@frizoncorrea.fr" }, ] @@ -17,7 +17,7 @@ classifiers = [ ] license = "MIT" license-files = ["LICEN[CS]E*"] -dependencies = [ "meshcore >= 2.1.7", "prompt_toolkit >= 3.0.50", "requests >= 2.28.0" ] +dependencies = [ "meshcore >= 2.1.9", "prompt_toolkit >= 3.0.50", "requests >= 2.28.0" ] [project.urls] Homepage = "https://github.com/fdlamotte/meshcore-cli" diff --git a/src/meshcore_cli/meshcore_cli.py b/src/meshcore_cli/meshcore_cli.py index 3bb1e82..ff4ad3a 100644 --- a/src/meshcore_cli/meshcore_cli.py +++ b/src/meshcore_cli/meshcore_cli.py @@ -23,7 +23,7 @@ from prompt_toolkit.shortcuts import radiolist_dialog from meshcore import MeshCore, EventType, logger # Version -VERSION = "v1.1.23" +VERSION = "v1.1.24" # default ble address is stored in a config file MCCLI_CONFIG_DIR = str(Path.home()) + "/.config/meshcore/" @@ -2160,6 +2160,7 @@ def usage () : -T : timeout for the ble scan (-S and -l) default 2s -a
: specifies device address (can be a name) -d : filter meshcore devices with name or address + -P : forces pairing via the OS -t : connects via tcp/ip -p : specifies tcp port (default 5000) -s : use serial port @@ -2179,19 +2180,22 @@ async def main(argv): serial_port = None baudrate = 115200 timeout = 2 + pin = None # If there is an address in config file, use it by default # unless an arg is explicitely given if os.path.exists(MCCLI_ADDRESS) : with open(MCCLI_ADDRESS, encoding="utf-8") as f : address = f.readline().strip() - opts, args = getopt.getopt(argv, "a:d:s:ht:p:b:jDhvSlT:") + opts, args = getopt.getopt(argv, "a:d:s:ht:p:b:jDhvSlT:P") for opt, arg in opts : match opt: case "-d" : # name specified on cmdline address = arg case "-a" : # address specified on cmdline address = arg + case "-P" : # pairing + pin = True case "-s" : # serial port serial_port = arg case "-b" : @@ -2297,7 +2301,7 @@ async def main(argv): logger.info(f"Couldn't find device {address}") return - mc = await MeshCore.create_ble(address=address, device=device, client=client, debug=debug, only_error=json_output) + mc = await MeshCore.create_ble(address=address, device=device, client=client, debug=debug, only_error=json_output, pin=pin) # Store device address in configuration if os.path.isdir(MCCLI_CONFIG_DIR) : @@ -2312,6 +2316,8 @@ async def main(argv): mc.subscribe(EventType.PATH_UPDATE, handle_path_update) mc.subscribe(EventType.NEW_CONTACT, handle_new_contact) + mc.auto_update_contacts = True + res = await mc.commands.send_device_query() if res.type == EventType.ERROR : logger.error(f"Error while querying device: {res}")