I get my Peripheral data, like the temperature, as long as my sensor is set already as “notify” or “indicate” on the descriptor.
Then from the Central I get it by:
peer.getCharacteristicByUUID(temperatureMeasurementCharacteristic, BleUuid(0x2a1c));
Now I am using a sensor (from TI) which is ready for notify but needs to have the descriptor set. It needs the Central to set the descriptor.
Its address UUID is 0xaa21 and the descriptor is on 0xaa22;
How can I do it with my Argon as a Central.
For that the peripheral would need to expose a WRITE characteristic for the descriptor, you need to "subscribe" to that characteristic and use characteristic.setValue() in order to write to it.
@ScruffR, thank you ScruffR.
It is what I am trying to do. But I cannot figure out where to set my address.
I do not know how to set my Property Notify in the declaration. Let say I do the following:
BleCharacteristic tempTiDescriptor; // my descriptor
Once connected, I do the following to tell what characteristic I desire and the UUID which is 0xaa21
peer.getCharacteristicByUUID(temperatureMeasurementCharacteristic, BleUuid(0xaa21));
Then I set the value 0x01 (notify) like the following, but where do I insert the address 0xaa22:
tempTiDescriptor.setValue(0x01);
How the system knows where is my descriptor address?
I’d have to read into the TI sensor datasheet (if I had it ) to answer that.
However, when you say the UUIDs are 0xaa21 and 0xaa22 respectively I’d assume these are refering to individual write characteristics where you’d first write (setValue) to the address characteristic to select the desired destination and then the descriptor characteristic to set the value.
But that is a mere guess due to the lack of actual info about the sensor.
You can also try a mobile app like nRF Connect to investigate the services and characteristics the sensor exposes and how to interact with it.
@ScruffR
I am using the nRF Connect and already run an Android App with the CC2650.
So I know the characteristic for the Temperature is at 0xaa21 and the descriptor with notify is at 0xaa22.
What I do not know is how to set the value of notify (0x01) at the 0xaa22 with the Particle BLE.
What is the format? in C++ for spark_wiring_ble.h
I know the TI sensor need the notify to be set by the Central.
@ScruffR
I tried to read the value (getValue) and get 0000.
It is the specificity of this sensor, the firmware request a Notify to fetch the data and this worse for the read as well. I can see it from my nRF connect. As long as I do not write 0x01 to the address 0xaa22 nothing happens. Once I set the value 0x01 all goes OK. I can or Read or get the data (notify)
That is why I need to understand how I can write 0x01 to the address 0xaa22.
UUID 0xaa21 is the temperature and humidity address on the sensor, in compare to the standard sensor temperature where it would be 0x2a1c.
The UUID 0xaa22 is the next characteristic which could be a custom Config.
I think I am wrong when mentioning as the Notify address, I confused it with the next Handle.
So the 0xaa22 is a config characteristic which requires 0x01.
To write the Notify I will see it next
Thank you for your patience but BLE is always a pain to understand
@ScruffR
OK all is OK now. I had made also several mistakes in the addresses of the TI product.
Addresses need to be used as long 128 bits and the addresses to write the config and was not as I noted 0xaa22 but f000aa22-0451-4000-b000-000000000000…
Your information about the setvalue that you gave me above is also is the key.
Now the code is:
defines the addresses one for the read characteristic and one for the config property:
Of course the temperatureMeasurementCharacteristic was also subscribed for the callback onDataReceived() previously on the code and received the data as per any other standard sensors.
I have a very similar issue that i am facing. I am trying to develop the Argon as a BLE central gateway for the new K21 KKM beacons (Portable Beacon K21 | Beacon with Sound for Asset Tracking).
Which now comes with a custom 2 ways communication protocol on top of the BLE layer that use one characteristics as READ and other as WRITE (similar to UART peripheral example).
The problem I face is that, I am not sure how to subscribe to the K21 beacon characteristics which will send data to my Argon central gateway app via notification.
Unlike your TI sensor, the K21 beacon does not has a separated 128 bits descriptor UUID that I can setValue to subscribe to the notification.
Here is a screen capture from the NrfConnect App of the Beacon’s Characteristic to push data (0000fea2-0000-1000-8000-00805f9b34fb) and in 16 bit form: (0xFEA2):
OK, I have found the solution to the problem I mentioned.
I think the current documentation of the BLE stack of Particle is kind of outdated, there are some functions with no information available.
Not until I studied the ble-gate-way library, I realize the existence of these functions.
First of all there is a subscribe() function for BleCharacteristic class.
In addition, there are several functions about discovering services which is very useful but not documented.
peer.getServiceByUUID
peer.discoverCharacteristicsOfService
Details of how these functions are being used can be referenced from this example: https://github.com/particle-iot/ble-gateway-library/blob/main/src/peripherals/masterbuilt-smoker.cpp