fix(transport): Kable BLE audit + thread-safety, MQTT, and logging fixes across transport layers (#5071)

This commit is contained in:
James Rich 2026-04-11 17:56:29 -05:00 committed by GitHub
parent 5f0e60eb21
commit a3c0a4832d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
44 changed files with 1123 additions and 513 deletions

View file

@ -42,7 +42,7 @@ import kotlin.uuid.Uuid
class FakeBleDevice(
override val address: String,
override val name: String? = "Fake Device",
initialState: BleConnectionState = BleConnectionState.Disconnected,
initialState: BleConnectionState = BleConnectionState.Disconnected(),
) : BaseFake(),
BleDevice {
private val _state = mutableStateFlow(initialState)
@ -124,11 +124,11 @@ class FakeBleConnection :
}
}
override suspend fun connectAndAwait(device: BleDevice, timeoutMs: Long): BleConnectionState {
override suspend fun connectAndAwait(device: BleDevice, timeout: Duration): BleConnectionState {
connectException?.let { throw it }
if (failNextN > 0) {
failNextN--
return BleConnectionState.Disconnected
return BleConnectionState.Disconnected()
}
connect(device)
return BleConnectionState.Connected
@ -137,9 +137,9 @@ class FakeBleConnection :
override suspend fun disconnect() {
disconnectCalls++
val currentDevice = _device.value
_connectionState.emit(BleConnectionState.Disconnected)
_connectionState.emit(BleConnectionState.Disconnected())
if (currentDevice is FakeBleDevice) {
currentDevice.setState(BleConnectionState.Disconnected)
currentDevice.setState(BleConnectionState.Disconnected())
}
_device.value = null
_deviceFlow.emit(null)