Skip to main content

Command line interface to meshcore companion radios

Project description

meshcore-cli

meshcore-cli : CLI interface to MeschCore companion app over BLE, TCP or Serial

Install

Meshcore-cli depends on the python meshcore package. You can install both via pip or pipx using the command :

$ pipx install meshcore-cli

It will install you meshcore-cli and meshcli, which is an alias to the former.

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).

Usage

$ meshcli <args> <commands>

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.

Arguments

Arguments mostly deals with ble connection

    -h : prints this help                                                                      
    -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

Available Commands

Commands are given after arguments, they can be chained and some have shortcuts.

    infos                  : print informations about the node      i 
    reboot                 : reboots node                             
    send <key> <msg>       : sends msg to node using pubkey[0:6]
    sendto <name> <msg>    : sends msg to node with given name        
    msg <name> <msg>       : same as sendto                         m 
    wait_ack               : wait an ack for last sent msg          wa
    recv                   : reads next msg                         r 
    sync_msgs              : gets all unread msgs from the node     sm
    wait_msg               : wait for a message and read it         wm
    advert                 : sends advert                           a 
    contacts               : gets contact list                      lc
    share_contact <ct>     : share a contact with others            sc
    remove_contact <ct>    : removes a contact from this node         
    reset_path <ct>        : resets path to a contact to flood      rp
    change_path <ct> <path>: change the path to a contact           cp
    get_time               : gets current time                        
    set_time <epoch>       : sets time to given epoch                 
    sync_time              : sync time with system                    
    set_name <name>        : sets node name                           
    get_bat                : gets battery level                     b 
    login <name> <pwd>     : log into a node (rep) with given pwd   l 
    wait_login             : wait for login (timeouts after 5sec)   wl
    cmd <name> <cmd>       : sends a command to a repeater (no ack) c 
    req_status <name>      : requests status from a node            rs
    wait_status            : wait and print reply                   ws
    sleep <secs>           : sleeps for a given amount of secs      s

Examples

# gets info from first MC device it finds (was -s but now used for serial port)
$ meshcli -d "" infos
Scanning for devices
Found device : F0:F5:BD:4F:9B:AD: MeshCore
Connexion started
{'adv_type': 1, 'public_key': '54c11cff0c2a861cfc5b0bd6e4b81cd5e6ca85e058bf53932d86c87dc7a20011', 'device_loc': '000000000000000000000000', 'radio_freq': 867500, 'radio_bw': 250000, 'radio_sf': 10, 'radio_cr': 5, 'name': 'toto'}
cmd ['infos'] processed ...

$ meshcli -a F0:F5:BD:4F:9B:AD get_time
Connexion started
Current time : 2024-05-15 12:52:53 (1715770373)
cmd ['get_time'] processed ...

$ date
Tue Feb  4 12:55:05 CET 2025

$ meshcli -a F0:F5:BD:4F:9B:AD sync_time get_time
Connexion started
True
cmd ['sync_time'] processed ...
Current time : 2025-02-04 12:55:24 (1738670124)
cmd ['get_time'] processed ...

$ meshcli -a F0:F5:BD:4F:9B:AD contacts
Connexion started
{}
cmd ['contacts'] processed ...

$ meshcli -a F0:F5:BD:4F:9B:AD sleep 10 contacts
Connexion started
Advertisment received
cmd ['sleep', '10'] processed ...
{
    "flo2": {
        "public_key": "d6e43f8e9ef26b801d6f5fee39f55ad6dfabfc939c84987256532d8b94aa25dd",
        "type": 1,
        "flags": 0,
        "out_path_len": 255,
        "out_path": "",
        "adv_name": "flo2",
        "last_advert": 1738670344,
        "adv_lat": 0,
        "adv_lon": 0,
        "lastmod": 1738670354
    }
}
cmd ['contacts'] processed ...

$ meshcli -a F0:F5:BD:4F:9B:AD sendto flo2 "Hello flo2" sleep 10
Connexion started
{'type': 1, 'expected_ack': b'9\x05\x0c\x12', 'suggested_timeout': 3260}
cmd ['sendto', 'flo2', 'Hello flo2'] processed ...
Code path update
Received ACK
Msgs are waiting
cmd ['sleep', '10'] processed ...

$ meshcli -a F0:F5:BD:4F:9B:AD recv
Connexion started
{'type': 'PRIV', 'pubkey_prefix': 'd6e43f8e9ef2', 'path_len': 255, 'txt_type': 0, 'sender_timestamp': 1738670421, 'text': 'hi'}
cmd ['recv'] processed ...

# logs into a repeater (HomeRep) and check time
$ meshcli -d t1000 login HomeRep password
Scanning for devices
Found device : FB:F2:5C:40:4F:77: MeshCore-t1000
Connexion started
{'type': 0, 'expected_ack': b'\x82yU\x02', 'suggested_timeout': 4446}
cmd ['login', 'HomeRep', 'password'] processed ...

$ meshcli cmd HomeRep clock wait_msg
Connexion started
{'type': 0, 'expected_ack': b'\x00\x00\x00\x00', 'suggested_timeout': 2724}
cmd ['cmd', 'HomeRep', 'clock'] processed ...
Msgs are waiting
{'type': 'PRIV', 'pubkey_prefix': '827955027cad', 'path_len': 255, 'txt_type': 1, 'sender_timestamp': 1741030036, 'text': '19:27 - 3/3/2025 UTC'}
cmd ['wait_msg'] processed ...

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

meshcore_cli-0.4.0.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

meshcore_cli-0.4.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file meshcore_cli-0.4.0.tar.gz.

File metadata

  • Download URL: meshcore_cli-0.4.0.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for meshcore_cli-0.4.0.tar.gz
Algorithm Hash digest
SHA256 2374a7fef113ba459d580354f082fe0177f842154a8c211e7a5cb5215836a06f
MD5 230943592986fbf508e2a7976121c230
BLAKE2b-256 967b227d64e9213ec3734e0123b8ab0942e5ecc55d90bee0b40bcf9be1277af1

See more details on using hashes here.

File details

Details for the file meshcore_cli-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: meshcore_cli-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for meshcore_cli-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1d8de4db27f9f1b64007100add192b6f2a9d86299f0d4534dd610a10d7051562
MD5 307a0ed59755eb9dbb75b99181102aea
BLAKE2b-256 effee26d66637a7fbc0383f6e3ecb084a7f0f8a7fac673d34db90e4aa93e20e8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page