Android 14 crashing while trying to read from device, with 128 error code

120 views Asked by At

I have an app that works with BLE using https://github.com/Beepiz/BleGattCoroutines library and it is working fine but crashing while reading some characteristics from the device like

  val char = connection.getServiceCharacteristic(characteristic)!!
            connection.readCharacteristic(char).value!!

 private suspend fun GattConnection.getServiceCharacteristic(
        characteristic: String,
    ): BluetoothGattCharacteristic? {
        if (mockController.isMocksEnabled) {
            return BluetoothGattCharacteristic(characteristic.asUUID(), 0, 1)
        }
        val characteristicUUID = characteristic.asUUID()
        return discoverServices()
            .firstNotNullOfOrNull { service ->
                service.characteristics.firstOrNull { it.uuid == characteristicUUID }
            }
    }

[DefaultDispatcher-worker-8] - read error com.beepiz.bluetooth.gattcoroutines.OperationFailedException: com.beepiz.bluetooth.gattcoroutines.OperationFailedException: status: 128 at com.beepiz.bluetooth.gattcoroutines.GattConnectionImpl.readCharacteristic(GattConnectionImpl.kt:491) at com.beepiz.bluetooth.gattcoroutines.GattConnectionImpl$readCharacteristic$1.invokeSuspend(Unknown Source:15) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108) at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:115) at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:103) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)

and problem is occuring only on Android 14 devices and all is working fine with others. Permissions also granted. What could be the case ?

0

There are 0 answers