This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

BLE_ERROR_NOT_ENABLED with S120

Hi,

I'm using a lightly modified copy of the Multilink central S120 example code. When I get to ble_stack_init() the first thing it does is SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, NULL);

Unfortunately that gives me an error code of 4097 which is BLE_ERROR_NOT_ENABLED. The comment for that error says "sd_ble_enable has not been called". But in the example code sd_ble_enable() is after SOFTDEVICE_HANDLER_INIT() so of course it hasn't been called!

If I believe the error and move sd_ble_enable() before SOFTDEVICE_HANDLER_INIT() then sd_ble_enable() returns error code 2, which is NRF_ERROR_SOFTDEVICE_NOT_ENABLED!

What is going on here? Which one should go first, and why are there error codes for both of them not being called first?

Parents
  • Ok I did a lot of debugging on this, at some point the original BLE_ERROR_NOT_ENABLED error disappeared but I started having similar issues with device_manager_central.c

    I eventually narrowed this down to the -Os optimisation I was using (I naively assumed that it worked). Unfortunately it seems that -Os screws something up somewhere.

    If you take the multilink_central example and change -O3 to -Os in the settings it will crash indevice_manager_init().

    Kind of infuriating.

    Edit

    I found the cause of the original error - it was because I was using my own serial code, and I was initialising it before ble_stack_init(). If I move it after that function it works fine. No idea why, especially as the example code initialises the UART before ble_stack_init() but whatever...

  • -Os generally works - this is GCC? I use that for my release builds most of the time because it's smaller and generally pretty performant.

Reply Children
No Data
Related