mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
refactor(ble): improve connection lifecycle and enhance OTA reliability (#4721)
Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
parent
5a5aa1f026
commit
68b2b6d88e
19 changed files with 741 additions and 537 deletions
|
|
@ -38,7 +38,6 @@ import no.nordicsemi.kotlin.ble.core.LegacyAdvertisingSetParameters
|
|||
import no.nordicsemi.kotlin.ble.core.Permission
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.meshtastic.core.ble.BleError
|
||||
import org.meshtastic.core.ble.MeshtasticBleConstants.FROMNUM_CHARACTERISTIC
|
||||
import org.meshtastic.core.ble.MeshtasticBleConstants.FROMRADIO_CHARACTERISTIC
|
||||
import org.meshtastic.core.ble.MeshtasticBleConstants.LOGRADIO_CHARACTERISTIC
|
||||
|
|
@ -169,7 +168,7 @@ class NordicBleInterfaceRetryTest {
|
|||
assert(writtenValue!!.contentEquals(dataToSend))
|
||||
|
||||
// Verify we didn't disconnect due to the retryable error
|
||||
verify(exactly = 0) { service.onDisconnect(any<BleError.BluetoothError>()) }
|
||||
verify(exactly = 0) { service.onDisconnect(any(), any()) }
|
||||
|
||||
nordicInterface.close()
|
||||
}
|
||||
|
|
@ -274,7 +273,7 @@ class NordicBleInterfaceRetryTest {
|
|||
|
||||
// Verify onDisconnect was called after retries exhausted
|
||||
// Nordic BLE wraps RuntimeException in BluetoothException
|
||||
verify { service.onDisconnect(any<BleError.BluetoothError>()) }
|
||||
verify { service.onDisconnect(any(), any()) }
|
||||
|
||||
nordicInterface.close()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@ import no.nordicsemi.kotlin.ble.core.and
|
|||
import no.nordicsemi.kotlin.ble.environment.android.mock.MockAndroidEnvironment
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.meshtastic.core.ble.BleError
|
||||
import org.meshtastic.core.ble.MeshtasticBleConstants.FROMNUM_CHARACTERISTIC
|
||||
import org.meshtastic.core.ble.MeshtasticBleConstants.FROMRADIOSYNC_CHARACTERISTIC
|
||||
import org.meshtastic.core.ble.MeshtasticBleConstants.FROMRADIO_CHARACTERISTIC
|
||||
|
|
@ -400,8 +399,7 @@ class NordicBleInterfaceTest {
|
|||
advanceUntilIdle()
|
||||
|
||||
// Verify onDisconnect was called on the service
|
||||
// NordicBleInterface calls onDisconnect(BleError.Disconnected)
|
||||
verify { service.onDisconnect(any<BleError.Disconnected>()) }
|
||||
verify { service.onDisconnect(any(), any()) }
|
||||
|
||||
nordicInterface.close()
|
||||
}
|
||||
|
|
@ -481,7 +479,7 @@ class NordicBleInterfaceTest {
|
|||
advanceUntilIdle()
|
||||
|
||||
// Verify that discovery failed
|
||||
verify { service.onDisconnect(any<BleError.DiscoveryFailed>()) }
|
||||
verify { service.onDisconnect(false, "Required characteristic missing") }
|
||||
|
||||
nordicInterface.close()
|
||||
}
|
||||
|
|
@ -575,7 +573,7 @@ class NordicBleInterfaceTest {
|
|||
advanceUntilIdle()
|
||||
|
||||
// Verify onDisconnect was called with error
|
||||
verify { service.onDisconnect(any<BleError>()) }
|
||||
verify { service.onDisconnect(any(), any()) }
|
||||
|
||||
nordicInterface.close()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue