From 6ff84a180851b52a5a0b6a73324484e8f868c3d1 Mon Sep 17 00:00:00 2001 From: geeksville Date: Fri, 10 Apr 2020 18:04:39 -0700 Subject: [PATCH] fix rare mystery bluetooth status 133 error Thanks to comment by @pederovarela86 https://github.com/android/connectivity-samples/issues/18#issuecomment-374600798 --- .../com/geeksville/mesh/service/SafeBluetooth.kt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/geeksville/mesh/service/SafeBluetooth.kt b/app/src/main/java/com/geeksville/mesh/service/SafeBluetooth.kt index abd95a1b1..d0bc86e60 100644 --- a/app/src/main/java/com/geeksville/mesh/service/SafeBluetooth.kt +++ b/app/src/main/java/com/geeksville/mesh/service/SafeBluetooth.kt @@ -5,6 +5,7 @@ import android.content.BroadcastReceiver import android.content.Context import android.content.Intent import android.content.IntentFilter +import android.os.Build import android.os.Handler import com.geeksville.android.GeeksvilleApplication import com.geeksville.android.Logging @@ -357,7 +358,17 @@ class SafeBluetooth(private val context: Context, private val device: BluetoothD private fun queueConnect(autoConnect: Boolean = false, cont: Continuation) { // assert(gatt == null) this now might be !null with our new reconnect support queueWork("connect", cont) { - val g = device.connectGatt(context, autoConnect, gattCallback) + val g = + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + device.connectGatt( + context, + autoConnect, + gattCallback, + BluetoothDevice.TRANSPORT_LE + ) + } else { + device.connectGatt(context, autoConnect, gattCallback) + } if (g != null) gatt = g g != null