Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions pages/board-view.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,19 +268,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 <msg>`, `chan <n> <msg>`,
`msg <contact> <msg>`, `login <contact> <password>`, `req_status <contact>`,
`scope <name>`, `infos`, `ver`, `contacts`, `sync_msgs`, `set`, `time`.
`cmd <contact> <command>`, `scope <name>`, `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
Expand All @@ -294,6 +295,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 <contact> <command>` 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 <key>: <text>` with the simulated time it arrived.

`scope <name>` sets the region the node's floods go out under, and `scope *`
sends unscoped. The same commands work in a fixture's schedule.

Expand Down
52 changes: 48 additions & 4 deletions pages/scripting.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <msg>`, `chan <n> <msg>`,
`msg <contact> <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 <contact> <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
Expand All @@ -217,6 +217,50 @@ sentence the console prints under the reply: whatever the command sends is
queued and goes on the air when the run plays. A call held with `at_ms` runs
inside a step and does not carry it.

### 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 <contact> <password>`. 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
Expand Down