meshcore-cli 1.6.1__tar.gz → 1.6.3__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.1 → meshcore_cli-1.6.3}/PKG-INFO +4 -2
- {meshcore_cli-1.6.1 → meshcore_cli-1.6.3}/README.md +2 -0
- {meshcore_cli-1.6.1 → meshcore_cli-1.6.3}/flake.nix +2 -2
- {meshcore_cli-1.6.1 → meshcore_cli-1.6.3}/pyproject.toml +2 -2
- {meshcore_cli-1.6.1 → meshcore_cli-1.6.3}/src/meshcore_cli/meshcore_cli.py +98 -37
- meshcore_cli-1.6.1/REPEATER_COMMANDS.md +0 -292
- {meshcore_cli-1.6.1 → meshcore_cli-1.6.3}/.github/funding.yml +0 -0
- {meshcore_cli-1.6.1 → meshcore_cli-1.6.3}/.gitignore +0 -0
- {meshcore_cli-1.6.1 → meshcore_cli-1.6.3}/LICENSE +0 -0
- {meshcore_cli-1.6.1 → meshcore_cli-1.6.3}/flake.lock +0 -0
- {meshcore_cli-1.6.1 → meshcore_cli-1.6.3}/scripts/README.md +0 -0
- {meshcore_cli-1.6.1 → meshcore_cli-1.6.3}/scripts/ask_mepo_coords +0 -0
- {meshcore_cli-1.6.1 → meshcore_cli-1.6.3}/scripts/contact_markers.sh +0 -0
- {meshcore_cli-1.6.1 → meshcore_cli-1.6.3}/scripts/getpos.py +0 -0
- {meshcore_cli-1.6.1 → meshcore_cli-1.6.3}/scripts/neighbour_map.sh +0 -0
- {meshcore_cli-1.6.1 → meshcore_cli-1.6.3}/src/meshcore_cli/__init__.py +0 -0
- {meshcore_cli-1.6.1 → meshcore_cli-1.6.3}/src/meshcore_cli/__main__.py +0 -0
- {meshcore_cli-1.6.1 → meshcore_cli-1.6.3}/sxmo/sxmo_accel.sh +0 -0
- {meshcore_cli-1.6.1 → meshcore_cli-1.6.3}/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.3
|
|
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
|
|
@@ -11,7 +11,7 @@ Classifier: Operating System :: OS Independent
|
|
|
11
11
|
Classifier: Programming Language :: Python :: 3
|
|
12
12
|
Requires-Python: >=3.10
|
|
13
13
|
Requires-Dist: bleak>=0.22
|
|
14
|
-
Requires-Dist: meshcore>=2.3.
|
|
14
|
+
Requires-Dist: meshcore>=2.3.9
|
|
15
15
|
Requires-Dist: prompt-toolkit>=3.0.50
|
|
16
16
|
Requires-Dist: requests>=2.28.0
|
|
17
17
|
Description-Content-Type: text/markdown
|
|
@@ -136,6 +136,8 @@ Commands are given after arguments, they can be chained and some have shortcuts.
|
|
|
136
136
|
clock : get current time
|
|
137
137
|
clock sync : sync device clock st
|
|
138
138
|
node_discover <filter> : discovers nodes based on their type nd
|
|
139
|
+
cli <cmd> : executes cli command cmd
|
|
140
|
+
send_raw <pkt> : sends a raw packet (hex string)
|
|
139
141
|
Contacts
|
|
140
142
|
contacts / list : gets contact list lc
|
|
141
143
|
reload_contacts : force reloading all contacts rc
|
|
@@ -118,6 +118,8 @@ Commands are given after arguments, they can be chained and some have shortcuts.
|
|
|
118
118
|
clock : get current time
|
|
119
119
|
clock sync : sync device clock st
|
|
120
120
|
node_discover <filter> : discovers nodes based on their type nd
|
|
121
|
+
cli <cmd> : executes cli command cmd
|
|
122
|
+
send_raw <pkt> : sends a raw packet (hex string)
|
|
121
123
|
Contacts
|
|
122
124
|
contacts / list : gets contact list lc
|
|
123
125
|
reload_contacts : force reloading all contacts rc
|
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
|
|
18
18
|
meshcore = python3Packages.buildPythonPackage rec {
|
|
19
19
|
pname = "meshcore";
|
|
20
|
-
version = "2.3.
|
|
20
|
+
version = "2.3.9";
|
|
21
21
|
pyproject = true;
|
|
22
22
|
|
|
23
23
|
src = python3Packages.fetchPypi {
|
|
24
24
|
inherit pname version;
|
|
25
|
-
sha256 = "sha256-
|
|
25
|
+
sha256 = "sha256-sX0ozXspS6kGKp46RseoYdpBgQ8dfCBXBgO9GO3aXr0=";
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
build-system = [ python3Packages.hatchling ];
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "meshcore-cli"
|
|
7
|
-
version = "1.6.
|
|
7
|
+
version = "1.6.3"
|
|
8
8
|
authors = [
|
|
9
9
|
{ name="Florent de Lamotte", email="florent@frizoncorrea.fr" },
|
|
10
10
|
]
|
|
@@ -17,7 +17,7 @@ classifiers = [
|
|
|
17
17
|
]
|
|
18
18
|
license = "MIT"
|
|
19
19
|
license-files = ["LICEN[CS]E*"]
|
|
20
|
-
dependencies = [ "meshcore >= 2.3.
|
|
20
|
+
dependencies = [ "meshcore >= 2.3.9",
|
|
21
21
|
"bleak >= 0.22",
|
|
22
22
|
"prompt_toolkit >= 3.0.50",
|
|
23
23
|
"requests >= 2.28.0" ]
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"""
|
|
5
5
|
|
|
6
6
|
import asyncio
|
|
7
|
-
import os, sys, io, platform
|
|
7
|
+
import os, sys, io, platform, shutil
|
|
8
8
|
import string
|
|
9
9
|
import time, datetime
|
|
10
10
|
import getopt, json, shlex, re
|
|
@@ -34,7 +34,7 @@ except ImportError:
|
|
|
34
34
|
from meshcore import MeshCore, EventType, logger
|
|
35
35
|
|
|
36
36
|
# Version
|
|
37
|
-
VERSION = "v1.6.
|
|
37
|
+
VERSION = "v1.6.3"
|
|
38
38
|
|
|
39
39
|
# default ble address is stored in a config file
|
|
40
40
|
MCCLI_CONFIG_DIR = os.path.expanduser("~/.config/meshcore/")
|
|
@@ -48,9 +48,14 @@ SCOPES = {}
|
|
|
48
48
|
if os.path.exists(MCCLI_SCOPES_FILE) :
|
|
49
49
|
with open(MCCLI_SCOPES_FILE, "r") as lines:
|
|
50
50
|
for line in lines:
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
try:
|
|
52
|
+
line = line.strip()
|
|
53
|
+
if line == "" or line.startswith(";"):
|
|
54
|
+
continue
|
|
55
|
+
channel, scope = line.split()
|
|
56
|
+
SCOPES[channel] = scope
|
|
57
|
+
except ValueError as e:
|
|
58
|
+
logger.error(f"while reading scope file {MCCLI_SCOPES_FILE}: {e} ... proceeding")
|
|
54
59
|
|
|
55
60
|
PAYLOAD_TYPENAMES = ["REQ", "RESPONSE", "TEXT_MSG", "ACK", "ADVERT", "GRP_TXT", "GRP_DATA", "ANON_REQ", "PATH", "TRACE", "MULTIPART", "CONTROL"]
|
|
56
61
|
ROUTE_TYPENAMES = ["TC_FLOOD", "FLOOD", "DIRECT", "TC_DIRECT"]
|
|
@@ -114,6 +119,9 @@ HANDLERS = { # dicts that will be indexed by numbers
|
|
|
114
119
|
LAST_HANDLER_ID = 0
|
|
115
120
|
HANDLER_QUEUE_SIZE = 100
|
|
116
121
|
|
|
122
|
+
# is the companion supposed to have cli
|
|
123
|
+
HAS_CLI_CMD = False
|
|
124
|
+
|
|
117
125
|
def enqueue_handler_event(handler_type, payload):
|
|
118
126
|
message = json.dumps(payload) + "\n"
|
|
119
127
|
for handler in HANDLERS[handler_type].values():
|
|
@@ -167,8 +175,16 @@ def strip_outer_quotes(text):
|
|
|
167
175
|
|
|
168
176
|
def split_pipeline(pipeline):
|
|
169
177
|
lines, buf, quote = [], [], None
|
|
178
|
+
escaped = False
|
|
179
|
+
|
|
170
180
|
for c in pipeline:
|
|
171
|
-
if
|
|
181
|
+
if escaped:
|
|
182
|
+
buf.append(c)
|
|
183
|
+
escaped = False
|
|
184
|
+
elif c == "\\" and quote != "'":
|
|
185
|
+
buf.append(c)
|
|
186
|
+
escaped = True
|
|
187
|
+
elif quote:
|
|
172
188
|
buf.append(c)
|
|
173
189
|
if c == quote:
|
|
174
190
|
quote = None
|
|
@@ -327,7 +343,7 @@ async def handle_log_rx(event):
|
|
|
327
343
|
message = "-- unhandled --"
|
|
328
344
|
|
|
329
345
|
if chan_name != "" :
|
|
330
|
-
width =
|
|
346
|
+
width = shutil.get_terminal_size(fallback=(80, 24)).columns
|
|
331
347
|
cars = width - 13 - len(event.payload["path"]) - len(chan_name) - 1
|
|
332
348
|
dispmsg = message.replace("\n","")[0:cars]
|
|
333
349
|
txt = f"{ANSI_LIGHT_GRAY}{chan_name} {ANSI_DGREEN}{dispmsg+(cars-len(dispmsg))*' '} {ANSI_START}{width-11-len(event.payload['path'])}G{ANSI_YELLOW}[{event.payload['path']}]{ANSI_LIGHT_GRAY}{event.payload['snr']:6,.2f}{event.payload['rssi']:4}{ANSI_END}"
|
|
@@ -566,6 +582,7 @@ def make_completion_dict(contacts, pending=None, to=None, channels=None):
|
|
|
566
582
|
"infos" : None,
|
|
567
583
|
"advert" : None,
|
|
568
584
|
"floodadv" : None,
|
|
585
|
+
"cli" : None,
|
|
569
586
|
"msg" : contact_list,
|
|
570
587
|
"wait_ack" : None,
|
|
571
588
|
"time" : None,
|
|
@@ -618,7 +635,7 @@ def make_completion_dict(contacts, pending=None, to=None, channels=None):
|
|
|
618
635
|
"apply_to": None,
|
|
619
636
|
"at": None,
|
|
620
637
|
"scope": None,
|
|
621
|
-
"
|
|
638
|
+
"send_raw": None,
|
|
622
639
|
"set" : {
|
|
623
640
|
"name" : None,
|
|
624
641
|
"pin" : None,
|
|
@@ -1234,7 +1251,9 @@ async def process_line(mc, line, contact=None, scope="*", prev_contact=None, pre
|
|
|
1234
1251
|
if line.startswith("$$") :
|
|
1235
1252
|
try :
|
|
1236
1253
|
args = shlex.split(line[2:], posix=True)
|
|
1237
|
-
await process_cmds(mc, args, json_output=json_output, sink=sink)
|
|
1254
|
+
res = await process_cmds(mc, args, json_output=json_output, sink=sink)
|
|
1255
|
+
if not res:
|
|
1256
|
+
logger.error(f"Problem while executing {args}")
|
|
1238
1257
|
except ValueError:
|
|
1239
1258
|
logger.error(f"Error parsing line {line[1:]}")
|
|
1240
1259
|
|
|
@@ -1242,6 +1261,9 @@ async def process_line(mc, line, contact=None, scope="*", prev_contact=None, pre
|
|
|
1242
1261
|
|
|
1243
1262
|
line = line.rstrip("\r\n")
|
|
1244
1263
|
|
|
1264
|
+
if line in ["~", "/"]:
|
|
1265
|
+
line = "/to ~"
|
|
1266
|
+
|
|
1245
1267
|
if line.startswith("/scope") or\
|
|
1246
1268
|
line.startswith("scope") and contact is None:
|
|
1247
1269
|
if not scope is None:
|
|
@@ -1345,8 +1367,17 @@ async def process_line(mc, line, contact=None, scope="*", prev_contact=None, pre
|
|
|
1345
1367
|
# commands are passed through if at root
|
|
1346
1368
|
elif contact is None or line.startswith(".") :
|
|
1347
1369
|
try:
|
|
1348
|
-
|
|
1349
|
-
|
|
1370
|
+
if line.startswith(":"):
|
|
1371
|
+
args = ["cli", line[1:].strip()]
|
|
1372
|
+
res = await process_cmds(mc, args, json_output=json_output, sink=sink,end=end)
|
|
1373
|
+
else:
|
|
1374
|
+
args = shlex.split(line, posix=True)
|
|
1375
|
+
res = await process_cmds(mc, args, json_output=json_output, sink=sink,end=end)
|
|
1376
|
+
if not res and HAS_CLI_CMD: # if command was not found, try cli
|
|
1377
|
+
args = ["cli", line.strip()]
|
|
1378
|
+
res = await process_cmds(mc, args, json_output=json_output, sink=sink,end=end)
|
|
1379
|
+
if not res :
|
|
1380
|
+
logger.error(f"Problem while running {args}")
|
|
1350
1381
|
except ValueError:
|
|
1351
1382
|
logger.error(f"Error processing {line}")
|
|
1352
1383
|
|
|
@@ -1368,7 +1399,10 @@ async def process_line(mc, line, contact=None, scope="*", prev_contact=None, pre
|
|
|
1368
1399
|
if line.startswith("send") :
|
|
1369
1400
|
line = line[5:].strip()
|
|
1370
1401
|
line = strip_outer_quotes(line)
|
|
1371
|
-
|
|
1402
|
+
if contact["type"] == 0 : # channel, send msg to channel
|
|
1403
|
+
await send_chan_msg(mc, contact["chan_nb"], strip_outer_quotes(line))
|
|
1404
|
+
else:
|
|
1405
|
+
last_ack = await msg_ack(mc, contact, line)
|
|
1372
1406
|
|
|
1373
1407
|
elif contact["type"] == 0 : # channel, send msg to channel
|
|
1374
1408
|
await send_chan_msg(mc, contact["chan_nb"], strip_outer_quotes(line))
|
|
@@ -2209,6 +2243,7 @@ async def next_cmd(mc, cmds, json_output=False, sink=sys.stdout, end="\n"):
|
|
|
2209
2243
|
if res.payload["fw ver"] >= 3:
|
|
2210
2244
|
output_str += f" Model: {res.payload['model']}\n"
|
|
2211
2245
|
output_str += f" Version: {res.payload['ver']}\n"
|
|
2246
|
+
output_str += f" Comp. radio protocol: {res.payload['fw ver']}\n"
|
|
2212
2247
|
output_str += f" Build date: {res.payload['fw_build']}\n"
|
|
2213
2248
|
if "repeat" in res.payload :
|
|
2214
2249
|
output_str += f" Repeat: {'on' if res.payload['repeat'] else 'off'}{end}"
|
|
@@ -2237,12 +2272,13 @@ async def next_cmd(mc, cmds, json_output=False, sink=sys.stdout, end="\n"):
|
|
|
2237
2272
|
output_str += f"Time synced{end}"
|
|
2238
2273
|
else:
|
|
2239
2274
|
res = await mc.commands.get_time()
|
|
2240
|
-
|
|
2241
|
-
if res.type == EventType.ERROR:
|
|
2275
|
+
if res is None or res.type == EventType.ERROR:
|
|
2242
2276
|
output_str += f"Error getting time: {res}{end}"
|
|
2243
2277
|
elif json_output :
|
|
2278
|
+
timestamp = res.payload["time"]
|
|
2244
2279
|
output_str += json.dumps(res.payload, indent=4)+end
|
|
2245
2280
|
else :
|
|
2281
|
+
timestamp = res.payload["time"]
|
|
2246
2282
|
output_str += 'Current time :'\
|
|
2247
2283
|
+ f' {datetime.datetime.fromtimestamp(timestamp).strftime("%Y-%m-%d %H:%M:%S")}'\
|
|
2248
2284
|
+ f' ({timestamp})'\
|
|
@@ -2881,13 +2917,13 @@ async def next_cmd(mc, cmds, json_output=False, sink=sys.stdout, end="\n"):
|
|
|
2881
2917
|
case "self_telemetry" | "t":
|
|
2882
2918
|
res = await mc.commands.get_self_telemetry()
|
|
2883
2919
|
logger.debug(res)
|
|
2884
|
-
if res
|
|
2885
|
-
output_str += f"Error while requesting telemetry{end}"
|
|
2886
|
-
elif res is None:
|
|
2920
|
+
if res is None:
|
|
2887
2921
|
if json_output :
|
|
2888
2922
|
output_str += json.dumps({"error" : "Timeout waiting telemetry"})+end
|
|
2889
2923
|
else:
|
|
2890
2924
|
output_str += "Timeout waiting telemetry" + end
|
|
2925
|
+
elif res.type == EventType.ERROR:
|
|
2926
|
+
output_str += f"Error while requesting telemetry{end}"
|
|
2891
2927
|
else :
|
|
2892
2928
|
output_str += json.dumps(res.payload, indent=4)+end
|
|
2893
2929
|
|
|
@@ -3019,14 +3055,9 @@ async def next_cmd(mc, cmds, json_output=False, sink=sys.stdout, end="\n"):
|
|
|
3019
3055
|
argnum = 2
|
|
3020
3056
|
dest = None
|
|
3021
3057
|
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
except ValueError:
|
|
3026
|
-
dest = None
|
|
3027
|
-
|
|
3028
|
-
if dest is None:
|
|
3029
|
-
dest = await get_contact_from_arg(mc, cmds[1])
|
|
3058
|
+
# force getting contacts, as we don't know the type
|
|
3059
|
+
# might add rpt_cmd that assumes the contact is a repeater
|
|
3060
|
+
dest = await get_contact_from_arg(mc, cmds[1])
|
|
3030
3061
|
|
|
3031
3062
|
if dest is None:
|
|
3032
3063
|
if json_output :
|
|
@@ -3450,7 +3481,7 @@ async def next_cmd(mc, cmds, json_output=False, sink=sys.stdout, end="\n"):
|
|
|
3450
3481
|
if json_output:
|
|
3451
3482
|
output_str += json.dumps(res, indent=4)+end
|
|
3452
3483
|
else:
|
|
3453
|
-
width =
|
|
3484
|
+
width = shutil.get_terminal_size(fallback=(80, 24)).columns
|
|
3454
3485
|
output_str += f"Got {res['results_count']} neighbours out of {res['neighbours_count']} from {contact['adv_name']}:\n"
|
|
3455
3486
|
first = True
|
|
3456
3487
|
for n in res['neighbours']:
|
|
@@ -3676,7 +3707,7 @@ async def next_cmd(mc, cmds, json_output=False, sink=sys.stdout, end="\n"):
|
|
|
3676
3707
|
else:
|
|
3677
3708
|
output_str += f"Unknown contact {cmds[1]}{end}"
|
|
3678
3709
|
else:
|
|
3679
|
-
res = await mc.commands.change_contact_flags(contact, int(cmds[2]))
|
|
3710
|
+
res = await mc.commands.change_contact_flags(contact, int(cmds[2], 0))
|
|
3680
3711
|
logger.debug(res)
|
|
3681
3712
|
if res.type == EventType.ERROR:
|
|
3682
3713
|
output_str += f"Error setting path: {res}{end}"
|
|
@@ -3882,6 +3913,24 @@ async def next_cmd(mc, cmds, json_output=False, sink=sys.stdout, end="\n"):
|
|
|
3882
3913
|
else:
|
|
3883
3914
|
output_str += f"Advert sent{end}"
|
|
3884
3915
|
|
|
3916
|
+
case "cli":
|
|
3917
|
+
argnum = 1
|
|
3918
|
+
res = await mc.commands.run_cli_command(cmds[1])
|
|
3919
|
+
logger.debug(res)
|
|
3920
|
+
if res.type == EventType.ERROR:
|
|
3921
|
+
output_str += f"Error sending cli command: {res}{end}"
|
|
3922
|
+
elif json_output:
|
|
3923
|
+
output_str += json.dumps(res.payload) + end
|
|
3924
|
+
else:
|
|
3925
|
+
output_str += res.payload['text'] + end
|
|
3926
|
+
|
|
3927
|
+
case "send_raw":
|
|
3928
|
+
argnum = 1
|
|
3929
|
+
res = await mc.commands.send_raw_packet(cmds[1])
|
|
3930
|
+
logger.debug(res)
|
|
3931
|
+
if res.type == EventType.ERROR:
|
|
3932
|
+
output_str += f"Error sending raw packet [{cmds[1]}]: {res}{end}"
|
|
3933
|
+
|
|
3885
3934
|
case "flood_advert" | "floodadv":
|
|
3886
3935
|
res = await mc.commands.send_advert(flood=True)
|
|
3887
3936
|
logger.debug(res)
|
|
@@ -3985,9 +4034,9 @@ async def next_cmd(mc, cmds, json_output=False, sink=sys.stdout, end="\n"):
|
|
|
3985
4034
|
else:
|
|
3986
4035
|
file_name = await prompt_for_file()
|
|
3987
4036
|
|
|
3988
|
-
file_name = file_name.strip()
|
|
3989
|
-
fn = file_name
|
|
3990
4037
|
if not file_name is None:
|
|
4038
|
+
file_name = file_name.strip()
|
|
4039
|
+
fn = file_name
|
|
3991
4040
|
file_name = os.path.expanduser(file_name)
|
|
3992
4041
|
if not os.path.exists(file_name) :
|
|
3993
4042
|
if os.path.exists(MCCLI_CONFIG_DIR + file_name) :
|
|
@@ -4084,7 +4133,7 @@ async def next_cmd(mc, cmds, json_output=False, sink=sys.stdout, end="\n"):
|
|
|
4084
4133
|
pass
|
|
4085
4134
|
|
|
4086
4135
|
case _ :
|
|
4087
|
-
logger.
|
|
4136
|
+
logger.debug(f"Unknown command : {cmd}, {cmds} not executed ...")
|
|
4088
4137
|
return (None, output_str)
|
|
4089
4138
|
|
|
4090
4139
|
logger.debug(f"cmd {cmds[0:argnum+1]} processed ...")
|
|
@@ -4092,14 +4141,14 @@ async def next_cmd(mc, cmds, json_output=False, sink=sys.stdout, end="\n"):
|
|
|
4092
4141
|
|
|
4093
4142
|
except IndexError:
|
|
4094
4143
|
logger.error("Error in parameters")
|
|
4095
|
-
return (
|
|
4144
|
+
return ([], "")
|
|
4096
4145
|
except (EOFError, KeyboardInterrupt):
|
|
4097
4146
|
logger.error("Cancelled")
|
|
4098
|
-
return (
|
|
4147
|
+
return ([], "")
|
|
4099
4148
|
except Exception as e:
|
|
4100
4149
|
logger.error(f"Unexpected error while processing '{cmds[0]}': {e}")
|
|
4101
4150
|
logger.debug(traceback.format_exc())
|
|
4102
|
-
return (
|
|
4151
|
+
return ([], "")
|
|
4103
4152
|
|
|
4104
4153
|
async def process_cmds (mc, cmds, json_output=False, sink=sys.stdout, end="\n") :
|
|
4105
4154
|
while cmds and len(cmds) > 0 :
|
|
@@ -4107,7 +4156,9 @@ async def process_cmds (mc, cmds, json_output=False, sink=sys.stdout, end="\n")
|
|
|
4107
4156
|
if not cur_output is None:
|
|
4108
4157
|
sink.write(cur_output)
|
|
4109
4158
|
sink.flush()
|
|
4110
|
-
|
|
4159
|
+
if cmds is None:
|
|
4160
|
+
return False
|
|
4161
|
+
return True
|
|
4111
4162
|
|
|
4112
4163
|
async def process_script(mc, file, json_output=False, sink=sys.stdout):
|
|
4113
4164
|
output_str = ""
|
|
@@ -4131,7 +4182,9 @@ async def process_script(mc, file, json_output=False, sink=sys.stdout):
|
|
|
4131
4182
|
logger.debug(f"processing {line}")
|
|
4132
4183
|
try :
|
|
4133
4184
|
cmds = shlex.split(line, posix=True)
|
|
4134
|
-
await process_cmds(mc, cmds, json_output=json_output, sink=sink)
|
|
4185
|
+
res = await process_cmds(mc, cmds, json_output=json_output, sink=sink)
|
|
4186
|
+
if not res:
|
|
4187
|
+
logger.error(f"Problem executing {cmds}")
|
|
4135
4188
|
except ValueError:
|
|
4136
4189
|
logger.error(f"Error processing {line}")
|
|
4137
4190
|
return output_str
|
|
@@ -4180,6 +4233,8 @@ def command_help():
|
|
|
4180
4233
|
clock : get current time
|
|
4181
4234
|
clock sync : sync device clock st
|
|
4182
4235
|
node_discover <filter> : discovers nodes based on their type nd
|
|
4236
|
+
cli <cmd> : executes cli command cmd
|
|
4237
|
+
send_raw <pkt> : sends a raw packet (hex string)
|
|
4183
4238
|
Contacts
|
|
4184
4239
|
contacts / list : gets contact list lc
|
|
4185
4240
|
reload_contacts : force reloading all contacts rc
|
|
@@ -4957,6 +5012,7 @@ async def repeater_loop(ser):
|
|
|
4957
5012
|
|
|
4958
5013
|
async def main(argv):
|
|
4959
5014
|
""" Do the job """
|
|
5015
|
+
global HAS_CLI_CMD
|
|
4960
5016
|
json_output = JSON
|
|
4961
5017
|
debug = False
|
|
4962
5018
|
address = ADDRESS
|
|
@@ -5219,11 +5275,14 @@ async def main(argv):
|
|
|
5219
5275
|
if os.path.isdir(MCCLI_CONFIG_DIR) :
|
|
5220
5276
|
log_message.file = MCCLI_CONFIG_DIR + (mc.self_info["name"].replace("/","")) + ".msgs"
|
|
5221
5277
|
|
|
5278
|
+
if res.payload["fw ver"] >= 14 :
|
|
5279
|
+
HAS_CLI_CMD = True
|
|
5280
|
+
|
|
5222
5281
|
if (json_output or quiet) :
|
|
5223
5282
|
logger.setLevel(logging.ERROR)
|
|
5224
5283
|
else :
|
|
5225
5284
|
if res.payload["fw ver"] > 2 :
|
|
5226
|
-
logger.info(f"Connected to {mc.self_info['name']} running on a {res.payload['ver']} fw.")
|
|
5285
|
+
logger.info(f"Connected to {mc.self_info['name']} running on a {res.payload['ver']} ({res.payload['fw ver']}) fw.")
|
|
5227
5286
|
else :
|
|
5228
5287
|
logger.info(f"Connected to {mc.self_info['name']}.")
|
|
5229
5288
|
|
|
@@ -5242,7 +5301,9 @@ async def main(argv):
|
|
|
5242
5301
|
if args[-1] == "interactive" or args[-1] == "chat" or args[-1] == "im":
|
|
5243
5302
|
force_interactive = True
|
|
5244
5303
|
|
|
5245
|
-
await process_cmds(mc, args, json_output=json_output, sink=sys.stdout)
|
|
5304
|
+
res = await process_cmds(mc, args, json_output=json_output, sink=sys.stdout)
|
|
5305
|
+
if not res :
|
|
5306
|
+
logger.error(f"Problem while executing {args}")
|
|
5246
5307
|
|
|
5247
5308
|
if len(args) == 0 or force_interactive :
|
|
5248
5309
|
await interactive_loop(mc, json_output=json_output)
|
|
@@ -1,292 +0,0 @@
|
|
|
1
|
-
# Repeater Commands Reference
|
|
2
|
-
|
|
3
|
-
meshcore-cli can interact with repeaters through two fundamentally different paths, each exposing a different set of commands.
|
|
4
|
-
|
|
5
|
-
## Connection Paths
|
|
6
|
-
|
|
7
|
-
### Serial direct (`-r -s <port>`)
|
|
8
|
-
|
|
9
|
-
Connects USB directly to the repeater hardware. The CLI talks to the firmware's text CLI — raw text in, raw text out over UART. This gives access to the firmware's full serial command set.
|
|
10
|
-
|
|
11
|
-
### Client mode (`to <repeater>`)
|
|
12
|
-
|
|
13
|
-
Connects to your companion client node (via BLE, TCP or serial without `-r`), then sends commands to the repeater over the mesh radio network using encrypted MeshCore `cmd` messages. The repeater firmware processes these through its mesh command handler, which is more limited than the serial interface.
|
|
14
|
-
|
|
15
|
-
The transport between you and your companion node (BLE, TCP or serial) does not matter — all three use the same MeshCore API and the same mesh protocol to reach the repeater.
|
|
16
|
-
|
|
17
|
-
<pre>
|
|
18
|
-
+------------------+
|
|
19
|
-
-r -s (serial) ------->| Firmware text CLI | (raw UART)
|
|
20
|
-
| on repeater |
|
|
21
|
-
+------------------+
|
|
22
|
-
|
|
23
|
-
+--------------+ +-------------------+
|
|
24
|
-
BLE -----+ | | mesh | Firmware mesh cmd |
|
|
25
|
-
TCP -----+--> MeshCore --> Companion +------->| handler on |
|
|
26
|
-
Serial --+ (same API) | node | radio | repeater |
|
|
27
|
-
+--------------+ +-------------------+
|
|
28
|
-
</pre>
|
|
29
|
-
|
|
30
|
-
## Commands Available in Both Modes
|
|
31
|
-
|
|
32
|
-
The following commands work regardless of how you connect to the repeater. In serial mode they are sent as raw text. In client mode they are wrapped in a `cmd` message and sent over the mesh.
|
|
33
|
-
|
|
34
|
-
### Information
|
|
35
|
-
|
|
36
|
-
<pre>
|
|
37
|
-
ver - Firmware version
|
|
38
|
-
board - Board name
|
|
39
|
-
clock - Show current time
|
|
40
|
-
</pre>
|
|
41
|
-
|
|
42
|
-
### Statistics
|
|
43
|
-
|
|
44
|
-
<pre>
|
|
45
|
-
stats-core - Core stats (uptime, battery, queue)
|
|
46
|
-
stats-radio - Radio stats (RSSI, SNR, noise floor)
|
|
47
|
-
stats-packets - Packet statistics (sent/recv counts)
|
|
48
|
-
clear stats - Reset all statistics
|
|
49
|
-
</pre>
|
|
50
|
-
|
|
51
|
-
### Network
|
|
52
|
-
|
|
53
|
-
<pre>
|
|
54
|
-
neighbors - Show neighboring repeaters (zero-hop)
|
|
55
|
-
neighbor.remove <n> - Remove a specific neighbor
|
|
56
|
-
discover.neighbors - Actively discover neighbors
|
|
57
|
-
advert - Send advertisement now
|
|
58
|
-
</pre>
|
|
59
|
-
|
|
60
|
-
### Logging
|
|
61
|
-
|
|
62
|
-
<pre>
|
|
63
|
-
log start - Enable packet logging
|
|
64
|
-
log stop - Disable packet logging
|
|
65
|
-
</pre>
|
|
66
|
-
|
|
67
|
-
Note: after `log start` in client mode, log data streams back as `RX_LOG_DATA` events and is processed with rich packet parsing (headers, routes, paths, channel/advert echoes). In serial mode, log data is printed as raw firmware text.
|
|
68
|
-
|
|
69
|
-
### Configuration (get/set)
|
|
70
|
-
|
|
71
|
-
<pre>
|
|
72
|
-
get name - Node name
|
|
73
|
-
get role - Node role
|
|
74
|
-
get radio - Radio params (freq,bw,sf,cr)
|
|
75
|
-
get freq - Frequency
|
|
76
|
-
get tx - TX power (dBm)
|
|
77
|
-
get af - Antenna factor
|
|
78
|
-
get repeat - Repeat mode on/off
|
|
79
|
-
get public.key - Node public key
|
|
80
|
-
get lat - Latitude
|
|
81
|
-
get lon - Longitude
|
|
82
|
-
get advert.interval - Advertisement interval (minutes)
|
|
83
|
-
get flood.advert.interval - Flood advertisement interval
|
|
84
|
-
get flood.max - Maximum flood hops
|
|
85
|
-
get guest.password - Guest password
|
|
86
|
-
get allow.read.only - Read-only access mode
|
|
87
|
-
get owner.info - Owner information
|
|
88
|
-
get acl - Access control list
|
|
89
|
-
get rxdelay - RX delay
|
|
90
|
-
get txdelay - TX delay
|
|
91
|
-
get direct.txdelay - Direct TX delay
|
|
92
|
-
|
|
93
|
-
set name <name> - Set node name
|
|
94
|
-
set radio f,bw,sf,cr - Set radio params (reboot to apply)
|
|
95
|
-
set freq <freq> - Set frequency
|
|
96
|
-
set tx <power> - Set TX power (dBm)
|
|
97
|
-
set af <value> - Set antenna factor
|
|
98
|
-
set repeat on|off - Enable/disable repeating
|
|
99
|
-
set lat <value> - Set latitude
|
|
100
|
-
set lon <value> - Set longitude
|
|
101
|
-
set advert.interval <min> - Set advert interval (60-240 min)
|
|
102
|
-
set flood.advert.interval <min> - Set flood advert interval
|
|
103
|
-
set flood.max <value> - Set max flood hops
|
|
104
|
-
set guest.password <pwd> - Set guest password
|
|
105
|
-
set allow.read.only on|off - Set read-only access
|
|
106
|
-
set owner.info <info> - Set owner information
|
|
107
|
-
set rxdelay <value> - Set RX delay
|
|
108
|
-
set txdelay <value> - Set TX delay
|
|
109
|
-
set direct.txdelay <val> - Set direct TX delay
|
|
110
|
-
</pre>
|
|
111
|
-
|
|
112
|
-
### Bridge Configuration (get/set)
|
|
113
|
-
|
|
114
|
-
<pre>
|
|
115
|
-
get bridge.enabled - Bridge enabled state
|
|
116
|
-
get bridge.delay - Bridge delay
|
|
117
|
-
get bridge.source - Bridge source
|
|
118
|
-
get bridge.baud - Bridge baud rate
|
|
119
|
-
get bridge.secret - Bridge secret
|
|
120
|
-
|
|
121
|
-
set bridge.enabled on|off - Enable/disable bridge
|
|
122
|
-
set bridge.delay <value> - Set bridge delay
|
|
123
|
-
set bridge.source <value> - Set bridge source
|
|
124
|
-
set bridge.baud <value> - Set bridge baud rate
|
|
125
|
-
set bridge.secret <value> - Set bridge secret
|
|
126
|
-
</pre>
|
|
127
|
-
|
|
128
|
-
### Region Management
|
|
129
|
-
|
|
130
|
-
<pre>
|
|
131
|
-
region - Display currently configured regions
|
|
132
|
-
region save - Save current region config to flash
|
|
133
|
-
region home - Get/set home region
|
|
134
|
-
region get - Get info (and parent) for a region
|
|
135
|
-
region put - Add or update a region
|
|
136
|
-
region remove - Remove a region definition
|
|
137
|
-
region allowf - Give flood permission to a region
|
|
138
|
-
region denyf - Remove flood permission from a region
|
|
139
|
-
</pre>
|
|
140
|
-
|
|
141
|
-
### GPS
|
|
142
|
-
|
|
143
|
-
<pre>
|
|
144
|
-
gps on|off - Enable/disable GPS
|
|
145
|
-
gps sync - Sync GPS
|
|
146
|
-
gps setloc - Set location from GPS
|
|
147
|
-
gps advert none|share|prefs - GPS advertisement mode
|
|
148
|
-
</pre>
|
|
149
|
-
|
|
150
|
-
### Sensors
|
|
151
|
-
|
|
152
|
-
<pre>
|
|
153
|
-
sensor list - List sensors
|
|
154
|
-
sensor get - Get sensor value
|
|
155
|
-
sensor set - Set sensor value
|
|
156
|
-
</pre>
|
|
157
|
-
|
|
158
|
-
### Other
|
|
159
|
-
|
|
160
|
-
<pre>
|
|
161
|
-
password <pwd> - Set admin password
|
|
162
|
-
powersaving on|off - Toggle power saving mode
|
|
163
|
-
setperm <key> <perm> - Set permissions for a node
|
|
164
|
-
time <epoch> - Set time to given epoch
|
|
165
|
-
reboot - Reboot device
|
|
166
|
-
erase - Erase filesystem
|
|
167
|
-
</pre>
|
|
168
|
-
|
|
169
|
-
## Commands Available Only in Serial Mode (`-r`)
|
|
170
|
-
|
|
171
|
-
These commands only work over the serial text CLI. They return "Unknown command" when sent via mesh `cmd`.
|
|
172
|
-
|
|
173
|
-
### Logging (serial only)
|
|
174
|
-
|
|
175
|
-
<pre>
|
|
176
|
-
log - Dump stored log file to console
|
|
177
|
-
log erase - Erase log file
|
|
178
|
-
</pre>
|
|
179
|
-
|
|
180
|
-
The bare `log` command streams stored log data over the serial output, which doesn't fit the mesh command request/response model. `log erase` is similarly a serial-only operation.
|
|
181
|
-
|
|
182
|
-
### Region File Transfer (serial only)
|
|
183
|
-
|
|
184
|
-
These are meshcore-cli convenience commands that handle file I/O over the serial link:
|
|
185
|
-
|
|
186
|
-
<pre>
|
|
187
|
-
region upload <file> - Upload regions config from local file to node
|
|
188
|
-
region load <file> - Alias for region upload
|
|
189
|
-
region download <file> - Download regions config from node to local file
|
|
190
|
-
region list - List allowed/denied regions
|
|
191
|
-
</pre>
|
|
192
|
-
|
|
193
|
-
### Other Serial-Only Commands
|
|
194
|
-
|
|
195
|
-
<pre>
|
|
196
|
-
tempradio - Temporary radio configuration
|
|
197
|
-
script <file> - Execute a local script file (lines sent one by one)
|
|
198
|
-
clock sync - Sync repeater clock to host time (alias: st, sync_time)
|
|
199
|
-
</pre>
|
|
200
|
-
|
|
201
|
-
Note: `clock sync` in serial mode is intercepted by meshcore-cli, which reads the host clock and sends `time <epoch>` to the firmware. In client mode, `clock sync` is available as a meshcore-cli command on the companion node (not sent to the repeater).
|
|
202
|
-
|
|
203
|
-
## Commands Available Only in Client Mode (`to <repeater>`)
|
|
204
|
-
|
|
205
|
-
These are meshcore-cli commands that use the MeshCore protocol to query repeaters. They are not raw firmware commands — they use dedicated binary protocol messages.
|
|
206
|
-
|
|
207
|
-
### Repeater Management
|
|
208
|
-
|
|
209
|
-
<pre>
|
|
210
|
-
login <pwd> - Log into repeater with password l
|
|
211
|
-
logout - Log out of repeater
|
|
212
|
-
req_status - Request status from repeater rs
|
|
213
|
-
req_neighbours - Request neighbours in binary form rn
|
|
214
|
-
req_regions - Request regions list rr
|
|
215
|
-
req_owner - Request owner information ro
|
|
216
|
-
req_clock - Request repeater timestamp (for sync)
|
|
217
|
-
req_acl - Request access control list ra
|
|
218
|
-
trace - Run a trace to this repeater tr
|
|
219
|
-
dtrace - Discover path and trace dt
|
|
220
|
-
</pre>
|
|
221
|
-
|
|
222
|
-
### Contact Operations (on the repeater contact)
|
|
223
|
-
|
|
224
|
-
<pre>
|
|
225
|
-
contact_info - Print contact info for this repeater ci
|
|
226
|
-
path - Display path to this repeater
|
|
227
|
-
disc_path - Discover new path and display dp
|
|
228
|
-
reset_path - Reset path to flood rp
|
|
229
|
-
change_path <path> - Change the path to this repeater cp
|
|
230
|
-
change_flags <flags> - Change contact flags cf
|
|
231
|
-
share_contact - Share this repeater's contact sc
|
|
232
|
-
export_contact - Export this repeater's URI ec
|
|
233
|
-
req_telemetry - Request telemetry data rt
|
|
234
|
-
forget_password - Remove stored password for repeater fp
|
|
235
|
-
set timeout <value> - Set command timeout for this repeater
|
|
236
|
-
get timeout - Get command timeout for this repeater
|
|
237
|
-
</pre>
|
|
238
|
-
|
|
239
|
-
### Special Operations
|
|
240
|
-
|
|
241
|
-
<pre>
|
|
242
|
-
clkreboot - Clock-aware reboot
|
|
243
|
-
start ota - Start OTA (over-the-air) update
|
|
244
|
-
get telemetry - Alias for req_telemetry
|
|
245
|
-
get status - Alias for req_status
|
|
246
|
-
get acl - Alias for req_acl
|
|
247
|
-
</pre>
|
|
248
|
-
|
|
249
|
-
### Prefix Shortcuts
|
|
250
|
-
|
|
251
|
-
<pre>
|
|
252
|
-
: <cmd> - Force send as raw cmd (e.g. ":ver")
|
|
253
|
-
send <msg> / "<msg> - Send a text message to repeater (room)
|
|
254
|
-
</pre>
|
|
255
|
-
|
|
256
|
-
## Quick Reference Table
|
|
257
|
-
|
|
258
|
-
| Command | Serial (`-r`) | Client (`to`) | Notes |
|
|
259
|
-
| --- | :---: | :---: | --- |
|
|
260
|
-
| ver, board, clock | Yes | Yes | |
|
|
261
|
-
| stats-core/radio/packets | Yes | Yes | |
|
|
262
|
-
| clear stats | Yes | Yes | |
|
|
263
|
-
| neighbors | Yes | Yes | |
|
|
264
|
-
| neighbor.remove | Yes | Yes | |
|
|
265
|
-
| discover.neighbors | Yes | Yes | |
|
|
266
|
-
| advert | Yes | Yes | |
|
|
267
|
-
| log start / log stop | Yes | Yes | Client receives data via RX_LOG_DATA events |
|
|
268
|
-
| log (dump) | Yes | **No** | Serial streaming, no mesh equivalent |
|
|
269
|
-
| log erase | Yes | **No** | Serial only |
|
|
270
|
-
| get/set (all params) | Yes | Yes | |
|
|
271
|
-
| region (get/put/remove/save/home/allowf/denyf) | Yes | Yes | |
|
|
272
|
-
| region upload/download | Yes | **No** | Requires serial file transfer |
|
|
273
|
-
| region list | Yes | **No** | Serial only |
|
|
274
|
-
| gps | Yes | Yes | |
|
|
275
|
-
| sensor | Yes | Yes | |
|
|
276
|
-
| password | Yes | Yes | |
|
|
277
|
-
| powersaving | Yes | Yes | |
|
|
278
|
-
| setperm | Yes | Yes | Client mode resolves contact names to keys |
|
|
279
|
-
| time, reboot, erase | Yes | Yes | |
|
|
280
|
-
| tempradio | Yes | **No** | Serial only |
|
|
281
|
-
| clock sync | Yes | **No** | CLI intercepts and sends `time <epoch>` |
|
|
282
|
-
| script | Yes | **No** | Reads local file, sends lines over serial |
|
|
283
|
-
| login/logout | **No** | Yes | MeshCore protocol commands |
|
|
284
|
-
| req_status | **No** | Yes | Binary protocol request |
|
|
285
|
-
| req_neighbours | **No** | Yes | Binary protocol request |
|
|
286
|
-
| req_regions | **No** | Yes | Binary protocol request |
|
|
287
|
-
| req_owner | **No** | Yes | Binary protocol request |
|
|
288
|
-
| req_clock | **No** | Yes | Binary protocol request |
|
|
289
|
-
| req_acl | **No** | Yes | Binary protocol request |
|
|
290
|
-
| trace/dtrace | **No** | Yes | Path tracing via mesh |
|
|
291
|
-
| contact management | **No** | Yes | CLI-level operations on companion node |
|
|
292
|
-
| clkreboot, start ota | **No** | Yes | Mesh protocol commands |
|
|
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
|