Issues compiling BLE examples

Hello,

I have downloaded the BLE samples (more concreteley BLE_LED) and have been able to deploy (once) using Mbed studio (I couldn’t make it compile via Mbed Cli and GCC).

Nonetheless, after adding the following line to enable pairing with Windows 10:

_ble.securityManager().init();

It does not compile anymore. Even if I remove the line and build again it does not compile…

The errors I am getting are:

[Error] LEDService.h@25,16: unknown type name 'uint16_t'

[Error] LEDService.h@26,16: unknown type name 'uint16_t'

[Error] LEDService.h@28,14: unknown type name 'BLE'

[Error] LEDService.h@38,3: use of undeclared identifier 'GattAttribute'

[Error] LEDService.h@43,3: unknown type name 'BLE'

[Error] LEDService.h@44,3: no template named 'ReadWriteGattCharacteristic'

[Error] LEDService.h@31,5: unknown type name 'GattCharacteristic'

[Error] LEDService.h@32,5: unknown type name 'GattService'

[Error] LEDService.h@33,55: use of undeclared identifier 'GattCharacteristic'

[Error] LEDService.h@33,75: expected expression

[Warning] main.cpp@42,18: 'call_every' is deprecated: Pass a chrono duration, not an integer millisecond count. For example use `5s` rather than `5000`. [since mbed-os-6.0.0] [-Wdeprecated-declarations]

[Warning] main.cpp@42,18: 'call_every<LEDDemo, void>' is deprecated: Pass a chrono duration, not an integer millisecond count. For example use `5s` rather than `5000`. [since mbed-os-6.0.0] [-Wdeprecated-declarations]

[Error] main.cpp@55,24: no matching constructor for initialization of 'LEDService'

[ERROR] In file included from .\source\main.cpp:17:

After adding the following lines to LEDService.h file it compiles again.

#include "ble/BLE.h"
#include <mbed.h>

Why aren’t these headers not included in the official version?

Hi, sounds like you changed the order of includes. That LEDService.h header needs to be included after the ble/BLE.h as it does’t have any includes itself (which is bad, I am in the process of updating examples and this is will no longer be a problem).

1 Like

Hi Paul,

I checked and indeed Mbed Studio is reorganizing the imports automatically so it is the reason why it stopped building just after I modified the file (even if I was restoring the changes).

Thank you very much for your answer and for updating the samples with the missing headers.