mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
Fix autobugs related to Samsung BLE
This commit is contained in:
parent
7a47240e47
commit
25ceaa6364
2 changed files with 27 additions and 23 deletions
|
|
@ -609,7 +609,7 @@ class SafeBluetooth(private val context: Context, private val device: BluetoothD
|
|||
|
||||
private fun queueDiscoverServices(cont: Continuation<Unit>) {
|
||||
queueWork("discover", cont) {
|
||||
gatt!!.discoverServices()
|
||||
gatt?.discoverServices() ?: throw BLEException("GATT is null")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -742,6 +742,10 @@ class SafeBluetooth(private val context: Context, private val device: BluetoothD
|
|||
null // clear gat before calling close, bcause close might throw dead object exception
|
||||
g2.close()
|
||||
}
|
||||
} catch (ex: NullPointerException) {
|
||||
// Attempt to invoke virtual method 'com.android.bluetooth.gatt.AdvertiseClient com.android.bluetooth.gatt.AdvertiseManager.getAdvertiseClient(int)' on a null object reference
|
||||
//com.geeksville.mesh.service.SafeBluetooth.closeGatt
|
||||
warn("Ignoring NPE in close - probably buggy Samsung BLE")
|
||||
} catch (ex: DeadObjectException) {
|
||||
warn("Ignoring dead object exception, probably bluetooth was just disabled")
|
||||
} finally {
|
||||
|
|
@ -789,28 +793,28 @@ class SafeBluetooth(private val context: Context, private val device: BluetoothD
|
|||
gatt!!.setCharacteristicNotification(c, enable)
|
||||
|
||||
/*
|
||||
c is null sometimes
|
||||
c is null sometimes
|
||||
2020-04-13 15:59:38.222 2111-2182/com.geeksville.mesh D/BluetoothGatt: setCharacteristicNotification() - uuid: ed9da18c-a800-4f66-a670-aa7547e34453 enable: true
|
||||
2020-04-13 15:59:38.225 2111-2182/com.geeksville.mesh E/com.geeksville.util.Exceptions: exceptionReporter Uncaught Exception
|
||||
kotlin.KotlinNullPointerException
|
||||
at com.geeksville.mesh.service.SafeBluetooth.setNotify(SafeBluetooth.kt:505)
|
||||
at com.geeksville.mesh.service.RadioInterfaceService$onConnect$1$1.invoke(RadioInterfaceService.kt:328)
|
||||
at com.geeksville.mesh.service.RadioInterfaceService$onConnect$1$1.invoke(RadioInterfaceService.kt:90)
|
||||
at com.geeksville.concurrent.CallbackContinuation.resume(SyncContinuation.kt:20)
|
||||
at com.geeksville.mesh.service.SafeBluetooth$completeWork$1.invoke(SafeBluetooth.kt:329)
|
||||
at com.geeksville.mesh.service.SafeBluetooth$completeWork$1.invoke(SafeBluetooth.kt:33)
|
||||
at com.geeksville.util.ExceptionsKt.exceptionReporter(Exceptions.kt:34)
|
||||
at com.geeksville.mesh.service.SafeBluetooth.completeWork(SafeBluetooth.kt:312)
|
||||
at com.geeksville.mesh.service.SafeBluetooth.access$completeWork(SafeBluetooth.kt:33)
|
||||
at com.geeksville.mesh.service.SafeBluetooth$gattCallback$1.onMtuChanged(SafeBluetooth.kt:221)
|
||||
at android.bluetooth.BluetoothGatt$1$13.run(BluetoothGatt.java:658)
|
||||
at android.bluetooth.BluetoothGatt.runOrQueueCallback(BluetoothGatt.java:780)
|
||||
at android.bluetooth.BluetoothGatt.access$200(BluetoothGatt.java:41)
|
||||
at android.bluetooth.BluetoothGatt$1.onConfigureMTU(BluetoothGatt.java:653)
|
||||
at android.bluetooth.IBluetoothGattCallback$Stub.onTransact(IBluetoothGattCallback.java:330)
|
||||
at android.os.Binder.execTransactInternal(Binder.java:1021)
|
||||
at android.os.Binder.execTransact(Binder.java:994)
|
||||
*/
|
||||
kotlin.KotlinNullPointerException
|
||||
at com.geeksville.mesh.service.SafeBluetooth.setNotify(SafeBluetooth.kt:505)
|
||||
at com.geeksville.mesh.service.RadioInterfaceService$onConnect$1$1.invoke(RadioInterfaceService.kt:328)
|
||||
at com.geeksville.mesh.service.RadioInterfaceService$onConnect$1$1.invoke(RadioInterfaceService.kt:90)
|
||||
at com.geeksville.concurrent.CallbackContinuation.resume(SyncContinuation.kt:20)
|
||||
at com.geeksville.mesh.service.SafeBluetooth$completeWork$1.invoke(SafeBluetooth.kt:329)
|
||||
at com.geeksville.mesh.service.SafeBluetooth$completeWork$1.invoke(SafeBluetooth.kt:33)
|
||||
at com.geeksville.util.ExceptionsKt.exceptionReporter(Exceptions.kt:34)
|
||||
at com.geeksville.mesh.service.SafeBluetooth.completeWork(SafeBluetooth.kt:312)
|
||||
at com.geeksville.mesh.service.SafeBluetooth.access$completeWork(SafeBluetooth.kt:33)
|
||||
at com.geeksville.mesh.service.SafeBluetooth$gattCallback$1.onMtuChanged(SafeBluetooth.kt:221)
|
||||
at android.bluetooth.BluetoothGatt$1$13.run(BluetoothGatt.java:658)
|
||||
at android.bluetooth.BluetoothGatt.runOrQueueCallback(BluetoothGatt.java:780)
|
||||
at android.bluetooth.BluetoothGatt.access$200(BluetoothGatt.java:41)
|
||||
at android.bluetooth.BluetoothGatt$1.onConfigureMTU(BluetoothGatt.java:653)
|
||||
at android.bluetooth.IBluetoothGattCallback$Stub.onTransact(IBluetoothGattCallback.java:330)
|
||||
at android.os.Binder.execTransactInternal(Binder.java:1021)
|
||||
at android.os.Binder.execTransact(Binder.java:994)
|
||||
*/
|
||||
// per https://stackoverflow.com/questions/27068673/subscribe-to-a-ble-gatt-notification-android
|
||||
val descriptor: BluetoothGattDescriptor = c.getDescriptor(configurationDescriptorUUID)
|
||||
?: throw BLEException("Notify descriptor not found for ${c.uuid}") // This can happen on buggy BLE implementations
|
||||
|
|
@ -820,5 +824,4 @@ class SafeBluetooth(private val context: Context, private val device: BluetoothD
|
|||
debug("Notify enable=$enable completed")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -73,4 +73,5 @@
|
|||
<string name="about">About</string>
|
||||
<string name="a_list_of_nodes_in_the_mesh">A list of nodes in the mesh</string>
|
||||
<string name="text_messages">Text messages</string>
|
||||
<string name="channel_invalid">This Channel URL is invalid and can not be used</string>
|
||||
</resources>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue