autobug - don't fail if the gatt goes away while we are connecting

This commit is contained in:
geeksville 2020-06-28 16:09:37 -07:00
parent 3246bd6505
commit 68cc494021

View file

@ -285,10 +285,11 @@ class BluetoothInterface(val service: RadioInterfaceService, val address: String
*/
private fun forceServiceRefresh() {
exceptionReporter {
// BluetoothGatt gatt
val gatt = safe!!.gatt!!
val refresh: Method = gatt.javaClass.getMethod("refresh")
refresh.invoke(gatt)
// If the gatt has been destroyed, skip the refresh attempt
safe?.gatt?.let { gatt ->
val refresh: Method = gatt.javaClass.getMethod("refresh")
refresh.invoke(gatt)
}
}
}