Skip to content

Commit 6ff84a1

Browse files
committed
fix rare mystery bluetooth status 133 error
Thanks to comment by @pederovarela86 android/connectivity-samples#18 (comment)
1 parent 2ba398c commit 6ff84a1

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

app/src/main/java/com/geeksville/mesh/service/SafeBluetooth.kt

+12-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import android.content.BroadcastReceiver
55
import android.content.Context
66
import android.content.Intent
77
import android.content.IntentFilter
8+
import android.os.Build
89
import android.os.Handler
910
import com.geeksville.android.GeeksvilleApplication
1011
import com.geeksville.android.Logging
@@ -357,7 +358,17 @@ class SafeBluetooth(private val context: Context, private val device: BluetoothD
357358
private fun queueConnect(autoConnect: Boolean = false, cont: Continuation<Unit>) {
358359
// assert(gatt == null) this now might be !null with our new reconnect support
359360
queueWork("connect", cont) {
360-
val g = device.connectGatt(context, autoConnect, gattCallback)
361+
val g =
362+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
363+
device.connectGatt(
364+
context,
365+
autoConnect,
366+
gattCallback,
367+
BluetoothDevice.TRANSPORT_LE
368+
)
369+
} else {
370+
device.connectGatt(context, autoConnect, gattCallback)
371+
}
361372
if (g != null)
362373
gatt = g
363374
g != null

0 commit comments

Comments
 (0)