dotintent / react-native-ble-plx

React Native BLE library
Apache License 2.0
3.06k stars 513 forks source link

Characteristic 0003cdd1-0000-1000-8000-00805f9b0131 notification change failed: The attribute could not be found. #229

Closed honbaa closed 6 years ago

honbaa commented 6 years ago

I use "monitorCharacteristicForDevice" method to receive notification from device. but error occurs as follows: 'Characteristic 0003cdd1-0000-1000-8000-00805f9b0131 notification change failed: The attribute could not be found.'

But the android app is ok, the error happened on iOS.

I don't know why this happened. Does anyone know ?

honbaa commented 6 years ago

I have found that this error described at https://github.com/Polidea/react-native-ble-plx/blob/master/ErrorMapping.md#error-mapping-for-react-native-ble-plx as follows:

characteristicNotifyChangeFailed(Characteristic, Error?) | Notify change | ???

I can't understand the reason really. Any ideas?

honbaa commented 6 years ago

@corymsmith @iegik @literator

iegik commented 6 years ago

Does your characteristic has a PROPERTY_NOTIFY? I think that your characteristic (0003cdd1-0000-1000-8000-00805f9b0131) does not have a Client Characteristic Config descriptor

Cierpliwy commented 6 years ago

@honbaa Please reopen if needed.

AntonioAlfrz commented 6 years ago

Hello,

before opening a new issue I would like to ask first because I think I have a similar problem. I am facing the error: "Cannot find client characteristic config descriptor (code 2) with characteristic UUID 1ed9e2c0-266f-11e6-850b-0002a5d5c51B" (Error code 403) when trying to monitor a characteristic wiht the function monitorCharacteristicForService, although the characteristic is notifiable.

I have been able to subscribe to changes using other libraries.

Thank you.

dariuszseweryn commented 6 years ago

@AntonioAlfrz I am guessing you have tested on Android and that you are trying to monitor characteristic changes on some device that violates Bluetooth Spec by not having a Command Characteristic Configuration Descriptor under a characteristic that has a Notify property?

AntonioAlfrz commented 6 years ago

Yes, Android 6.0.1 and the device is bosch XDK

dariuszseweryn commented 6 years ago

I have just checked my old code for XDK interactions. It indeed does not have a proper CCC descriptor attached to notification characteristics. As for Today the newest version of the library 0.9.0 does not handle this case. You would need to revert to 0.8.0 which in turn does not correctly cancel monitoring of characteristics that do have CCC descriptor

yashkmochi commented 5 years ago

It can happen , if your characteristic is not notifying or indicating. Or, your characteristic might not have a Client Characteristic Config descriptor which can cause the error. If that is the case you could use function RxBleConnection.setupNotification(UUID, NotificationSetupMode.COMPAT) as a workaround. in this location ('../node_modules/react-native-ble-plx/android/src/main/java/com/polidea/reactnativeble/BleModule.java')

Andy4ward commented 5 years ago

@yashkmochi how do you access that function from javascript?

I've been chasing around the package to see if it's possible but coming up empty

yashkmochi commented 5 years ago

@Andy4ward I am not using that function direclty from javascript. It is internally being used while subscribing to specific characteristic using ble-plx.

dariuszseweryn commented 5 years ago

The above mentioned PR has been merged Today and there is version 1.0.2 available that should address your needs,

Best Regards

asurare commented 5 years ago

I had a issue pretty similar, but on iOS. I had to modify the swift sources in react-native-ble-plx⁩/ios⁩/RxBluetoothKit/Peripheral.swift⁩ with the following changes in the setNotifyValue line 326, and commenting the throw BluetoothError :

 let observable = peripheral
            .rx_didUpdateNotificationStateForCharacteristic
            .filter { $0.0 == characteristic.characteristic }
            .take(1)
            .map { (_, error) -> Characteristic in
                if let error = error {
                    // throw BluetoothError.characteristicNotifyChangeFailed(characteristic, error)
                }
                return characteristic
            }

@dariuszseweryn Would you have a better way to achieve this ?

packetstracer commented 5 years ago

@asurare same issue happening to me on iOS, check the bug I opened if you want to get more info.

https://github.com/Polidea/react-native-ble-plx/issues/468

What bluetooth peripheral are you trying to connect from iOS? I'm using an ESP32 (Arduino compatible) device.

asurare commented 5 years ago

@packetstracer The url behind your link is broken ^^