mirror of
https://github.com/geoffwhittington/meshtastic-bridge.git
synced 2026-03-28 17:42:37 +01:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
461d540c30 | ||
|
|
6585f52f91 | ||
|
|
1f4027829e |
31
README.md
31
README.md
@@ -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`:
|
||||
|
||||
| Plugin | Description |
|
||||
| ----------------- | -------------------------------------------------------------------- |
|
||||
| `debugger` | Log the packet to the system console |
|
||||
| `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` |
|
||||
| `webhook` | Send HTTP requests with custom payloads using packet information |
|
||||
| `mqtt_plugin` | Send packets to a MQTT server |
|
||||
| `encrypt_filter` | Encrypt a packet for a desired MQTT recipient |
|
||||
| `decrypt_filter` | Decrypt a packet originating from MQTT |
|
||||
| `radio_message_plugin` | Send a packet to a specified `device` |
|
||||
| Plugin | Description |
|
||||
| ---------------------- | -------------------------------------------------------------------- |
|
||||
| `debugger` | Log the packet to the system console |
|
||||
| `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` |
|
||||
| `webhook` | Send HTTP requests with custom payloads using packet information |
|
||||
| `mqtt_plugin` | Send packets to a MQTT server |
|
||||
| `encrypt_filter` | Encrypt a packet for a desired MQTT recipient |
|
||||
| `decrypt_filter` | Decrypt a packet originating from MQTT |
|
||||
| `radio_message_plugin` | Send a packet to a specified `device` |
|
||||
|
||||
### debugger - Output the contents of a packet
|
||||
|
||||
@@ -199,7 +199,7 @@ webhook:
|
||||
- **log_level** `debug` or `info`. Default `info`
|
||||
- **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
|
||||
- **message** Override the packet message with a custom value
|
||||
- **message** Override the packet message with a custom value.
|
||||
- **topic** The message topic
|
||||
|
||||
For example:
|
||||
@@ -210,6 +210,10 @@ mqtt_plugin:
|
||||
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
|
||||
|
||||
- **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:
|
||||
|
||||
#### 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
|
||||
|
||||
- Example guidance for creating [PEM](https://www.suse.com/support/kb/doc/?id=000018152) key files.
|
||||
- Test webhooks using [Webhooks.site](https://webhook.site/)
|
||||
|
||||
1
main.py
1
main.py
@@ -136,7 +136,6 @@ if "mqtt_servers" in bridge_config:
|
||||
def on_message(mqttc, obj, msg):
|
||||
orig_packet = msg.payload.decode()
|
||||
|
||||
logger.debug(f"MQTT {config['name']}: on_message")
|
||||
logger.debug(f"MQTT {config['name']}: {orig_packet}")
|
||||
|
||||
if "pipelines" not in config:
|
||||
|
||||
@@ -242,8 +242,8 @@ class WebhookPlugin(Plugin):
|
||||
text = packet["decoded"]["text"] if "text" in packet["decoded"] else None
|
||||
|
||||
macros = {
|
||||
"{LAT}": position["latitude"] if position else None,
|
||||
"{LNG}": position["longitude"] if position else None,
|
||||
"{LAT}": position["latitude"] if position else "",
|
||||
"{LNG}": position["longitude"] if position else "",
|
||||
"{MSG}": self.config["message"] if "message" in self.config else text,
|
||||
"{FID}": packet["fromId"],
|
||||
"{TID}": packet["toId"],
|
||||
@@ -312,6 +312,8 @@ class MQTTPlugin(Plugin):
|
||||
|
||||
self.logger.debug("Message sent")
|
||||
|
||||
return packet
|
||||
|
||||
|
||||
plugins["mqtt_plugin"] = MQTTPlugin()
|
||||
|
||||
|
||||
18
use-cases/webhook/config.yaml
Normal file
18
use-cases/webhook/config.yaml
Normal file
@@ -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