feat: implement XModem file transfers and enhance BLE connection robustness (#4959)
Some checks are pending
Dependency Submission / dependency-submission (push) Waiting to run
Main CI (Verify & Build) / validate-and-build (push) Waiting to run
Main Push Changelog / Generate main push changelog (push) Waiting to run

This commit is contained in:
James Rich 2026-03-30 22:49:31 -05:00 committed by GitHub
parent ae4465d7c8
commit c75c9b34d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
43 changed files with 1100 additions and 120 deletions

View file

@ -94,6 +94,12 @@ class FakeBleConnection :
private val _connectionState = mutableSharedFlow<BleConnectionState>(replay = 1)
override val connectionState: SharedFlow<BleConnectionState> = _connectionState.asSharedFlow()
/** When > 0, the next [failNextN] calls to [connectAndAwait] return [BleConnectionState.Disconnected]. */
var failNextN: Int = 0
/** When non-null, [connectAndAwait] throws this exception instead of connecting. */
var connectException: Exception? = null
override suspend fun connect(device: BleDevice) {
_device.value = device
_deviceFlow.emit(device)
@ -107,13 +113,13 @@ class FakeBleConnection :
}
}
override suspend fun connectAndAwait(
device: BleDevice,
timeoutMs: Long,
onRegister: suspend () -> Unit,
): BleConnectionState {
override suspend fun connectAndAwait(device: BleDevice, timeoutMs: Long): BleConnectionState {
connectException?.let { throw it }
if (failNextN > 0) {
failNextN--
return BleConnectionState.Disconnected
}
connect(device)
onRegister()
return BleConnectionState.Connected
}
@ -154,7 +160,8 @@ class FakeBluetoothRepository :
override fun isValid(bleAddress: String): Boolean = bleAddress.isNotBlank()
override fun isBonded(address: String): Boolean = _state.value.bondedDevices.any { it.address == address }
override fun isBonded(address: String): Boolean =
_state.value.bondedDevices.any { it.address.equals(address, ignoreCase = true) }
override suspend fun bond(device: BleDevice) {
val currentState = _state.value