Arduino 101 CurieBLE library : addAttribute() & BLEDescriptor questions

...newbee to BLE.

I see examples of others (not on the Arduino forum) using these function calls but I am stuck.

First, the .addAttribute function in the BLE Peripheral class does not compile. Returns error like "Function does not exist in the BLEPeripheral Class"

Second issue: BLEDescriptor
Starting with the Battery Monitor example in the CurieBLE Library, I've added an additional Characterisitic: "MyTestChar" No problem :slight_smile:

The problem comes when I try to add a Descriptor to a Characteristic (for instance to define the location of the sensor), the compiler bombs.

I've tried all the permutations I can think of for these declarations, but no luck.

CODE:

Declarations:
BLEUnsignedCharCharacteristic batteryLevelChar("2A19", BLERead | BLENotify); // standard 16-bit characteristic UUID. Returns percentage units.
// remote clients will be able to get notifications if this characteristic changes
BLEDescriptor batteryLevelDescriptor("2901","My Descriptor Here");

Set Up:
BLE.setLocalName("BatteryMonitor");
BLE.setAdvertisedService(batteryService); // add the service UUID
BLE.addService(batteryService); // Add the BLE Battery service
batteryService.addCharacteristic(batteryLevelChar); // add the battery level characteristic
batteryService.addCharacteristic(batteryLevelDescriptor);

error returned:

/tmp/532174548/BatteryMonitor_test_copy/BatteryMonitor_test_copy.ino: In function ‘void setup()’:

/tmp/532174548/BatteryMonitor_test_copy/BatteryMonitor_test_copy.ino:56:58: error: no matching function for call to ‘BLEService::addCharacteristic(BLEDescriptor&)’

batteryService.addCharacteristic(batteryLevelDescriptor);

^

/tmp/532174548/BatteryMonitor_test_copy/BatteryMonitor_test_copy.ino:56:58: note: candidate is:

In file included from /home/admin/builder/arduino-builder/packages/cores/Intel/arc32/libraries/CurieBLE/src/CurieBLE.h:39:0,

from /tmp/532174548/BatteryMonitor_test_copy/BatteryMonitor_test_copy.ino:18:

/home/admin/builder/arduino-builder/packages/cores/Intel/arc32/libraries/CurieBLE/src/BLEService.h:50:9: note: int BLEService::addCharacteristic(BLECharacteristic&)

int addCharacteristic(BLECharacteristic& characteristic);

^

/home/admin/builder/arduino-builder/packages/cores/Intel/arc32/libraries/CurieBLE/src/BLEService.h:50:9: note: no known conversion for argument 1 from ‘BLEDescriptor’ to ‘BLECharacteristic&’

exit status 1

First, the .addAttribute function in the BLE Peripheral class does not compile. Returns error like "Function does not exist in the BLEPeripheral Class"

Read that sentence. It's complete nonsense. Either the class has an addAttribute() method, and you can use it, and the code will compile, or it doesn't.

We do NOT know what BLE library you are using, or where you got it, so we can't help you.