Skip to content

Cannot monitor characteristic. #1286

@cristianmoroaica

Description

@cristianmoroaica

I see there is an old issue regarding this, but it seems that it still occurs.

The issue:

I'm having the same issue. Any updates on this?

The code:

scanAndConnect = async () => {
        console.log("scanAndConnect: start");
        this.ble_manager.startDeviceScan(null, null, async(error, device) => {
            if (error || !device) {
                console.log("Error scanning for devices");
                return
            }
            if (device.name && device.name.includes('LM068')) {
                console.log("Found device: ", device)
                this.ble_manager.stopDeviceScan()

                console.log("Stopped device scan. Discovering services and characteristics for device: ", device.name)
                device.connect().then(() => {

                    console.log("Connected to device: ", device.name)
                    device.discoverAllServicesAndCharacteristics().then((res) => {
                        const sercvices_uuid = res.serviceUUIDs as string[];

                        console.log("Discovered all services for device: ", res);
                        device.characteristicsForService(sercvices_uuid[sercvices_uuid.length-1]).then((characteristics) => {

                            console.log("Characteristics for service: ", characteristics);
                            const characteristic = characteristics[0];
                            device.monitorCharacteristicForService(
                                characteristic.serviceUUID,
                                characteristic.uuid,
                                (error, data) => {
                                    if (error) {

                                        console.error("Error monitoring characteristic: ", JSON.stringify(error, null, 2));
                                        return;
                                    }
                                    if (data && data.value) {
                                        const buffer = Buffer.from(data.value, 'base64');
                                        const bytes = Array.from(buffer);
                                        console.log("Received data: ", bytes);
                                        // Handle the received data here
                                    } else {
                                        console.error("No data received");
                                    }
                                },
                                'monitorData', // optional identifier for the Subscription
                                'notification'
                            );
                        }).catch((err) => {
                            console.error("Error getting characteristics: ", err)
                        });
                    }).catch((err) => {
                            console.error("Error discovering device: ", err)
                        });
                }).catch((err) => {
                        console.error("Error connecting to device: ", err)
                });
            }
        })
    }

The logs:

 LOG  Multiple permissions result: {"android.permission.ACCESS_FINE_LOCATION": "granted", "android.permission.BLUETOOTH_CONNECT": "granted", "android.permission.BLUETOOTH_SCAN": "granted"}    
 LOG  scanAndConnect: start
 LOG  Found device:  {"id": "34:C9:F0:9A:2E:DD", "isConnectable": true, "localName": "LM068_UniversalLEDD", "manufacturerData": null, "mtu": 23, "name": "LM068_UniversalLEDD", "overflowService
UUIDs": null, "rawScanRecord": "AgEGFAlMTTA2OF9Vbml2ZXJzYWxMRUREAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=", "rssi": -34, "serviceData": null, "serviceUUIDs": null, "solicitedService
UUIDs": null, "txPowerLevel": null}
 LOG  Stopped device scan. Discovering services and characteristics for device:  LM068_UniversalLEDD
 LOG  Connected to device:  LM068_UniversalLEDD
 LOG  Discovered all services for device:  {"id": "34:C9:F0:9A:2E:DD", "isConnectable": null, "localName": null, "manufacturerData": null, "mtu": 23, "name": "LM068_UniversalLEDD", "overflowSe
rviceUUIDs": null, "rssi": null, "serviceData": null, "serviceUUIDs": ["00001801-0000-1000-8000-00805f9b34fb", "00001800-0000-1000-8000-00805f9b34fb", "0000180a-0000-1000-8000-00805f9b34fb", "
00005500-d102-11e1-9b23-00025b00a5a5"], "solicitedServiceUUIDs": null, "txPowerLevel": null}
 LOG  Characteristics for service:  [{"deviceID": "34:C9:F0:9A:2E:DD", "id": 12, "isIndicatable": false, "isNotifiable": true, "isNotifying": false, "isReadable": false, "isWritableWithRespons
e": true, "isWritableWithoutResponse": true, "serviceID": 11, "serviceUUID": "00005500-d102-11e1-9b23-00025b00a5a5", "uuid": "00005501-d102-11e1-9b23-00025b00a5a5", "value": null}]
 ERROR  Error monitoring characteristic:  {
  "message": "Characteristic 00005501-d102-11e1-9b23-00025b00a5a5 notify change failed for device ? and service 00005500-d102-11e1-9b23-00025b00a5a5",
  "errorCode": 403,
  "attErrorCode": null,
  "iosErrorCode": null,
  "androidErrorCode": null,
  "reason": "Cannot write client characteristic config descriptor (code 3) with characteristic UUID 00005501-d102-11e1-9b23-00025b00a5a5",
  "name": "BleError"
}

React Native: 0.79.0
react-native-ble-plx: 3.5.0

Also getting the same error when trying to put the CCC as @ad-boschung
@ad-boschung @inamarinap did you find some solution? I tried put the CCC with the writeDescriptorForService(), but I have the message "Cannot write to descriptor 00002902-0000-1000-8000-00805f9b34fb. It's not allowed by iOS and therefore forbidden on Android as well". And in other services that I tried, I got this message: "BleError: Descriptor 00002902-0000-1000-8000-00805f9b34fb not found".

So, I'm facing the same issue until now, that is: Characteristic X notify change failed for device ? and service Y.

I'm tring read characteristic for a Omron Weight Scale and Body Composition.

I cannot use monitorCharacteristicForDevice as it is not available anymore.
I had the same problem and managed to solve it with using bleManager.monitorCharacteristicForDevice(device.id, service, charName, (error, characteristic) => { ... } instead of device.monitorCharacteristicForService(service, charName, (error, characteristic) => { ... }

BLE hardware module logs:

REP*:BLE_CONNECTED:=6aa8-d0-58d035:23
REP*:SER_CCFG=Enabled
BLE_ADAPTER=Ready For USE
REP*:SER_CCFG=Disabled

Same behavior as @inamarinap
Any news on this? I am facing the same issue. When I try to monitor the characteristic, notifications are being enabled and then disabled. I receive the following error: I/ReactNativeJS: {"message":"Characteristic 0000ff35-0000-1000-8000-00805f9b34fb notify change failed for device ? and service 0000ff30-0000-1000-8000-00805f9b34fb","errorCode":403,"attErrorCode":null,"iosErrorCode":null,"androidErrorCode":null,"reason":"Cannot write client characteristic config descriptor (code 3) with characteristic UUID 0000ff35-0000-1000-8000-00805f9b34fb","name":"BleError"}

Logcat: snap2

I tried testing with nrfConnect and enabling the notifications works and I am receiving data.

Works with nRF Connect for me as well. The notifications can be enabled through the app.

Originally posted by @cristianmoroaica in #666

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions