meshctl ES

Fake radios

A Meshtastic radio and a MeshCore one that transmit nothing, anywhere: to try meshctl, or your own app, with no radio, or without risking one. Your app reaches them over the network as it would a real one, and you decide what the mesh around them says and does.

What they are

Two programs, fake-meshtastic and fake-meshcore. Each listens on the port a real radio on the network does and speaks its protocol, as its firmware's own source has it: the Meshtastic one hands its clients every setting and module, answers admin requests and keeps what it is told to change; the MeshCore one is a companion radio with its contacts, channels, queued messages, rooms and repeaters to log in to.

Around them, a mesh you set up as you like:

  • Nodes that answer when asked, or now and then, or never; reached directly, through hops or by MQTT; with a route of their own for a traceroute.
  • A crowd of up to a thousand nodes, for lists and maps to be full.
  • Scenarios: conversations, direct messages, waypoints, telemetry over hours, a Store & Forward router; set up at once and undone whole.
  • A panel in the browser, a command line and an API, to do it by hand or from a script.

They are meant for work and tests, demos and screenshots. A real radio still has the last word: what the fakes do is what meshctl's authors read in the firmware.

Getting them

Each release brings an archive with both, meshctl-fakes-*.tar.gz, for Linux (x86_64 and aarch64, static, any distribution) and macOS (Apple silicon and Intel). Each program is one file, its panel and scenarios inside; beside them, an example of each node's file and their full reference.

tar xzf meshctl-fakes-*-x86_64-unknown-linux-musl.tar.gz
cd meshctl-fakes-*/
./fake-meshtastic --config examples/meshtastic.toml

The Meshtastic radio listens on port 4403 and the MeshCore one on 5000, as real ones; each answers its API, and its panel, on the port after it, 4404 and 5001. Other ports go after, as ./fake-meshcore 5100 5101. With no --config, each starts as a radio of its own with a few nodes; the examples add a crowd of fifty.

Then add it to meshctl, or to your app, as a radio on the network: 127.0.0.1:4403 or 127.0.0.1:5000. Its panel is at http://127.0.0.1:4404 or :5001; it listens on your machine alone unless its file says otherwise.

From the source, with Rust: cargo run -p meshctl-fakes --bin fake-meshtastic.

The panel

