|
32 | 32 | from meshcore import MeshCore, EventType, logger |
33 | 33 |
|
34 | 34 | # Version |
35 | | -VERSION = "v1.2.11" |
| 35 | +VERSION = "v1.2.12" |
36 | 36 |
|
37 | 37 | # default ble address is stored in a config file |
38 | 38 | MCCLI_CONFIG_DIR = str(Path.home()) + "/.config/meshcore/" |
@@ -578,6 +578,7 @@ def make_completion_dict(contacts, pending={}, to=None, channels=None): |
578 | 578 | "logout" : None, |
579 | 579 | "req_status" : None, |
580 | 580 | "req_bstatus" : None, |
| 581 | + "req_neighbours": None, |
581 | 582 | "cmd" : None, |
582 | 583 | "ver" : None, |
583 | 584 | "advert" : None, |
@@ -1083,6 +1084,7 @@ async def process_contact_chat_line(mc, contact, line): |
1083 | 1084 | line == "dp" or line == "disc_path" or\ |
1084 | 1085 | line == "contact_info" or line == "ci" or\ |
1085 | 1086 | line == "req_status" or line == "rs" or\ |
| 1087 | + line == "req_neighbours" or line == "rn" or\ |
1086 | 1088 | line == "req_bstatus" or line == "rbs" or\ |
1087 | 1089 | line == "req_telemetry" or line == "rt" or\ |
1088 | 1090 | line == "req_acl" or\ |
@@ -2634,6 +2636,31 @@ async def next_cmd(mc, cmds, json_output=False): |
2634 | 2636 | name = f"{ct['adv_name']:<20} [{e['key']}]" |
2635 | 2637 | print(f"{name:{' '}<35}: {e['perm']:02x}") |
2636 | 2638 |
|
| 2639 | + case "req_neighbours"|"rn" : |
| 2640 | + argnum = 1 |
| 2641 | + await mc.ensure_contacts() |
| 2642 | + contact = mc.get_contact_by_name(cmds[1]) |
| 2643 | + timeout = 0 if not "timeout" in contact else contact["timeout"] |
| 2644 | + res = await mc.commands.fetch_all_neighbours(contact, timeout=timeout) |
| 2645 | + if res is None : |
| 2646 | + if json_output : |
| 2647 | + print(json.dumps({"error" : "Getting data"})) |
| 2648 | + else: |
| 2649 | + print("Error getting data") |
| 2650 | + else : |
| 2651 | + if json_output: |
| 2652 | + print(json.dumps(res, indent=4)) |
| 2653 | + else: |
| 2654 | + print(f"Got {res['results_count']} neighbours out of {res['neighbours_count']} from {contact['adv_name']}:") |
| 2655 | + for n in res['neighbours']: |
| 2656 | + ct = mc.get_contact_by_key_prefix(n["pubkey"]) |
| 2657 | + if ct : |
| 2658 | + name = f"[{n['pubkey'][0:8]}] {ct['adv_name']}" |
| 2659 | + else: |
| 2660 | + name = f"[{n['pubkey']}]" |
| 2661 | + |
| 2662 | + print(f" {name:30} last viewed {n['secs_ago']} sec ago at {n['snr']} ") |
| 2663 | + |
2637 | 2664 | case "req_binary" : |
2638 | 2665 | argnum = 2 |
2639 | 2666 | await mc.ensure_contacts() |
@@ -3131,6 +3158,7 @@ def command_help(): |
3131 | 3158 | cmd <name> <cmd> : sends a command to a repeater (no ack) c [ |
3132 | 3159 | wmt8 : wait for a msg (reply) with a timeout ] |
3133 | 3160 | req_status <name> : requests status from a node rs |
| 3161 | + req_neighbours <name> : requests for neighbours in binary form rn |
3134 | 3162 | trace <path> : run a trace, path is comma separated""") |
3135 | 3163 |
|
3136 | 3164 | def usage () : |
|
0 commit comments