mirror of
https://github.com/geoffwhittington/meshtastic-bridge.git
synced 2026-07-15 22:20:58 +02:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 461d540c30 | |||
| 6585f52f91 | |||
| 1f4027829e |
@@ -101,16 +101,16 @@ NOTE: If `tcp` or `serial` are not given the bridge will attempt to detect a rad
|
|||||||
|
|
||||||
The following plugins can be used in the `pipelines` section of `config.yaml`:
|
The following plugins can be used in the `pipelines` section of `config.yaml`:
|
||||||
|
|
||||||
| Plugin | Description |
|
| Plugin | Description |
|
||||||
| ----------------- | -------------------------------------------------------------------- |
|
| ---------------------- | -------------------------------------------------------------------- |
|
||||||
| `debugger` | Log the packet to the system console |
|
| `debugger` | Log the packet to the system console |
|
||||||
| `message_filter` | Filters out packets from the bridge that match a specific criteria |
|
| `message_filter` | Filters out packets from the bridge that match a specific criteria |
|
||||||
| `location_filter` | Filters out packets that originate too far from a specified `device` |
|
| `location_filter` | Filters out packets that originate too far from a specified `device` |
|
||||||
| `webhook` | Send HTTP requests with custom payloads using packet information |
|
| `webhook` | Send HTTP requests with custom payloads using packet information |
|
||||||
| `mqtt_plugin` | Send packets to a MQTT server |
|
| `mqtt_plugin` | Send packets to a MQTT server |
|
||||||
| `encrypt_filter` | Encrypt a packet for a desired MQTT recipient |
|
| `encrypt_filter` | Encrypt a packet for a desired MQTT recipient |
|
||||||
| `decrypt_filter` | Decrypt a packet originating from MQTT |
|
| `decrypt_filter` | Decrypt a packet originating from MQTT |
|
||||||
| `radio_message_plugin` | Send a packet to a specified `device` |
|
| `radio_message_plugin` | Send a packet to a specified `device` |
|
||||||
|
|
||||||
### debugger - Output the contents of a packet
|
### debugger - Output the contents of a packet
|
||||||
|
|
||||||
@@ -199,7 +199,7 @@ webhook:
|
|||||||
- **log_level** `debug` or `info`. Default `info`
|
- **log_level** `debug` or `info`. Default `info`
|
||||||
- **active** Plugin is active. Values: `true` or `false`. Default = `true`.
|
- **active** Plugin is active. Values: `true` or `false`. Default = `true`.
|
||||||
- **name** Reference of an existing MQTT server configured in the top-level `mqtt_servers` configuration
|
- **name** Reference of an existing MQTT server configured in the top-level `mqtt_servers` configuration
|
||||||
- **message** Override the packet message with a custom value
|
- **message** Override the packet message with a custom value.
|
||||||
- **topic** The message topic
|
- **topic** The message topic
|
||||||
|
|
||||||
For example:
|
For example:
|
||||||
@@ -210,6 +210,10 @@ mqtt_plugin:
|
|||||||
topic: meshtastic/topic
|
topic: meshtastic/topic
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Placeholders can be used with the **message** value:
|
||||||
|
|
||||||
|
- `{MSG}` - Packet text
|
||||||
|
|
||||||
### encrypt_filter - Encrypt a packet before sending it to a MQTT server
|
### encrypt_filter - Encrypt a packet before sending it to a MQTT server
|
||||||
|
|
||||||
- **log_level** `debug` or `info`. Default `info`
|
- **log_level** `debug` or `info`. Default `info`
|
||||||
@@ -277,10 +281,13 @@ python main.py
|
|||||||
|
|
||||||
Create a `config.yaml` with the desired settings and run the following Docker command:
|
Create a `config.yaml` with the desired settings and run the following Docker command:
|
||||||
|
|
||||||
|
#### Linux
|
||||||
|
|
||||||
```
|
```
|
||||||
docker run -v $(pwd)/config.yaml:/code/config.yaml gwhittington/meshtastic-bridge:latest
|
docker run --rm --network host -v $(pwd)/config.yaml:/code/config.yaml gwhittington/meshtastic-bridge:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
## Resources
|
## Resources
|
||||||
|
|
||||||
- Example guidance for creating [PEM](https://www.suse.com/support/kb/doc/?id=000018152) key files.
|
- Example guidance for creating [PEM](https://www.suse.com/support/kb/doc/?id=000018152) key files.
|
||||||
|
- Test webhooks using [Webhooks.site](https://webhook.site/)
|
||||||
|
|||||||
@@ -136,7 +136,6 @@ if "mqtt_servers" in bridge_config:
|
|||||||
def on_message(mqttc, obj, msg):
|
def on_message(mqttc, obj, msg):
|
||||||
orig_packet = msg.payload.decode()
|
orig_packet = msg.payload.decode()
|
||||||
|
|
||||||
logger.debug(f"MQTT {config['name']}: on_message")
|
|
||||||
logger.debug(f"MQTT {config['name']}: {orig_packet}")
|
logger.debug(f"MQTT {config['name']}: {orig_packet}")
|
||||||
|
|
||||||
if "pipelines" not in config:
|
if "pipelines" not in config:
|
||||||
|
|||||||
+4
-2
@@ -242,8 +242,8 @@ class WebhookPlugin(Plugin):
|
|||||||
text = packet["decoded"]["text"] if "text" in packet["decoded"] else None
|
text = packet["decoded"]["text"] if "text" in packet["decoded"] else None
|
||||||
|
|
||||||
macros = {
|
macros = {
|
||||||
"{LAT}": position["latitude"] if position else None,
|
"{LAT}": position["latitude"] if position else "",
|
||||||
"{LNG}": position["longitude"] if position else None,
|
"{LNG}": position["longitude"] if position else "",
|
||||||
"{MSG}": self.config["message"] if "message" in self.config else text,
|
"{MSG}": self.config["message"] if "message" in self.config else text,
|
||||||
"{FID}": packet["fromId"],
|
"{FID}": packet["fromId"],
|
||||||
"{TID}": packet["toId"],
|
"{TID}": packet["toId"],
|
||||||
@@ -312,6 +312,8 @@ class MQTTPlugin(Plugin):
|
|||||||
|
|
||||||
self.logger.debug("Message sent")
|
self.logger.debug("Message sent")
|
||||||
|
|
||||||
|
return packet
|
||||||
|
|
||||||
|
|
||||||
plugins["mqtt_plugin"] = MQTTPlugin()
|
plugins["mqtt_plugin"] = MQTTPlugin()
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
devices:
|
||||||
|
- name: radio1
|
||||||
|
tcp: meshtastic.local
|
||||||
|
pipelines:
|
||||||
|
pipeline1:
|
||||||
|
- debugger:
|
||||||
|
log_level: debug
|
||||||
|
radio-to-webhook:
|
||||||
|
- message_filter:
|
||||||
|
app:
|
||||||
|
allow:
|
||||||
|
- "TEXT_MESSAGE_APP"
|
||||||
|
- webhook:
|
||||||
|
active: true
|
||||||
|
body: '{"lat": "{LAT}", "lng": "{LNG}", "text_message": "{MSG}"}'
|
||||||
|
url: "https://webhook.site/452ea027-f9f1-4a62-827b-c921715fcdfb"
|
||||||
|
headers:
|
||||||
|
Content-type: application/json
|
||||||
Reference in New Issue
Block a user