Hello Meshtastic Community!
We are excited to share with you our project, a Meshtastic and Matrix relay (M<>M Relay), which aims to bridge the gap between the Meshtastic mesh network and the Matrix communication platform.
Background
As an avid user of Matrix since 2018, I have always appreciated its open-source, self-hostable nature, and interoperability with existing platforms through the use of bridges, gateways, or relays. After discovering the amazing Meshtastic project, I wanted to find a way to connect these two platforms. Along with @kwmesh , we started working on the M<>M Relay a few weeks ago.
How It Works
The M<>M Relay connects to Matrix using a dedicated bot user account and relays messages between Matrix and a Meshtastic device through the Meshtastic API. To make this possible, a dedicated node on your local meshnet is required to relay messages between the two networks.
All relay settings are managed through a yaml configuration file, which includes details for the Matrix bot user (homeserver, username, access token) and Meshtastic device (serial connection or network connection, serial port or hostname/IP, and Meshnet Name). The relay supports mapping all 8 Meshtastic channels to a Matrix room in a 1:1 connection.
In Action
When messages are sent from Matrix users to Meshtastic, the Matrix display name is truncated to 5 characters + a [M] suffix (e.g., “JohnS[M]: Message”). Messages sent from the local meshnet to Matrix will include the node’s longname, meshnet name (defined in the relay’s config.yaml file), and message (e.g., “[James/OurMeshnet]: Message goes here.”).
When a Meshtastic message is relayed to Matrix, the bot creates a Matrix message event with custom keys for relaying the longname and meshnet to remote meshnets. Remote relays present in the room will use this information to send messages back to the local meshnet with the format "Jam/OurM: Message goes here " (with the longname and meshnet name truncated to save space).
Plugins and Future Development
@kwmesh has developed a plugin framework and written a few plugins, including a !map command for displaying node meshnet locations (with an optional randomized offset) and a !health command for showing battery levels and other telemetry stats. These plugins are optional and can be enabled in the config.yaml file.
Element (and many other clients) support end-to-end encryption (E2EE) optionally in its rooms. We plan to add encrypted room support to the bot, but it’s not yet implemented at the moment.
Expanding Connectivity
With the successful bridging of Meshtastic and Matrix, we have opened the door to many possibilities, as there are many existing bridges available for the Matrix network. Some examples include Discord, WhatsApp, Slack, Telegram, SMS, Twitter, Email, and more (full list available at Bridges | Matrix.org). While we haven’t extensively tested Meshtastic <-> Matrix <-> Secondary bridges, our initial tests with a Discord bridge have shown promising results.
Help Appreciated!
We welcome your contributions to the project, whether it’s helping with testing, submitting bug fixes or feature additions, developing plugins, or even just offering suggestions. We are grateful to the Meshtastic developers and community for making this possible. M<>M Relay has been a fun project to work on, and we look forward to seeing where it goes from here!
Let us know what you think and if you have any questions or suggestions. Happy meshing!
Project website: https://github.com/geoffwhittington/meshtastic-matrix-relay
Our TWIM announcement: This Week in Matrix 2023-04-28 | Matrix.org
Edit: I added a wiki page (Getting Started With Matrix & MM Relay) with instructions on how to get started with Matrix & join our project’s room. Once there it will be easier to help you get up and running with the relay for the first time.
I’ve added a few screenshots here so you can see what it looks like in both the Meshtastic Android & Element apps.