mirror of
https://github.com/meshtastic/meshtastic.git
synced 2025-03-05 21:00:08 -08:00
implemented feedback of @scruplelesswizard
This commit is contained in:
parent
3d4bb4b609
commit
ef9647e8d7
|
@ -16,31 +16,44 @@ I will use this platform as a practical example on how to interface with the MQT
|
||||||
|
|
||||||
Use http://client.meshtastic.org/ , the python CLI, or an Apple or Android app to connect to your device and adjust these settings.
|
Use http://client.meshtastic.org/ , the python CLI, or an Apple or Android app to connect to your device and adjust these settings.
|
||||||
|
|
||||||
Step one:
|
|
||||||
Enable and enter network SSID/PSK.
|
|
||||||
|
|
||||||
- Settings--> Radio Config--> Network; Save.
|
1. Settings--> Radio Config--> Network
|
||||||
- Set MQTT server address.
|
- On the node that will act as the gateway between the mesh and MQTT enable a network connection (i.e. Wifi, Ethernet).
|
||||||
- Settings--> Module Config--> MQTT config; Verify Encryption Enabled is OFF.
|
- Save
|
||||||
- (optional) Turn JSON Output Enabled ON. Save.
|
|
||||||
- Go to Channel Editor and set Uplink and Downlink enabled to True. Save.
|
|
||||||
|
|
||||||
Step two: if you don't want to depend on JSON decoding on the device, you can decode the protobuf messages off-device. To do that you will need to get the .proto files from https://github.com/meshtastic/protobufs. They function as a schema and are required for decoding in Node-RED. Save the files where the node-RED application can access them and note the file path of the "mqtt.proto" file.
|
2. Settings--> Module Config--> MQTT config
|
||||||
|
- Configure the MQTT gateway's network configuration.
|
||||||
|
- Verify Encryption Enabled is OFF.
|
||||||
|
- (optional) Turn JSON Output Enabled ON.
|
||||||
|
- Save
|
||||||
|
3. Channel Editor
|
||||||
|
- Go to Channel Editor and enable Uplink and Downlink on the channels you wish to publish to MQTT.
|
||||||
|
- Save
|
||||||
|
|
||||||
|
|
||||||
### Using Node-RED with Meshtastic
|
### Using Node-RED with Meshtastic
|
||||||
Now, there are three possible approaches:
|
There are three common approaches:
|
||||||
|
|
||||||
1. Using JSON messages.
|
1. Using JSON-encoded messages
|
||||||
2. Using protobuf with a converter node.
|
2. Using protobuf-encoded messages with the Meshtastic decode node
|
||||||
3. Using protobuf with locally saved proto files
|
3. Using protobuf-encoded messages with a protobuf decode node and the Meshtastic protobuf definitions
|
||||||
|
|
||||||
Be aware that JSON option is somewhat less supported:
|
The JSON output only publishes the following subset of the messages on a Meshtastic network
|
||||||
> JSON was only ever intended to be a convenience for folks wanting to consume data in things like Home Assistant.
|
- Text Message
|
||||||
|
- Telemetry
|
||||||
|
- Device Metrics
|
||||||
|
- Environment Metrics
|
||||||
|
- Power Metrics
|
||||||
|
- Node Info
|
||||||
|
- Position
|
||||||
|
- Waypoint
|
||||||
|
- Neighbor Info
|
||||||
|
|
||||||
|
> JSON is intended to be a convenience for consuming data in other applications like Home Assistant.
|
||||||
|
|
||||||
> Protobufs are mesh native.
|
> Protobufs are mesh native.
|
||||||
|
|
||||||
#### 1. Using JSON messages
|
#### 1. Using JSON-encoded messages
|
||||||
Make sure that option *JSON Output Enabled* is set in MQTT module options.
|
Make sure that option *JSON Output Enabled* is set in MQTT module options.
|
||||||
|
|
||||||
Below is a valid JSON envelope for information sent by MQTT to a device for broadcast onto the mesh.
|
Below is a valid JSON envelope for information sent by MQTT to a device for broadcast onto the mesh.
|
||||||
|
@ -52,15 +65,20 @@ Below is a valid JSON envelope for information sent by MQTT to a device for broa
|
||||||
"payload": text or a json object go here
|
"payload": text or a json object go here
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
#### 2. Using protobuf with a converter node
|
#### 2. Using protobuf-encoded messages with the Meshtastic decode node
|
||||||
Install Node-Red plug-in:
|
Install Node-Red plug-in:
|
||||||
https://flows.nodered.org/node/@meshtastic/node-red-contrib-meshtastic
|
https://flows.nodered.org/node/@meshtastic/node-red-contrib-meshtastic
|
||||||
|
|
||||||
More info and example flow is in the plug-in source repository:
|
More info is in the plug-in source repository.
|
||||||
|
|
||||||
|
There is an example flow using this mechanism available
|
||||||
https://github.com/scruplelesswizard/meshtastic-node-red
|
https://github.com/scruplelesswizard/meshtastic-node-red
|
||||||
|
|
||||||
|
|
||||||
#### 3. Using protobuf with locally saved proto files
|
#### 3. Using protobuf-encoded messages with a protobuf decode node and the Meshtastic protobuf definitions
|
||||||
|
|
||||||
|
If you don't want to depend on JSON decoding on the device, you can decode the protobuf messages off-device. To do that you will need to get the .proto files from https://github.com/meshtastic/protobufs. They function as a schema and are required for decoding in Node-RED. Save the files where the node-RED application can access them and note the file path of the "mqtt.proto" file.
|
||||||
|
|
||||||
Install Node-RED plug-ins to your Node-RED application for an embedded MQTT server and a protobuf decoder.
|
Install Node-RED plug-ins to your Node-RED application for an embedded MQTT server and a protobuf decoder.
|
||||||
https://flows.nodered.org/node/node-red-contrib-aedes
|
https://flows.nodered.org/node/node-red-contrib-aedes
|
||||||
https://flows.nodered.org/node/node-red-contrib-protobuf
|
https://flows.nodered.org/node/node-red-contrib-protobuf
|
||||||
|
|
Loading…
Reference in a new issue