kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
autobug, prevent redundant notifcations from onConnectChanged
rodzic
238ae9a06c
commit
4d6ca25caf
|
@ -164,7 +164,12 @@ class SafeBluetooth(private val context: Context, private val device: BluetoothD
|
|||
status: Int,
|
||||
newState: Int
|
||||
) = exceptionReporter {
|
||||
|
||||
if (gatt == null)
|
||||
info("No gatt: ignoring connection state $newState, status $status") // Probably just shutting down
|
||||
else {
|
||||
info("new bluetooth connection state $newState, status $status")
|
||||
|
||||
when (newState) {
|
||||
BluetoothProfile.STATE_CONNECTED -> {
|
||||
state =
|
||||
|
@ -223,6 +228,7 @@ class SafeBluetooth(private val context: Context, private val device: BluetoothD
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onServicesDiscovered(gatt: BluetoothGatt, status: Int) {
|
||||
// For testing lie and claim failure
|
||||
|
@ -619,11 +625,12 @@ class SafeBluetooth(private val context: Context, private val device: BluetoothD
|
|||
|
||||
failAllWork(BLEException("Connection closing"))
|
||||
|
||||
if (gatt != null) {
|
||||
gatt?.let { g ->
|
||||
info("Closing our GATT connection")
|
||||
gatt!!.disconnect()
|
||||
gatt!!.close()
|
||||
gatt = null
|
||||
gatt =
|
||||
null // Clear this first so the onConnectionChange callback can ignore while we are shutting down
|
||||
g.disconnect()
|
||||
g.close()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue