Skip to content

Commit ae30ef7

Browse files
committed
update help and readme
1 parent b8096dd commit ae30ef7

File tree

2 files changed

+162
-75
lines changed

2 files changed

+162
-75
lines changed

README.md

Lines changed: 91 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -40,83 +40,96 @@ Init files can also be defined for a given device, meshcore-cli will look for `&
4040

4141
### Arguments
4242

43-
Arguments mostly deals with ble connection
43+
Arguments mostly deals with connection to the node
4444

4545
<pre>
4646
-h : prints this help
4747
-v : prints version
4848
-j : json output (disables init file)
4949
-D : debug
50-
-S : performs a ble scan and ask for device
51-
-l : list available ble devices and exit
52-
-T &lt;timeout> : timeout for the ble scan (-S and -l) default 2s
53-
-a &lt;address> : specifies device address (can be a name)
54-
-d &lt;name> : filter meshcore devices with name or address
55-
-t &lt;hostname> : connects via tcp/ip
56-
-p &lt;port> : specifies tcp port (default 5000)
57-
-s &lt;port> : use serial port &lt;port>
58-
-b &lt;baudrate> : specify baudrate
50+
-S : scan for devices and show a selector
51+
-l : list available ble/serial devices and exit
52+
-T &lt;timeout&gt; : timeout for the ble scan (-S and -l) default 2s
53+
-a &lt;address&gt; : specifies device address (can be a name)
54+
-d &lt;name&gt; : filter meshcore devices with name or address
55+
-P : forces pairing via the OS
56+
-t &lt;hostname&gt; : connects via tcp/ip
57+
-p &lt;port&gt; : specifies tcp port (default 5000)
58+
-s &lt;port&gt; : use serial port &lt;port&gt;
59+
-b &lt;baudrate&gt; : specify baudrate
60+
-C : toggles classic mode for prompt
61+
-c &lt;on/off&gt; : disables most of color output if off
5962
</pre>
6063

6164
### Available Commands
6265

6366
Commands are given after arguments, they can be chained and some have shortcuts. Also prefixing a command with a dot `.` will force it to output json instead of synthetic result.
6467

6568
<pre>
69+
?&lt;cmd&gt; may give you some more help about cmd
6670
General commands
6771
chat : enter the chat (interactive) mode
68-
chat_to &lt;ct> : enter chat with contact to
69-
script &lt;filename> : execute commands in filename
72+
chat_to &lt;ct&gt; : enter chat with contact to
73+
script &lt;filename&gt; : execute commands in filename
7074
infos : print informations about the node i
7175
self_telemetry : print own telemtry t
7276
card : export this node URI e
7377
ver : firmware version v
7478
reboot : reboots node
75-
sleep &lt;secs> : sleeps for a given amount of secs s
76-
wait_key : wait until user presses &lt;Enter> wk
77-
Messenging
78-
msg &lt;name> &lt;msg> : send message to node by name m {
79+
sleep &lt;secs&gt; : sleeps for a given amount of secs s
80+
wait_key : wait until user presses &lt;Enter&gt; wk
81+
apply_to &lt;f&gt; &lt;cmds&gt; : sends cmds to contacts matching f at
82+
Messaging
83+
msg &lt;name&gt; &lt;msg&gt; : send message to node by name m {
7984
wait_ack : wait an ack wa }
80-
chan &lt;nb> &lt;msg> : send message to channel number &lt;nb> ch
81-
public &lt;msg> : send message to public channel (0) dch
85+
chan &lt;nb&gt; &lt;msg&gt; : send message to channel number &lt;nb&gt; ch
86+
public &lt;msg&gt; : send message to public channel (0) dch
8287
recv : reads next msg r
8388
wait_msg : wait for a message and read it wm
8489
sync_msgs : gets all unread msgs from the node sm
8590
msgs_subscribe : display msgs as they arrive ms
86-
get_channel &lt;n> : get info for channel n
91+
get_channels : prints all channel info
92+
get_channel &lt;n&gt; : get info for channel (by number or name)
8793
set_channel n nm k : set channel info (nb, name, key)
94+
remove_channel &lt;n&gt; : remove channel (by number or name)
95+
scope &lt;s&gt; : sets node's flood scope
8896
Management
8997
advert : sends advert a
9098
floodadv : flood advert
91-
get &lt;param> : gets a param, "get help" for more
92-
set &lt;param> &lt;value> : sets a param, "set help" for more
93-
time &lt;epoch> : sets time to given epoch
99+
get &lt;param&gt; : gets a param, \"get help\" for more
100+
set &lt;param&gt; &lt;value&gt; : sets a param, \"set help\" for more
101+
time &lt;epoch&gt; : sets time to given epoch
94102
clock : get current time
95103
clock sync : sync device clock st
104+
node_discover &lt;filter&gt; : discovers nodes based on their type nd
96105
Contacts
97106
contacts / list : gets contact list lc
98-
contact_info &lt;ct> : prints information for contact ct ci
99-
contact_timeout &lt;ct> v : sets temp default timeout for contact
100-
share_contact &lt;ct> : share a contact with others sc
101-
export_contact &lt;ct> : get a contact's URI ec
102-
import_contact &lt;URI> : import a contact from its URI ic
103-
remove_contact &lt;ct> : removes a contact from this node
104-
path &lt;ct> : diplays path for a contact
105-
reset_path &lt;ct> : resets path to a contact to flood rp
106-
change_path &lt;ct> &lt;pth> : change the path to a contact cp
107-
change_flags &lt;ct> &lt;f> : change contact flags (tel_l|tel_a|star)cf
108-
req_telemetry &lt;ct> : prints telemetry data as json rt
109-
req_mma &lt;ct> : requests min/max/avg for a sensor rm
110-
req_acl &lt;ct> : requests access control list for sensor
107+
reload_contacts : force reloading all contacts rc
108+
contact_info &lt;ct&gt; : prints information for contact ct ci
109+
contact_timeout &lt;ct&gt; v : sets temp default timeout for contact
110+
share_contact &lt;ct&gt; : share a contact with others sc
111+
export_contact &lt;ct&gt; : get a contact's URI ec
112+
import_contact &lt;URI&gt; : import a contact from its URI ic
113+
remove_contact &lt;ct&gt; : removes a contact from this node
114+
path &lt;ct&gt; : diplays path for a contact
115+
disc_path &lt;ct&gt; : discover new path and display dp
116+
reset_path &lt;ct&gt; : resets path to a contact to flood rp
117+
change_path &lt;ct&gt; &lt;pth&gt; : change the path to a contact cp
118+
change_flags &lt;ct&gt; &lt;f&gt; : change contact flags (tel_l|tel_a|star)cf
119+
req_telemetry &lt;ct&gt; : prints telemetry data as json rt
120+
req_mma &lt;ct&gt; : requests min/max/avg for a sensor rm
121+
req_acl &lt;ct&gt; : requests access control list for sensor
111122
pending_contacts : show pending contacts
112-
add_pending &lt;key> : manually add pending contact from key
113-
flush_pending : flush pending contact clist
123+
add_pending &lt;pending&gt; : manually add pending contact
124+
flush_pending : flush pending contact list
114125
Repeaters
115-
login &lt;name> &lt;pwd> : log into a node (rep) with given pwd l
116-
logout &lt;name> : log out of a repeater
117-
cmd &lt;name> &lt;cmd> : sends a command to a repeater (no ack) c [
126+
login &lt;name&gt; &lt;pwd&gt; : log into a node (rep) with given pwd l
127+
logout &lt;name&gt; : log out of a repeater
128+
cmd &lt;name&gt; &lt;cmd&gt; : sends a command to a repeater (no ack) c [
118129
wmt8 : wait for a msg (reply) with a timeout ]
119-
req_status &lt;name> : requests status from a node rs
130+
req_status &lt;name&gt; : requests status from a node rs
131+
req_neighbours &lt;name&gt; : requests for neighbours in binary form rn
132+
trace &lt;path&gt; : run a trace, path is comma separated
120133
</pre>
121134

122135
### Interactive Mode
@@ -138,6 +151,43 @@ When you are connected to a node, the behaviour will depend on the node type, if
138151

139152
You can alse set a channel as recipient, `to public` will switch to the public channel, and `to ch1` to channel 1.
140153

154+
#### Flood Scope in interactive mode
155+
156+
Flood scope has recently been introduced in meshcore (from `v1.10.0`). It limits the scope of packets to regions, using transport codes in the frame.
157+
158+
When entering chat mode, scope will be reset to `*`, meaning classic flood.
159+
160+
You can switch scope using the `scope` command, or postfixing the `to` command with `%<scope>`.
161+
162+
Scope can also be applied to a command using `%` before the scope name. For instance `login%#Morbihan` will limit diffusion of the login command (which is usually sent flood to get the path to a repeater) to the `#Morbihan` region.
163+
164+
### Issuing batch commands to contacts with apply to
165+
166+
`apply_to <f> <cmd>` : applies cmd to contacts matching filter `<f>` it can be used to apply the same command to a pool of repeaters, or remove some contacts matching a condition.
167+
168+
Filter is constructed with comma separated fields :
169+
170+
- `u`, matches modification time `<` or `>` than a timestamp (can also be days hours or minutes ago if followed by `d`,`h` or `m`)
171+
- `t`, matches the type (1: client, 2: repeater, 3: room, 4: sensor)
172+
- `h`, matches number of hops
173+
- `d`, direct, similar to `h>-1`
174+
- `f`, flood, similar to `h<0` or `h=-1`
175+
176+
Commands should be written as if in interactive mode, if writing from the commandline don't forget to use commas to clearly delimit fields.
177+
178+
Note: Some commands like `contact_name` (aka `cn`), `reset_path` (aka `rp`), `forget_password` (aka `fp`) can be chained. There is also a `sleep` command taking an optional time parameter. The sleep will be issued after the command, it helps limiting rate through repeaters ...
179+
180+
#### Examples
181+
182+
```
183+
# removes all clients that have not been updated in last 2 days
184+
at u<2d,t=1 remove_contact
185+
# gives traces to repeaters that have been updated in the last 24h and are direct
186+
at t=2,u>1d,d cn trace
187+
# tries to do flood login to all repeaters
188+
at t=2 rp login
189+
```
190+
141191
## Examples
142192

