kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
Fix #23: autobug, if we get mystery BLE error 133 while reading messages
drop the BLE link and reconnect and try again.pull/28/head
rodzic
d28eb97497
commit
5822dddc6c
|
@ -295,19 +295,27 @@ class RadioInterfaceService : Service(), Logging {
|
|||
else {
|
||||
val fromRadio = getCharacteristic(BTM_FROMRADIO_CHARACTER)
|
||||
safe!!.asyncReadCharacteristic(fromRadio) {
|
||||
val b = it.getOrThrow()
|
||||
.value.clone() // We clone the array just in case, I'm not sure if they keep reusing the array
|
||||
try {
|
||||
val b = it.getOrThrow()
|
||||
.value.clone() // We clone the array just in case, I'm not sure if they keep reusing the array
|
||||
|
||||
if (b.isNotEmpty()) {
|
||||
debug("Received ${b.size} bytes from radio")
|
||||
handleFromRadio(b)
|
||||
if (b.isNotEmpty()) {
|
||||
debug("Received ${b.size} bytes from radio")
|
||||
handleFromRadio(b)
|
||||
|
||||
// Queue up another read, until we run out of packets
|
||||
doReadFromRadio(firstRead)
|
||||
} else {
|
||||
debug("Done reading from radio, fromradio is empty")
|
||||
if (firstRead) // If we just finished our initial download, now we want to start listening for notifies
|
||||
startWatchingFromNum()
|
||||
// Queue up another read, until we run out of packets
|
||||
doReadFromRadio(firstRead)
|
||||
} else {
|
||||
debug("Done reading from radio, fromradio is empty")
|
||||
if (firstRead) // If we just finished our initial download, now we want to start listening for notifies
|
||||
startWatchingFromNum()
|
||||
}
|
||||
} catch (ex: BLEException) {
|
||||
errormsg(
|
||||
"error during doReadFromRadio",
|
||||
ex
|
||||
)
|
||||
serviceScope.handledLaunch { retryDueToException() }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -418,7 +418,9 @@ class SafeBluetooth(private val context: Context, private val device: BluetoothD
|
|||
cb: (Result<Unit>) -> Unit,
|
||||
lostConnectCb: () -> Unit
|
||||
) {
|
||||
logAssert(workQueue.isEmpty() && currentWork == null) // I don't think anything should be able to sneak in front
|
||||
logAssert(workQueue.isEmpty())
|
||||
logAssert(currentWork == null) // I don't think anything should be able to sneak in front
|
||||
|
||||
lostConnectCallback = lostConnectCb
|
||||
connectionCallback = if (autoConnect)
|
||||
cb
|
||||
|
|
Ładowanie…
Reference in New Issue