meshcore-cli 1.2.4__py3-none-any.whl → 1.2.5__py3-none-any.whl

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.
@@ -33,7 +33,7 @@ import re
33
33
  from meshcore import MeshCore, EventType, logger
34
34
 
35
35
  # Version
36
- VERSION = "v1.2.4"
36
+ VERSION = "v1.2.5"
37
37
 
38
38
  # default ble address is stored in a config file
39
39
  MCCLI_CONFIG_DIR = str(Path.home()) + "/.config/meshcore/"
@@ -211,6 +211,7 @@ async def handle_log_rx(event):
211
211
 
212
212
  if handle_log_rx.channel_echoes:
213
213
  if pkt[0] == 0x15:
214
+ chan_name = ""
214
215
  path_len = pkt[1]
215
216
  path = pkt[2:path_len+2].hex()
216
217
  chan_hash = pkt[path_len+2:path_len+3].hex()
@@ -226,27 +227,29 @@ async def handle_log_rx(event):
226
227
  break
227
228
 
228
229
  if channel is None :
229
- chan_name = chan_hash
230
- message = msg.hex()
230
+ if handle_log_rx.echo_unk_chans:
231
+ chan_name = chan_hash
232
+ message = msg.hex()
231
233
  else:
232
234
  chan_name = channel["channel_name"]
233
235
  aes_key = bytes.fromhex(channel["channel_secret"])
234
236
  cipher = AES.new(aes_key, AES.MODE_ECB)
235
237
  message = cipher.decrypt(msg)[5:].decode("utf-8").strip("\x00")
236
238
 
237
- width = os.get_terminal_size().columns
238
- cars = width - 13 - 2 * path_len - len(chan_name) - 1
239
- dispmsg = message[0:cars]
240
- txt = f"{ANSI_LIGHT_GRAY}{chan_name} {ANSI_DGREEN}{dispmsg+(cars-len(dispmsg))*' '} {ANSI_YELLOW}[{path}]{ANSI_LIGHT_GRAY}{event.payload['snr']:6,.2f}{event.payload['rssi']:4}{ANSI_END}"
241
- if handle_message.above:
242
- print_above(txt)
243
- else:
244
- print(txt)
245
- return
239
+ if chan_name != "" :
240
+ width = os.get_terminal_size().columns
241
+ cars = width - 13 - 2 * path_len - len(chan_name) - 1
242
+ dispmsg = message[0:cars]
243
+ txt = f"{ANSI_LIGHT_GRAY}{chan_name} {ANSI_DGREEN}{dispmsg+(cars-len(dispmsg))*' '} {ANSI_YELLOW}[{path}]{ANSI_LIGHT_GRAY}{event.payload['snr']:6,.2f}{event.payload['rssi']:4}{ANSI_END}"
244
+ if handle_message.above:
245
+ print_above(txt)
246
+ else:
247
+ print(txt)
246
248
 
247
249
  handle_log_rx.json_log_rx = False
248
250
  handle_log_rx.channel_echoes = False
249
251
  handle_log_rx.mc = None
252
+ handle_log_rx.echo_unk_chans=False
250
253
 
251
254
  async def handle_advert(event):
252
255
  if not handle_advert.print_adverts:
@@ -396,6 +399,10 @@ def make_completion_dict(contacts, pending={}, to=None, channels=None):
396
399
  for c in it :
397
400
  contact_list[c[1]['adv_name']] = None
398
401
 
402
+ pit = iter(pending.items())
403
+ for c in pit :
404
+ pending_list[c[1]['adv_name']] = None
405
+
399
406
  pit = iter(pending.items())
400
407
  for c in pit :
401
408
  pending_list[c[1]['public_key']] = None
@@ -474,6 +481,7 @@ def make_completion_dict(contacts, pending={}, to=None, channels=None):
474
481
  "print_adverts" : {"on":None, "off":None},
475
482
  "json_log_rx" : {"on":None, "off":None},
476
483
  "channel_echoes" : {"on":None, "off":None},
484
+ "echo_unk_chans" : {"on":None, "off":None},
477
485
  "print_new_contacts" : {"on": None, "off":None},
478
486
  "print_path_updates" : {"on":None,"off":None},
479
487
  "classic_prompt" : {"on" : None, "off":None},
@@ -503,6 +511,7 @@ def make_completion_dict(contacts, pending={}, to=None, channels=None):
503
511
  "print_adverts":None,
504
512
  "json_log_rx":None,
505
513
  "channel_echoes":None,
514
+ "echo_unk_chans":None,
506
515
  "print_path_updates":None,
507
516
  "print_new_contacts":None,
508
517
  "classic_prompt":None,
@@ -1524,6 +1533,10 @@ async def next_cmd(mc, cmds, json_output=False):
1524
1533
  handle_log_rx.channel_echoes = (cmds[2] == "on")
1525
1534
  if json_output :
1526
1535
  print(json.dumps({"cmd" : cmds[1], "param" : cmds[2]}))
1536
+ case "echo_unk_chans" :
1537
+ handle_log_rx.echo_unk_chans = (cmds[2] == "on")
1538
+ if json_output :
1539
+ print(json.dumps({"cmd" : cmds[1], "param" : cmds[2]}))
1527
1540
  case "print_adverts" :
1528
1541
  handle_advert.print_adverts = (cmds[2] == "on")
1529
1542
  if json_output :
@@ -1764,6 +1777,11 @@ async def next_cmd(mc, cmds, json_output=False):
1764
1777
  print(json.dumps({"channel_echoes" : handle_log_rx.channel_echoes}))
1765
1778
  else:
1766
1779
  print(f"{'on' if handle_log_rx.channel_echoes else 'off'}")
1780
+ case "echo_unk_chans":
1781
+ if json_output :
1782
+ print(json.dumps({"echo_unk_chans" : handle_log_rx.echo_unk_chans}))
1783
+ else:
1784
+ print(f"{'on' if handle_log_rx.echo_unk_chans else 'off'}")
1767
1785
  case "print_adverts":
1768
1786
  if json_output :
1769
1787
  print(json.dumps({"print_adverts" : handle_advert.print_adverts}))
@@ -2355,6 +2373,13 @@ async def next_cmd(mc, cmds, json_output=False):
2355
2373
  case "add_pending":
2356
2374
  argnum = 1
2357
2375
  contact = mc.pop_pending_contact(cmds[1])
2376
+ if contact is None: # try to find by name
2377
+ key = None
2378
+ for c in mc.pending_contacts.items():
2379
+ if c[1]['adv_name'] == cmds[1]:
2380
+ key = c[1]['public_key']
2381
+ contact = mc.pop_pending_contact(key)
2382
+ break
2358
2383
  if contact is None:
2359
2384
  if json_output:
2360
2385
  print(json.dumps({"error":"Contact does not exist"}))
@@ -2693,7 +2718,7 @@ async def next_cmd(mc, cmds, json_output=False):
2693
2718
  await mc.ensure_contacts()
2694
2719
  contact = mc.get_contact_by_name(cmds[0])
2695
2720
  if contact is None:
2696
- logger.error(f"Unknown command : {cmd}, will exit ...")
2721
+ logger.error(f"Unknown command : {cmd}. {cmds} not executed ...")
2697
2722
  return None
2698
2723
 
2699
2724
  await interactive_loop(mc, to=contact)
@@ -2702,7 +2727,7 @@ async def next_cmd(mc, cmds, json_output=False):
2702
2727
  return cmds[argnum+1:]
2703
2728
 
2704
2729
  except IndexError:
2705
- logger.error("Error in parameters, returning")
2730
+ logger.error("Error in parameters")
2706
2731
  return None
2707
2732
  except EOFError:
2708
2733
  logger.error("Cancelled")
@@ -2787,7 +2812,7 @@ def command_help():
2787
2812
  req_mma <ct> : requests min/max/avg for a sensor rm
2788
2813
  req_acl <ct> : requests access control list for sensor
2789
2814
  pending_contacts : show pending contacts
2790
- add_pending <key> : manually add pending contact from key
2815
+ add_pending <pending> : manually add pending contact
2791
2816
  flush_pending : flush pending contact list
2792
2817
  Repeaters
2793
2818
  login <name> <pwd> : log into a node (rep) with given pwd l
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: meshcore-cli
3
- Version: 1.2.4
3
+ Version: 1.2.5
4
4
  Summary: Command line interface to meshcore companion radios
5
5
  Project-URL: Homepage, https://github.com/fdlamotte/meshcore-cli
6
6
  Project-URL: Issues, https://github.com/fdlamotte/meshcore-cli/issues
@@ -0,0 +1,8 @@
1
+ meshcore_cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ meshcore_cli/__main__.py,sha256=PfYgibmu2LEtC-OV7L1UgmvV3swJ5rQ4bbXHlwUFlgE,83
3
+ meshcore_cli/meshcore_cli.py,sha256=Vh-oA4_FLEzlvS_6bVan8vyuXwOo3bIbajG-1_eZXck,128150
4
+ meshcore_cli-1.2.5.dist-info/METADATA,sha256=_7w4NJP4SlJjWfZ9qNRjfi25k5EmwtzHcH5OAzZ9MbE,11657
5
+ meshcore_cli-1.2.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
6
+ meshcore_cli-1.2.5.dist-info/entry_points.txt,sha256=77V29Pyth11GteDk7tneBN3MMk8JI7bTlS-BGSmxCmI,103
7
+ meshcore_cli-1.2.5.dist-info/licenses/LICENSE,sha256=F9s987VtS0AKxW7LdB2EkLMkrdeERI7ICdLJR60A9M4,1066
8
+ meshcore_cli-1.2.5.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- meshcore_cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- meshcore_cli/__main__.py,sha256=PfYgibmu2LEtC-OV7L1UgmvV3swJ5rQ4bbXHlwUFlgE,83
3
- meshcore_cli/meshcore_cli.py,sha256=BJYQj2brE9tpWi-oDAtORCV8UDp9w1gFK3PJsjKJR-g,126909
4
- meshcore_cli-1.2.4.dist-info/METADATA,sha256=B1yKgcSP5eRjaSlZyMvUHuZv-TkWlHCd2IGaUFOJ_vc,11657
5
- meshcore_cli-1.2.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
6
- meshcore_cli-1.2.4.dist-info/entry_points.txt,sha256=77V29Pyth11GteDk7tneBN3MMk8JI7bTlS-BGSmxCmI,103
7
- meshcore_cli-1.2.4.dist-info/licenses/LICENSE,sha256=F9s987VtS0AKxW7LdB2EkLMkrdeERI7ICdLJR60A9M4,1066
8
- meshcore_cli-1.2.4.dist-info/RECORD,,