143193
<pre>

src/meshcore_cli/meshcore_cli.py

Lines changed: 71 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1746,19 +1746,7 @@ async def next_cmd(mc, cmds, json_output=False):
17461746
match cmds[1]:
17471747
case "help" :
17481748
argnum = 1
1749-
print("""Available parameters :
1750-
pin <pin> : ble pin
1751-
radio <freq,bw,sf,cr> : radio params
1752-
tuning <rx_dly,af> : tuning params
1753-
tx <dbm> : tx power
1754-
name <name> : node name
1755-
lat <lat> : latitude
1756-
lon <lon> : longitude
1757-
coords <lat,lon> : coordinates
1758-
print_snr <on/off> : toggle snr display in messages
1759-
print_adverts <on/off> : display adverts as they come
1760-
print_new_contacts <on/off> : display new pending contacts when available
1761-
print_path_updates <on/off> : display path updates as they come""")
1749+
get_help_for("set")
17621750
case "max_flood_attempts":
17631751
msg_ack.max_flood_attempts=int(cmds[2])
17641752
case "max_attempts":
@@ -1982,21 +1970,7 @@ async def next_cmd(mc, cmds, json_output=False):
19821970
argnum = 1
19831971
match cmds[1]:
19841972
case "help":
1985-
print("""Gets parameters from node
1986-
name : node name
1987-
bat : battery level in mV
1988-
fstats : fs statistics
1989-
coords : adv coordinates
1990-
lat : latitude
1991-
lon : longitude
1992-
radio : radio parameters
1993-
tx : tx power
1994-
print_snr : snr display in messages
1995-
print_adverts : display adverts as they come
1996-
print_new_contacts : display new pending contacts when available
1997-
print_path_updates : display path updates as they come
1998-
custom : all custom variables in json format
1999-
each custom var can also be get/set directly""")
1973+
get_help_for("get")
20001974
case "max_flood_attempts":
20011975
if json_output :
20021976
print(json.dumps({"max_flood_attempts" : msg_ack.max_flood_attempts}))
@@ -3107,8 +3081,8 @@ def command_help():
31073081
reboot : reboots node
31083082
sleep <secs> : sleeps for a given amount of secs s
31093083
wait_key : wait until user presses <Enter> wk
3110-
apply_to <scope> <cmds>: sends cmds to contacts matching scope at
3111-
Messenging
3084+
apply_to <f> <cmds> : sends cmds to contacts matching f at
3085+
Messaging
31123086
msg <name> <msg> : send message to node by name m {
31133087
wait_ack : wait an ack wa }
31143088
chan <nb> <msg> : send message to channel number <nb> ch
@@ -3121,6 +3095,7 @@ def command_help():
31213095
get_channel <n> : get info for channel (by number or name)
31223096
set_channel n nm k : set channel info (nb, name, key)
31233097
remove_channel <n> : remove channel (by number or name)
3098+
scope <s> : sets scope for flood messages
31243099
Management
31253100
advert : sends advert a
31263101
floodadv : flood advert
@@ -3172,8 +3147,6 @@ def usage () :
31723147
-D : debug
31733148
-S : scan for devices and show a selector
31743149
-l : list available ble/serial devices and exit
3175-
-C : toggles classic mode for prompt
3176-
-c <on/off> : disables most of color output if off
31773150
-T <timeout> : timeout for the ble scan (-S and -l) default 2s
31783151
-a <address> : specifies device address (can be a name)
31793152
-d <name> : filter meshcore devices with name or address
@@ -3182,14 +3155,16 @@ def usage () :
31823155
-p <port> : specifies tcp port (default 5000)
31833156
-s <port> : use serial port <port>
31843157
-b <baudrate> : specify baudrate
3158+
-C : toggles classic mode for prompt
3159+
-c <on/off> : disables most of color output if off
31853160
31863161
Available Commands and shorcuts (can be chained) :""")
31873162
command_help()
31883163

31893164
def get_help_for (cmdname, context="line") :
31903165
if cmdname == "apply_to" or cmdname == "at" :
3191-
print("""apply_to <scope> <cmd> : applies cmd to contacts matching scope
3192-
Scope acts like a filter with comma separated fields :
3166+
print("""apply_to <f> <cmd> : applies cmd to contacts matching filter <f>
3167+
Filter is constructed with comma separated fields :
31933168
- u, matches modification time < or > than a timestamp
31943169
(can also be days hours or minutes ago if followed by d,h or m)
31953170
- t, matches the type (1: client, 2: repeater, 3: room, 4: sensor)
@@ -3220,6 +3195,68 @@ def get_help_for (cmdname, context="line") :
32203195
nd can be used with no filter parameter ... !!! BEWARE WITH CHAINING !!!
32213196
""")
32223197

3198+
elif cmdname == "get" :
3199+
print("""Gets parameters from node
3200+
Please see also help for set command, which is more up to date ...
3201+
name : node name
3202+
bat : battery level in mV
3203+
fstats : fs statistics
3204+
coords : adv coordinates
3205+
lat : latitude
3206+
lon : longitude
3207+
radio : radio parameters
3208+
tx : tx power
3209+
print_snr : snr display in messages
3210+
print_adverts : display adverts as they come
3211+
print_new_contacts : display new pending contacts when available
3212+
print_path_updates : display path updates as they come
3213+
custom : all custom variables in json format
3214+
each custom var can also be get/set directly""")
3215+
3216+
elif cmdname == "set" :
3217+
print("""Available parameters :
3218+
device:
3219+
pin <pin> : ble pin
3220+
radio <freq,bw,sf,cr> : radio params
3221+
tuning <rx_dly,af> : tuning params
3222+
tx <dbm> : tx power
3223+
name <name> : node name
3224+
lat <lat> : latitude
3225+
lon <lon> : longitude
3226+
coords <lat,lon> : coordinates
3227+
auto_update_contacts <> : automatically updates contact list
3228+
multi_ack <on/off> : multi-acks feature
3229+
telemetry_mode_base <mode> : set basic telemetry mode all/selected/off
3230+
telemetry_mode_loc <mode> : set location telemetry mode all/selected/off
3231+
telemetry_mode_env <mode> : set env telemetry mode all/selected/off
3232+
advert_loc_policy <policy> : "share" means loc will be shared in adv
3233+
display:
3234+
print_snr <on/off> : toggle snr display in messages
3235+
print_adverts <on/off> : display adverts as they come
3236+
print_new_contacts <on/off> : display new pending contacts when available
3237+
print_path_updates <on/off> : display path updates as they come
3238+
json_log_rx <on/off> : logs packets incoming to device as json
3239+
channel_echoes <on/off> : print repeats for channel data
3240+
echo_unk_channels <on/off> : also dump unk channels (encrypted)
3241+
color <on/off> : color off should remove ANSI codes from output
3242+
prompt:
3243+
classic_prompt <on/off> : activates less fancier prompt
3244+
arrow_head <string> : change arrow head in prompt
3245+
slash_start <string> : idem for slash start
3246+
slash_end <string> : slash end
3247+
invert_slash <on/off> : apply color inversion to slash """)
3248+
3249+
elif cmdname == "scope":
3250+
print("""scope <scope> : changes flood scope of the node
3251+
3252+
The scope command can be used from command line or interactive mode to set the region in which flood packets will be transmitted.
3253+
3254+
Managing Flood Scope in interactive mode
3255+
Flood scope has recently been introduced in meshcore (from v1.10.0). It limits the scope of packets to regions, using transport codes in the frame.
3256+
When entering chat mode, scope will be reset to *, meaning classic flood.
3257+
You can switch scope using the scope command, or postfixing the to command with %<scope>.
3258+
Scope can also be applied to a command using % before the scope name. For instance login%#Morbihan will limit diffusion of the login command (which is usually sent flood to get the path to a repeater) to the #Morbihan region.""")
3259+
32233260
else:
32243261
print(f"Sorry, no help yet for {cmdname}")
32253262

0 commit comments

Comments
 (0)