Fixed RNodeInterface BLE reconnection hang on Android
Some checks are pending
Build Reticulum / test (push) Waiting to run
Build Reticulum / package (push) Blocked by required conditions
Build Reticulum / release (push) Blocked by required conditions

This commit is contained in:
Mark Qvist 2025-10-28 12:31:52 +01:00
parent af7697f223
commit 7138749307

View file

@ -456,6 +456,7 @@ class RNodeInterface(Interface):
self.first_tx = None self.first_tx = None
self.reconnect_w = RNodeInterface.RECONNECT_WAIT self.reconnect_w = RNodeInterface.RECONNECT_WAIT
self.reconnect_lock = threading.Lock() self.reconnect_lock = threading.Lock()
self.awaiting_ble_reset = False
self.r_frequency = None self.r_frequency = None
self.r_bandwidth = None self.r_bandwidth = None
@ -599,14 +600,16 @@ class RNodeInterface(Interface):
else: else:
raise IOError("No ports available for writing") raise IOError("No ports available for writing")
# def reset_ble(self): def reset_ble(self):
# RNS.log(f"Clearing previous connection instance: "+str(self.ble)) if not self.awaiting_ble_reset: return
# del self.ble else:
# self.ble = None RNS.log(f"Clearing previous connection instance: "+str(self.ble), RNS.LOG_DEBUG)
# self.serial = None self.ble = None
# self.ble = BLEConnection(owner=self, target_name=self.ble_name, target_bt_addr=self.ble_addr) self.serial = None
# self.serial = self.ble self.ble = BLEConnection(owner=self, target_name=self.ble_name, target_bt_addr=self.ble_addr)
# RNS.log(f"New connection instance: "+str(self.ble)) self.serial = self.ble
self.awaiting_ble_reset = False
RNS.log(f"New connection instance: "+str(self.ble), RNS.LOG_DEBUG)
def open_port(self): def open_port(self):
if not self.use_ble: if not self.use_ble:
@ -1699,12 +1702,15 @@ class BLEConnection(BluetoothDispatcher):
else: else:
RNS.log(f"BLE device connection timed out for {self.owner}", RNS.LOG_DEBUG) RNS.log(f"BLE device connection timed out for {self.owner}", RNS.LOG_DEBUG)
if self.mtu_requested_time: if self.mtu_requested_time:
RNS.log("MTU update timeout, tearing down connection") RNS.log("MTU update timeout, tearing down connection and resetting BLE dispatcher")
self.owner.hw_errors.append({"error": KISS.ERROR_INVALID_BLE_MTU, "description": "The Bluetooth Low Energy transfer MTU could not be configured for the connected device, and communication has failed. Restart Reticulum and any connected applications to retry connecting."}) self.owner.hw_errors.append({"error": KISS.ERROR_INVALID_BLE_MTU, "description": "The Bluetooth Low Energy transfer MTU could not be configured for the connected device, and communication has failed. Restart Reticulum and any connected applications to retry connecting."})
self.close() self.close()
self.close_gatt()
self.should_run = False self.should_run = False
self.owner.awaiting_ble_reset = True
self.close_gatt()
else:
self.close_gatt()
self.connect_job_running = False self.connect_job_running = False