mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
bug #76 - old sonys can take a VERY long time for the setMTU operation
to complete. Change timeout to 10 secs (units in the field were showing the mtu operation completing after 5 seconds. Also - don't throw an exception if we encounter a result when we've already killed things with the failsafe timer
This commit is contained in:
parent
cc05be7d87
commit
92b3fa8d1f
1 changed files with 20 additions and 15 deletions
|
|
@ -392,25 +392,30 @@ class SafeBluetooth(private val context: Context, private val device: BluetoothD
|
|||
// startup next job in queue before calling the completion handler
|
||||
val work =
|
||||
synchronized(workQueue) {
|
||||
val w =
|
||||
currentWork
|
||||
?: throw Exception("currentWork was null") // will throw if null, which is helpful (FIXME - throws in the field - because of a bogus mtu completion gatt call)
|
||||
stopCurrentWork() // We are now no longer working on anything
|
||||
val w = currentWork
|
||||
|
||||
startNewWork()
|
||||
if (w != null) {
|
||||
stopCurrentWork() // We are now no longer working on anything
|
||||
|
||||
startNewWork()
|
||||
}
|
||||
w
|
||||
}
|
||||
|
||||
debug("work ${work.tag} is completed, resuming status=$status, res=$res")
|
||||
if (status != 0)
|
||||
work.completion.resumeWithException(
|
||||
BLEStatusException(
|
||||
status,
|
||||
"Bluetooth status=$status while doing ${work.tag}"
|
||||
if (work == null)
|
||||
warn("wor completed, but we already killed it via failsafetimer? status=$status, res=$res")
|
||||
else {
|
||||
debug("work ${work.tag} is completed, resuming status=$status, res=$res")
|
||||
if (status != 0)
|
||||
work.completion.resumeWithException(
|
||||
BLEStatusException(
|
||||
status,
|
||||
"Bluetooth status=$status while doing ${work.tag}"
|
||||
)
|
||||
)
|
||||
)
|
||||
else
|
||||
work.completion.resume(Result.success(res) as Result<Nothing>)
|
||||
else
|
||||
work.completion.resume(Result.success(res) as Result<Nothing>)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -607,7 +612,7 @@ class SafeBluetooth(private val context: Context, private val device: BluetoothD
|
|||
private fun queueRequestMtu(
|
||||
len: Int,
|
||||
cont: Continuation<Unit>
|
||||
) = queueWork("reqMtu", cont, 5 * 1000) {
|
||||
) = queueWork("reqMtu", cont, 10 * 1000) {
|
||||
isSettingMtu = true
|
||||
gatt?.requestMtu(len) ?: false
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue