Kotlin-BLE-Library icon indicating copy to clipboard operation
Kotlin-BLE-Library copied to clipboard

Can not discover services with ble client sdk.

Open maitolab opened this issue 1 year ago • 1 comments

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)

maitolab avatar Nov 27 '23 04:11 maitolab

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!

andrewowen avatar Jan 18 '24 13:01 andrewowen