meshcore-cli 1.2.14__tar.gz → 1.3.4__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.
@@ -0,0 +1,348 @@
1
+ Metadata-Version: 2.4
2
+ Name: meshcore-cli
3
+ Version: 1.3.4
4
+ Summary: Command line interface to meshcore companion radios
5
+ Project-URL: Homepage, https://github.com/fdlamotte/meshcore-cli
6
+ Project-URL: Issues, https://github.com/fdlamotte/meshcore-cli/issues
7
+ Author-email: Florent de Lamotte <florent@frizoncorrea.fr>
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Programming Language :: Python :: 3
12
+ Requires-Python: >=3.10
13
+ Requires-Dist: meshcore>=2.2.1
14
+ Requires-Dist: prompt-toolkit>=3.0.50
15
+ Requires-Dist: pycryptodome
16
+ Requires-Dist: requests>=2.28.0
17
+ Description-Content-Type: text/markdown
18
+
19
+ # meshcore-cli
20
+
21
+ meshcore-cli : CLI interface to MeschCore companion app over BLE, TCP or Serial
22
+
23
+ ## Install
24
+
25
+ Meshcore-cli depends on the [python meshcore](https://github.com/fdlamotte/meshcore_py) package. You can install both via `pip` or `pipx` using the command:
26
+
27
+ <pre>
28
+ $ pipx install meshcore-cli
29
+ </pre>
30
+
31
+ It will install you `meshcore-cli` and `meshcli`, which is an alias to the former.
32
+
33
+ You can use the flake under [nix](https://nixos.org/):
34
+
35
+ <pre>
36
+ $ nix run github:meshcore-dev/meshcore-cli#meshcore-cli
37
+ </pre>
38
+
39
+ If you want meshcore-cli to remember last BLE device, you should have some `$HOME/.config/meshcore` where configuration for meschcore-cli will be stored (if not it will use first device it finds).
40
+
41
+ ## Usage
42
+
43
+ <pre>
44
+ $ meshcli &lt;args&gt; &lt;commands&gt;
45
+ </pre>
46
+
47
+ If using BLE, don't forget to pair your device first (using `bluetoothctl` for instance on Linux) or meshcli won't be able to communicate. There is a device selector for BLE, you'll just have to use `meshcli -S` to select your device, subsequent calls to meshcli will be send to that device.
48
+
49
+ ### Configuration
50
+
51
+ Configuration files are stored in `$HOME/.config/meshcore`
52
+
53
+ If the directory exists, default ble address and history will be stored there.
54
+
55
+ If there is an initialization script file called `init`, it will be executed just before the commands provided on command line are executed (and after evaluation of the arguments).
56
+
57
+ Init files can also be defined for a given device, meshcore-cli will look for `&lt;device-name>.init` file in configuration directory (usefull to specify timeout for contacts that are behind bridges with `contact_timeout` command).
58
+
59
+ ### Arguments
60
+
61
+ Arguments mostly deals with connection to the node
62
+
63
+ <pre>
64
+ -h : prints this help
65
+ -v : prints version
66
+ -j : json output (disables init file)
67
+ -D : debug
68
+ -S : scan for devices and show a selector
69
+ -l : list available ble/serial devices and exit
70
+ -T &lt;timeout&gt; : timeout for the ble scan (-S and -l) default 2s
71
+ -a &lt;address&gt; : specifies device address (can be a name)
72
+ -d &lt;name&gt; : filter meshcore devices with name or address
73
+ -P : forces pairing via the OS
74
+ -t &lt;hostname&gt; : connects via tcp/ip
75
+ -p &lt;port&gt; : specifies tcp port (default 5000)
76
+ -s &lt;port&gt; : use serial port &lt;port&gt;
77
+ -b &lt;baudrate&gt; : specify baudrate
78
+ -C : toggles classic mode for prompt
79
+ -c &lt;on/off&gt; : disables most of color output if off
80
+ </pre>
81
+
82
+ ### Available Commands
83
+
84
+ 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.
85
+
86
+ <pre>
87
+ ?&lt;cmd&gt; may give you some more help about cmd
88
+ General commands
89
+ chat : enter the chat (interactive) mode
90
+ chat_to &lt;ct&gt; : enter chat with contact to
91
+ script &lt;filename&gt; : execute commands in filename
92
+ infos : print informations about the node i
93
+ self_telemetry : print own telemtry t
94
+ card : export this node URI e
95
+ ver : firmware version v
96
+ reboot : reboots node
97
+ sleep &lt;secs&gt; : sleeps for a given amount of secs s
98
+ wait_key : wait until user presses &lt;Enter&gt; wk
99
+ apply_to &lt;f&gt; &lt;cmds&gt; : sends cmds to contacts matching f at
100
+ Messaging
101
+ msg &lt;name&gt; &lt;msg&gt; : send message to node by name m {
102
+ wait_ack : wait an ack wa }
103
+ chan &lt;nb&gt; &lt;msg&gt; : send message to channel number &lt;nb&gt; ch
104
+ public &lt;msg&gt; : send message to public channel (0) dch
105
+ recv : reads next msg r
106
+ wait_msg : wait for a message and read it wm
107
+ sync_msgs : gets all unread msgs from the node sm
108
+ msgs_subscribe : display msgs as they arrive ms
109
+ get_channels : prints all channel info
110
+ get_channel &lt;n&gt; : get info for channel (by number or name)
111
+ set_channel n nm k : set channel info (nb, name, key)
112
+ remove_channel &lt;n&gt; : remove channel (by number or name)
113
+ scope &lt;s&gt; : sets node's flood scope
114
+ Management
115
+ advert : sends advert a
116
+ floodadv : flood advert
117
+ get &lt;param&gt; : gets a param, \"get help\" for more
118
+ set &lt;param&gt; &lt;value&gt; : sets a param, \"set help\" for more
119
+ time &lt;epoch&gt; : sets time to given epoch
120
+ clock : get current time
121
+ clock sync : sync device clock st
122
+ node_discover &lt;filter&gt; : discovers nodes based on their type nd
123
+ Contacts
124
+ contacts / list : gets contact list lc
125
+ reload_contacts : force reloading all contacts rc
126
+ contact_info &lt;ct&gt; : prints information for contact ct ci
127
+ contact_timeout &lt;ct&gt; v : sets temp default timeout for contact
128
+ share_contact &lt;ct&gt; : share a contact with others sc
129
+ export_contact &lt;ct&gt; : get a contact's URI ec
130
+ import_contact &lt;URI&gt; : import a contact from its URI ic
131
+ remove_contact &lt;ct&gt; : removes a contact from this node
132
+ path &lt;ct&gt; : diplays path for a contact
133
+ disc_path &lt;ct&gt; : discover new path and display dp
134
+ reset_path &lt;ct&gt; : resets path to a contact to flood rp
135
+ change_path &lt;ct&gt; &lt;pth&gt; : change the path to a contact cp
136
+ change_flags &lt;ct&gt; &lt;f&gt; : change contact flags (tel_l|tel_a|star)cf
137
+ req_telemetry &lt;ct&gt; : prints telemetry data as json rt
138
+ req_mma &lt;ct&gt; : requests min/max/avg for a sensor rm
139
+ req_acl &lt;ct&gt; : requests access control list for sensor
140
+ pending_contacts : show pending contacts
141
+ add_pending &lt;pending&gt; : manually add pending contact
142
+ flush_pending : flush pending contact list
143
+ Repeaters
144
+ login &lt;name&gt; &lt;pwd&gt; : log into a node (rep) with given pwd l
145
+ logout &lt;name&gt; : log out of a repeater
146
+ cmd &lt;name&gt; &lt;cmd&gt; : sends a command to a repeater (no ack) c [
147
+ wmt8 : wait for a msg (reply) with a timeout ]
148
+ req_status &lt;name&gt; : requests status from a node rs
149
+ req_neighbours &lt;name&gt; : requests for neighbours in binary form rn
150
+ trace &lt;path&gt; : run a trace, path is comma separated
151
+ </pre>
152
+
153
+ ### Interactive Mode
154
+
155
+ aka Instant Message or chat mode ...
156
+
157
+ Chat mode lets you interactively interact with your node or remote nodes. It is automatically triggered when no option is given on the command line.
158
+
159
+ You'll get a prompt with the name of your node. From here you can type meshcore-cli commands. The prompt has history and a basic completion (pressing tab will display possible command or argument options).
160
+
161
+ The `to` command is specific to chat mode, it lets you enter the recipient for next command. By default you're on your node but you can enter other nodes or public rooms. Here are some examples :
162
+
163
+ - `to <dest>` : will enter dest (node or channel)
164
+ - `to /`, `to ~` : will go to the root (your node)
165
+ - `to ..` : will go to the last node (it will switch between the two last nodes, this is just a 1-depth history)
166
+ - `to !` : will switch to the node you received last message from
167
+
168
+ When you are in a node, the behaviour will depend on the node type, if you're on a chat node, it will send messages by default and you can chat. On a repeater or a room server, it will send commands (autocompletion has been set to comply with the CommonCli class of meshcore). To send a message through a room you'll have to prefix the message with a quote or use the send command.
169
+
170
+ The `/` character is used to bypass the node you have currently selected using `to`:
171
+ - `/<cmd>` issues cmd command on the root
172
+ - `/<node>/<cmd>` will send cmd to selected node
173
+ - `/<dest> <msg>` will send msg to dest (channel or node)
174
+
175
+ #### Flood Scope in interactive mode
176
+
177
+ 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.
178
+
179
+ When entering chat mode, scope will be reset to `*`, meaning classic flood.
180
+
181
+ You can switch scope using the `scope` command, or postfixing the `to` command with `%<scope>`.
182
+
183
+ 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.
184
+
185
+ #### Channel echoes
186
+
187
+ It's sometimes interesting to know the path taken by a message received from a channel or which repeaters have repeated a sent message.
188
+
189
+ The app give you the information by listening `rx_log` from the device, when obtained the information is attached to the message and can be read.
190
+
191
+ In meshcore-cli I went lower-level by implementing channel echoes. When activated (with `/set channel_echoes on`), all the channel messages will be printed on the terminal along with the SNR and path taken. When sending a message, you'll have all the repeats from 0-hop repeaters as echoes, and when a message is received, you should see information about the received message, but also all the instances of the same message that might have reached you from another path.
192
+
193
+ In the example below, a msg has been sent between two repeaters, 21 and 25. 25 repeated the message and 21 the repeat and both echoes came back to the node with different SNRs.
194
+
195
+ ```
196
+ f1down/#fdl|*> 8
197
+ #fdl f1down: 8 [25] -4.75-112
198
+ #fdl f1down: 8 [2521] 1.00-109
199
+ ```
200
+
201
+ ### Contact management
202
+
203
+ To receive a message from another user, it is necessary to have its public key. This key is stored on a contact list in the device, and this list has a finite size (50 when meshcore started, now over 350 for most devices).
204
+
205
+ By default contacts are automatically added to the device contact list when an advertisement is received, so as soon as you receive an advert, you can talk with your buddy.
206
+
207
+ With growing number of users, it becomes necessary to manage contact list and one of the ways is to add contacts manually to the device. This is done by turning on `manual_add_contacts`. Once this option has been turned on, a pending list is built by meshcore-cli from the received adverts. You can view the list issuing a `pending_contacts` command, flush the list using `flush_pending` or add a contact from the list with `add_pending` followed by the key of the contact or its name (both will be auto-completed with tab).
208
+
209
+ This feature only really works in interactive mode.
210
+
211
+ Note: There is also an `auto_update_contacts` setting that has nothing to do with adding contacts, it permits to automatically sync contact lists between device and meshcore-cli (when there is an update in name, location or path).
212
+
213
+ ### Issuing batch commands to contacts with apply to
214
+
215
+ `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.
216
+
217
+ Filter is constructed with comma separated fields :
218
+
219
+ - `u`, matches modification time `<` or `>` than a timestamp (can also be days hours or minutes ago if followed by `d`,`h` or `m`)
220
+ - `t`, matches the type (1: client, 2: repeater, 3: room, 4: sensor)
221
+ - `h`, matches number of hops
222
+ - `d`, direct, similar to `h>-1`
223
+ - `f`, flood, similar to `h<0` or `h=-1`
224
+
225
+ Commands should be written as if in interactive mode, if writing from the commandline don't forget to use commas to clearly delimit fields.
226
+
227
+ 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 ...
228
+
229
+ #### Examples
230
+
231
+ ```
232
+ # removes all clients that have not been updated in last 2 days
233
+ at u<2d,t=1 remove_contact
234
+ # gives traces to repeaters that have been updated in the last 24h and are direct
235
+ at t=2,u>1d,d cn trace
236
+ # tries to do flood login to all repeaters
237
+ at t=2 rp login
238
+ ```
239
+
240
+ ## Examples
241
+
242
+ <pre>
243
+ # gets info from first ble MC device it finds (was -s but now used for serial port)
244
+ $ meshcore-cli -d "" infos
245
+ INFO:meshcore:Scanning for devices
246
+ INFO:meshcore:Found device : C2:2B:A1:D5:3E:B6: MeshCore-t114_fdl
247
+ INFO:meshcore:BLE Connection started
248
+ {
249
+ "adv_type": 1,
250
+ "tx_power": 22,
251
+ "max_tx_power": 22,
252
+ "public_key": "993acd42fc779962c68c627829b32b111fa27a67d86b75c17460ff48c3102db4",
253
+ "adv_lat": 47.794,
254
+ "adv_lon": -3.428,
255
+ "radio_freq": 869.525,
256
+ "radio_bw": 250.0,
257
+ "radio_sf": 11,
258
+ "radio_cr": 5,
259
+ "name": "t114_fdl"
260
+ }
261
+
262
+ # getting time
263
+ $ meshcli -a C2:2B:A1:D5:3E:B6 clock
264
+ INFO:meshcore:BLE Connection started
265
+ Current time : 2025-04-18 08:19:26 (1744957166)
266
+
267
+ # If you're familiar with meshcli, you should have noted that
268
+ # now output is not json only, to get json output, use -j
269
+ # or prefix your commands with a dot
270
+ $ meshcli -a C2:2B:A1:D5:3E:B6 .clock
271
+ INFO:meshcore:BLE Connection started
272
+ {
273
+ "time": 1744957249
274
+ }
275
+
276
+ # Using -j, meshcli will return replies in json format ...
277
+ $ meshcli -j -a C2:2B:A1:D5:3E:B6 clock
278
+ {
279
+ "time": 1744957261
280
+ }
281
+
282
+ # So if I reboot the node, and want to set time, I can chain the commands
283
+ # and get that kind of output (even better by feeding it to jq)
284
+ $ meshcli reboot
285
+ INFO:meshcore:BLE Connection started
286
+ $ meshcli -j clock clock sync clock | jq -c
287
+ { "time": 1715770371 }
288
+ { "ok": "time synced" }
289
+ { "time": 1745996105 }
290
+
291
+ # Now check if time is ok with human output (I don't read epoch time yet)
292
+ $ meshcli clock
293
+ INFO:meshcore:BLE Connection started
294
+ Current time : 2025-04-30 08:56:27 (1745996187)
295
+
296
+ # Now you'll probably want to send some messages ...
297
+ # For that, there is the msg command, wait_ack
298
+ $ meshcli msg Techo_fdl "Hello T-Echo" wa
299
+ INFO:meshcore:BLE Connection started
300
+ Msg acked
301
+
302
+ # I can check the message on the techo
303
+ $ meshcli -d Techo sm
304
+ INFO:meshcore:Scanning for devices
305
+ INFO:meshcore:Found device : DE:B6:D0:68:D5:62: MeshCore-Techo_fdl
306
+ INFO:meshcore:BLE Connection started
307
+ t114_fdl(0): Hello T-Echo
308
+
309
+ # And reply using json output for more verbosity
310
+ # here I've used jq with -cs to get a compact array
311
+ $ meshcli msg t114_fdl hello wa | jq -cs
312
+ [{"type":0,"expected_ack":"4802ed93","suggested_timeout":2970},{"code":"4802ed93"}]
313
+
314
+ # But this could have been done interactively using the chat mode
315
+ # Here from the techo side. Note that un-acked messages will be
316
+ # signaled with an ! at the start of the prompt (or red color in color mode)
317
+ $ meshcli chat
318
+ INFO:meshcore:BLE Connection started
319
+ Interactive mode, most commands from terminal chat should work.
320
+ Use "to" to selects contact, "list" to list contacts, "send" to send a message ...
321
+ Line starting with "$" or "." will issue a meshcli command.
322
+ "quit" or "q" will end interactive mode
323
+ t114_fdl(D): Hello T-Echo
324
+ EnsibsRoom> Hi
325
+ !EnsibsRoom> to t114_fdl
326
+ t114_fdl> Hi
327
+ t114_fdl(D): It took you long to reply ...
328
+ t114_fdl> I forgot to set the recipient with the to command
329
+ t114_fdl(D): It happens ...
330
+ t114_fdl>
331
+
332
+ # Loging into repeaters and sending commands is also possible
333
+ # directly from the chat, because we can use meshcli commands ;)
334
+ $ meshcli chat (pending msgs are shown at connexion ...)
335
+ INFO:meshcore:BLE Connection started
336
+ Interactive mode, most commands from terminal chat should work.
337
+ Use "to" to selects contact, "list" to list contacts, "send" to send a message ...
338
+ Line starting with "$" or "." will issue a meshcli command.
339
+ "quit" or "q" will end interactive mode
340
+ Techo_fdl(0): Cool to receive some msgs from you
341
+ Techo_fdl(D): Hi
342
+ Techo_fdl(D): I forgot to set the recipient with the to command
343
+ FdlRoom> login password
344
+ Login success
345
+ FdlRoom> clock
346
+ FdlRoom(0): 06:40 - 18/4/2025 UTC
347
+ FdlRoom>
348
+ </pre>
@@ -0,0 +1,330 @@
1
+ # meshcore-cli
2
+
3
+ meshcore-cli : CLI interface to MeschCore companion app over BLE, TCP or Serial
4
+
5
+ ## Install
6
+
7
+ Meshcore-cli depends on the [python meshcore](https://github.com/fdlamotte/meshcore_py) package. You can install both via `pip` or `pipx` using the command:
8
+
9
+ <pre>
10
+ $ pipx install meshcore-cli
11
+ </pre>
12
+
13
+ It will install you `meshcore-cli` and `meshcli`, which is an alias to the former.
14
+
15
+ You can use the flake under [nix](https://nixos.org/):
16
+
17
+ <pre>
18
+ $ nix run github:meshcore-dev/meshcore-cli#meshcore-cli
19
+ </pre>
20
+
21
+ If you want meshcore-cli to remember last BLE device, you should have some `$HOME/.config/meshcore` where configuration for meschcore-cli will be stored (if not it will use first device it finds).
22
+
23
+ ## Usage
24
+
25
+ <pre>
26
+ $ meshcli &lt;args&gt; &lt;commands&gt;
27
+ </pre>
28
+
29
+ If using BLE, don't forget to pair your device first (using `bluetoothctl` for instance on Linux) or meshcli won't be able to communicate. There is a device selector for BLE, you'll just have to use `meshcli -S` to select your device, subsequent calls to meshcli will be send to that device.
30
+
31
+ ### Configuration
32
+
33
+ Configuration files are stored in `$HOME/.config/meshcore`
34
+
35
+ If the directory exists, default ble address and history will be stored there.
36
+
37
+ If there is an initialization script file called `init`, it will be executed just before the commands provided on command line are executed (and after evaluation of the arguments).
38
+
39
+ Init files can also be defined for a given device, meshcore-cli will look for `&lt;device-name>.init` file in configuration directory (usefull to specify timeout for contacts that are behind bridges with `contact_timeout` command).
40
+
41
+ ### Arguments
42
+
43
+ Arguments mostly deals with connection to the node
44
+
45
+ <pre>
46
+ -h : prints this help
47
+ -v : prints version
48
+ -j : json output (disables init file)
49
+ -D : debug
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
62
+ </pre>
63
+
64
+ ### Available Commands
65
+
66
+ 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.
67
+
68
+ <pre>
69
+ ?&lt;cmd&gt; may give you some more help about cmd
70
+ General commands
71
+ chat : enter the chat (interactive) mode
72
+ chat_to &lt;ct&gt; : enter chat with contact to
73
+ script &lt;filename&gt; : execute commands in filename
74
+ infos : print informations about the node i
75
+ self_telemetry : print own telemtry t
76
+ card : export this node URI e
77
+ ver : firmware version v
78
+ reboot : reboots node
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 {
84
+ wait_ack : wait an ack wa }
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
87
+ recv : reads next msg r
88
+ wait_msg : wait for a message and read it wm
89
+ sync_msgs : gets all unread msgs from the node sm
90
+ msgs_subscribe : display msgs as they arrive ms
91
+ get_channels : prints all channel info
92
+ get_channel &lt;n&gt; : get info for channel (by number or name)
93
+ 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
96
+ Management
97
+ advert : sends advert a
98
+ floodadv : flood advert
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
102
+ clock : get current time
103
+ clock sync : sync device clock st
104
+ node_discover &lt;filter&gt; : discovers nodes based on their type nd
105
+ Contacts
106
+ contacts / list : gets contact list lc
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
122
+ pending_contacts : show pending contacts
123
+ add_pending &lt;pending&gt; : manually add pending contact
124
+ flush_pending : flush pending contact list
125
+ Repeaters
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 [
129
+ wmt8 : wait for a msg (reply) with a timeout ]
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
133
+ </pre>
134
+
135
+ ### Interactive Mode
136
+
137
+ aka Instant Message or chat mode ...
138
+
139
+ Chat mode lets you interactively interact with your node or remote nodes. It is automatically triggered when no option is given on the command line.
140
+
141
+ You'll get a prompt with the name of your node. From here you can type meshcore-cli commands. The prompt has history and a basic completion (pressing tab will display possible command or argument options).
142
+
143
+ The `to` command is specific to chat mode, it lets you enter the recipient for next command. By default you're on your node but you can enter other nodes or public rooms. Here are some examples :
144
+
145
+ - `to <dest>` : will enter dest (node or channel)
146
+ - `to /`, `to ~` : will go to the root (your node)
147
+ - `to ..` : will go to the last node (it will switch between the two last nodes, this is just a 1-depth history)
148
+ - `to !` : will switch to the node you received last message from
149
+
150
+ When you are in a node, the behaviour will depend on the node type, if you're on a chat node, it will send messages by default and you can chat. On a repeater or a room server, it will send commands (autocompletion has been set to comply with the CommonCli class of meshcore). To send a message through a room you'll have to prefix the message with a quote or use the send command.
151
+
152
+ The `/` character is used to bypass the node you have currently selected using `to`:
153
+ - `/<cmd>` issues cmd command on the root
154
+ - `/<node>/<cmd>` will send cmd to selected node
155
+ - `/<dest> <msg>` will send msg to dest (channel or node)
156
+
157
+ #### Flood Scope in interactive mode
158
+
159
+ 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.
160
+
161
+ When entering chat mode, scope will be reset to `*`, meaning classic flood.
162
+
163
+ You can switch scope using the `scope` command, or postfixing the `to` command with `%<scope>`.
164
+
165
+ 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.
166
+
167
+ #### Channel echoes
168
+
169
+ It's sometimes interesting to know the path taken by a message received from a channel or which repeaters have repeated a sent message.
170
+
171
+ The app give you the information by listening `rx_log` from the device, when obtained the information is attached to the message and can be read.
172
+
173
+ In meshcore-cli I went lower-level by implementing channel echoes. When activated (with `/set channel_echoes on`), all the channel messages will be printed on the terminal along with the SNR and path taken. When sending a message, you'll have all the repeats from 0-hop repeaters as echoes, and when a message is received, you should see information about the received message, but also all the instances of the same message that might have reached you from another path.
174
+
175
+ In the example below, a msg has been sent between two repeaters, 21 and 25. 25 repeated the message and 21 the repeat and both echoes came back to the node with different SNRs.
176
+
177
+ ```
178
+ f1down/#fdl|*> 8
179
+ #fdl f1down: 8 [25] -4.75-112
180
+ #fdl f1down: 8 [2521] 1.00-109
181
+ ```
182
+
183
+ ### Contact management
184
+
185
+ To receive a message from another user, it is necessary to have its public key. This key is stored on a contact list in the device, and this list has a finite size (50 when meshcore started, now over 350 for most devices).
186
+
187
+ By default contacts are automatically added to the device contact list when an advertisement is received, so as soon as you receive an advert, you can talk with your buddy.
188
+
189
+ With growing number of users, it becomes necessary to manage contact list and one of the ways is to add contacts manually to the device. This is done by turning on `manual_add_contacts`. Once this option has been turned on, a pending list is built by meshcore-cli from the received adverts. You can view the list issuing a `pending_contacts` command, flush the list using `flush_pending` or add a contact from the list with `add_pending` followed by the key of the contact or its name (both will be auto-completed with tab).
190
+
191
+ This feature only really works in interactive mode.
192
+
193
+ Note: There is also an `auto_update_contacts` setting that has nothing to do with adding contacts, it permits to automatically sync contact lists between device and meshcore-cli (when there is an update in name, location or path).
194
+
195
+ ### Issuing batch commands to contacts with apply to
196
+
197
+ `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.
198
+
199
+ Filter is constructed with comma separated fields :
200
+
201
+ - `u`, matches modification time `<` or `>` than a timestamp (can also be days hours or minutes ago if followed by `d`,`h` or `m`)
202
+ - `t`, matches the type (1: client, 2: repeater, 3: room, 4: sensor)
203
+ - `h`, matches number of hops
204
+ - `d`, direct, similar to `h>-1`
205
+ - `f`, flood, similar to `h<0` or `h=-1`
206
+
207
+ Commands should be written as if in interactive mode, if writing from the commandline don't forget to use commas to clearly delimit fields.
208
+
209
+ 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 ...
210
+
211
+ #### Examples
212
+
213
+ ```
214
+ # removes all clients that have not been updated in last 2 days
215
+ at u<2d,t=1 remove_contact
216
+ # gives traces to repeaters that have been updated in the last 24h and are direct
217
+ at t=2,u>1d,d cn trace
218
+ # tries to do flood login to all repeaters
219
+ at t=2 rp login
220
+ ```
221
+
222
+ ## Examples
223
+
224
+ <pre>
225
+ # gets info from first ble MC device it finds (was -s but now used for serial port)
226
+ $ meshcore-cli -d "" infos
227
+ INFO:meshcore:Scanning for devices
228
+ INFO:meshcore:Found device : C2:2B:A1:D5:3E:B6: MeshCore-t114_fdl
229
+ INFO:meshcore:BLE Connection started
230
+ {
231
+ "adv_type": 1,
232
+ "tx_power": 22,
233
+ "max_tx_power": 22,
234
+ "public_key": "993acd42fc779962c68c627829b32b111fa27a67d86b75c17460ff48c3102db4",
235
+ "adv_lat": 47.794,
236
+ "adv_lon": -3.428,
237
+ "radio_freq": 869.525,
238
+ "radio_bw": 250.0,
239
+ "radio_sf": 11,
240
+ "radio_cr": 5,
241
+ "name": "t114_fdl"
242
+ }
243
+
244
+ # getting time
245
+ $ meshcli -a C2:2B:A1:D5:3E:B6 clock
246
+ INFO:meshcore:BLE Connection started
247
+ Current time : 2025-04-18 08:19:26 (1744957166)
248
+
249
+ # If you're familiar with meshcli, you should have noted that
250
+ # now output is not json only, to get json output, use -j
251
+ # or prefix your commands with a dot
252
+ $ meshcli -a C2:2B:A1:D5:3E:B6 .clock
253
+ INFO:meshcore:BLE Connection started
254
+ {
255
+ "time": 1744957249
256
+ }
257
+
258
+ # Using -j, meshcli will return replies in json format ...
259
+ $ meshcli -j -a C2:2B:A1:D5:3E:B6 clock
260
+ {
261
+ "time": 1744957261
262
+ }
263
+
264
+ # So if I reboot the node, and want to set time, I can chain the commands
265
+ # and get that kind of output (even better by feeding it to jq)
266
+ $ meshcli reboot
267
+ INFO:meshcore:BLE Connection started
268
+ $ meshcli -j clock clock sync clock | jq -c
269
+ { "time": 1715770371 }
270
+ { "ok": "time synced" }
271
+ { "time": 1745996105 }
272
+
273
+ # Now check if time is ok with human output (I don't read epoch time yet)
274
+ $ meshcli clock
275
+ INFO:meshcore:BLE Connection started
276
+ Current time : 2025-04-30 08:56:27 (1745996187)
277
+
278
+ # Now you'll probably want to send some messages ...
279
+ # For that, there is the msg command, wait_ack
280
+ $ meshcli msg Techo_fdl "Hello T-Echo" wa
281
+ INFO:meshcore:BLE Connection started
282
+ Msg acked
283
+
284
+ # I can check the message on the techo
285
+ $ meshcli -d Techo sm
286
+ INFO:meshcore:Scanning for devices
287
+ INFO:meshcore:Found device : DE:B6:D0:68:D5:62: MeshCore-Techo_fdl
288
+ INFO:meshcore:BLE Connection started
289
+ t114_fdl(0): Hello T-Echo
290
+
291
+ # And reply using json output for more verbosity
292
+ # here I've used jq with -cs to get a compact array
293
+ $ meshcli msg t114_fdl hello wa | jq -cs
294
+ [{"type":0,"expected_ack":"4802ed93","suggested_timeout":2970},{"code":"4802ed93"}]
295
+
296
+ # But this could have been done interactively using the chat mode
297
+ # Here from the techo side. Note that un-acked messages will be
298
+ # signaled with an ! at the start of the prompt (or red color in color mode)
299
+ $ meshcli chat
300
+ INFO:meshcore:BLE Connection started
301
+ Interactive mode, most commands from terminal chat should work.
302
+ Use "to" to selects contact, "list" to list contacts, "send" to send a message ...
303
+ Line starting with "$" or "." will issue a meshcli command.
304
+ "quit" or "q" will end interactive mode
305
+ t114_fdl(D): Hello T-Echo
306
+ EnsibsRoom> Hi
307
+ !EnsibsRoom> to t114_fdl
308
+ t114_fdl> Hi
309
+ t114_fdl(D): It took you long to reply ...
310
+ t114_fdl> I forgot to set the recipient with the to command
311
+ t114_fdl(D): It happens ...
312
+ t114_fdl>
313
+
314
+ # Loging into repeaters and sending commands is also possible
315
+ # directly from the chat, because we can use meshcli commands ;)
316
+ $ meshcli chat (pending msgs are shown at connexion ...)
317
+ INFO:meshcore:BLE Connection started
318
+ Interactive mode, most commands from terminal chat should work.
319
+ Use "to" to selects contact, "list" to list contacts, "send" to send a message ...
320
+ Line starting with "$" or "." will issue a meshcli command.
321
+ "quit" or "q" will end interactive mode
322
+ Techo_fdl(0): Cool to receive some msgs from you
323
+ Techo_fdl(D): Hi
324
+ Techo_fdl(D): I forgot to set the recipient with the to command
325
+ FdlRoom> login password
326
+ Login success
327
+ FdlRoom> clock
328
+ FdlRoom(0): 06:40 - 18/4/2025 UTC
329
+ FdlRoom>
330
+ </pre>