meshtastic 0.0.178 → 0.0.179
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -175
- data/documentation/README.md +59 -0
- data/documentation/admin.md +54 -0
- data/documentation/apponly.md +22 -0
- data/documentation/atak.md +27 -0
- data/documentation/bluetooth-bluez.md +35 -0
- data/documentation/bluetooth.md +87 -0
- data/documentation/cannedmessages.md +25 -0
- data/documentation/channel.md +30 -0
- data/documentation/clientonly.md +21 -0
- data/documentation/config.md +29 -0
- data/documentation/connection-status.md +22 -0
- data/documentation/deviceonly.md +22 -0
- data/documentation/localonly.md +21 -0
- data/documentation/mesh-interface.md +52 -0
- data/documentation/meshtastic.md +45 -0
- data/documentation/module-config.md +26 -0
- data/documentation/mqtt.md +101 -0
- data/documentation/paxcount.md +25 -0
- data/documentation/portnums.md +67 -0
- data/documentation/position.md +34 -0
- data/documentation/protobufs.md +162 -0
- data/documentation/remote-hardware.md +33 -0
- data/documentation/rtttl.md +24 -0
- data/documentation/serial.md +78 -0
- data/documentation/storeforward.md +24 -0
- data/documentation/stream-interface.md +15 -0
- data/documentation/tcp.md +43 -0
- data/documentation/telemetry.md +32 -0
- data/documentation/traceroute.md +28 -0
- data/documentation/util.md +27 -0
- data/documentation/xmodem.md +22 -0
- data/lib/meshtastic/admin.rb +66 -8
- data/lib/meshtastic/apponly.rb +14 -8
- data/lib/meshtastic/atak.rb +21 -8
- data/lib/meshtastic/cannedmessages.rb +16 -8
- data/lib/meshtastic/channel.rb +13 -9
- data/lib/meshtastic/clientonly.rb +14 -8
- data/lib/meshtastic/config.rb +12 -9
- data/lib/meshtastic/connection_status.rb +7 -9
- data/lib/meshtastic/deviceonly.rb +11 -8
- data/lib/meshtastic/localonly.rb +11 -8
- data/lib/meshtastic/module_config.rb +12 -9
- data/lib/meshtastic/paxcount.rb +19 -9
- data/lib/meshtastic/portnums.rb +12 -9
- data/lib/meshtastic/position.rb +35 -0
- data/lib/meshtastic/remote_hardware.rb +34 -9
- data/lib/meshtastic/rtttl.rb +17 -8
- data/lib/meshtastic/storeforward.rb +16 -8
- data/lib/meshtastic/tcp.rb +102 -0
- data/lib/meshtastic/telemetry.rb +18 -9
- data/lib/meshtastic/traceroute.rb +33 -0
- data/lib/meshtastic/version.rb +1 -1
- data/lib/meshtastic/xmodem.rb +11 -9
- data/lib/meshtastic.rb +26 -5
- data/spec/lib/meshtastic/admin_pb_spec.rb +1 -1
- data/spec/lib/meshtastic/admin_spec.rb +39 -0
- data/spec/lib/meshtastic/apponly_pb_spec.rb +1 -1
- data/spec/lib/meshtastic/apponly_spec.rb +4 -0
- data/spec/lib/meshtastic/atak_pb_spec.rb +1 -1
- data/spec/lib/meshtastic/atak_spec.rb +22 -0
- data/spec/lib/meshtastic/cannedmessages_pb_spec.rb +1 -1
- data/spec/lib/meshtastic/cannedmessages_spec.rb +3 -0
- data/spec/lib/meshtastic/channel_pb_spec.rb +1 -1
- data/spec/lib/meshtastic/channel_spec.rb +21 -0
- data/spec/lib/meshtastic/clientonly_pb_spec.rb +1 -1
- data/spec/lib/meshtastic/clientonly_spec.rb +5 -0
- data/spec/lib/meshtastic/config_pb_spec.rb +1 -1
- data/spec/lib/meshtastic/config_spec.rb +22 -1
- data/spec/lib/meshtastic/connection_status_pb_spec.rb +1 -1
- data/spec/lib/meshtastic/connection_status_spec.rb +3 -0
- data/spec/lib/meshtastic/deviceonly_legacy_pb_spec.rb +1 -1
- data/spec/lib/meshtastic/deviceonly_pb_spec.rb +1 -1
- data/spec/lib/meshtastic/deviceonly_spec.rb +3 -0
- data/spec/lib/meshtastic/localonly_pb_spec.rb +1 -1
- data/spec/lib/meshtastic/localonly_spec.rb +3 -0
- data/spec/lib/meshtastic/mesh_beacon_pb_spec.rb +1 -1
- data/spec/lib/meshtastic/mesh_pb_spec.rb +1 -1
- data/spec/lib/meshtastic/module_config_pb_spec.rb +1 -1
- data/spec/lib/meshtastic/module_config_spec.rb +21 -0
- data/spec/lib/meshtastic/mqtt_pb_spec.rb +1 -1
- data/spec/lib/meshtastic/paxcount_pb_spec.rb +1 -1
- data/spec/lib/meshtastic/paxcount_spec.rb +23 -0
- data/spec/lib/meshtastic/portnums_pb_spec.rb +1 -1
- data/spec/lib/meshtastic/portnums_spec.rb +4 -0
- data/spec/lib/meshtastic/position_spec.rb +33 -0
- data/spec/lib/meshtastic/remote_hardware_pb_spec.rb +1 -1
- data/spec/lib/meshtastic/remote_hardware_spec.rb +24 -0
- data/spec/lib/meshtastic/rtttl_pb_spec.rb +1 -1
- data/spec/lib/meshtastic/rtttl_spec.rb +21 -0
- data/spec/lib/meshtastic/storeforward_pb_spec.rb +1 -1
- data/spec/lib/meshtastic/storeforward_spec.rb +21 -0
- data/spec/lib/meshtastic/tcp_spec.rb +48 -0
- data/spec/lib/meshtastic/telemetry_pb_spec.rb +1 -1
- data/spec/lib/meshtastic/telemetry_spec.rb +21 -0
- data/spec/lib/meshtastic/traceroute_spec.rb +27 -0
- data/spec/lib/meshtastic/xmodem_pb_spec.rb +1 -1
- data/spec/lib/meshtastic/xmodem_spec.rb +6 -1
- data/spec/lib/meshtastic_spec.rb +3 -0
- metadata +38 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3fa03c5234c1b6d136fca93a0a37a5c9dd6588b116b6f932f457f4e139eee89c
|
|
4
|
+
data.tar.gz: 54d66239895c5989f8f8ee5423e63d05769bdecd6281d59d914b31561177fabd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fd7705cf063ef5448b167dc7d3f1664dea20cc25ff1b1791a72de2e4a656afc11ef5717969b4171f65736448616e05f985a9a5c40dc11196559b9767a2b5b286
|
|
7
|
+
data.tar.gz: 506c41dfa105d57a5fae6febd3fa9748f30319c1a280f0ebbc5412d1bfd8b9f9330c337aba25033ee06e9fbc10fa4c600a28cecd61baab145422ec02162df238
|
data/README.md
CHANGED
|
@@ -24,185 +24,13 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
|
24
24
|
|
|
25
25
|
## Usage
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
### MQTT
|
|
30
|
-
|
|
31
|
-
To view MQTT messages, and include only messages containing `_APP` _and_ `LongFast` strings, use the following code:
|
|
32
|
-
|
|
33
|
-
```ruby
|
|
34
|
-
require 'meshtastic'
|
|
35
|
-
Meshtastic::MQTT.help
|
|
36
|
-
mqtt_obj = Meshtastic::MQTT.connect
|
|
37
|
-
puts mqtt_obj.inspect
|
|
38
|
-
Meshtastic::MQTT.subscribe(
|
|
39
|
-
mqtt_obj: mqtt_obj,
|
|
40
|
-
include: '_APP, LongFast'
|
|
41
|
-
)
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
This code will dump the contents of every message:
|
|
45
|
-
|
|
46
|
-
```ruby
|
|
47
|
-
require 'meshtastic'
|
|
48
|
-
mqtt_obj = Meshtastic::MQTT.connect
|
|
49
|
-
Meshtastic::MQTT.subscribe(
|
|
50
|
-
mqtt_obj: mqtt_obj,
|
|
51
|
-
root_topic: 'msh',
|
|
52
|
-
region: 'US',
|
|
53
|
-
topic: '2/e/LongFast/#',
|
|
54
|
-
psks: { LongFast: 'AQ==' }
|
|
55
|
-
) do |message|
|
|
56
|
-
puts message.inspect
|
|
57
|
-
end
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
Sending a message over MQTT:
|
|
61
|
-
|
|
62
|
-
```ruby
|
|
63
|
-
require 'meshtastic'
|
|
64
|
-
mqtt_obj = Meshtastic::MQTT.connect
|
|
65
|
-
client_id = "!#{mqtt_obj.client_id}"
|
|
66
|
-
Meshtastic::MQTT.send_text(
|
|
67
|
-
mqtt_obj: mqtt_obj,
|
|
68
|
-
from: client_id,
|
|
69
|
-
to: '!ffffffff',
|
|
70
|
-
root_topic: 'msh',
|
|
71
|
-
region: 'US',
|
|
72
|
-
topic: '2/e/LongFast/#',
|
|
73
|
-
channel: 93,
|
|
74
|
-
text: 'Hello, World!',
|
|
75
|
-
psks: { LongFast: 'AQ==' }
|
|
76
|
-
)
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
One of the "gotchas" when sending messages is ensuring you're sending over the proper integer for the `channel` parameter. The best way to determine the proper `channel` value is by sending a test message from within the meshtastic app and then viewing the MQTT message similar to the following:
|
|
27
|
+
All usage examples live under [documentation/](documentation/README.md): transports (MQTT, Serial, Bluetooth, TCP), Admin and other feature modules, internals, and generated protobuf types.
|
|
80
28
|
|
|
81
29
|
```ruby
|
|
82
30
|
require 'meshtastic'
|
|
83
|
-
|
|
84
|
-
Meshtastic::
|
|
85
|
-
mqtt_obj: mqtt_obj,
|
|
86
|
-
root_topic: 'msh',
|
|
87
|
-
region: 'US',
|
|
88
|
-
topic: '2/e/LongFast/#',
|
|
89
|
-
psks: { LongFast: 'AQ==' },
|
|
90
|
-
include: '!YOUR_CLIENT_ID'
|
|
91
|
-
) do |message|
|
|
92
|
-
puts message.inspect
|
|
93
|
-
end
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
You should see something like this:
|
|
97
|
-
|
|
31
|
+
Meshtastic.help # constants in the namespace
|
|
32
|
+
Meshtastic::Serial.help # methods for one module
|
|
98
33
|
```
|
|
99
|
-
{packet: {from: 3237997296, to: 4294967295, channel: 93, id: 1, rx_time: 1735689600, rx_snr: 0.0, hop_limit: 3, want_ack: false, priority: :HIGH, rx_rssi: 0, delayed: :NO_DELAY, via_mqtt: false, hop_start: 3, public_key: "", pki_encrypted: false, next_hop: 0, relay_node: 0, tx_after: 0, decoded: {portnum: :TEXT_MESSAGE_APP, payload: "WHAT IS MY channel VALUE?", want_response: false, dest: 0, source: 0, request_id: 0, reply_id: 0, emoji: 0, bitfield: 0}, encrypted: :decrypted, topic: "msh/US/2/e/LongFast/!c0ffee00", node_id_from: "!c0ffee00", node_id_to: "!ffffffff", rx_time_utc: "2025-01-01 00:00:00 UTC"}, channel_id: "LongFast", gateway_id: "!c0ffee00"}
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
Note where is says `channel: 93`. This is the `channel` value required to send messages in this particular example.
|
|
103
|
-
|
|
104
|
-
### Serial and Bluetooth (send / receive)
|
|
105
|
-
|
|
106
|
-
`Meshtastic::Serial` (USB/UART) and `Meshtastic::Bluetooth` (Linux BLE via BlueZ) talk to a local radio using the same client API. The radio encrypts with its configured channel keys. Payloads are sent decoded; `channel:` is the index on the device, not an MQTT channel hash.
|
|
107
|
-
|
|
108
|
-
Do not open Serial and Bluetooth to the same radio at once. Disconnect when finished (`ensure` is the reliable pattern). `send_text` / `send_data` report bytes written, not mesh delivery. `want_ack: true` requests a `ROUTING_APP` acknowledgment (`error_reason: NONE` means the local radio accepted the route). Incoming text is a UTF-8 string under `message[:packet][:decoded][:payload]`.
|
|
109
|
-
|
|
110
|
-
Call `wait_for_config` before using `my_node_num` or sending. It raises `Timeout::Error` if the firmware never completes the handshake. Opening a port or pairing is not the same as a completed handshake.
|
|
111
|
-
|
|
112
|
-
#### Serial (`Meshtastic::Serial`)
|
|
113
|
-
|
|
114
|
-
Use the device’s USB CDC port (`/dev/ttyACM*` or `/dev/ttyUSB*`). Enable Radio Configuration → Security → Serial Console (`security.serial_enabled`). That is not Module Configuration → Serial (`TEXTMSG` / `PROTO` on GPIO). Keep “Override Console Serial Port” off.
|
|
115
|
-
|
|
116
|
-
```ruby
|
|
117
|
-
require 'meshtastic'
|
|
118
|
-
|
|
119
|
-
serial_obj = nil
|
|
120
|
-
begin
|
|
121
|
-
serial_obj = Meshtastic::Serial.connect(block_dev: '/dev/ttyACM0', baud: 115_200)
|
|
122
|
-
Meshtastic::Serial.wait_for_config(serial_obj: serial_obj, timeout: 10)
|
|
123
|
-
puts "local node: !#{serial_obj[:my_node_num].to_s(16)}"
|
|
124
|
-
|
|
125
|
-
# Direct message, or to: '!ffffffff' for the shared channel.
|
|
126
|
-
Meshtastic::Serial.send_text(
|
|
127
|
-
serial_obj: serial_obj,
|
|
128
|
-
to: '!aabbccdd',
|
|
129
|
-
channel: 0,
|
|
130
|
-
text: 'Hello over serial!',
|
|
131
|
-
want_ack: true
|
|
132
|
-
)
|
|
133
|
-
|
|
134
|
-
Meshtastic::Serial.subscribe(
|
|
135
|
-
serial_obj: serial_obj,
|
|
136
|
-
include: 'TEXT_MESSAGE_APP'
|
|
137
|
-
) do |message|
|
|
138
|
-
packet = message[:packet]
|
|
139
|
-
puts "#{packet[:node_id_from]}: #{packet.dig(:decoded, :payload)}"
|
|
140
|
-
end
|
|
141
|
-
ensure
|
|
142
|
-
Meshtastic::Serial.disconnect(serial_obj: serial_obj)
|
|
143
|
-
end
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
Drive the loop yourself with `recv_from_radio(serial_obj:, timeout:)` (`0` polls, `nil` blocks) or `drain_from_radio`. A closed empty queue returns `nil`; an unplugged device raises `IOError`. If `wait_for_config` times out, the USB path is up but the Stream API is not (wrong port, Serial Console disabled, or firmware not responding).
|
|
147
|
-
|
|
148
|
-
#### Bluetooth (`Meshtastic::Bluetooth`)
|
|
149
|
-
|
|
150
|
-
Linux only (BlueZ + `ruby-dbus`). Connect with a BLE address (`AA:BB:CC:DD:EE:FF`), not a mesh id (`!11223344`). Pair first; this gem does not guess a PIN. BLE writes unframed ToRadio protobufs (no UART `0x94 0xC3` header).
|
|
151
|
-
|
|
152
|
-
Scan:
|
|
153
|
-
|
|
154
|
-
```ruby
|
|
155
|
-
require 'meshtastic'
|
|
156
|
-
Meshtastic::Bluetooth.scan(adapter: 'hci0', timeout: 5)
|
|
157
|
-
# => [{ address: 'AA:BB:CC:DD:EE:FF', name: 'Meshtastic_eeff', paired: true }, ...]
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
Pair while discovery is running. Screen devices typically show a random 6-digit PIN:
|
|
161
|
-
|
|
162
|
-
```text
|
|
163
|
-
bluetoothctl
|
|
164
|
-
agent KeyboardDisplay
|
|
165
|
-
default-agent
|
|
166
|
-
scan on
|
|
167
|
-
pair AA:BB:CC:DD:EE:FF
|
|
168
|
-
trust AA:BB:CC:DD:EE:FF
|
|
169
|
-
scan off
|
|
170
|
-
quit
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
`Failed to pair: AuthenticationFailed` means the agent never got the PIN. `Device … not available` means scan first; the advertisement dropped.
|
|
174
|
-
|
|
175
|
-
Send and receive (same options as Serial, `bluetooth_obj:` instead of `serial_obj:`):
|
|
176
|
-
|
|
177
|
-
```ruby
|
|
178
|
-
require 'meshtastic'
|
|
179
|
-
|
|
180
|
-
bluetooth_obj = nil
|
|
181
|
-
begin
|
|
182
|
-
bluetooth_obj = Meshtastic::Bluetooth.connect(address: 'AA:BB:CC:DD:EE:FF')
|
|
183
|
-
Meshtastic::Bluetooth.wait_for_config(bluetooth_obj: bluetooth_obj, timeout: 30)
|
|
184
|
-
|
|
185
|
-
Meshtastic::Bluetooth.send_text(
|
|
186
|
-
bluetooth_obj: bluetooth_obj,
|
|
187
|
-
to: '!aabbccdd',
|
|
188
|
-
channel: 0,
|
|
189
|
-
text: 'Hello over BLE!',
|
|
190
|
-
want_ack: true
|
|
191
|
-
)
|
|
192
|
-
|
|
193
|
-
Meshtastic::Bluetooth.subscribe(
|
|
194
|
-
bluetooth_obj: bluetooth_obj,
|
|
195
|
-
include: 'TEXT_MESSAGE_APP'
|
|
196
|
-
) do |message|
|
|
197
|
-
packet = message[:packet]
|
|
198
|
-
puts "#{packet[:node_id_from]}: #{packet.dig(:decoded, :payload)}"
|
|
199
|
-
end
|
|
200
|
-
ensure
|
|
201
|
-
Meshtastic::Bluetooth.disconnect(bluetooth_obj: bluetooth_obj)
|
|
202
|
-
end
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
Disconnect the phone’s Meshtastic BLE session while Linux is connected. After an aborted reconnect (`le-connection-abort-by-local`), `bluetoothctl disconnect <addr>` and wait a couple of seconds before `connect` again. Config dumps over BLE can take longer than serial; 30 seconds is a reasonable `wait_for_config` timeout.
|
|
206
34
|
|
|
207
35
|
## Contributing
|
|
208
36
|
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Meshtastic Ruby documentation
|
|
2
|
+
|
|
3
|
+
Usage for every constant in the `Meshtastic` namespace lives here. The root [README](../README.md) is install, expectations, and contributing only.
|
|
4
|
+
|
|
5
|
+
`require 'meshtastic'` then `Meshtastic.help` lists loaded constants. Each first-class API module also has `.help` and `.authors`.
|
|
6
|
+
|
|
7
|
+
Examples use placeholder addresses only:
|
|
8
|
+
|
|
9
|
+
- Serial port: `/dev/ttyACM0`
|
|
10
|
+
- BLE: `AA:BB:CC:DD:EE:FF`
|
|
11
|
+
- Mesh node: `!aabbccdd` (destination), `!11223344` (local)
|
|
12
|
+
- MQTT sample node: `!c0ffee00`
|
|
13
|
+
- TCP radio: `192.0.2.10`
|
|
14
|
+
- Broadcast: `!ffffffff` (protocol all-nodes address)
|
|
15
|
+
|
|
16
|
+
## Transports
|
|
17
|
+
|
|
18
|
+
- [Meshtastic::MQTT](mqtt.md)
|
|
19
|
+
- [Meshtastic::Serial](serial.md)
|
|
20
|
+
- [Meshtastic::Bluetooth](bluetooth.md)
|
|
21
|
+
- [Meshtastic::Bluetooth::BlueZ](bluetooth-bluez.md)
|
|
22
|
+
- [Meshtastic::TCP](tcp.md)
|
|
23
|
+
|
|
24
|
+
Feature modules send protobufs over Serial, Bluetooth, or TCP via `Meshtastic.deliver_data`. Pass `serial_obj:`, `bluetooth_obj:`, or `tcp_obj:`. MQTT encrypts on the host; the radio encrypts on the other three.
|
|
25
|
+
|
|
26
|
+
Do not open Serial and Bluetooth to the same radio at once. Always `disconnect` in `ensure`.
|
|
27
|
+
|
|
28
|
+
## Feature modules
|
|
29
|
+
|
|
30
|
+
- [Meshtastic::Admin](admin.md)
|
|
31
|
+
- [Meshtastic::Channel](channel.md)
|
|
32
|
+
- [Meshtastic::Config](config.md)
|
|
33
|
+
- [Meshtastic::ModuleConfig](module-config.md)
|
|
34
|
+
- [Meshtastic::Position](position.md)
|
|
35
|
+
- [Meshtastic::Telemetry](telemetry.md)
|
|
36
|
+
- [Meshtastic::Traceroute](traceroute.md)
|
|
37
|
+
- [Meshtastic::RemoteHardware](remote-hardware.md)
|
|
38
|
+
- [Meshtastic::Storeforward](storeforward.md)
|
|
39
|
+
- [Meshtastic::ATAK](atak.md)
|
|
40
|
+
- [Meshtastic::Paxcount](paxcount.md)
|
|
41
|
+
- [Meshtastic::Cannedmessages](cannedmessages.md)
|
|
42
|
+
- [Meshtastic::RTTTL](rtttl.md)
|
|
43
|
+
- [Meshtastic::Portnums](portnums.md)
|
|
44
|
+
- [Meshtastic::Apponly](apponly.md)
|
|
45
|
+
- [Meshtastic::Clientonly](clientonly.md)
|
|
46
|
+
- [Meshtastic::Deviceonly](deviceonly.md)
|
|
47
|
+
- [Meshtastic::Localonly](localonly.md)
|
|
48
|
+
- [Meshtastic::ConnectionStatus](connection-status.md)
|
|
49
|
+
- [Meshtastic::Xmodem](xmodem.md)
|
|
50
|
+
|
|
51
|
+
## Internals
|
|
52
|
+
|
|
53
|
+
- [Meshtastic (top-level)](meshtastic.md)
|
|
54
|
+
- [Meshtastic::MeshInterface](mesh-interface.md)
|
|
55
|
+
- [Meshtastic::StreamInterface](stream-interface.md)
|
|
56
|
+
- [Meshtastic::Util](util.md)
|
|
57
|
+
- [Generated protobuf types](protobufs.md)
|
|
58
|
+
|
|
59
|
+
Protobuf message classes that this gem reopens (`Channel`, `Config`, `Position`, `Telemetry`, `ModuleConfig`, `Paxcount`) must not define class methods named `send` or `encode` (those belong to protobuf). Use `get`/`set`, `transmit`, `build`, or `request` instead.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Meshtastic::Admin
|
|
2
|
+
|
|
3
|
+
Builds `Meshtastic::AdminMessage` and sends it on `ADMIN_APP` (port 6) through [Meshtastic.deliver_data](meshtastic.md). Pass a connected `serial_obj`, `bluetooth_obj`, or `tcp_obj`.
|
|
4
|
+
|
|
5
|
+
Responses come back as `FromRadio` packets on the same transport (`subscribe` / `recv_from_radio`).
|
|
6
|
+
|
|
7
|
+
## Methods
|
|
8
|
+
|
|
9
|
+
- `encode` — copies matching keys onto an `AdminMessage`
|
|
10
|
+
- `send` — wrap and deliver (`want_response` default true)
|
|
11
|
+
- `reboot(seconds: 5)`
|
|
12
|
+
- `shutdown(seconds: 5)`
|
|
13
|
+
- `get_owner` / `set_owner(long_name:, short_name:, owner:)`
|
|
14
|
+
- `get_channel(index:)` / `set_channel(channel_settings:)`
|
|
15
|
+
- `get_config(config_type:)` / `set_config(config:)`
|
|
16
|
+
- `nodedb_reset`
|
|
17
|
+
- `help` / `authors`
|
|
18
|
+
|
|
19
|
+
`config_type` values: `:DEVICE_CONFIG`, `:POSITION_CONFIG`, `:POWER_CONFIG`, `:NETWORK_CONFIG`, `:DISPLAY_CONFIG`, `:LORA_CONFIG`, `:BLUETOOTH_CONFIG`, `:SECURITY_CONFIG`, `:SESSIONKEY_CONFIG`, `:DEVICEUI_CONFIG`.
|
|
20
|
+
|
|
21
|
+
Any other `AdminMessage` field can be passed to `send` / `encode` (for example `set_ringtone_message`, `get_module_config_request`).
|
|
22
|
+
|
|
23
|
+
## Examples
|
|
24
|
+
|
|
25
|
+
```ruby
|
|
26
|
+
require 'meshtastic'
|
|
27
|
+
|
|
28
|
+
serial_obj = Meshtastic::Serial.connect(block_dev: '/dev/ttyACM0')
|
|
29
|
+
Meshtastic::Serial.wait_for_config(serial_obj: serial_obj)
|
|
30
|
+
|
|
31
|
+
Meshtastic::Admin.set_owner(serial_obj: serial_obj, long_name: 'Node', short_name: 'N1')
|
|
32
|
+
Meshtastic::Admin.get_owner(serial_obj: serial_obj)
|
|
33
|
+
Meshtastic::Admin.get_config(serial_obj: serial_obj, config_type: :LORA_CONFIG)
|
|
34
|
+
Meshtastic::Admin.get_channel(serial_obj: serial_obj, index: 0)
|
|
35
|
+
Meshtastic::Admin.reboot(serial_obj: serial_obj, seconds: 5)
|
|
36
|
+
# Meshtastic::Admin.shutdown(serial_obj: serial_obj, seconds: 5)
|
|
37
|
+
# Meshtastic::Admin.nodedb_reset(serial_obj: serial_obj)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Raw field:
|
|
41
|
+
|
|
42
|
+
```ruby
|
|
43
|
+
Meshtastic::Admin.send(
|
|
44
|
+
serial_obj: serial_obj,
|
|
45
|
+
factory_reset_config: true
|
|
46
|
+
)
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Related
|
|
50
|
+
|
|
51
|
+
- [Meshtastic::Channel](channel.md)
|
|
52
|
+
- [Meshtastic::Config](config.md)
|
|
53
|
+
- [Meshtastic::ModuleConfig](module-config.md)
|
|
54
|
+
- [Meshtastic::RTTTL](rtttl.md)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Meshtastic::Apponly
|
|
2
|
+
|
|
3
|
+
App-side channel export: `Meshtastic::ChannelSet` (from `apponly.proto`).
|
|
4
|
+
|
|
5
|
+
## Methods
|
|
6
|
+
|
|
7
|
+
- `encode(settings:, lora_config:)`
|
|
8
|
+
- `decode(bytes)`
|
|
9
|
+
- `help` / `authors`
|
|
10
|
+
|
|
11
|
+
## Example
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
set = Meshtastic::Apponly.encode(
|
|
15
|
+
settings: [Meshtastic::ChannelSettings.new(name: 'LongFast')]
|
|
16
|
+
)
|
|
17
|
+
round_trip = Meshtastic::Apponly.decode(set.to_proto)
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Related
|
|
21
|
+
|
|
22
|
+
- [Meshtastic::Channel](channel.md)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Meshtastic::ATAK
|
|
2
|
+
|
|
3
|
+
Encodes `Meshtastic::TAKPacket` and sends it on `ATAK_PLUGIN` (port 72).
|
|
4
|
+
|
|
5
|
+
## Methods
|
|
6
|
+
|
|
7
|
+
- `encode(is_compressed:, chat:, message:)` — `message:` builds a `GeoChat`
|
|
8
|
+
- `send`
|
|
9
|
+
- `help` / `authors`
|
|
10
|
+
|
|
11
|
+
## Example
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
Meshtastic::ATAK.send(
|
|
15
|
+
serial_obj: serial_obj,
|
|
16
|
+
message: 'ATAK chat'
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
packet = Meshtastic::ATAK.encode(message: 'ATAK chat')
|
|
20
|
+
packet.chat.message # => "ATAK chat"
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Related protobufs: `TAKPacket`, `GeoChat`, `Contact`, `Group`, `PLI`, `TAKPacketV2`. See [protobufs.md](protobufs.md).
|
|
24
|
+
|
|
25
|
+
## Related
|
|
26
|
+
|
|
27
|
+
- [Meshtastic::ModuleConfig](module-config.md) (`:TAK_CONFIG`)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Meshtastic::Bluetooth::BlueZ
|
|
2
|
+
|
|
3
|
+
Linux D-Bus backend used by [Meshtastic::Bluetooth](bluetooth.md). You normally call `Meshtastic::Bluetooth.scan` / `connect` instead of this class.
|
|
4
|
+
|
|
5
|
+
## Constants
|
|
6
|
+
|
|
7
|
+
- `SERVICE_UUID`
|
|
8
|
+
- `TORADIO_UUID`
|
|
9
|
+
- `FROMRADIO_UUID`
|
|
10
|
+
|
|
11
|
+
## Methods
|
|
12
|
+
|
|
13
|
+
- `BlueZ.scan(adapter: 'hci0', timeout: 5)` — `StartDiscovery` then list Device1 objects on that adapter. Returns `{ address:, name:, paired: }`.
|
|
14
|
+
- `#connect` — requires an already paired device; raises if not paired or `ServicesResolved` times out
|
|
15
|
+
- `#read` / write ToRadio characteristic
|
|
16
|
+
- `#close`
|
|
17
|
+
|
|
18
|
+
Requires `ruby-dbus`. Uses the system bus. D-Bus calls are serialized on a mutex.
|
|
19
|
+
|
|
20
|
+
```ruby
|
|
21
|
+
require 'meshtastic'
|
|
22
|
+
|
|
23
|
+
hits = Meshtastic::Bluetooth::BlueZ.scan(adapter: 'hci0', timeout: 5)
|
|
24
|
+
hits.each { |d| puts "#{d[:address]} #{d[:name]} paired=#{d[:paired]}" }
|
|
25
|
+
|
|
26
|
+
conn = Meshtastic::Bluetooth::BlueZ.new(address: 'AA:BB:CC:DD:EE:FF', adapter: 'hci0', timeout: 15)
|
|
27
|
+
conn.connect
|
|
28
|
+
conn.close
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Pairing is outside this class (`bluetoothctl`). The module will not try PIN values.
|
|
32
|
+
|
|
33
|
+
## Related
|
|
34
|
+
|
|
35
|
+
- [Meshtastic::Bluetooth](bluetooth.md)
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# Meshtastic::Bluetooth
|
|
2
|
+
|
|
3
|
+
Linux BLE client (BlueZ + `ruby-dbus`). Same send/receive API as Serial, with `bluetooth_obj:` instead of `serial_obj:`.
|
|
4
|
+
|
|
5
|
+
Connect with a BLE address (`AA:BB:CC:DD:EE:FF`), not a mesh id (`!11223344`). Pair first; this gem does not guess a PIN. BLE writes unframed `ToRadio` protobufs (no UART `0x94 0xC3` header).
|
|
6
|
+
|
|
7
|
+
Do not open Serial and Bluetooth to the same radio at once. Disconnect the phone’s Meshtastic BLE session while Linux is connected.
|
|
8
|
+
|
|
9
|
+
## Methods
|
|
10
|
+
|
|
11
|
+
- `scan(adapter:, timeout:)`
|
|
12
|
+
- `connect(address:, adapter:, timeout:, want_config:)`
|
|
13
|
+
- `wait_for_config` — 30 seconds is a reasonable BLE timeout
|
|
14
|
+
- `send_text` / `send_data` / `send_to_radio`
|
|
15
|
+
- `recv_from_radio` / `drain_from_radio`
|
|
16
|
+
- `dump_stdout_data` / `flush_data`
|
|
17
|
+
- `subscribe`
|
|
18
|
+
- `disconnect`
|
|
19
|
+
- `help` / `authors`
|
|
20
|
+
|
|
21
|
+
## Scan
|
|
22
|
+
|
|
23
|
+
```ruby
|
|
24
|
+
require 'meshtastic'
|
|
25
|
+
Meshtastic::Bluetooth.scan(adapter: 'hci0', timeout: 5)
|
|
26
|
+
# => [{ address: 'AA:BB:CC:DD:EE:FF', name: 'Meshtastic_eeff', paired: true }, ...]
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Pair
|
|
30
|
+
|
|
31
|
+
Pair while discovery is running. Screen devices typically show a random 6-digit PIN. Do not invent PIN values.
|
|
32
|
+
|
|
33
|
+
```text
|
|
34
|
+
bluetoothctl
|
|
35
|
+
agent KeyboardDisplay
|
|
36
|
+
default-agent
|
|
37
|
+
scan on
|
|
38
|
+
pair AA:BB:CC:DD:EE:FF
|
|
39
|
+
trust AA:BB:CC:DD:EE:FF
|
|
40
|
+
scan off
|
|
41
|
+
quit
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
`Failed to pair: AuthenticationFailed` means the agent never got the PIN. `Device … not available` means scan first; the advertisement dropped.
|
|
45
|
+
|
|
46
|
+
## Send / receive
|
|
47
|
+
|
|
48
|
+
```ruby
|
|
49
|
+
require 'meshtastic'
|
|
50
|
+
|
|
51
|
+
bluetooth_obj = nil
|
|
52
|
+
begin
|
|
53
|
+
bluetooth_obj = Meshtastic::Bluetooth.connect(address: 'AA:BB:CC:DD:EE:FF')
|
|
54
|
+
Meshtastic::Bluetooth.wait_for_config(bluetooth_obj: bluetooth_obj, timeout: 30)
|
|
55
|
+
|
|
56
|
+
Meshtastic::Bluetooth.send_text(
|
|
57
|
+
bluetooth_obj: bluetooth_obj,
|
|
58
|
+
to: '!aabbccdd',
|
|
59
|
+
channel: 0,
|
|
60
|
+
text: 'Hello over BLE!',
|
|
61
|
+
want_ack: true
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
Meshtastic::Bluetooth.subscribe(
|
|
65
|
+
bluetooth_obj: bluetooth_obj,
|
|
66
|
+
include: 'TEXT_MESSAGE_APP'
|
|
67
|
+
) do |message|
|
|
68
|
+
packet = message[:packet]
|
|
69
|
+
puts "#{packet[:node_id_from]}: #{packet.dig(:decoded, :payload)}"
|
|
70
|
+
end
|
|
71
|
+
ensure
|
|
72
|
+
Meshtastic::Bluetooth.disconnect(bluetooth_obj: bluetooth_obj)
|
|
73
|
+
end
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
After an aborted reconnect (`le-connection-abort-by-local`), `bluetoothctl disconnect <addr>` and wait a couple of seconds before `connect` again.
|
|
77
|
+
|
|
78
|
+
GATT UUIDs (see [BlueZ](bluetooth-bluez.md)):
|
|
79
|
+
|
|
80
|
+
- Service `6ba1b218-15a8-461f-9fa8-5dcae273eafd`
|
|
81
|
+
- ToRadio `f75c76d2-129e-4dad-a1dd-7866124401e7`
|
|
82
|
+
- FromRadio `2c55e69e-4993-11ed-b878-0242ac120002`
|
|
83
|
+
|
|
84
|
+
## Related
|
|
85
|
+
|
|
86
|
+
- [Meshtastic::Bluetooth::BlueZ](bluetooth-bluez.md)
|
|
87
|
+
- [Meshtastic::Serial](serial.md)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Meshtastic::Cannedmessages
|
|
2
|
+
|
|
3
|
+
Wraps `Meshtastic::CannedMessageModuleConfig` (`messages` is a newline-separated string).
|
|
4
|
+
|
|
5
|
+
## Methods
|
|
6
|
+
|
|
7
|
+
- `encode(messages:)`
|
|
8
|
+
- `send` — publishes the string on `TEXT_MESSAGE_APP` (not an admin set). To store canned lines on the device, use [Admin](admin.md) `set_canned_message_module_messages` or [ModuleConfig](module-config.md).
|
|
9
|
+
- `help` / `authors`
|
|
10
|
+
|
|
11
|
+
## Example
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
cfg = Meshtastic::Cannedmessages.encode(messages: "Yes\nNo\nMaybe")
|
|
15
|
+
cfg.messages # => "Yes\nNo\nMaybe"
|
|
16
|
+
|
|
17
|
+
Meshtastic::Admin.send(
|
|
18
|
+
serial_obj: serial_obj,
|
|
19
|
+
set_canned_message_module_messages: "Yes\nNo\nMaybe"
|
|
20
|
+
)
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Related
|
|
24
|
+
|
|
25
|
+
- [Meshtastic::Admin](admin.md)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Meshtastic::Channel
|
|
2
|
+
|
|
3
|
+
Reopens the generated `Meshtastic::Channel` protobuf class with get/set helpers that call [Admin](admin.md).
|
|
4
|
+
|
|
5
|
+
This is a protobuf class, not a Ruby module. Do not add class methods named `send` or `encode`.
|
|
6
|
+
|
|
7
|
+
## Methods
|
|
8
|
+
|
|
9
|
+
- `get(serial_obj:, index:)` — `get_channel_request`
|
|
10
|
+
- `set(serial_obj:, channel:)` — `set_channel`
|
|
11
|
+
- `help` / `authors`
|
|
12
|
+
|
|
13
|
+
Also all protobuf instance fields: `index`, `settings` (`ChannelSettings`), `role` (`:DISABLED`, `:PRIMARY`, `:SECONDARY`).
|
|
14
|
+
|
|
15
|
+
## Example
|
|
16
|
+
|
|
17
|
+
```ruby
|
|
18
|
+
Meshtastic::Channel.get(serial_obj: serial_obj, index: 0)
|
|
19
|
+
|
|
20
|
+
settings = Meshtastic::ChannelSettings.new(name: 'LongFast', psk: "\x01")
|
|
21
|
+
channel = Meshtastic::Channel.new(index: 0, settings: settings, role: :PRIMARY)
|
|
22
|
+
Meshtastic::Channel.set(serial_obj: serial_obj, channel: channel)
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Listen for `ADMIN_APP` replies on the same transport.
|
|
26
|
+
|
|
27
|
+
## Related
|
|
28
|
+
|
|
29
|
+
- [Meshtastic::Admin](admin.md)
|
|
30
|
+
- [Meshtastic::Apponly](apponly.md) (`ChannelSet`)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Meshtastic::Clientonly
|
|
2
|
+
|
|
3
|
+
Client-side `Meshtastic::DeviceProfile` encode/decode (`clientonly.proto`).
|
|
4
|
+
|
|
5
|
+
## Methods
|
|
6
|
+
|
|
7
|
+
- `encode(long_name:, short_name:)`
|
|
8
|
+
- `decode(bytes)`
|
|
9
|
+
- `help` / `authors`
|
|
10
|
+
|
|
11
|
+
## Example
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
profile = Meshtastic::Clientonly.encode(long_name: 'Node', short_name: 'N1')
|
|
15
|
+
profile.long_name # => "Node"
|
|
16
|
+
Meshtastic::Clientonly.decode(profile.to_proto)
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Related
|
|
20
|
+
|
|
21
|
+
- [Meshtastic::Admin](admin.md) (`set_owner`)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Meshtastic::Config
|
|
2
|
+
|
|
3
|
+
Reopens the generated `Meshtastic::Config` protobuf class. Get/set go through [Admin](admin.md).
|
|
4
|
+
|
|
5
|
+
## Methods
|
|
6
|
+
|
|
7
|
+
- `get(serial_obj:, config_type: :DEVICE_CONFIG)`
|
|
8
|
+
- `set(serial_obj:, config:)` — `config` is a `Meshtastic::Config`
|
|
9
|
+
- `help` / `authors`
|
|
10
|
+
|
|
11
|
+
Protobuf oneofs include `device`, `position`, `power`, `network`, `display`, `lora`, `bluetooth`, `security`, `sessionkey`, `device_ui`.
|
|
12
|
+
|
|
13
|
+
## Example
|
|
14
|
+
|
|
15
|
+
```ruby
|
|
16
|
+
Meshtastic::Config.get(serial_obj: serial_obj, config_type: :LORA_CONFIG)
|
|
17
|
+
|
|
18
|
+
config = Meshtastic::Config.new
|
|
19
|
+
config.device = Meshtastic::Config::DeviceConfig.new(role: :CLIENT)
|
|
20
|
+
Meshtastic::Config.set(serial_obj: serial_obj, config: config)
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
`config_type` list: [Admin](admin.md).
|
|
24
|
+
|
|
25
|
+
## Related
|
|
26
|
+
|
|
27
|
+
- [Meshtastic::Admin](admin.md)
|
|
28
|
+
- [Meshtastic::ModuleConfig](module-config.md)
|
|
29
|
+
- [Meshtastic::Localonly](localonly.md)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Meshtastic::ConnectionStatus
|
|
2
|
+
|
|
3
|
+
Decodes `Meshtastic::DeviceConnectionStatus`.
|
|
4
|
+
|
|
5
|
+
## Methods
|
|
6
|
+
|
|
7
|
+
- `decode(bytes)`
|
|
8
|
+
- `help` / `authors`
|
|
9
|
+
|
|
10
|
+
## Example
|
|
11
|
+
|
|
12
|
+
```ruby
|
|
13
|
+
status = Meshtastic::ConnectionStatus.decode(
|
|
14
|
+
Meshtastic::DeviceConnectionStatus.new.to_proto
|
|
15
|
+
)
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Related types: `WifiConnectionStatus`, `EthernetConnectionStatus`, `NetworkConnectionStatus`, `BluetoothConnectionStatus`, `SerialConnectionStatus`.
|
|
19
|
+
|
|
20
|
+
## Related
|
|
21
|
+
|
|
22
|
+
- [Generated protobuf types](protobufs.md)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Meshtastic::Deviceonly
|
|
2
|
+
|
|
3
|
+
Decodes device-only snapshots: `DeviceState` and `NodeDatabase`.
|
|
4
|
+
|
|
5
|
+
## Methods
|
|
6
|
+
|
|
7
|
+
- `decode_state(bytes)`
|
|
8
|
+
- `decode_nodedb(bytes)`
|
|
9
|
+
- `help` / `authors`
|
|
10
|
+
|
|
11
|
+
## Example
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
state = Meshtastic::Deviceonly.decode_state(Meshtastic::DeviceState.new.to_proto)
|
|
15
|
+
nodedb = Meshtastic::Deviceonly.decode_nodedb(Meshtastic::NodeDatabase.new.to_proto)
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Related types: `PositionLite`, `UserLite`, `NodeInfoLite`, `ChannelFile`, `BackupPreferences`.
|
|
19
|
+
|
|
20
|
+
## Related
|
|
21
|
+
|
|
22
|
+
- [Meshtastic::Localonly](localonly.md)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Meshtastic::Localonly
|
|
2
|
+
|
|
3
|
+
Decodes `LocalConfig` and `LocalModuleConfig` (full config blobs stored on the client).
|
|
4
|
+
|
|
5
|
+
## Methods
|
|
6
|
+
|
|
7
|
+
- `decode_config(bytes)`
|
|
8
|
+
- `decode_module_config(bytes)`
|
|
9
|
+
- `help` / `authors`
|
|
10
|
+
|
|
11
|
+
## Example
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
Meshtastic::Localonly.decode_config(Meshtastic::LocalConfig.new.to_proto)
|
|
15
|
+
Meshtastic::Localonly.decode_module_config(Meshtastic::LocalModuleConfig.new.to_proto)
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Related
|
|
19
|
+
|
|
20
|
+
- [Meshtastic::Config](config.md)
|
|
21
|
+
- [Meshtastic::ModuleConfig](module-config.md)
|