Retrieving descriptors and properties from characteristics
See original GitHub issueHello,
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:
- Created 5 years ago
- Comments:9 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@nixoschu This is something, which is missing in the library and definitely should be implemented. I’ll schedule work to fully support descriptors.
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