mirror of
https://github.com/TheCommsChannel/TC2-BBS-mesh.git
synced 2025-12-14 15:36:23 -05:00
Handle radio connection loss
I added a flag and function to handle when the connection to the node is lost. This will now close the script and docker should detect this and restart the container
This commit is contained in:
parent
295fb35c92
commit
3e8553b848
1 changed files with 9 additions and 1 deletions
10
server.py
10
server.py
|
|
@ -37,6 +37,8 @@ js8call_formatter = logging.Formatter('%(asctime)s - JS8Call - %(levelname)s - %
|
|||
js8call_handler.setFormatter(js8call_formatter)
|
||||
js8call_logger.addHandler(js8call_handler)
|
||||
|
||||
continue_running = True
|
||||
|
||||
def display_banner():
|
||||
banner = """
|
||||
████████╗ ██████╗██████╗ ██████╗ ██████╗ ███████╗
|
||||
|
|
@ -70,7 +72,13 @@ def main():
|
|||
def receive_packet(packet, interface):
|
||||
on_receive(packet, interface)
|
||||
|
||||
def on_connection_loss(interface):
|
||||
logging.error("Connection to Meshtastic device lost.")
|
||||
global continue_running
|
||||
continue_running = False
|
||||
|
||||
pub.subscribe(receive_packet, system_config['mqtt_topic'])
|
||||
pub.subscribe(on_connection_loss, 'meshtastic.connection.lost')
|
||||
|
||||
# Initialize and start JS8Call Client if configured
|
||||
js8call_client = JS8CallClient(interface)
|
||||
|
|
@ -80,7 +88,7 @@ def main():
|
|||
js8call_client.connect()
|
||||
|
||||
try:
|
||||
while True:
|
||||
while continue_running:
|
||||
time.sleep(1)
|
||||
|
||||
except KeyboardInterrupt:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue