meshcore-cli 1.3.3__py3-none-any.whl → 1.3.4__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.
@@ -32,7 +32,7 @@ import re
32
32
  from meshcore import MeshCore, EventType, logger
33
33
 
34
34
  # Version
35
- VERSION = "v1.3.3"
35
+ VERSION = "v1.3.4"
36
36
 
37
37
  # default ble address is stored in a config file
38
38
  MCCLI_CONFIG_DIR = str(Path.home()) + "/.config/meshcore/"
@@ -766,6 +766,7 @@ Use \"to\" to select recipient, use Tab to complete name ...
766
766
  Some cmds have an help accessible with ?<cmd>. Do ?[Tab] to get a list.
767
767
  \"quit\", \"q\", CTRL+D will end interactive mode""")
768
768
 
769
+
769
770
  contact = to
770
771
  prev_contact = None
771
772
 
@@ -774,16 +775,16 @@ Some cmds have an help accessible with ?<cmd>. Do ?[Tab] to get a list.
774
775
 
775
776
  await get_contacts(mc, anim=True)
776
777
  await get_channels(mc, anim=True)
778
+
779
+ # Call sync_msg before going further so there is no issue when scrolling
780
+ # long list of msgs
781
+ await next_cmd(mc, ["sync_msgs"])
782
+
777
783
  await subscribe_to_msgs(mc, above=True)
778
784
 
779
785
  handle_new_contact.print_new_contacts = True
780
786
 
781
787
  try:
782
- while True: # purge msgs
783
- res = await mc.commands.get_msg()
784
- if res.type == EventType.NO_MORE_MSGS:
785
- break
786
-
787
788
  if os.path.isdir(MCCLI_CONFIG_DIR) :
788
789
  our_history = FileHistory(MCCLI_HISTORY_FILE)
789
790
  else:
@@ -1493,7 +1494,8 @@ async def send_msg (mc, contact, msg) :
1493
1494
  return res
1494
1495
 
1495
1496
  async def msg_ack (mc, contact, msg) :
1496
- timeout = 0 if not 'timeout' in contact else contact['timeout']
1497
+ timeout = 0 if not isinstance(contact, dict) or not 'timeout' in contact\
1498
+ else contact['timeout']
1497
1499
  res = await mc.commands.send_msg_with_retry(contact, msg,
1498
1500
  max_attempts=msg_ack.max_attempts,
1499
1501
  flood_after=msg_ack.flood_after,
@@ -2333,7 +2335,7 @@ async def next_cmd(mc, cmds, json_output=False):
2333
2335
  argnum = 2
2334
2336
  dest = None
2335
2337
 
2336
- if len(cmds[1]) == 12: # possibly an hex prefix
2338
+ if len(cmds[1]) >= 12: # possibly an hex prefix
2337
2339
  try:
2338
2340
  dest = bytes.fromhex(cmds[1])
2339
2341
  except ValueError:
@@ -3244,11 +3246,16 @@ def command_help():
3244
3246
  def usage () :
3245
3247
  """ Prints some help """
3246
3248
  version()
3249
+ command_usage()
3250
+ print(" Available Commands and shorcuts (can be chained) :""")
3251
+ command_help()
3252
+
3253
+ def command_usage() :
3247
3254
  print("""
3248
3255
  Usage : meshcore-cli <args> <commands>
3249
3256
 
3250
3257
  Arguments :
3251
- -h : prints this help
3258
+ -h : prints help for arguments and commands
3252
3259
  -v : prints version
3253
3260
  -j : json output (disables init file)
3254
3261
  -D : debug
@@ -3264,9 +3271,7 @@ def usage () :
3264
3271
  -b <baudrate> : specify baudrate
3265
3272
  -C : toggles classic mode for prompt
3266
3273
  -c <on/off> : disables most of color output if off
3267
-
3268
- Available Commands and shorcuts (can be chained) :""")
3269
- command_help()
3274
+ """)
3270
3275
 
3271
3276
  def get_help_for (cmdname, context="line") :
3272
3277
  if cmdname == "apply_to" or cmdname == "at" :
@@ -3409,13 +3414,19 @@ async def main(argv):
3409
3414
  baudrate = 115200
3410
3415
  timeout = 2
3411
3416
  pin = None
3417
+ first_device = False
3412
3418
  # If there is an address in config file, use it by default
3413
3419
  # unless an arg is explicitely given
3414
3420
  if os.path.exists(MCCLI_ADDRESS) :
3415
3421
  with open(MCCLI_ADDRESS, encoding="utf-8") as f :
3416
3422
  address = f.readline().strip()
3417
3423
 
3418
- opts, args = getopt.getopt(argv, "a:d:s:ht:p:b:fjDhvSlT:Pc:C")
3424
+ try:
3425
+ opts, args = getopt.getopt(argv, "a:d:s:ht:p:b:fjDhvSlT:Pc:C")
3426
+ except getopt.GetoptError:
3427
+ print("Unrecognized option, use -h to get more help")
3428
+ command_usage()
3429
+ return
3419
3430
  for opt, arg in opts :
3420
3431
  match opt:
3421
3432
  case "-c" :
@@ -3452,6 +3463,7 @@ async def main(argv):
3452
3463
  return
3453
3464
  case "-f": # connect to first encountered device
3454
3465
  address = ""
3466
+ first_device = True
3455
3467
  case "-l" :
3456
3468
  print("BLE devices:")
3457
3469
  try :
@@ -3547,8 +3559,15 @@ async def main(argv):
3547
3559
 
3548
3560
  try :
3549
3561
  mc = await MeshCore.create_ble(address=address, device=device, client=client, debug=debug, only_error=json_output, pin=pin)
3562
+ except BleakError :
3563
+ print("BLE connection asked (default behaviour), but no BLE HW found")
3564
+ print("Call meshcore-cli with -h for some more help (on commands)")
3565
+ command_usage()
3566
+ return
3550
3567
  except ConnectionError :
3551
3568
  logger.info("Error while connecting, retrying once ...")
3569
+ if first_device :
3570
+ address = "" # reset address to change device if first_device was asked
3552
3571
  if device is None and client is None: # Search for device
3553
3572
  logger.info(f"Scanning BLE for device matching {address}")
3554
3573
  devices = await BleakScanner.discover(timeout=timeout)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: meshcore-cli
3
- Version: 1.3.3
3
+ Version: 1.3.4
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=HEIf0cCzrl1NKQeeh15R-RBdDC0cUh8xw0-cvb2XHTE,151800
4
+ meshcore_cli-1.3.4.dist-info/METADATA,sha256=4dva0jFFNntaaOaUfrV5yHg20aRcJSUoWuU1-3qEaXk,17105
5
+ meshcore_cli-1.3.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
6
+ meshcore_cli-1.3.4.dist-info/entry_points.txt,sha256=77V29Pyth11GteDk7tneBN3MMk8JI7bTlS-BGSmxCmI,103
7
+ meshcore_cli-1.3.4.dist-info/licenses/LICENSE,sha256=F9s987VtS0AKxW7LdB2EkLMkrdeERI7ICdLJR60A9M4,1066
8
+ meshcore_cli-1.3.4.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=9QoU-ERTiGkNRyuecAm2rET_ncN7VQthZpeyf9ASAy4,151114
4
- meshcore_cli-1.3.3.dist-info/METADATA,sha256=hNRWTyoFSIOxospg9JyNtJ5KFVox5NJq3Fn9radiSuA,17105
5
- meshcore_cli-1.3.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
6
- meshcore_cli-1.3.3.dist-info/entry_points.txt,sha256=77V29Pyth11GteDk7tneBN3MMk8JI7bTlS-BGSmxCmI,103
7
- meshcore_cli-1.3.3.dist-info/licenses/LICENSE,sha256=F9s987VtS0AKxW7LdB2EkLMkrdeERI7ICdLJR60A9M4,1066
8
- meshcore_cli-1.3.3.dist-info/RECORD,,