2025-03-25 10:22:14 +01:00
# meshcore-cli
2025-02-04 13:02:00 +01:00
2025-03-25 10:22:14 +01:00
meshcore-cli : CLI interface to MeschCore companion app over BLE, TCP or Serial
2025-02-04 13:02:00 +01:00
2025-03-24 16:49:39 +01:00
## Install
2025-03-25 10:28:36 +01:00
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 :
2025-03-24 16:49:39 +01:00
< pre >
2025-03-25 10:22:14 +01:00
$ pipx install meshcore-cli
2025-03-24 16:49:39 +01:00
< / pre >
2025-03-25 10:22:14 +01:00
It will install you `meshcore-cli` and `meshcli` , which is an alias to the former.
2025-03-25 13:33:10 +01:00
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).
2025-03-24 16:57:38 +01:00
2025-02-04 13:02:00 +01:00
## Usage
< pre >
2025-03-25 10:22:14 +01:00
$ meshcli < args> < commands>
2025-02-04 13:02:00 +01:00
< / pre >
2025-04-30 09:19:58 +02:00
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.
2025-03-27 10:58:06 +01:00
2025-04-30 09:19:58 +02:00
### Configuration
2025-04-20 08:14:05 +02:00
Configuration files are stored in ```$HOME/.config/meshcore` ``
2025-04-30 09:22:50 +02:00
If the directory exists, default ble address and history will be stored there.
2025-04-20 08:14:05 +02:00
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).
2025-07-20 16:00:03 +02:00
Init files can also be defined for a given device, meshcore-cli will look for ```<device-name>.init` `` file in configuration directory (usefull to specify timeout for contacts that are behind bridges with ` ``contact_timeout` `` command).
2025-02-04 13:02:00 +01:00
### Arguments
Arguments mostly deals with ble connection
< pre >
2025-04-30 09:19:58 +02:00
-h : prints this help
2025-06-16 09:54:44 +02:00
-v : prints version
-j : json output (disables init file)
-D : debug
-S : performs a ble scan and ask for device
-l : list available ble devices and exit
-T < timeout> : timeout for the ble scan (-S and -l) default 2s
-a < address> : specifies device address (can be a name)
-d < name> : filter meshcore devices with name or address
-t < hostname> : connects via tcp/ip
-p < port> : specifies tcp port (default 5000)
-s < port> : use serial port < port>
-b < baudrate> : specify baudrate
2025-02-04 13:02:00 +01:00
< / pre >
### Available Commands
2025-04-18 08:42:06 +02:00
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.
2025-02-04 13:02:00 +01:00
2025-04-18 10:57:59 +02:00
< pre >
2025-04-30 09:19:58 +02:00
General commands
2025-04-18 08:42:06 +02:00
chat : enter the chat (interactive) mode
2025-04-30 09:19:58 +02:00
chat_to < ct> : enter chat with contact to
script < filename> : execute commands in filename
2025-04-18 08:42:06 +02:00
infos : print informations about the node i
2025-06-16 09:54:44 +02:00
self_telemetry : print own telemtry t
2025-04-18 08:42:06 +02:00
card : export this node URI e
ver : firmware version v
reboot : reboots node
2025-04-30 09:19:58 +02:00
sleep < secs> : sleeps for a given amount of secs s
wait_key : wait until user presses < Enter> wk
2025-04-18 08:42:06 +02:00
Messenging
2025-04-30 09:19:58 +02:00
msg < name> < msg> : send message to node by name m {
2025-04-18 08:42:06 +02:00
wait_ack : wait an ack wa }
2025-05-22 17:19:07 +02:00
chan < nb> < msg> : send message to channel number < nb> ch
2025-04-30 09:19:58 +02:00
public < msg> : send message to public channel (0) dch
2025-04-18 08:42:06 +02:00
recv : reads next msg r
2025-03-05 11:37:32 +01:00
wait_msg : wait for a message and read it wm
2025-04-30 09:19:58 +02:00
sync_msgs : gets all unread msgs from the node sm
msgs_subscribe : display msgs as they arrive ms
2025-06-16 09:54:44 +02:00
get_channel < n> : get info for channel n
set_channel n nm k : set channel info (nb, name, key)
2025-04-18 08:42:06 +02:00
Management
advert : sends advert a
floodadv : flood advert
2025-04-30 09:19:58 +02:00
get < param> : gets a param, "get help" for more
2025-07-20 16:00:03 +02:00
set < param> < value> : sets a param, "set help" for more
2025-04-30 09:19:58 +02:00
time < epoch> : sets time to given epoch
2025-04-18 08:42:06 +02:00
clock : get current time
clock sync : sync device clock st
Contacts
contacts / list : gets contact list lc
2025-06-16 09:54:44 +02:00
contact_info < ct> : prints information for contact ct ci
2025-07-20 16:00:03 +02:00
contact_timeout < ct> v : sets temp default timeout for contact
2025-04-30 09:19:58 +02:00
share_contact < ct> : share a contact with others sc
export_contact < ct> : get a contact's URI ec
2025-06-16 10:03:31 +02:00
import_contact < URI> : import a contact from its URI ic
2025-04-30 09:19:58 +02:00
remove_contact < ct> : removes a contact from this node
2025-06-16 09:54:44 +02:00
path < ct> : diplays path for a contact
2025-04-30 09:19:58 +02:00
reset_path < ct> : resets path to a contact to flood rp
change_path < ct> < pth> : change the path to a contact cp
2025-05-22 17:19:07 +02:00
change_flags < ct> < f> : change contact flags (tel_l|tel_a|star)cf
req_telemetry < ct> : prints telemetry data as json rt
2025-07-20 16:00:03 +02:00
req_mma < ct> : requests min/max/avg for a sensor rm
req_acl < ct> : requests access control list for sensor
pending_contacts : show pending contacts
add_pending < key> : manually add pending contact from key
flush_pending : flush pending contact clist
2025-04-18 08:42:06 +02:00
Repeaters
2025-04-30 09:19:58 +02:00
login < name> < pwd> : log into a node (rep) with given pwd l
logout < name> : log out of a repeater
cmd < name> < cmd> : sends a command to a repeater (no ack) c [
2025-04-18 08:42:06 +02:00
wmt8 : wait for a msg (reply) with a timeout ]
2025-04-30 09:19:58 +02:00
req_status < name> : requests status from a node rs
2025-02-04 13:02:00 +01:00
< / pre >
2025-04-30 09:19:58 +02:00
### Interactive Mode
aka Instant Message or chat mode ...
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.
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).
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 :
* `to <nodename>` : will enter nodename
* `to /` , `to ~` : will go to the root (your node)
* `to ..` : will go to the last node (it will switch between the two last nodes, this is just a 1-depth history)
* `to !` : will switch to the node you received last message from
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.
You can alse set a channel as recipient, `to public` will switch to the public channel, and `to ch1` to channel 1.
## Examples
2025-02-04 13:02:00 +01:00
< pre >
2025-04-18 08:42:06 +02:00
# gets info from first ble MC device it finds (was -s but now used for serial port)
$ meshcore-cli -d "" infos
INFO:meshcore:Scanning for devices
INFO:meshcore:Found device : C2:2B:A1:D5:3E:B6: MeshCore-t114_fdl
INFO:meshcore:BLE Connection started
{
"adv_type": 1,
"tx_power": 22,
"max_tx_power": 22,
"public_key": "993acd42fc779962c68c627829b32b111fa27a67d86b75c17460ff48c3102db4",
"adv_lat": 47.794,
"adv_lon": -3.428,
"radio_freq": 869.525,
"radio_bw": 250.0,
"radio_sf": 11,
"radio_cr": 5,
"name": "t114_fdl"
}
# getting time
$ meshcli -a C2:2B:A1:D5:3E:B6 clock
INFO:meshcore:BLE Connection started
Current time : 2025-04-18 08:19:26 (1744957166)
# If you're familiar with meshcli, you should have noted that
# now output is not json only, to get json output, use -j
# or prefix your commands with a dot
$ meshcli -a C2:2B:A1:D5:3E:B6 .clock
INFO:meshcore:BLE Connection started
2025-02-04 13:02:00 +01:00
{
2025-04-18 08:42:06 +02:00
"time": 1744957249
2025-02-04 13:02:00 +01:00
}
2025-04-18 08:42:06 +02:00
2025-04-30 09:19:58 +02:00
# Using -j, meshcli will return replies in json format ...
2025-04-18 08:42:06 +02:00
$ meshcli -j -a C2:2B:A1:D5:3E:B6 clock
{
"time": 1744957261
}
# So if I reboot the node, and want to set time, I can chain the commands
# and get that kind of output (even better by feeding it to jq)
$ meshcli reboot
INFO:meshcore:BLE Connection started
2025-04-30 09:19:58 +02:00
$ meshcli -j clock clock sync clock | jq -c
{ "time": 1715770371 }
{ "ok": "time synced" }
{ "time": 1745996105 }
2025-04-18 08:42:06 +02:00
# Now check if time is ok with human output (I don't read epoch time yet)
$ meshcli clock
INFO:meshcore:BLE Connection started
2025-04-30 09:19:58 +02:00
Current time : 2025-04-30 08:56:27 (1745996187)
2025-04-18 08:42:06 +02:00
# Now you'll probably want to send some messages ...
# For that, there is the msg command, wait_ack
$ meshcli msg Techo_fdl "Hello T-Echo" wa
INFO:meshcore:BLE Connection started
Msg acked
# I can check the message on the techo
$ meshcli -d Techo sm
INFO:meshcore:Scanning for devices
INFO:meshcore:Found device : DE:B6:D0:68:D5:62: MeshCore-Techo_fdl
INFO:meshcore:BLE Connection started
t114_fdl(0): Hello T-Echo
# And reply using json output for more verbosity
2025-04-30 09:19:58 +02:00
# here I've used jq with -cs to get a compact array
$ meshcli msg t114_fdl hello wa | jq -cs
[{"type":0,"expected_ack":"4802ed93","suggested_timeout":2970},{"code":"4802ed93"}]
# But this could have been done interactively using the chat mode
2025-04-18 08:42:06 +02:00
# Here from the techo side. Note that un-acked messages will be
2025-04-30 09:19:58 +02:00
# signaled with an ! at the start of the prompt (or red color in color mode)
2025-04-18 08:42:06 +02:00
$ meshcli chat
INFO:meshcore:BLE Connection started
Interactive mode, most commands from terminal chat should work.
Use "to" to selects contact, "list" to list contacts, "send" to send a message ...
Line starting with "$" or "." will issue a meshcli command.
"quit" or "q" will end interactive mode
2025-04-30 09:19:58 +02:00
t114_fdl(D): Hello T-Echo
2025-04-18 08:42:06 +02:00
EnsibsRoom> Hi
!EnsibsRoom> to t114_fdl
t114_fdl> Hi
2025-04-30 09:19:58 +02:00
t114_fdl(D): It took you long to reply ...
2025-04-18 08:42:06 +02:00
t114_fdl> I forgot to set the recipient with the to command
2025-04-30 09:19:58 +02:00
t114_fdl(D): It happens ...
2025-04-18 08:42:06 +02:00
t114_fdl>
# Loging into repeaters and sending commands is also possible
# directly from the chat, because we can use meshcli commands ;)
$ meshcli chat (pending msgs are shown at connexion ...)
INFO:meshcore:BLE Connection started
Interactive mode, most commands from terminal chat should work.
Use "to" to selects contact, "list" to list contacts, "send" to send a message ...
Line starting with "$" or "." will issue a meshcli command.
"quit" or "q" will end interactive mode
2025-04-30 09:19:58 +02:00
Techo_fdl(0): Cool to receive some msgs from you
Techo_fdl(D): Hi
Techo_fdl(D): I forgot to set the recipient with the to command
FdlRoom> login password
2025-04-18 08:42:06 +02:00
Login success
2025-04-30 09:19:58 +02:00
FdlRoom> clock
FdlRoom(0): 06:40 - 18/4/2025 UTC
2025-04-18 08:42:06 +02:00
FdlRoom>
2025-02-04 13:02:00 +01:00
< / pre >
2025-04-18 08:42:06 +02:00