diff --git a/app/src/main/java/com/bitchat/android/mesh/BluetoothConnectionTracker.kt b/app/src/main/java/com/bitchat/android/mesh/BluetoothConnectionTracker.kt index 13e9f6dd..e4406f1f 100644 --- a/app/src/main/java/com/bitchat/android/mesh/BluetoothConnectionTracker.kt +++ b/app/src/main/java/com/bitchat/android/mesh/BluetoothConnectionTracker.kt @@ -244,17 +244,12 @@ class BluetoothConnectionTracker( /** * Clean up a specific device connection */ - fun cleanupDeviceConnection(deviceAddress: String, cleanupPending: Boolean = true) { + fun cleanupDeviceConnection(deviceAddress: String) { connectedDevices.remove(deviceAddress)?.let { deviceConn -> subscribedDevices.removeAll { it.address == deviceAddress } addressPeerMap.remove(deviceAddress) } - if (!cleanupPending) { - Log.d(TAG, "Skipped cleanup of pending connection for $deviceAddress") - } - if (cleanupPending) { - pendingConnections.remove(deviceAddress) - } + pendingConnections.remove(deviceAddress) Log.d(TAG, "Cleaned up device connection for $deviceAddress") } diff --git a/app/src/main/java/com/bitchat/android/mesh/BluetoothGattClientManager.kt b/app/src/main/java/com/bitchat/android/mesh/BluetoothGattClientManager.kt index 1a5bf5a0..4c14ae82 100644 --- a/app/src/main/java/com/bitchat/android/mesh/BluetoothGattClientManager.kt +++ b/app/src/main/java/com/bitchat/android/mesh/BluetoothGattClientManager.kt @@ -338,11 +338,8 @@ class BluetoothGattClientManager( if (status == 147) { Log.e(TAG, "Client: Connection establishment failed (status 147) for $deviceAddress") } - // cleanup without removing the pending connection so we don't reattempt - connectionTracker.cleanupDeviceConnection(deviceAddress, cleanupPending = false) } else { Log.d(TAG, "Client: Cleanly disconnected from $deviceAddress") - // cleanup so we can reattempt connection later connectionTracker.cleanupDeviceConnection(deviceAddress) } @@ -377,7 +374,7 @@ class BluetoothGattClientManager( gatt.discoverServices() } else { Log.w(TAG, "MTU negotiation failed for $deviceAddress with status: $status. Disconnecting.") - connectionTracker.removePendingConnection(deviceAddress) + //connectionTracker.removePendingConnection(deviceAddress) gatt.disconnect() } } @@ -458,13 +455,13 @@ class BluetoothGattClientManager( val gatt = device.connectGatt(context, false, gattCallback, BluetoothDevice.TRANSPORT_LE) if (gatt == null) { Log.e(TAG, "connectGatt returned null for $deviceAddress") - connectionTracker.removePendingConnection(deviceAddress) + // connectionTracker.removePendingConnection(deviceAddress) } else { Log.d(TAG, "Client: GATT connection initiated successfully for $deviceAddress") } } catch (e: Exception) { Log.e(TAG, "Client: Exception connecting to $deviceAddress: ${e.message}") - connectionTracker.removePendingConnection(deviceAddress) + // connectionTracker.removePendingConnection(deviceAddress) } } diff --git a/app/src/main/java/com/bitchat/android/mesh/BluetoothMeshService.kt b/app/src/main/java/com/bitchat/android/mesh/BluetoothMeshService.kt index 467aed39..bbe4cd53 100644 --- a/app/src/main/java/com/bitchat/android/mesh/BluetoothMeshService.kt +++ b/app/src/main/java/com/bitchat/android/mesh/BluetoothMeshService.kt @@ -64,7 +64,7 @@ class BluetoothMeshService(private val context: Context) { // Wire up PacketProcessor reference for recursive handling in MessageHandler messageHandler.packetProcessor = packetProcessor - // startPeriodicDebugLogging() + startPeriodicDebugLogging() } /**