mirror of
https://github.com/pdxlocations/contact.git
synced 2026-05-01 11:02:15 +02:00
fixes and cleanup
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import logging
|
||||
import time
|
||||
from datetime import datetime
|
||||
|
||||
from utilities.utils import refresh_node_list
|
||||
from datetime import datetime
|
||||
from ui.curses_ui import draw_packetlog_win, draw_node_list, draw_messages_window, draw_channel_list, add_notification
|
||||
@@ -8,8 +10,6 @@ import default_config as config
|
||||
import globals
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
def on_receive(packet, interface):
|
||||
|
||||
with globals.lock:
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
from datetime import datetime
|
||||
import google.protobuf.json_format
|
||||
from meshtastic import BROADCAST_NUM
|
||||
|
||||
from meshtastic.protobuf import mesh_pb2, portnums_pb2
|
||||
|
||||
from db_handler import save_message_to_db, update_ack_nak, get_name_from_database, is_chat_archived, update_node_info_in_db
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
import yaml
|
||||
import logging
|
||||
from typing import List
|
||||
|
||||
@@ -3,7 +3,6 @@ import io
|
||||
import contextlib
|
||||
import socket
|
||||
import logging
|
||||
import logging
|
||||
|
||||
from .interfaces import initialize_interface
|
||||
import globals
|
||||
@@ -26,21 +25,27 @@ def getNodeFirmware(interface):
|
||||
|
||||
return -1
|
||||
except (socket.error, BrokenPipeError, ConnectionResetError, Exception) as e:
|
||||
logging.info(f"Error retrieving firmware: {e}")
|
||||
logging.warning(f"Error retrieving firmware: {e}")
|
||||
raise e # Propagate the error to handle reconnection
|
||||
|
||||
# Async function to retry connection
|
||||
async def retry_interface(args):
|
||||
logging.info("Retrying connection to the interface...")
|
||||
logging.warning("Retrying connection to the interface...")
|
||||
await asyncio.sleep(retry_connection_seconds) # Wait before retrying
|
||||
|
||||
try:
|
||||
globals.interface = initialize_interface(args)
|
||||
if globals.interface and hasattr(globals.interface, 'localNode'):
|
||||
logging.warning("Interface reinitialized successfully.")
|
||||
return globals.interface
|
||||
else:
|
||||
logging.error("Failed to reinitialize interface: Missing localNode or invalid interface.")
|
||||
globals.interface = None # Clear invalid interface
|
||||
return None
|
||||
|
||||
logging.info("Interface reinitialized successfully.")
|
||||
return globals.interface
|
||||
except (ConnectionRefusedError, socket.error, Exception) as e:
|
||||
logging.error(f"Failed to reinitialize interface: {e}")
|
||||
globals.interface = None
|
||||
return None
|
||||
|
||||
# Function to check connection and reconnect if needed
|
||||
@@ -60,6 +65,7 @@ async def check_and_reconnect(args):
|
||||
|
||||
except (socket.error, BrokenPipeError, ConnectionResetError, Exception) as e:
|
||||
logging.error(f"Error with the interface, setting to None and attempting reconnect: {e}")
|
||||
globals.interface = None
|
||||
return await retry_interface(args)
|
||||
|
||||
# Main watchdog loop
|
||||
@@ -70,6 +76,4 @@ async def watchdog(args):
|
||||
if globals.interface:
|
||||
pass # Interface is connected
|
||||
else:
|
||||
logging.error("Interface connection failed. Retrying...")
|
||||
|
||||
|
||||
logging.error("Interface connection failed. Retrying...")
|
||||
Reference in New Issue
Block a user