Skip to content

Commit f332d2f

Browse files
committed
documentation ...
1 parent 7da64a0 commit f332d2f

File tree

3 files changed

+74
-62
lines changed

3 files changed

+74
-62
lines changed

README.md

Lines changed: 66 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ If you want meshcore-cli to remember last BLE device, you should have some `$HOM
2020
$ meshcli <args> <commands>
2121
</pre>
2222

23-
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.
23+
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.
2424

25-
## Configuration
25+
### Configuration
2626

2727
Configuration files are stored in ```$HOME/.config/meshcore```
2828

@@ -35,7 +35,7 @@ If there is an initialization script file called ```init```, it will be executed
3535
Arguments mostly deals with ble connection
3636

3737
<pre>
38-
-h : prints this help
38+
-h : prints this help
3939
-j : json output
4040
-D : print debug messages
4141
-S : BLE device selector
@@ -53,49 +53,68 @@ Arguments mostly deals with ble connection
5353
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.
5454

5555
<pre>
56-
General commands
56+
General commands
5757
chat : enter the chat (interactive) mode
58-
chat_to &lt;ct&gt; : enter chat with contact to
59-
script &lt;file&gt; : executes script stored in file
58+
chat_to &lt;ct> : enter chat with contact to
59+
script &lt;filename> : execute commands in filename
6060
infos : print informations about the node i
6161
card : export this node URI e
6262
ver : firmware version v
6363
reboot : reboots node
64-
sleep &lt;secs&gt; : sleeps for a given amount of secs s
64+
sleep &lt;secs> : sleeps for a given amount of secs s
65+
wait_key : wait until user presses &lt;Enter> wk
6566
Messenging
66-
msg &lt;name&gt; &lt;msg&gt; : send message to node by name m {
67+
msg &lt;name> &lt;msg> : send message to node by name m {
6768
wait_ack : wait an ack wa }
68-
chan &lt;nb&gt; &lt;msg&gt; : send message to channel number &lt;nb&gt; ch
69-
public : send message to public channel (0) dch
69+
chan &lt;nb> &lt;msg> : send message to channel number <nb> ch
70+
public &lt;msg> : send message to public channel (0) dch
7071
recv : reads next msg r
71-
sync_msgs : gets all unread msgs from the node sm
7272
wait_msg : wait for a message and read it wm
73+
sync_msgs : gets all unread msgs from the node sm
74+
msgs_subscribe : display msgs as they arrive ms
7375
Management
7476
advert : sends advert a
7577
floodadv : flood advert
76-
get &lt;param&gt; : gets a param, "get help" for more
77-
set &lt;param&gt; &lt;value&gt; : sets a param, "set help" for more
78-
time &lt;epoch&gt; : sets time to given epoch
78+
get &lt;param> : gets a param, "get help" for more
79+
set &lt;param> &lt;value> : sets a param, "set help" for more
80+
time &lt;epoch> : sets time to given epoch
7981
clock : get current time
8082
clock sync : sync device clock st
8183
cli : send a cmd to node's cli (if avail) @
8284
Contacts
8385
contacts / list : gets contact list lc
84-
share_contact &lt;ct&gt; : share a contact with others sc
85-
export_contact &lt;ct&gt; : get a contact's URI ec
86-
remove_contact &lt;ct&gt; : removes a contact from this node
87-
reset_path &lt;ct&gt; : resets path to a contact to flood rp
88-
change_path &lt;ct&gt; &lt;pth&gt; : change the path to a contact cp
86+
share_contact &lt;ct> : share a contact with others sc
87+
export_contact &lt;ct> : get a contact's URI ec
88+
remove_contact &lt;ct> : removes a contact from this node
89+
reset_path &lt;ct> : resets path to a contact to flood rp
90+
change_path &lt;ct> &lt;pth> : change the path to a contact cp
8991
Repeaters
90-
login &lt;name&gt; &lt;pwd&gt; : log into a node (rep) with given pwd l [[
91-
wait_login : wait for login (timeouts after 5sec) wl ]]
92-
cmd &lt;name&gt; &lt;cmd&gt; : sends a command to a repeater (no ack) c [
92+
login &lt;name> &lt;pwd> : log into a node (rep) with given pwd l
93+
logout &lt;name> : log out of a repeater
94+
cmd &lt;name> &lt;cmd> : sends a command to a repeater (no ack) c [
9395
wmt8 : wait for a msg (reply) with a timeout ]
94-
req_status &lt;name&gt; : requests status from a node rs
95-
wait_status : wait and print reply ws
96+
req_status &lt;name> : requests status from a node rs
9697
</pre>
9798

98-
### Examples
99+
### Interactive Mode
100+
101+
aka Instant Message or chat mode ...
102+
103+
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.
104+
105+
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).
106+
107+
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 :
108+
* `to <nodename>` : will enter nodename
109+
* `to /`, `to ~` : will go to the root (your node)
110+
* `to ..` : will go to the last node (it will switch between the two last nodes, this is just a 1-depth history)
111+
* `to !` : will switch to the node you received last message from
112+
113+
When you are connected to 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 (autocompletioin 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.
114+
115+
You can alse set a channel as recipient, `to public` will switch to the public channel, and `to ch1` to channel 1.
116+
117+
## Examples
99118

100119
<pre>
101120
# gets info from first ble MC device it finds (was -s but now used for serial port)
@@ -131,32 +150,25 @@ INFO:meshcore:BLE Connection started
131150
"time": 1744957249
132151
}
133152

134-
# Using -j, meshcli will return a json array of replies ...
153+
# Using -j, meshcli will return replies in json format ...
135154
$ meshcli -j -a C2:2B:A1:D5:3E:B6 clock
136-
[
137155
{
138156
"time": 1744957261
139157
}
140-
]
141158

142159
# So if I reboot the node, and want to set time, I can chain the commands
143160
# and get that kind of output (even better by feeding it to jq)
144161
$ meshcli reboot
145162
INFO:meshcore:BLE Connection started
146-
$ meshcli -j clock clock sync clock | jq
147-
[
148-
{
149-
"time": 1715770360
150-
},
151-
{},
152-
{
153-
"time": 1744957460
154-
}
155-
]
163+
$ meshcli -j clock clock sync clock | jq -c
164+
{ "time": 1715770371 }
165+
{ "ok": "time synced" }
166+
{ "time": 1745996105 }
167+
156168
# Now check if time is ok with human output (I don't read epoch time yet)
157169
$ meshcli clock
158170
INFO:meshcore:BLE Connection started
159-
Current time : 2025-04-18 08:26:25 (1744957585)
171+
Current time : 2025-04-30 08:56:27 (1745996187)
160172

161173
# Now you'll probably want to send some messages ...
162174
# For that, there is the msg command, wait_ack
@@ -172,33 +184,26 @@ INFO:meshcore:BLE Connection started
172184
t114_fdl(0): Hello T-Echo
173185

174186
# And reply using json output for more verbosity
175-
[
176-
{
177-
"type": 0,
178-
"expected_ack": "83059275",
179-
"suggested_timeout": 4446
180-
},
181-
{
182-
"code": "83059275"
183-
}
184-
]
185-
186-
# But this could have been done easier using the chat mode
187+
# here I've used jq with -cs to get a compact array
188+
$ meshcli msg t114_fdl hello wa | jq -cs
189+
[{"type":0,"expected_ack":"4802ed93","suggested_timeout":2970},{"code":"4802ed93"}]
190+
191+
# But this could have been done interactively using the chat mode
187192
# Here from the techo side. Note that un-acked messages will be
188-
# signaled with an ! at the start of the prompt
193+
# signaled with an ! at the start of the prompt (or red color in color mode)
189194
$ meshcli chat
190195
INFO:meshcore:BLE Connection started
191196
Interactive mode, most commands from terminal chat should work.
192197
Use "to" to selects contact, "list" to list contacts, "send" to send a message ...
193198
Line starting with "$" or "." will issue a meshcli command.
194199
"quit" or "q" will end interactive mode
195-
t114_fdl(D): Hello T-Echo
200+
t114_fdl(D): Hello T-Echo
196201
EnsibsRoom> Hi
197202
!EnsibsRoom> to t114_fdl
198203
t114_fdl> Hi
199-
t114_fdl(D): It took you long to reply ...
204+
t114_fdl(D): It took you long to reply ...
200205
t114_fdl> I forgot to set the recipient with the to command
201-
t114_fdl(D): It happens ...
206+
t114_fdl(D): It happens ...
202207
t114_fdl>
203208

204209
# Loging into repeaters and sending commands is also possible
@@ -209,13 +214,13 @@ Interactive mode, most commands from terminal chat should work.
209214
Use "to" to selects contact, "list" to list contacts, "send" to send a message ...
210215
Line starting with "$" or "." will issue a meshcli command.
211216
"quit" or "q" will end interactive mode
212-
Techo_fdl(0): Cool to receive some msgs from you
213-
Techo_fdl(D): Hi
214-
Techo_fdl(D): I forgot to set the recipient with the to command
215-
FdlRoom> $login FdlRoom password wl
217+
Techo_fdl(0): Cool to receive some msgs from you
218+
Techo_fdl(D): Hi
219+
Techo_fdl(D): I forgot to set the recipient with the to command
220+
FdlRoom> login password
216221
Login success
217-
FdlRoom> $cmd FdlRoom clock
218-
FdlRoom(0): 06:40 - 18/4/2025 UTC
222+
FdlRoom> clock
223+
FdlRoom(0): 06:40 - 18/4/2025 UTC
219224
FdlRoom>
220225
</pre>
221226

pyproject.toml

Lines changed: 1 addition & 1 deletion
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 = "0.7.4"
7+
version = "0.7.5"
88
authors = [
99
{ name="Florent de Lamotte", email="[email protected]" },
1010
]

src/meshcore_cli/meshcore_cli.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
from meshcore import TCPConnection, BLEConnection, SerialConnection
2222
from meshcore import MeshCore, EventType, logger
2323

24+
# Version
25+
VERSION = "0.7.5"
26+
2427
# default ble address is stored in a config file
2528
MCCLI_CONFIG_DIR = str(Path.home()) + "/.config/meshcore/"
2629
MCCLI_ADDRESS = MCCLI_CONFIG_DIR + "default_address"
@@ -1406,6 +1409,7 @@ def usage () :
14061409
14071410
Arguments :
14081411
-h : prints this help
1412+
-v : prints version
14091413
-j : json output (disables init file)
14101414
-D : debug
14111415
-S : performs a ble scan and ask for device
@@ -1462,6 +1466,9 @@ async def main(argv):
14621466
return
14631467
case "-T" :
14641468
timeout = float(arg)
1469+
case "-v":
1470+
print (f"meshcore cli version {VERSION}")
1471+
return
14651472
case "-l" :
14661473
devices = await BleakScanner.discover(timeout=timeout)
14671474
if len(devices) == 0:

0 commit comments

Comments
 (0)