Skip to content

Commit

Permalink
Modified radio channel config options and added a broadcast function …
Browse files Browse the repository at this point in the history
…so the BBS can send broadcast messages on a preconfigured channel index
  • Loading branch information
rickoooooo committed Dec 30, 2024
1 parent 9c27656 commit 3332472
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion config.toml.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[main]
activate_keyword = "bbs"
radio_channel = 1
radio_channel_index = 1
log_level = "DEBUG"

[interface_mesh_tcp]
Expand Down
20 changes: 14 additions & 6 deletions interfaces/comm_interface_meshtastic_tcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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
)

'''
Expand Down
4 changes: 2 additions & 2 deletions mbbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit 3332472

Please sign in to comment.