Kotlin-BLE-Library
Kotlin-BLE-Library copied to clipboard
Can not discover services with ble client sdk.
I am using the client sdk with the latest version 1.0.10. After calling the connect and discoverService function as below:
val client = ClientBleGatt.Companion.connect(context, device.address, scope)
val service = client.discoverServices()
Then I faced the warning and could not find any services.
Unhandled exception in callback
java.lang.IllegalStateException: This mutex is not locked
at kotlinx.coroutines.sync.MutexImpl.unlock(Mutex.kt:213)
at kotlinx.coroutines.sync.Mutex$DefaultImpls.unlock$default(Mutex.kt:98)
at no.nordicsemi.android.kotlin.ble.core.mutex.MutexWrapper.unlock(MutexWrapper.kt:56)
at no.nordicsemi.android.kotlin.ble.client.api.ClientMutexHandleCallback.tryEmit(ClientMutexHandleCallback.kt:32)
at no.nordicsemi.android.kotlin.ble.client.real.ClientBleGattCallback.onServicesDiscovered(ClientBleGattCallback.kt:70)
at android.bluetooth.BluetoothGatt$1$5.run(BluetoothGatt.java:347)
at android.bluetooth.BluetoothGatt.runOrQueueCallback(BluetoothGatt.java:823)
at android.bluetooth.BluetoothGatt.access$200(BluetoothGatt.java:47)
at android.bluetooth.BluetoothGatt$1.onSearchComplete(BluetoothGatt.java:342)
at android.bluetooth.IBluetoothGattCallback$Stub.onTransact(IBluetoothGattCallback.java:241)
at android.os.Binder.execTransactInternal(Binder.java:1184)
at android.os.Binder.execTransact(Binder.java:1143)
late response, but I noticed you're using ClientBleGatt.Companion.connect()
but I'm pretty positive you should just be calling ClientBleGatt.connect(context, device.address, scope)
instead. Hope this helps!