meshtastic-matrix-relay/README.md

100 wiersze
3.4 KiB
Markdown
Czysty Zwykły widok Historia

2023-04-17 23:50:28 +00:00
# Meshtastic <=> Matrix Relay
2023-04-19 06:21:25 +00:00
A powerful and easy-to-use relay between Meshtastic devices and Matrix chat rooms, allowing seamless communication across platforms. This opens the door for bridging Meshtastic devices to [many other platforms](https://matrix.org/bridges/).
2023-04-19 05:30:30 +00:00
## Features
- Bidirectional message relay between Meshtastic devices and Matrix chat rooms, capable of supporting multiple meshnets
- Supports both serial and network connections for Meshtastic devices
2023-04-19 06:10:37 +00:00
- Custom keys are embedded in Matrix messages which are used when relaying messages between two or more meshnets.
2023-04-19 05:30:30 +00:00
- Truncates long messages to fit within Meshtastic's payload size
- SQLite database to store Meshtastic longnames for improved functionality
- Customizable logging level for easy debugging
- Configurable through a simple YAML file
## Custom Keys in Matrix Messages
2023-04-19 06:47:45 +00:00
This relay utilizes custom keys in Matrix messages. When a message is received from a remote meshnet, the relay includes the sender's longname and the meshnet name as custom keys in the Matrix message. This metadata helps identify the source of the message and provides context for users in the Matrix chat room.
2023-04-19 05:30:30 +00:00
Example message format with custom keys:
```
{
"msgtype": "m.text",
"body": "[Alice/RemoteMesh]: Hello from the remote meshnet!",
"meshtastic_longname": "Alice",
"meshtastic_meshnet": "RemoteMesh"
}
```
2023-04-17 23:50:28 +00:00
## Installation
2023-04-19 05:30:30 +00:00
Clone the repository:
2023-04-17 23:50:28 +00:00
```
git clone https://github.com/geoffwhittington/meshtastic-matrix-relay.git
```
### Setup
2023-04-19 05:30:30 +00:00
Create a Python virtual environment in the project directory:
2023-04-17 23:50:28 +00:00
```
python3 -m venv .pyenv
```
2023-04-19 05:30:30 +00:00
Activate the virtual environment and install dependencies:
2023-04-17 23:50:28 +00:00
```
source .pyenv/bin/activate
pip install -r requirements.txt
```
2023-04-19 05:30:30 +00:00
2023-04-17 23:50:28 +00:00
### Configuration
2023-04-19 05:30:30 +00:00
Create a `config.yaml` in the project directory with the appropriate values. A sample configuration is provided below:
2023-04-17 23:50:28 +00:00
2023-04-19 05:30:30 +00:00
```yaml
2023-04-17 23:50:28 +00:00
matrix:
homeserver: "https://example.matrix.org"
access_token: "reaalllllyloooooongsecretttttcodeeeeeeforrrrbot"
bot_user_id: "@botuser:example.matrix.org"
room_id: "!someroomid:example.matrix.org"
meshtastic:
2023-04-18 19:06:00 +00:00
connection_type: serial # Choose either "network" or "serial"
serial_port: /dev/ttyUSB0 # Only used when connection is "serial"
2023-04-19 05:30:30 +00:00
host: "meshtastic.local" # Only used when connection is "network"
channel: 0 # Channel ID of the Meshtastic Channel you want to relay
meshnet_name: "Your Meshnet Name" # This is displayed in full on Matrix, but is truncated when sent to a remote Meshnet
2023-04-18 19:06:00 +00:00
display_meshnet_name: true
2023-04-17 23:50:28 +00:00
logging:
level: "debug"
```
2023-04-19 05:30:30 +00:00
## Usage
Activate the virtual environment:
2023-04-17 23:50:28 +00:00
```
source .pyenv/bin/activate
```
2023-04-19 05:30:30 +00:00
Run the `main.py` script:
2023-04-17 23:50:28 +00:00
```
python main.py
```
2023-04-19 05:30:30 +00:00
Example output:
2023-04-17 23:50:28 +00:00
```
$ python main.py
INFO:meshtastic.matrix.relay:Starting Meshtastic <==> Matrix Relay...
INFO:meshtastic.matrix.relay:Connecting to radio at meshtastic.local ...
INFO:meshtastic.matrix.relay:Connected to radio at meshtastic.local.
INFO:meshtastic.matrix.relay:Listening for inbound radio messages ...
INFO:meshtastic.matrix.relay:Listening for inbound matrix messages ...
2023-04-19 05:30:30 +00:00
INFO:meshtastic.matrix.relay:Sending radio message from Alice to radio broadcast
INFO:meshtastic.matrix.relay:Processing inbound radio message from !613501e4
INFO:meshtastic.matrix.relay:Processing matrix message from @bob:matrix.org: Hi Alice!
INFO:meshtastic.matrix.relay:Sending radio message from Alice to radio broadcast
INFO:meshtastic.matrix.relay:Processing inbound radio message from !613501e4
2023-04-17 23:50:28 +00:00
```