meshcore-cli 1.5.4__tar.gz → 1.5.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: meshcore-cli
3
- Version: 1.5.4
3
+ Version: 1.5.6
4
4
  Summary: Command line interface to meshcore companion radios and repeaters
5
5
  Project-URL: Homepage, https://github.com/fdlamotte/meshcore-cli
6
6
  Project-URL: Issues, https://github.com/fdlamotte/meshcore-cli/issues
@@ -11,7 +11,7 @@ Classifier: Operating System :: OS Independent
11
11
  Classifier: Programming Language :: Python :: 3
12
12
  Requires-Python: >=3.10
13
13
  Requires-Dist: bleak>=0.22
14
- Requires-Dist: meshcore>=2.3.2
14
+ Requires-Dist: meshcore>=2.3.6
15
15
  Requires-Dist: prompt-toolkit>=3.0.50
16
16
  Requires-Dist: requests>=2.28.0
17
17
  Description-Content-Type: text/markdown
@@ -17,12 +17,12 @@
17
17
 
18
18
  meshcore = python3Packages.buildPythonPackage rec {
19
19
  pname = "meshcore";
20
- version = "2.3.2";
20
+ version = "2.3.6";
21
21
  pyproject = true;
22
22
 
23
23
  src = python3Packages.fetchPypi {
24
24
  inherit pname version;
25
- sha256 = "sha256-mM64woqKvltbd/CUGzD5m6PU/CNQ923pm2yKTneNrW8=";
25
+ sha256 = "sha256-EUK0iFaCN2tpOL3XL2ejVLGz/gLTdvzPpvgBxETLL3w=";
26
26
  };
27
27
 
28
28
  build-system = [ python3Packages.hatchling ];
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "meshcore-cli"
7
- version = "1.5.4"
7
+ version = "1.5.6"
8
8
  authors = [
9
9
  { name="Florent de Lamotte", email="florent@frizoncorrea.fr" },
10
10
  ]
@@ -17,7 +17,7 @@ classifiers = [
17
17
  ]
18
18
  license = "MIT"
19
19
  license-files = ["LICEN[CS]E*"]
20
- dependencies = [ "meshcore >= 2.3.2",
20
+ dependencies = [ "meshcore >= 2.3.6",
21
21
  "bleak >= 0.22",
22
22
  "prompt_toolkit >= 3.0.50",
23
23
  "requests >= 2.28.0" ]
@@ -35,7 +35,7 @@ import re
35
35
  from meshcore import MeshCore, EventType, logger
36
36
 
37
37
  # Version
38
- VERSION = "v1.5.4"
38
+ VERSION = "v1.5.5"
39
39
 
40
40
  # default ble address is stored in a config file
41
41
  MCCLI_CONFIG_DIR = str(Path.home()) + "/.config/meshcore/"
@@ -1809,16 +1809,12 @@ async def print_trace_to (mc, contact):
1809
1809
 
1810
1810
  async def discover_path(mc, contact):
1811
1811
  await mc.ensure_contacts()
1812
- res = await mc.commands.send_path_discovery(contact)
1813
- if res.type == EventType.ERROR:
1814
- return None
1815
- else:
1816
- timeout = res.payload["suggested_timeout"]/600 if not "timeout" in contact or contact['timeout']==0 else contact["timeout"]
1817
- res = await mc.wait_for_event(EventType.PATH_RESPONSE, timeout=timeout)
1818
- if res is None:
1819
- return {"error": "timeout"}
1820
- else :
1821
- return res.payload
1812
+ timeout = 0 if not "timeout" in contact else contact["timeout"]
1813
+ res = await mc.commands.send_path_discovery_sync(contact, timeout)
1814
+ if res is None:
1815
+ return {"error": "timeout"}
1816
+ else :
1817
+ return res.payload
1822
1818
 
1823
1819
  async def print_disc_trace_to (mc, contact):
1824
1820
  p = await discover_path(mc, contact)
@@ -2614,7 +2610,7 @@ async def next_cmd(mc, cmds, json_output=False):
2614
2610
  elif len(cmds[2]) != 32:
2615
2611
  res = None
2616
2612
  else:
2617
- res = await set_channel(mc, "", cmds[1], bytes.fromhex(cmds[3]))
2613
+ res = await set_channel(mc, "", cmds[1], bytes.fromhex(cmds[2]))
2618
2614
  if res is None:
2619
2615
  print("Error adding channel")
2620
2616
 
@@ -2789,29 +2785,21 @@ async def next_cmd(mc, cmds, json_output=False):
2789
2785
  sess = PromptSession("Password: ", is_password=True)
2790
2786
  password = await sess.prompt_async()
2791
2787
 
2792
- res = await mc.commands.send_login(contact, password)
2788
+ timeout = 0 if not "timeout" in contact else contact["timeout"]
2789
+ res = await mc.commands.send_login_sync(contact, password, timeout = timeout)
2793
2790
  logger.debug(res)
2794
- if res.type == EventType.ERROR:
2795
- if json_output :
2796
- print(json.dumps({"error" : "Error while login"}))
2791
+ if res is None:
2792
+ print("Login failed : Error or Timeout waiting response")
2793
+ elif json_output :
2794
+ if res.type == EventType.LOGIN_SUCCESS:
2795
+ print(json.dumps({"login_success" : True}, indent=4))
2797
2796
  else:
2798
- print(f"Error while loging: {res}")
2799
- else: # should probably wait for the good ack
2800
- timeout = res.payload["suggested_timeout"]/800 if not "timeout" in contact or contact['timeout']==0 else contact["timeout"]
2801
- res = await mc.wait_for_event(EventType.LOGIN_SUCCESS, timeout=timeout)
2802
- logger.debug(res)
2803
- if res is None:
2804
- print("Login failed : Timeout waiting response")
2805
- elif json_output :
2806
- if res.type == EventType.LOGIN_SUCCESS:
2807
- print(json.dumps({"login_success" : True}, indent=4))
2808
- else:
2809
- print(json.dumps({"login_success" : False, "error" : "login failed"}, indent=4))
2797
+ print(json.dumps({"login_success" : False, "error" : "login failed"}, indent=4))
2798
+ else:
2799
+ if res.type == EventType.LOGIN_SUCCESS:
2800
+ print("Login success")
2810
2801
  else:
2811
- if res.type == EventType.LOGIN_SUCCESS:
2812
- print("Login success")
2813
- else:
2814
- print("Login failed")
2802
+ print("Login failed")
2815
2803
 
2816
2804
  case "logout" :
2817
2805
  argnum = 1
@@ -3281,6 +3269,30 @@ async def next_cmd(mc, cmds, json_output=False):
3281
3269
  else:
3282
3270
  print(json.dumps(contact, indent=4))
3283
3271
 
3272
+ case "add_contact" :
3273
+ argnum = 3 # key type name
3274
+ contact = {
3275
+ "public_key": cmds[1],
3276
+ "type" : int (cmds[2]),
3277
+ "flags" : 0,
3278
+ "out_path_len" : 0,
3279
+ "out_path" : "",
3280
+ "out_path_hash_mode" : 0,
3281
+ "adv_name" : cmds[3],
3282
+ "adv_lat" : 0,
3283
+ "adv_lon" : 0,
3284
+ "last_advert" : 0,
3285
+ }
3286
+ try:
3287
+ res = await mc.commands.update_contact(contact)
3288
+ logger.debug(res)
3289
+ if res.type == EventType.ERROR:
3290
+ print(f"Error adding contact: {res}")
3291
+ elif json_output :
3292
+ print(json.dumps(res.payload, indent=4))
3293
+ except ValueError:
3294
+ print(f"Error ! Command format add_contact key type namez")
3295
+
3284
3296
  case "change_path" | "cp":
3285
3297
  argnum = 2
3286
3298
  contact = await get_contact_from_arg(mc, cmds[1])
File without changes
File without changes
File without changes
File without changes