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?

Parents
  • 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.

Reply
  • 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.

Children
  • 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

Related