kopia lustrzana https://github.com/mate-dev/meshtastic-matrix-relay
Added serial connection support
rodzic
957a4e3b76
commit
4ce36f8222
12
main.py
12
main.py
|
@ -6,6 +6,7 @@ import logging
|
|||
import yaml
|
||||
import re
|
||||
import meshtastic.tcp_interface
|
||||
import meshtastic.serial_interface
|
||||
from nio import AsyncClient, AsyncClientConfig, MatrixRoom, RoomMessageText, RoomMessage
|
||||
from pubsub import pub
|
||||
from meshtastic import mesh_pb2
|
||||
|
@ -28,11 +29,20 @@ elif relay_config["logging"]["level"] == "warn":
|
|||
elif relay_config["logging"]["level"] == "error":
|
||||
logger.setLevel(logging.ERROR)
|
||||
|
||||
target_host = relay_config["meshtastic"]["host"]
|
||||
|
||||
# Connect to the Meshtastic device
|
||||
logger.info(f"Starting Meshtastic <==> Matrix Relay...")
|
||||
|
||||
# Add a new configuration option to select between serial and network connections
|
||||
connection_type = relay_config["meshtastic"]["connection_type"]
|
||||
|
||||
if connection_type == "serial":
|
||||
serial_port = relay_config["meshtastic"]["serial_port"]
|
||||
logger.info(f"Connecting to radio using serial port {serial_port} ...")
|
||||
meshtastic_interface = meshtastic.serial_interface.SerialInterface(serial_port)
|
||||
logger.info(f"Connected to radio using serial port {serial_port}.")
|
||||
else:
|
||||
target_host = relay_config["meshtastic"]["host"]
|
||||
logger.info(f"Connecting to radio at {target_host} ...")
|
||||
meshtastic_interface = meshtastic.tcp_interface.TCPInterface(hostname=target_host)
|
||||
logger.info(f"Connected to radio at {target_host}.")
|
||||
|
|
Plik binarny nie jest wyświetlany.
|
@ -1,12 +1,14 @@
|
|||
matrix:
|
||||
homeserver: "https://scamdemic.wtf"
|
||||
access_token: "syt_bWVzaHRhc3RpY2JvdA_TJwsgMiKQmBdpPVIVlaQ_0S5MPm"
|
||||
bot_user_id: "@meshtasticbot:scamdemic.wtf"
|
||||
room_id: "!phZxXpkkANBjLFBWUB:scamdemic.wtf"
|
||||
homeserver: "https://example.matrix.org"
|
||||
access_token: "reaalllllyloooooongsecretttttcodeeeeeeforrrrbot"
|
||||
bot_user_id: "@botuser:example.matrix.org"
|
||||
room_id: "!someroomid:example.matrix.org"
|
||||
|
||||
meshtastic:
|
||||
host: "meshtastic.local"
|
||||
broadcast_enabled: false
|
||||
connection_type: serial # Choose either "network" or "serial"
|
||||
serial_port: /dev/ttyUSB0 # Only used when connection is "serial"
|
||||
host: "meshtastic.local" # Only used when connection is "network"
|
||||
broadcast_enabled: true
|
||||
channel: 0
|
||||
|
||||
logging:
|
||||
|
|
Ładowanie…
Reference in New Issue