BLE notify and READ

Using Argon as BLE Central.
My BLE peripheral sends 2 services
one temperature as INDICATE
BleCharacteristic temperatureMeasurementCharacteristic(“temp”, BleCharacteristicProperty::INDICATE, BleUuid(0x2A1C), healthThermometerService);
and one as Battery level as READ
BleCharacteristic batteryLevelCharacteristic(“bat”, BleCharacteristicProperty::READ, BleUuid(0x2A19), batteryLevelService);

In the Argon I am connecting and can read the temperature using
peer.getCharacteristicByUUID(temperatureMeasurementCharacteristic, BleUuid(0x2a1c));
But I cannot get the battery level
peer.getCharacteristicByUUID(batteryLevelCharacteristic, BleUuid(0x2a19));

Since the battery level is READ and not NOTIFY what function can I use other than getCharacteristicByUUID(…)?
I do not see any functions as readCharacteristics… or else.

Thank you for any help.
Jean-Marc

You store the characteristic object reference you get back from getCharacteristicByUUID() and then use (the approriate overload of) getValue() on that object reference.

@ScruffR, thank you for the rapid feeback. Not sure I understood…
I am using onDataReceive for the result and seems not to get any callback for the battery read.

For a callback like onDataReceive() you need someone to actively push the data to your central - a ::READ characterisitc does not do that, you have to read it :wink:

@ScruffR, you are right… :smiley:
so how to I store the object value? What overload? sorry I am not very good in C++
peer.getCharacteristicByUUID(…) return only a boolean.

Thank you for the help

The first parameter you pass into getCharachteristicByUUID() will “catch” the found characteristic reference.

so you will use batteryLevelCharacteristic.getValue(...) where ... should be the suitable type for the value you are going to read.

@ScruffR thx a lot your are the boss… :slight_smile: working perfectly…
here is my code:

int8_t batteryLevel;

peer.getCharacteristicByUUID(batteryLevelCharacteristic, BleUuid(0x2a19));
batteryLevelCharacteristic.getValue(&batteryLevel);

1 Like