From 8ff96ee2b061b0c5ab02711bfa4e58c3358f9cde Mon Sep 17 00:00:00 2001 From: R0ck Date: Fri, 30 Oct 2026 17:10:17 +0000 Subject: [PATCH] Document companion.cli and the companion's cmd command. --- pages/board-view.md | 25 +++++++++++++++------- pages/scripting.md | 52 +++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 65 insertions(+), 12 deletions(-) diff --git a/pages/board-view.md b/pages/board-view.md index 8c13e29..618b66a 100644 --- a/pages/board-view.md +++ b/pages/board-view.md @@ -238,19 +238,20 @@ what is sent, which are different questions. - A **companion** speaks a framed protocol whose command line is meshcore-cli's vocabulary: `advert`, `floodadv`, `public `, `chan `, `msg `, `login `, `req_status `, - `scope `, `infos`, `ver`, `contacts`, `sync_msgs`, `set`, `time`. + `cmd `, `scope `, `infos`, `ver`, `contacts`, + `sync_msgs`, `set`, `time`. There is no `send`. ### Talking to one node -`msg`, `login` and `req_status` address one contact, by the name the node holds -it under or by its public key in hex. Run `contacts` first: a name is looked up -among the contacts the node has listed, and one it has not listed is refused -with `holds no contact`. A key is sent as given, and the firmware itself answers -`not found` if it does not hold it. +`msg`, `login`, `req_status` and `cmd` address one contact, by the name the +node holds it under or by its public key in hex. Run `contacts` first: a name is +looked up among the contacts the node has listed, and one it has not listed is +refused with `holds no contact`. A key is sent as given, and the firmware itself +answers `not found` if it does not hold it. -Each is answered twice in the console, each line stamped with the simulated -time it arrived: +`msg`, `login` and `req_status` are each answered twice in the console, each +line stamped with the simulated time it arrived: 1. when the firmware takes it - `sent msg to West Lomond by flood, waiting up to 7060 ms`. By flood means the node knew no path and the message goes @@ -264,6 +265,14 @@ A message whose ack never comes back gets `no ack from West Lomond within repeater answers a status request only from a client that has logged in to it, so `login` comes before `req_status`, as it does on a phone. +`cmd ` runs a command on that node over the air, as an +operator's phone administers a repeater it cannot plug into: the command is the +same line the node's own serial console takes, such as `get name` or +`set af 7`. The node runs it only for a sender logged in to it as admin, so +`login` comes first. A command from a sender that is not logged in gets no +answer at all. Nothing is acked: the answer is the node's own reply, printed as +`reply from : ` with the simulated time it arrived. + `scope ` sets the region the node's floods go out under, and `scope *` sends unscoped. The same commands work in a fixture's schedule. diff --git a/pages/scripting.md b/pages/scripting.md index d4dbec7..286a662 100644 --- a/pages/scripting.md +++ b/pages/scripting.md @@ -194,10 +194,10 @@ tell "found it" from "found something that shares a word". A repeater has a text command line and reads what is typed at it. A companion does not: it speaks the framed companion protocol, and its command line is meshcore-cli's vocabulary - `advert`, `public `, `chan `, -`msg `, `login`, `req_status`, `scope`, `infos`, `contacts`. What -the node answers to `msg`, `login` and `req_status` - sent, delivered, answered -or refused, with the simulated time - lands in the companion's transcript, -which `companion.state` returns under `recent`. +`msg `, `login`, `req_status`, `cmd`, `scope`, `infos`, +`contacts`. What the node answers to `msg`, `login` and `req_status` - sent, +delivered, answered or refused, with the simulated time - lands in the +companion's transcript, which `companion.state` returns under `recent`. `node.console` chooses by the node's kind, so a script does not have to. Text sent to a companion's text console is echoed locally and reaches nothing, which @@ -212,6 +212,50 @@ loop runs when the engine steps - so reading immediately after sending reads the moment before the command went out. `ask` sends, gives the mesh its own time, and then reads. +### Running a command on another node + +`companion.cli` sends a command from a connected companion to another node, as +MeshCore's remote administration does: the text goes over the air as a +remote-admin message, the recipient runs it on its own command line, and its +answer comes back the same way. It is how a study provisions a mesh the way an +operator does, rather than over every node's serial port. + +The recipient runs the command only for a sender logged in to it as admin, so +log in first with `console.cli` and `login `. Nothing is +acked, and a command from a sender that is not logged in gets no answer at all. +The answer arrives later, and `companion.state` lists every one under +`cli_replies`, oldest first, each with the key it came `from` and its `text`. + +:::ways +::gui +On the companion's **CLI** tab, `login Kinross password`, then +`cmd Kinross get radio`. The reply is printed in the transcript as it +arrives. +::socket +```json +{"id":1,"method":"console.cli","params":{"node":"Phone","command":"login Kinross password"}} +{"id":2,"method":"companion.cli","params":{"node":"Phone","to":"Kinross","command":"get radio"}} +{"id":3,"method":"companion.state","params":{"node":"Phone"}} +``` +::python +```python +wb.call("console.cli", {"node": "Phone", "command": "login Kinross password"}) +wb.call("companion.cli", {"node": "Phone", "to": "Kinross", "command": "get radio"}) +print(wb.call("companion.state", {"node": "Phone"})["cli_replies"]) +``` +::go +```go +_, err := wb.Call(ctx, "companion.cli", map[string]any{ + "node": "Phone", "to": "Kinross", "command": "get radio"}) +``` +::: + +`to` is the contact's name as the companion holds it, or its public key in hex. +A name the companion has not listed is refused, so run `contacts` first. On the +command line a contact is one word, so a name with a space in it is addressed +there by its key. Like the other input verbs, `companion.cli` takes `at_ms` to +run at an instant of simulated time rather than now. + ## Importing a deployment ```python