1 week, 1 day ago.

AdvertisingDataBuilder support for nRF platform


3 months ago I posted a question regarding proper configuration of advertising data (

I was answered that since mbed os 5.11, a new API is available for this purpose, using AdvertisingDataBuilder and other new methods. Since 5.11, the old methods are annotated as deprecated. I thus decided to move my code to the 5.11 API. When starting testing on the nRF51 and nRF52 platforms, I got BLE_ERROR_NOT_IMPLEMENTED errors on calls to gap().setAdvertisingParameters() and gap().setAdvertisingPayload( ble::LEGACY_ADVERTISING_HANDLE, ...). For double checking that I was not making errors in my code, I imported the HeartRateService example and tried to make it run on either nRF platform. I got the same error.

A few questions: - is it correct that the pre 5.11 are deprecated and the post 5.11 methods are not implemented on the nRF platforms ? - if yes, how can this be and when will that be implemented ? - if I am not wrong in my assessment, how is it possible to understand before trying it whether a specific feature is implemented on a given platform. I have watched in the mbed-os source code, but it is not very obvious to understand what is supported or not on a platform. I believe that this is not a HW limitation since no specific use of BLE 5.0 is made.

Thank you in advance for your answer.



Hi Serge,

What BLE stack are you using? We are now using Cordio as our first supported BLE stack not SoftDevice, you can refer to the mbed_app.json here.

Thanks, Desmond

posted by Desmond Chen 18 Mar 2019

Hi Desmond, Thank you for your answer. I am using the online compiler and I believe that the online compiler does not allow the definition of custom targets. Is it correct ? It not, could you please let me know how ? I started using the mbed Studio IDE, but at this stage I am still having issues with my project. Thank you in advance for your answer. Serge

posted by Serge Ayer 18 Mar 2019
Comment on this question

1 Answer

3 days, 13 hours ago.

Hi Serge,

I just tried importing mbed-os-example-ble-HeartRate into online compiler, and it is able to compile and work on my nRF52840_DK(PS: Please switch mbed-os version to 5.11.4, there is one issue in 5.11.5 and will be fixed in next release).

If you are saying compile your custom target, then I believe you should use mbed-cli instead of online compiler which doesn't support custom targets. However if you are saying change definition of a existed target, you can change that in mbed_app.json which is also showed in project tree in left area.

What issues do you have of Mbed Studio? Having your feedback would be very helpful for us!


Desmond, team Mbed

Hi Desmond, Thank you for the answer. A few comments and questions: - I could finally make my program work on a nRF52-DK. It seems that the order of calls to the AdvertisingDataBuilder instance cannot be arbitrary. I followed the same order as in the example and it now works. It may be that the error code should be more relevant. - The reason for moving to the new API (as compared to the deprecated API) is the ability to add more than one service data to the advertising payload. I tested with 5.11.4 and 5.11.5 and the problem remains. Only the service data added with the last call to setServiceData() is added to the advertising payload. Is there an example showing that it works ? - Regarding Mbed Studio, I have many difficulties importing any working program from the online platform. I tried for instance with the mbed-os-example-ble-HeartRate example. Importing from URL does not work (the folder remains empty). Importing from a zip requires many manipulations before compilation may start. And ultimately, when compiling the BLE library/GenericGap.cpp file, an error arises at line 624 (invalid operands to binary expression). Could you give me indication on how to make the mbed-os-example-ble-HeartRate example compile in Mbed Studio ? Thank you in advance for your answer. Serge

posted by Serge Ayer 20 Mar 2019

Hi Serge,

I tried this API and got the same result. I looked into this API and found out the setUUIDData wiping old data so only the latest added service data will be kept. Let me check this API internally and will give you feedback when I have answers.

And regarding Mbed Studio, could you open a new questions? So other Mbed Studio experts can give you better assistance and that improves the search efficiency.

posted by Desmond Chen 21 Mar 2019

Since multiple service data is not a common request, so this function is designed for adding/updating service data, it's not allowed to append new service data. For you request, you may use addOrAppendData() function to create the payload you want. Please refer here.

posted by Desmond Chen 22 Mar 2019

To post an answer, please log in.