From 3332472b32f32b9b2e55931795d5886131f53366 Mon Sep 17 00:00:00 2001 From: Rick Date: Sun, 29 Dec 2024 22:00:57 -0800 Subject: [PATCH] Modified radio channel config options and added a broadcast function so the BBS can send broadcast messages on a preconfigured channel index --- README.md | 2 +- config.toml.example | 2 +- interfaces/comm_interface_meshtastic_tcp.py | 20 ++++++++++++++------ mbbs.py | 4 ++-- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 2104a30..18ed348 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ MBBS is a simple BBS system for use with Meshtastic. It is designed to be modula ![Screenshot of Android app with the default Tic Tac Toe example game](images/MBBS-Screenshot-TicTacToe.png?raw=true "Tic Tac Toe example game") # Status -This project is very much incomplete. It has not been extensively tested and certainly contains strange bugs. Contributions and bug reports are welcome. +This project is very much incomplete. It has not been extensively tested and probbably contains strange bugs. Contributions, bug reports, and feature requests are welcome. # Inspiration This project was inspired in part by the following projects: diff --git a/config.toml.example b/config.toml.example index 01b1553..10aba54 100644 --- a/config.toml.example +++ b/config.toml.example @@ -1,6 +1,6 @@ [main] activate_keyword = "bbs" -radio_channel = 1 +radio_channel_index = 1 log_level = "DEBUG" [interface_mesh_tcp] diff --git a/interfaces/comm_interface_meshtastic_tcp.py b/interfaces/comm_interface_meshtastic_tcp.py index 4ae89e4..21a0ef7 100644 --- a/interfaces/comm_interface_meshtastic_tcp.py +++ b/interfaces/comm_interface_meshtastic_tcp.py @@ -11,9 +11,9 @@ ''' class CommInterfaceMeshtasticTCP(CommInterface): - def __init__(self, radio_ip: str, channel_index: int) -> None: + def __init__(self, radio_ip: str, bc_channel_index: int) -> None: self.radio_ip = radio_ip - self.channel_index = channel_index + self.bc_channel_index = bc_channel_index self.interface = meshtastic.tcp_interface.TCPInterface(self.radio_ip, connectNow=True) self.monitor_thread = threading.Thread(target=self.check_socket_closed) @@ -30,7 +30,7 @@ def __init__(self, radio_ip: str, channel_index: int) -> None: def on_connection(self, interface: CommInterface, topic=pub.AUTO_TOPIC) -> None: # defaults to broadcast, specify a destination ID if you wish logger.info("Connected to radio.") - #interface.sendText("BBS Online!") + self.send_broadcast("BBS Online!") ''' Called when we lose connection to the radio @@ -45,9 +45,17 @@ def send_text(self, text: str, user_id: str) -> None: self.interface.sendText( text, user_id, - wantAck=True, - channelIndex=self.channel_index - #onResponse=self.menu.option_handler(packet, self.interface) + wantAck=True + ) + + ''' + Send broadcast message on configured channel index + ''' + def send_broadcast(self, text:str) -> None: + self.interface.sendText( + text, + channelIndex=self.bc_channel_index, + wantAck=True ) ''' diff --git a/mbbs.py b/mbbs.py index 78a55cf..5b3e130 100644 --- a/mbbs.py +++ b/mbbs.py @@ -19,7 +19,7 @@ # Meshtastic radio TCP interface try: radio_ip = config["interface_mesh_tcp"]["radio_ip"] - radio_channel = config["main"]["radio_channel"] + radio_channel = config["main"]["radio_channel_index"] except: logger.error("Unable to read radio's TCP config options from config.toml. Continuing without it.") else: @@ -28,7 +28,7 @@ # Meshtastic radio serial interface try: radio_device = config["interface_mesh_serial"]["serial_device"] - radio_channel = config["main"]["radio_channel"] + radio_channel = config["main"]["radio_channel_index"] except: logger.error("Unable to read serial device path from config.toml. Continuing without it.") else: