Kotlin kable observer error - The attribute cannot be written

Back
-1
votes
0 answers

update: turns out i was missing a cccd, however now after connecting, the client freezes for a bit and then unfreezes, reacts to all the sent notifications instantly and then throws this

com.juul.kable.btleplug.ffi.Exception$Other: v1=Windows UWP threw error on subscribe: GattCommunicationStatus(1)

I'm making an app (client) that connects to a phone (server, using native android ble API) which sends info via notifications using the 'kable' library

So far I've managed to scan and connect to the device and I can also read from my characteristic successfully

However when I use Peripheral.observe(Characteristic) it throws an error

com.juul.kable.btleplug.ffi.Exception$Other: v1=Error { code: HRESULT(0x80650003), message: "The attribute cannot be written." }`

which I find weird since I never write to it and when I made the characteristic writable on the server the error would persist with no difference

It seems that the error code originates from some windows api but I still don't know what to do about it.

observe code:

//selecteddevice holds the peripheral
selecteddevice!!.scope.launch {
    selecteddevice!!.observe(characteristicOf(serviceuuid, charuuid)).collect {
        println(it[0])
    }
}

which throws:

com.juul.kable.btleplug.ffi.Exception$Other: v1=Error { code: HRESULT(0x80650003), message: "The attribute cannot be written." }
    at com.juul.kable.btleplug.ffi.FfiConverterTypeError.read(btleplug_ffi.kt:3017)
    at com.juul.kable.btleplug.ffi.FfiConverterTypeError.read(btleplug_ffi.kt:2990)
    at com.juul.kable.btleplug.ffi.FfiConverter.liftFromRustBuffer(btleplug_ffi.kt:168)
    at com.juul.kable.btleplug.ffi.FfiConverterTypeError.liftFromRustBuffer(btleplug_ffi.kt:2990)
    at com.juul.kable.btleplug.ffi.FfiConverterTypeError.liftFromRustBuffer(btleplug_ffi.kt:2990)
    at com.juul.kable.btleplug.ffi.FfiConverterRustBuffer.lift(btleplug_ffi.kt:185)
    at com.juul.kable.btleplug.ffi.FfiConverterTypeError.lift(btleplug_ffi.kt:2990)
    at com.juul.kable.btleplug.ffi.FfiConverterTypeError.lift(btleplug_ffi.kt:2990)
    at com.juul.kable.btleplug.ffi.Exception$ErrorHandler.lift(btleplug_ffi.kt:2981)
    at com.juul.kable.btleplug.ffi.Exception$ErrorHandler.lift(btleplug_ffi.kt:2980)
    at com.juul.kable.btleplug.ffi.Btleplug_ffiKt.uniffiCheckCallStatus(btleplug_ffi.kt:252)
    at com.juul.kable.btleplug.ffi.Btleplug_ffiKt.access$uniffiCheckCallStatus(btleplug_ffi.kt:1)
    at com.juul.kable.btleplug.ffi.Btleplug_ffiKt.uniffiRustCallAsync(btleplug_ffi.kt:3736)
    at com.juul.kable.btleplug.ffi.Btleplug_ffiKt$uniffiRustCallAsync$1.invokeSuspend(btleplug_ffi.kt)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:34)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:100)
    at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:124)
    at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:89)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:586)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:798)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:717)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:704)

server characteristic declaration:

//(android.bluetooth.BluetoothGattCharacteristic)
//charuuid is the uuid of my characteristic
val char = BluetoothGattCharacteristic(charuuid,
        BluetoothGattCharacteristic.PROPERTY_READ or BluetoothGattCharacteristic.PROPERTY_NOTIFY,
        BluetoothGattCharacteristic.PERMISSION_READ)
User p851523
7/11/2026, 9:39:08 AM
View on Stack Overflow

Answers (0)

No answers available for this question on Stack Overflow.