I would like my device to advertise for 10s and then begin advertising again only on an external interrupt.
What steps are required to restart advertising without restarting the device after a timeout event has occurred?
I would like my device to advertise for 10s and then begin advertising again only on an external interrupt.
What steps are required to restart advertising without restarting the device after a timeout event has occurred?
Hi polarstate, i can't guarantee that this is 100% correct way to do this, but when i have to do tasks similiar to yours, i just call advertising_start() function and it starts advertising. Usually, every time i want to advertise different data, so to update advertisement data i just call advertise_init() function and then start advertising by calling advertising_start();
Hope This helps.
What Bluetooth chip(s) are you using?
Building a bit on what @Artucas answered: On the call to advertising_init during startup I would set the advertising timeout to 10 seconds. After advertising_start is called the device will only advertise for 10 seconds. Then in the button push handler (assuming it is done in an interrupt) I'd set a flag which I can check in the main loop. If the main loop sees the flag set I'd call advertising_init again if I needed to change the timeout to something longer/shorter and then call advertising_start again. Clear the button pushed flag when complete.
This is going to appear sarcastic, but it isn't meant to be: he tagged the question with nrf51822, so I think that is the chip he is using.
Oh yes - didn't look at the Tags!