BLE Central how to set Peripheral Notify

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.

Thank you for a hint.
jean-marc

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?

Thank you again for your help.

I’d have to read into the TI sensor datasheet (if I had it :wink:) 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.

According to the docs I linked above
https://docs.particle.io/reference/device-os/firmware/argon/#setvalue-pointer-
this would be my take

  uint8_t value = 0x01;
  characteristic.setValue(value);

However, if you don’t activate notification, have you at least tried to poll the value via getValue()?

@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.

Thank you for helping.

Have you tried something along the line of this?

BleCharacteristic blecharDescriptor;
peer.getCharacteristicByUUID(blecharDescriptor, BleUuid(0xaa22));
uint8_t val = 0x01;
blecharDescriptor.setValue(val);

AFAICT it’s not an address, it’s a characteristic UUID - that’s why you treat it as characteristic.

That’s why I earlier said this

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 :slight_smile:
Thank you for your patience but BLE is always a pain to understand :smiley:

1 Like

@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:

const char* uuidTempTi = “F000AA21-0451-4000-b000-000000000000”; //read charact
const char* uuidConfigTi = “F000AA22-0451-4000-b000-000000000000”; //property

Then the characteristic property:
BleCharacteristic tempTiConfig;

Then write the config as required by the sensor:

peer.getCharacteristicByUUID(tempTiConfig, BleUuid(uuidConfigTi));

uint8_t value = 0x01; //required by the sensor to start reading temperature and humidity
tempTiConfig.setValue(value);

Then get the notify with the regular peer.getCharacteristicByUUID

peer.getCharacteristicByUUID(temperatureMeasurementCharacteristic, BleUuid(uuidTempTi));

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.

Thank you again for your help.
Jean-Marc

2 Likes