Hi there,
I'm currently working on a project in which I need to be able to deactivate Bluetooth advertising at the press of a button. I am using SDK 15.3 and have built a custom service from the ble_app_template example, following this tutorial. I have been able to get Bluetooth communication up and running, but am having difficulty deactivating it without causing the script to fail. To clarify, all I need it to do is to disable communication, not necessarily disable the entire module.
Here is the way I am currently enabling Bluetooth (working):
And this is the function I'm trying to use to disable it:
When the button is pressed while no connected has been established, it hangs on sd_ble_gap_adv_stop() and will not reach the APP_ERROR_CHECK.
When the button is pressed while connected to a device, sd_ble_gap_disconnect() will work, but an error is generated at sd_ble_gap_adv_stop().
Is there a specific file I need to include in order to use sd_ble_gap_adv_stop()? Or maybe another way to achieve this?
*I have also tried using ble_advertising_start() to enter IDLE mode as a way of disabling communication but have not been able to get this to work either.
Any help would be much appreciated.
Cheers,
Charlie