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

Examples for enabling/disabling of BLE SoftDevice

So far I haven't run across any code examples that will switch the BLE (S110) stack in and out. I'm looking to test enabling and disabling of the softdevice to see how that works with a separate protocol that uses the radio. So far simply calling sd_softdevice_enable after calling sd_softdevice_disable doesn't seem to completely re-enable the soft device.

Any suggestions?

  • You can refer to ble_app_gzll in the SDK, which does such toggling.

    However, what do you mean that it doesn't seem to re-enable it completely? There are no intermediate steps; either enabling succeeds or it fails. Do you check the error code returned by the second enable? Could it be that you have some interrupts enabled with an illegal interrupt configuration (i.e. have enabled one of the interrupts that the softdevice needs, or have another interrupt with priority 0)? If so, enable will return NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION.

  • Thanks for mentioning a project I can use as an example. I apologize, I wasn't very clear in my message regarding re-enabling. I only meant that I modified the ble_app_lbs example so that Button 0 when pressed disables the softdevice and when pressed again re-enables it. I tested only at a high level, trying to see if the device could be discovered again using the Master Control Panel. I am in the process of setting up an Eclipse project for this code so that I can debug a little further. It's quite possible I did something wrong.

  • Be aware that enabling the softdevice is not sufficient to discover the device, you also have to start advertising, so if you don't do that, you won't be able to discover the device. If you have further problems, I'd be happy if you could edit your original question and supply the code you're working with, so I can test it here.

  • Hi Ole,

    Yes, my simple test revealed that I need to do more than simply re-enable the softdevice with a sd_softdevice_enable call. I see in the jzll example that the ble_stack_start uses BLE_STACK_HANDLER_INIT to re-enable things. I'll give that a try. I'm also having a bit of difficulty using Eclipse to debug with the app I created around the softdevice. That is likely a separate issue and will mark this thread resolved.

    Thanks

  • I re-opened this because it seemed better than posting a new question on the same topic.

    Basically, I'm getting stuck because I don't fully appreciate or understand some subtleties of the ble_app_lbs demo and the usage of the scheduler. What I've done is to modify this to look a little bit more like ble_app_gzll. What I mean by that is I have added functions to start and stop ble, similar to the ble_app_gzll. I've also modified the startup in main to use ble_lbs_start. I modified buttons_init so that the wakeup_button is now tied into the button_event_handler and it is supposed to toggle the ble stack on or off with each press. I've attached the source files here if someone wants to take a stab at pointing out what I'm doing wrong.

    The device comes up just fine and can be connected to with the Master Control Panel. When I hit the wakeup button (button 0), the stack goes away but there is no GPIO toggle when I hit the button a second time. The event isn't getting to the handler.

    main.c

Related