A terminal in the browser, laid out in five sections on keys 1 to 5, with what the radio says as it goes in a drawer beside, on `. Light, dark or as the system is.

The fake Meshtastic radio's panel: the list of what can be done, the chat scenario picked as a form, what is set up below it to undo, and the events drawer beside, with commands, chats and clients as they come.
do: your scenarios first, then the radio's, its own commands and the common ones, each as a form; what is set up, to undo.
The list of nodes the radio sees: their short names in their colours, long names such as Rusty Muros or Quiet Anxo, ids, roles, hops, origin and position.
nodes: every node it sees, to sort, filter, make, change or forget, many at once.
A channel's conversation as lines of a log: messages from over a year ago, days apart, then today's from nodes heard directly, through hops and by MQTT.
chats: its conversations as lines of a log, days apart; write in them as any node, reply and react.
The fake MeshCore radio's chats: the Galicia channel, with messages from Pepe, Uxia and Brais and a thumbs up.
The MeshCore radio, the same panel: on its channels, anyone can speak by name.
The node's settings, on its channels: the slots in a list, the first one picked, its name, key, role and MQTT switches beside it.
node: the node it is, a form for each section of its settings, its channels and its whole file as JSON.

state shows how the radio is, who it is and where, on a map, its battery and how busy it hears the channel, to change; events, all it said, to filter.

The panel on a phone: the sections across the top and what to do picked from a list that opens. A conversation on a phone, its days apart, and the line to write in at the foot.

The command line

At the foot of the panel, fake> takes everything the panel does as a line. It suggests as you type: Tab completes, the arrows go through the suggestions, and Enter takes the one picked and does it once nothing it needs is missing. help lists every command, scenario and key.

The command line with say #0 as typed, and the nodes it could be said as listed above it, each with its id.
A node to speak as, suggested from those it sees.
run lab                            the lab's nodes, around A Coruña
run chat 1                         a scenario, on channel 1
say #1 as OSCR hello, everyone     a node says something on a channel
say #1 as OSCR at=-3d long ago     …heard three days ago
react #1 👍 as OSCR                …and reacts to the last message
node Ana* answers=always           nodes picked by name, changed
node add long_name=Ana hops_away=1
radio pos 43.36 -8.41              where the radio is
crowd 200                          a crowd of two hundred
undo                               the last scenario, and all it brought

The same program is a command line for a radio running: it says the line to its API and prints what it did. With no line, it reads one per line, as a script, and ends with an error if any went wrong.

./fake-meshtastic do run chat 1
printf 'crowd 50\nrun dms\n' | ./fake-meshtastic do
./fake-meshcore do --api 192.168.1.20:5001 advert repeater

Scenarios

A scenario brings the nodes it needs, counts on nothing the radio has, and is undone whole, taking away what it brought. The radio's own commands are done at once, with no undo.

MeshtasticWhat it does
chat <slot>Five nodes talk on a channel, heard every way: directly, through hops, by MQTT; when you write there, two react and one answers.
past <slot>A node heard on a channel over the last year, for a conversation to show its days.
dmsNine nodes write to the radio directly.
waypoints <slot>Three waypoints shared on a channel: open, locked, and one that expires.
history <hours>A weather station's telemetry over the last hours, for charts.
storeforwardA Store & Forward router and its heartbeat.
crowd, telemetry, position, waypoint, heartbeat, trace, dropIts own commands: a crowd, a node's telemetry or position, a waypoint, a traceroute, the link dropped.
MeshCoreWhat it does
chat <slot>Four people talk on a channel, heard passing through repeaters; when you write there, one answers.
advert, crowd, trace, dropIts own commands: a node never seen advertises, a crowd of contacts, someone else's trace heard going by, the link dropped.

Your own scenarios

A scenario is a TOML file: what it takes, the nodes it brings, what they do at times, and what they do when something happens, as a client writing or connecting. Put yours in the directory the node's file names in [fake] scenarios: the panel lists them first, and they are set up and undone as the radio's are.

name = "hello"
help = "A node greets a channel, and answers whoever writes there."
undo = "its node"

[[arg]]
name = "slot"
type = "slot"

[[node]]
as = "ana"
long_name = "Ana"
hops_away = 1

[[step]]
at = "1s"
do = "say #{slot} as {ana} hello, anyone?"

[[on]]
heard = "#{slot}"
do = "reply #{slot} as {ana} I read you: {text}"

The radios' own scenarios are written so too, in fakes/scenarios, to read as examples; the reference has every key.

The node's file

With --config, the radio starts as a TOML file says: its name, channels, LoRa, position and every setting a real node has, and a [fake] section with what only a fake radio has: its ports, where its API listens, its scenarios' directory, the nodes it sees, each with how it behaves, and what it does as it starts.

  • Meshtastic takes the shape of what the official CLI exports, meshtastic --export-config: a real node's export, turned into TOML, starts the fake radio as that node.
  • MeshCore names its settings as meshcore-cli's set does, its channels slot after slot.
[fake]
port = 4403
api = 4404
listen = "0.0.0.0"
scenarios = "scenarios"

[[fake.start]]
scenario = "lab"

[[fake.node]]
long_name = "Lab neighbour"
short_name = "NBR"
hops_away = 0
answers = "sometimes"

A real node's export carries its Wi-Fi and MQTT passwords and its keys: keep it to yourself. The panel's node downloads the radio as it is now as such a file, to start it so again.

The API

Both radios answer the same API, the one the panel uses: its reference is at /docs on each, and the OpenAPI document behind it at /openapi.json.

The API's reference, on the fake Meshtastic radio: its sections down the side, scenarios, commands, events, node, nodes, chats and state, and what each call does.
Every call, what it takes and what it answers, to try from the page.
  • /command does a line, as the command line takes it; /command/complete says how a line may go on.
  • /scenarios sets them up and undoes them.
  • /nodes, /chats, /node and /radio: the nodes it sees, its conversations, the node it is and how it goes.
  • /events follows all it says as server-sent events, or answers it as JSON, by kind and waiting for it: what clients sent and were answered, byte for byte, for tests to check.
curl -X POST http://127.0.0.1:4404/command \
  -H 'Content-Type: application/json' -d '{"line": "run chat 0"}'

The crowd

crowd fills the radio with as many nodes as you ask for, up to a thousand on Meshtastic, and as many as a MeshCore radio has room for. Each is named as people name theirs, with no numbers: a name, a town and an adjective, two at a time, as Uxía Arteixo, Misty Lugo, Quiet Antía or Rusty Muros, over fourteen hundred of them, with a router's Relay or a MeshCore repeater's, room's or sensor's kind after it.

Of every role and many models; heard directly, through up to seven hops or by MQTT; minutes, days, weeks or months ago; most where they say, each near the town in its name, some nowhere and a few on the same spot. The same each time for the same number, so that what you saw once is there again.