question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Retrieving descriptors and properties from characteristics

See original GitHub issue

Hello,

I’m trying to port a library for Android (provided by the manufacturer of my device) from Java to JS using react-native-ble-plx.

Specifically, I’m having trouble understanding how to enable notifications, retrieve descriptors and properties of a characteristic:

BluetoothGattService service = gatt.getService(AndroidBluetoothConnection.METER_UUID);
mBluetoothGattChar = service.getCharacteristic(AndroidBluetoothConnection.METER_UUID2);
mDescriptor = ((BluetoothGattDescriptor)mBluetoothGattChar.getDescriptors().get(0));
mCharaProp = mBluetoothGattChar.getProperties();
          
AndroidBluetoothConnection.this.setCharacteristicNotification(mBluetoothGattChar, true);

Interestingly, the characteristic discovered has “isNotifying” set to “false”, even though the original code is enabling notification for the same characteristic. My code so far:

d.characteristicsForService('00001523-1212-efde-1523-785feabcd123').then((s) => {
    s.forEach((c) => {
        if (c.uuid === '00001524-1212-efde-1523-785feabcd123') {
            console.warn(c);
            const characteristic = d.writeCharacteristicWithResponseForService(
                c.serviceUUID,
                c.uuid,
                "AQ==" /* 0x01 in hex */
            ).then((characteristic) => {
                console.warn(characteristic);

                d.monitorCharacteristicForService(c.serviceUUID, c.uuid, (error, characteristic) => {
                /* Never reached */
                if (error) {
                    console.warn(error.message)
                    return;
                }
                console.warn('notified');
                console.warn(characteristic.uuid);
                console.warn(characteristic.value.toString());
            })
    })
    .catch((e) => {
        console.warn(e);
    })
});

Here is the library code for reference: https://gist.github.com/patrick-samy/4af06b06441e83fc9adb6b81db30ef3c

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
Cierpliwycommented, Apr 5, 2019

@nixoschu This is something, which is missing in the library and definitely should be implemented. I’ll schedule work to fully support descriptors.

0reactions
SuvabBaralcommented, Mar 30, 2021

Hi @Cierpliwy , the peripheral device I am using supports indicate, however, after the first command, my app(central device) is disabling the indication and all the subsequent commands are sent as notify. Is there a way I can continue sending commands as indicate rather than notify using the react-native-ble-plx in both android and iOS?.

I have added the same question on stackoverflow: https://stackoverflow.com/questions/66868468/react-native-ble-plx-is-it-possible-for-configuring-indicate-as-a-standard-prot

Read more comments on GitHub >

github_iconTop Results From Across the Web

Retrieving descriptors and properties from characteristics #240
Hello, I'm trying to port a library for Android (provided by the manufacturer of my device) from Java to JS using react-native-ble-plx.
Read more >
Descriptor HowTo Guide — Python 3.11.1 documentation
Descriptors let objects customize attribute lookup, storage, and deletion. This guide has four major sections: The “primer” gives a basic overview, ...
Read more >
Python Descriptors and How to Use them
A short explanation of Python Descriptors with examples on how (and ... Both attributes are accessed via their descriptors' __get__ methods.
Read more >
Data Descriptors: Bringing Attributes to the Next Level
Deep dive into how properties work, to learn how we can develop our own solution.
Read more >
Use of Descriptors in Python - Topcoder
Descriptors are usually used to implement the underlying functions of the object system, including bound and unbound methods, class methods, and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found