meshcore-cli 1.6.7__tar.gz → 1.6.9__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.
- {meshcore_cli-1.6.7 → meshcore_cli-1.6.9}/PKG-INFO +1 -1
- {meshcore_cli-1.6.7 → meshcore_cli-1.6.9}/pyproject.toml +1 -1
- {meshcore_cli-1.6.7 → meshcore_cli-1.6.9}/src/meshcore_cli/meshcore_cli.py +120 -49
- {meshcore_cli-1.6.7 → meshcore_cli-1.6.9}/.github/funding.yml +0 -0
- {meshcore_cli-1.6.7 → meshcore_cli-1.6.9}/.gitignore +0 -0
- {meshcore_cli-1.6.7 → meshcore_cli-1.6.9}/LICENSE +0 -0
- {meshcore_cli-1.6.7 → meshcore_cli-1.6.9}/README.md +0 -0
- {meshcore_cli-1.6.7 → meshcore_cli-1.6.9}/flake.lock +0 -0
- {meshcore_cli-1.6.7 → meshcore_cli-1.6.9}/flake.nix +0 -0
- {meshcore_cli-1.6.7 → meshcore_cli-1.6.9}/scripts/README.md +0 -0
- {meshcore_cli-1.6.7 → meshcore_cli-1.6.9}/scripts/ask_mepo_coords +0 -0
- {meshcore_cli-1.6.7 → meshcore_cli-1.6.9}/scripts/contact_markers.sh +0 -0
- {meshcore_cli-1.6.7 → meshcore_cli-1.6.9}/scripts/getpos.py +0 -0
- {meshcore_cli-1.6.7 → meshcore_cli-1.6.9}/scripts/neighbour_map.sh +0 -0
- {meshcore_cli-1.6.7 → meshcore_cli-1.6.9}/src/meshcore_cli/__init__.py +0 -0
- {meshcore_cli-1.6.7 → meshcore_cli-1.6.9}/src/meshcore_cli/__main__.py +0 -0
- {meshcore_cli-1.6.7 → meshcore_cli-1.6.9}/sxmo/sxmo_accel.sh +0 -0
- {meshcore_cli-1.6.7 → meshcore_cli-1.6.9}/sxmo/sxmo_mc.sh +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: meshcore-cli
|
|
3
|
-
Version: 1.6.
|
|
3
|
+
Version: 1.6.9
|
|
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
|
|
@@ -35,7 +35,7 @@ except ImportError:
|
|
|
35
35
|
from meshcore import MeshCore, EventType, logger
|
|
36
36
|
|
|
37
37
|
# Version
|
|
38
|
-
VERSION = "v1.6.
|
|
38
|
+
VERSION = "v1.6.9"
|
|
39
39
|
|
|
40
40
|
# default ble address is stored in a config file
|
|
41
41
|
MCCLI_CONFIG_DIR = os.path.expanduser("~/.config/meshcore/")
|
|
@@ -154,6 +154,8 @@ LC_DISPLAY_TYPES = [1, 2, 3, 4]
|
|
|
154
154
|
LC_OUTPUT_FORMAT = "tkah"
|
|
155
155
|
LC_SORT_ORDER = ""
|
|
156
156
|
|
|
157
|
+
LAST_DISCOVERED_NODES = []
|
|
158
|
+
|
|
157
159
|
def time_ago_from_timestamp (timestamp):
|
|
158
160
|
if timestamp == 0:
|
|
159
161
|
return "0"
|
|
@@ -663,6 +665,7 @@ def make_completion_dict(contacts, pending=None, to=None, channels=None):
|
|
|
663
665
|
pending = pending or {}
|
|
664
666
|
contact_list = {}
|
|
665
667
|
pending_list = {}
|
|
668
|
+
discovered_list = {"-a":None}
|
|
666
669
|
to_list = {}
|
|
667
670
|
|
|
668
671
|
to_list["~"] = None
|
|
@@ -683,6 +686,8 @@ def make_completion_dict(contacts, pending=None, to=None, channels=None):
|
|
|
683
686
|
for c in pit :
|
|
684
687
|
pending_list[c[1]['public_key']] = None
|
|
685
688
|
|
|
689
|
+
for n in LAST_DISCOVERED_NODES:
|
|
690
|
+
discovered_list[n['pubkey'][:16]] = None
|
|
686
691
|
to_list.update(contact_list)
|
|
687
692
|
|
|
688
693
|
to_list["ch"] = None
|
|
@@ -725,7 +730,9 @@ def make_completion_dict(contacts, pending=None, to=None, channels=None):
|
|
|
725
730
|
"path": contact_list,
|
|
726
731
|
"disc_path" : contact_list,
|
|
727
732
|
"advert_path" : contact_list | pending_list,
|
|
728
|
-
"node_discover": {"
|
|
733
|
+
"node_discover": {"-tall":None, "-tsens":None, "-trep":None, "-tcomp":None, "-troom":None, "-tcli":None},
|
|
734
|
+
"list_discovered": None,
|
|
735
|
+
"add_discovered": discovered_list,
|
|
729
736
|
"trace" : None,
|
|
730
737
|
"reset_path" : contact_list,
|
|
731
738
|
"change_path" : contact_list,
|
|
@@ -2231,62 +2238,57 @@ async def get_channel_by_name (mc, name):
|
|
|
2231
2238
|
|
|
2232
2239
|
return None
|
|
2233
2240
|
|
|
2234
|
-
async def get_contacts
|
|
2241
|
+
async def get_contacts(mc, anim=False, lastomod=0, timeout=5):
|
|
2235
2242
|
if mc._contacts:
|
|
2236
2243
|
return
|
|
2237
2244
|
|
|
2238
2245
|
if anim:
|
|
2239
2246
|
print("Fetching contacts ", end="", flush=True)
|
|
2240
2247
|
|
|
2241
|
-
|
|
2248
|
+
loop = asyncio.get_running_loop()
|
|
2249
|
+
result = loop.create_future()
|
|
2250
|
+
state = {"n": 0, "activity": False}
|
|
2242
2251
|
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
)
|
|
2249
|
-
futures.append(future)
|
|
2252
|
+
def on_next(event):
|
|
2253
|
+
state["n"] += 1
|
|
2254
|
+
state["activity"] = True
|
|
2255
|
+
if anim:
|
|
2256
|
+
print(".", end="", flush=True)
|
|
2250
2257
|
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
)
|
|
2258
|
+
def on_end(event):
|
|
2259
|
+
logger.debug(f"get_contacts: got {event.type}")
|
|
2260
|
+
if not result.done():
|
|
2261
|
+
result.set_result(event)
|
|
2256
2262
|
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
event = await future
|
|
2266
|
-
|
|
2267
|
-
if event:
|
|
2268
|
-
if event.type == EventType.NEXT_CONTACT:
|
|
2269
|
-
if anim:
|
|
2270
|
-
contact_nb = contact_nb+1
|
|
2271
|
-
print(".", end="", flush=True)
|
|
2272
|
-
else: # Done or Error ... cancel pending and return
|
|
2273
|
-
if anim:
|
|
2274
|
-
if event.type == EventType.CONTACTS:
|
|
2275
|
-
print ((len(event.payload)-contact_nb)*"." + " Done")
|
|
2276
|
-
else :
|
|
2277
|
-
print(" Error")
|
|
2278
|
-
for future in pending:
|
|
2279
|
-
future.cancel()
|
|
2280
|
-
return event
|
|
2263
|
+
subs = [
|
|
2264
|
+
mc.subscribe(EventType.NEXT_CONTACT, on_next),
|
|
2265
|
+
mc.subscribe(EventType.CONTACTS, on_end),
|
|
2266
|
+
mc.subscribe(EventType.ERROR, on_end),
|
|
2267
|
+
]
|
|
2268
|
+
|
|
2269
|
+
try:
|
|
2270
|
+
await mc.commands.get_contacts_async()
|
|
2281
2271
|
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2272
|
+
while True:
|
|
2273
|
+
state["activity"] = False
|
|
2274
|
+
try:
|
|
2275
|
+
# shield so the timeout doesn't cancel the future itself
|
|
2276
|
+
event = await asyncio.wait_for(asyncio.shield(result), timeout)
|
|
2277
|
+
except asyncio.TimeoutError:
|
|
2278
|
+
if state["activity"]:
|
|
2279
|
+
continue # still receiving contacts, keep waiting
|
|
2280
|
+
logger.debug("Timeout while getting contacts")
|
|
2281
|
+
return None
|
|
2285
2282
|
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2283
|
+
if anim:
|
|
2284
|
+
if event.type == EventType.CONTACTS:
|
|
2285
|
+
print(max(len(event.payload) - state["n"], 0) * "." + " Done")
|
|
2286
|
+
else:
|
|
2287
|
+
print(" Error")
|
|
2288
|
+
return event
|
|
2289
|
+
finally:
|
|
2290
|
+
for s in subs:
|
|
2291
|
+
s.unsubscribe()
|
|
2290
2292
|
|
|
2291
2293
|
async def get_channels (mc, anim=False) :
|
|
2292
2294
|
if hasattr(mc, 'channels') :
|
|
@@ -2414,6 +2416,7 @@ async def next_cmd(mc, cmds, json_output=False, sink=sys.stdout, end="\n"):
|
|
|
2414
2416
|
"""
|
|
2415
2417
|
global ARROW_HEAD, SLASH_START, SLASH_END, INVERT_SLASH, LAST_HANDLER_ID
|
|
2416
2418
|
global LC_DISPLAY_TYPES, LC_OUTPUT_FORMAT, LC_SORT_ORDER
|
|
2419
|
+
global LAST_DISCOVERED_NODES
|
|
2417
2420
|
output_str = ""
|
|
2418
2421
|
try :
|
|
2419
2422
|
argnum = 0
|
|
@@ -3540,6 +3543,7 @@ async def next_cmd(mc, cmds, json_output=False, sink=sys.stdout, end="\n"):
|
|
|
3540
3543
|
else:
|
|
3541
3544
|
exp_tag = res.payload["tag"].to_bytes(4, "little").hex()
|
|
3542
3545
|
dn = []
|
|
3546
|
+
LAST_DISCOVERED_NODES = []
|
|
3543
3547
|
while True:
|
|
3544
3548
|
r = await mc.wait_for_event(
|
|
3545
3549
|
EventType.DISCOVER_RESPONSE,
|
|
@@ -3549,7 +3553,12 @@ async def next_cmd(mc, cmds, json_output=False, sink=sys.stdout, end="\n"):
|
|
|
3549
3553
|
if r is None or r.type == EventType.ERROR:
|
|
3550
3554
|
break
|
|
3551
3555
|
else:
|
|
3552
|
-
|
|
3556
|
+
n = r.payload
|
|
3557
|
+
dn.append(n)
|
|
3558
|
+
if len(n['pubkey']) == 64:
|
|
3559
|
+
contact = mc.get_contact_by_key_prefix(n['pubkey'])
|
|
3560
|
+
if contact is None:
|
|
3561
|
+
LAST_DISCOVERED_NODES.append(n)
|
|
3553
3562
|
|
|
3554
3563
|
if json_output:
|
|
3555
3564
|
output_str += json.dumps(dn)+end
|
|
@@ -3568,6 +3577,57 @@ async def next_cmd(mc, cmds, json_output=False, sink=sys.stdout, end="\n"):
|
|
|
3568
3577
|
|
|
3569
3578
|
output_str += f" {name:28} {type:>4} SNR: {n['SNR_in']:6,.2f}->{n['SNR']:6,.2f} RSSI: ->{n['RSSI']:4}\n"
|
|
3570
3579
|
|
|
3580
|
+
case "list_discovered" :
|
|
3581
|
+
output_str += json.dumps(LAST_DISCOVERED_NODES, indent=4) + end
|
|
3582
|
+
|
|
3583
|
+
case "add_discovered" :
|
|
3584
|
+
name = None
|
|
3585
|
+
args = cmds[1:]
|
|
3586
|
+
add_all = False
|
|
3587
|
+
argnum = 1
|
|
3588
|
+
|
|
3589
|
+
while len(args) > 0 and args[0][0] == "-":
|
|
3590
|
+
if args[0].startswith('-n'): # name
|
|
3591
|
+
name = args[0][2:]
|
|
3592
|
+
|
|
3593
|
+
if args[0].startswith('-a'):
|
|
3594
|
+
add_all = True
|
|
3595
|
+
argnum = argnum - 1
|
|
3596
|
+
|
|
3597
|
+
argnum += 1
|
|
3598
|
+
args = args[1:]
|
|
3599
|
+
|
|
3600
|
+
if not add_all:
|
|
3601
|
+
prefix = args[0]
|
|
3602
|
+
nodes = 0
|
|
3603
|
+
jout = []
|
|
3604
|
+
for n in LAST_DISCOVERED_NODES[:]:
|
|
3605
|
+
if add_all or n['pubkey'].startswith(prefix):
|
|
3606
|
+
LAST_DISCOVERED_NODES.remove(n)
|
|
3607
|
+
if add_all or name is None:
|
|
3608
|
+
name = n['pubkey'][0:8]
|
|
3609
|
+
contact = {
|
|
3610
|
+
"public_key": n['pubkey'],
|
|
3611
|
+
"type" : n['node_type'],
|
|
3612
|
+
"flags" : 0,
|
|
3613
|
+
"out_path_len" : -1,
|
|
3614
|
+
"out_path" : "",
|
|
3615
|
+
"out_path_hash_mode" : 0,
|
|
3616
|
+
"adv_name" : name,
|
|
3617
|
+
"adv_lat" : 0,
|
|
3618
|
+
"adv_lon" : 0,
|
|
3619
|
+
"last_advert" : 0,
|
|
3620
|
+
}
|
|
3621
|
+
res = await mc.commands.update_contact(contact)
|
|
3622
|
+
logger.debug(res)
|
|
3623
|
+
if res.type == EventType.ERROR:
|
|
3624
|
+
output_str += f"Error adding contact: {res}\n"
|
|
3625
|
+
else :
|
|
3626
|
+
jout.append(json.dumps({'name':name, 'pubkey':n['pubkey'], 'type':n['node_type']}))
|
|
3627
|
+
|
|
3628
|
+
await mc.commands.get_contacts() # reload contacts
|
|
3629
|
+
output_str += json.dumps([json.loads(x) for x in jout]) + end
|
|
3630
|
+
|
|
3571
3631
|
case "req_regions"|"rr":
|
|
3572
3632
|
argnum = 1
|
|
3573
3633
|
await mc.ensure_contacts()
|
|
@@ -4643,6 +4703,8 @@ def command_help():
|
|
|
4643
4703
|
wmt8 : wait for a msg (reply) with a timeout ]
|
|
4644
4704
|
req_status <name> : requests status from a node rs
|
|
4645
4705
|
req_neighbours <name> : requests for neighbours in binary form rn
|
|
4706
|
+
node_discover : lauch a local node discovery
|
|
4707
|
+
add_discovered <key> : add a discovered node (repeater) to the list
|
|
4646
4708
|
trace <path> : run a trace, path is comma separated""")
|
|
4647
4709
|
|
|
4648
4710
|
def usage () :
|
|
@@ -4704,7 +4766,7 @@ def get_help_for (cmdname, context="line") :
|
|
|
4704
4766
|
at t=2 rp login
|
|
4705
4767
|
""")
|
|
4706
4768
|
|
|
4707
|
-
elif cmdname == "node_discover" or cmdname == "nd" :
|
|
4769
|
+
elif cmdname == "node_discover" or cmdname == "nd" or cmdname == "list_discovered" or cmdname == "add_discovered" :
|
|
4708
4770
|
print("""node_discover [-t<filter>] [-f] : discovers 0-hop nodes and displays signal info
|
|
4709
4771
|
|
|
4710
4772
|
`-t` asks for nodes regarding filter.
|
|
@@ -4717,6 +4779,15 @@ def get_help_for (cmdname, context="line") :
|
|
|
4717
4779
|
`-f` or `-full`: will ask for the full key of the node
|
|
4718
4780
|
|
|
4719
4781
|
BEWARE: filter option have changed since v1.6.4, using -t is now mandatory !!!
|
|
4782
|
+
|
|
4783
|
+
Once node_discover has been performed with -f (to get full key) you can add the node using `add_discovered` or list them with `list_discovered`. The discovered list is emptied at each node discovery.
|
|
4784
|
+
|
|
4785
|
+
add_discovered [-n<name>] [-a] <pubkey_prefix>
|
|
4786
|
+
|
|
4787
|
+
`-n`: to give a name to the node
|
|
4788
|
+
`-a`: will add all found nodes (won't use the provided name though)
|
|
4789
|
+
<pubkey_prefix>: to identify the node to add if `-a` has not been used
|
|
4790
|
+
|
|
4720
4791
|
""")
|
|
4721
4792
|
|
|
4722
4793
|
elif cmdname == "get" :
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|