Skip to content

Commit 91a6e31

Browse files
committed
support only_prefix flag on discover_nodes
1 parent 601c19c commit 91a6e31

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "meshcore-cli"
7-
version = "1.2.7"
7+
version = "1.2.8"
88
authors = [
99
{ name="Florent de Lamotte", email="[email protected]" },
1010
]
@@ -17,7 +17,7 @@ classifiers = [
1717
]
1818
license = "MIT"
1919
license-files = ["LICEN[CS]E*"]
20-
dependencies = [ "meshcore >= 2.1.21", "prompt_toolkit >= 3.0.50", "requests >= 2.28.0", "pycryptodome" ]
20+
dependencies = [ "meshcore >= 2.1.22", "prompt_toolkit >= 3.0.50", "requests >= 2.28.0", "pycryptodome" ]
2121

2222
[project.urls]
2323
Homepage = "https://github.com/fdlamotte/meshcore-cli"

src/meshcore_cli/meshcore_cli.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
from meshcore import MeshCore, EventType, logger
3434

3535
# Version
36-
VERSION = "v1.2.7"
36+
VERSION = "v1.2.8"
3737

3838
# default ble address is stored in a config file
3939
MCCLI_CONFIG_DIR = str(Path.home()) + "/.config/meshcore/"
@@ -711,7 +711,7 @@ async def interactive_loop(mc, to=None) :
711711
prev_contact = None
712712

713713
res = await mc.commands.set_flood_scope("0")
714-
if res is None or res.type == EventType.ERROR:
714+
if res is None or res.type == EventType.ERROR:
715715
scope = None
716716
prev_scope = None
717717
else:
@@ -2419,6 +2419,7 @@ async def next_cmd(mc, cmds, json_output=False):
24192419

24202420
case "node_discover"|"nd" :
24212421
argnum = 1
2422+
prefix_only = True
24222423
try: # try to decode type as int
24232424
types = int(cmds[1])
24242425
except ValueError:
@@ -2435,7 +2436,10 @@ async def next_cmd(mc, cmds, json_output=False):
24352436
if "sens" in cmds[1]:
24362437
types = types | 16
24372438

2438-
res = await mc.commands.send_node_discover_req(types)
2439+
if "full" in cmds[1]:
2440+
prefix_only = False
2441+
2442+
res = await mc.commands.send_node_discover_req(types, prefix_only=prefix_only)
24392443
if res is None or res.type == EventType.ERROR:
24402444
print("Error sending discover request")
24412445
else:
@@ -2458,10 +2462,20 @@ async def next_cmd(mc, cmds, json_output=False):
24582462
await mc.ensure_contacts()
24592463
print(f"Discovered {len(dn)} nodes:")
24602464
for n in dn:
2461-
name = mc.get_contact_by_key_prefix(n["pubkey"])['adv_name']
2465+
name = f"{n['pubkey'][0:2]} {mc.get_contact_by_key_prefix(n['pubkey'])['adv_name']}"
24622466
if name is None:
2463-
name = n["pubkey"][0:12]
2464-
print(f" {name:12} type {n['node_type']} SNR: {n['SNR_in']:6,.2f}->{n['SNR']:6,.2f} RSSI: ->{n['RSSI']:4}")
2467+
name = n["pubkey"][0:16]
2468+
type = f"t:{n['node_type']}"
2469+
if n['node_type'] == 1:
2470+
type = "cli"
2471+
elif n['node_type'] == 2:
2472+
type = "rep"
2473+
elif n['node_type'] == 3:
2474+
type = "room"
2475+
elif n['node_type'] == 4:
2476+
type = "sens"
2477+
2478+
print(f" {name:16} {type:>4} SNR: {n['SNR_in']:6,.2f}->{n['SNR']:6,.2f} RSSI: ->{n['RSSI']:4}")
24652479

24662480
case "req_btelemetry"|"rbt" :
24672481
argnum = 1

0 commit comments

Comments
 (0)