Prepared RNodeInterface for live detach/attach

This commit is contained in:
Mark Qvist 2026-09-27 19:26:09 +02:00
parent e68f4ff118
commit 24b1ac521e
No known key found for this signature in database
5 changed files with 34 additions and 22 deletions

View file

@ -1504,13 +1504,13 @@ class RNodeInterface(Interface):
except Exception as e:
self.online = False
RNS.log("A serial port error occurred, the contained exception was: "+str(e), RNS.LOG_ERROR)
RNS.log("The interface "+str(self)+" experienced an unrecoverable error and is now offline.", RNS.LOG_ERROR)
if not self.detached:
RNS.log("A serial port error occurred, the contained exception was: "+str(e), RNS.LOG_ERROR)
RNS.log("The interface "+str(self)+" experienced an unrecoverable error and is now offline.", RNS.LOG_ERROR)
if RNS.Reticulum.panic_on_interface_error:
RNS.panic()
if RNS.Reticulum.panic_on_interface_error: RNS.panic()
RNS.log("Reticulum will attempt to reconnect the interface periodically.", RNS.LOG_ERROR)
RNS.log("Reticulum will attempt to reconnect the interface periodically.", RNS.LOG_ERROR)
self.online = False
@ -1570,10 +1570,14 @@ class RNodeInterface(Interface):
except Exception as e:
RNS.log(f"An error occurred while detaching {self}: {e}", RNS.LOG_ERROR)
if self.use_ble: self.ble.close()
if self.use_tcp:
if self.use_ble:
self.ble.close()
self.ble.cleanup()
elif self.use_tcp:
time.sleep(0.5)
self.tcp.close()
else:
self.serial.close()
def should_ingress_limit(self):
return False
@ -1652,6 +1656,9 @@ class BLEConnection(BluetoothDispatcher):
self.owner.ble_rx_queue = b""
return data
def cleanup(self):
self.should_run = False
def close(self):
try:
if self.connected: