From 2bb2dfff02eac56c355149e993c587223a32864b Mon Sep 17 00:00:00 2001 From: Florent Date: Thu, 9 Apr 2026 11:47:47 +0200 Subject: [PATCH] v1.5.6 --- flake.nix | 4 +-- pyproject.toml | 4 +-- src/meshcore_cli/meshcore_cli.py | 48 ++++++++++++-------------------- 3 files changed, 22 insertions(+), 34 deletions(-) diff --git a/flake.nix b/flake.nix index cb7c0c9..4117a56 100644 --- a/flake.nix +++ b/flake.nix @@ -17,12 +17,12 @@ meshcore = python3Packages.buildPythonPackage rec { pname = "meshcore"; - version = "2.3.5"; + version = "2.3.6"; pyproject = true; src = python3Packages.fetchPypi { inherit pname version; - sha256 = "sha256-EUK0iFaCN2tpOL3XL2ejVLGz/gLTdvzPpvgBxETLL3w="; + sha256 = "sha256-l9/wDgRfzPSZGIt+tIUITs/mf/AeEIMDN9DXAbMSzSs="; }; build-system = [ python3Packages.hatchling ]; diff --git a/pyproject.toml b/pyproject.toml index 812b22c..94a11e8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "meshcore-cli" -version = "1.5.5" +version = "1.5.6" authors = [ { name="Florent de Lamotte", email="florent@frizoncorrea.fr" }, ] @@ -17,7 +17,7 @@ classifiers = [ ] license = "MIT" license-files = ["LICEN[CS]E*"] -dependencies = [ "meshcore >= 2.3.5", +dependencies = [ "meshcore >= 2.3.6", "bleak >= 0.22", "prompt_toolkit >= 3.0.50", "requests >= 2.28.0" ] diff --git a/src/meshcore_cli/meshcore_cli.py b/src/meshcore_cli/meshcore_cli.py index 535db28..021d70e 100644 --- a/src/meshcore_cli/meshcore_cli.py +++ b/src/meshcore_cli/meshcore_cli.py @@ -1809,16 +1809,12 @@ async def print_trace_to (mc, contact): async def discover_path(mc, contact): await mc.ensure_contacts() - res = await mc.commands.send_path_discovery(contact) - if res.type == EventType.ERROR: - return None - else: - timeout = res.payload["suggested_timeout"]/600 if not "timeout" in contact or contact['timeout']==0 else contact["timeout"] - res = await mc.wait_for_event(EventType.PATH_RESPONSE, timeout=timeout) - if res is None: - return {"error": "timeout"} - else : - return res.payload + timeout = 0 if not "timeout" in contact else contact["timeout"] + res = await mc.commands.send_path_discovery_sync(contact, timeout) + if res is None: + return {"error": "timeout"} + else : + return res.payload async def print_disc_trace_to (mc, contact): p = await discover_path(mc, contact) @@ -2789,29 +2785,21 @@ async def next_cmd(mc, cmds, json_output=False): sess = PromptSession("Password: ", is_password=True) password = await sess.prompt_async() - res = await mc.commands.send_login(contact, password) + timeout = 0 if not "timeout" in contact else contact["timeout"] + res = await mc.commands.send_login_sync(contact, password, timeout = timeout) logger.debug(res) - if res.type == EventType.ERROR: - if json_output : - print(json.dumps({"error" : "Error while login"})) + if res is None: + print("Login failed : Error or Timeout waiting response") + elif json_output : + if res.type == EventType.LOGIN_SUCCESS: + print(json.dumps({"login_success" : True}, indent=4)) else: - print(f"Error while loging: {res}") - else: # should probably wait for the good ack - timeout = res.payload["suggested_timeout"]/800 if not "timeout" in contact or contact['timeout']==0 else contact["timeout"] - res = await mc.wait_for_event(EventType.LOGIN_SUCCESS, timeout=timeout) - logger.debug(res) - if res is None: - print("Login failed : Timeout waiting response") - elif json_output : - if res.type == EventType.LOGIN_SUCCESS: - print(json.dumps({"login_success" : True}, indent=4)) - else: - print(json.dumps({"login_success" : False, "error" : "login failed"}, indent=4)) + print(json.dumps({"login_success" : False, "error" : "login failed"}, indent=4)) + else: + if res.type == EventType.LOGIN_SUCCESS: + print("Login success") else: - if res.type == EventType.LOGIN_SUCCESS: - print("Login success") - else: - print("Login failed") + print("Login failed") case "logout" : argnum = 1