Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Client]IllegalStateException in discoverServices method after connect device successfully #88

Open
ledvance-jason opened this issue Nov 29, 2023 · 0 comments

Comments

@ledvance-jason
Copy link

Exception

 W  java.lang.IllegalStateException: This mutex is not locked
 W  	at kotlinx.coroutines.sync.MutexImpl.unlock(Mutex.kt:213)
 W  	at kotlinx.coroutines.sync.Mutex$DefaultImpls.unlock$default(Mutex.kt:98)
 W  	at no.nordicsemi.android.kotlin.ble.core.mutex.MutexWrapper.unlock(MutexWrapper.kt:57)
 W  	at no.nordicsemi.android.kotlin.ble.client.api.ClientMutexHandleCallback.tryEmit(ClientMutexHandleCallback.kt:32)
 W  	at no.nordicsemi.android.kotlin.ble.client.real.ClientBleGattCallback.onServicesDiscovered(ClientBleGattCallback.kt:70)
 W  	at android.bluetooth.BluetoothGatt$1$5.run(BluetoothGatt.java:347)
 W  	at android.bluetooth.BluetoothGatt.runOrQueueCallback(BluetoothGatt.java:823)
 W  	at android.bluetooth.BluetoothGatt.access$200(BluetoothGatt.java:47)
 W  	at android.bluetooth.BluetoothGatt$1.onSearchComplete(BluetoothGatt.java:342)
 W  	at android.bluetooth.IBluetoothGattCallback$Stub.onTransact(IBluetoothGattCallback.java:241)
 W  	at android.os.Binder.execTransactInternal(Binder.java:1187)
 W  	at android.os.Binder.execTransact(Binder.java:1146)

Code

viewModelScope.launch {
                val connectDevice = bleRepository.connectDevice(
                    device = it,
                    scope = viewModelScope,
                    options = BleGattConnectOptions(autoConnect = true, closeOnDisconnect = false)
                )
                val services = connectDevice.discoverServices()
                val commissioningService =
                    services.findService(TubeSpecifications.UUID_SERVICE_DEVICE)
                val identifyCharacteristic =
                    commissioningService?.findCharacteristic(TubeSpecifications.UUID_IDENTIFY_CHAR)
                identifyCharacteristic?.write(DataByteArray.from(0x03,0x00))
            }
@ledvance-jason ledvance-jason changed the title [Client]IllegalStateException in discoverServices after connect device successfully [Client]IllegalStateException in discoverServices method after connect device successfully Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant