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

how to Restart advertising after timeout?

Hi. For my application, i want to do a battery saver profile. I need to send one advertising package every 30second. So now i do this by setting

#define ADV_TIMEOUT_IN_SECONDS          5
#define ADV_INTERVAL_IN_MS              10000     

and by setting a WDT that reset system every 29 second

void wdt_init(void)
{
NRF_WDT->CONFIG = (WDT_CONFIG_HALT_Pause << WDT_CONFIG_HALT_Pos) | ( WDT_CONFIG_SLEEP_Run << WDT_CONFIG_SLEEP_Pos);
NRF_WDT->CRV = 29*32768; 
NRF_WDT->RREN |= WDT_RREN_RR0_Msk;  
NRF_WDT->TASKS_START = 1;

I think there is a better way to do this. can you help me? thanks so much

Parents
  • I understand that the limitation of the advertising interval to 0x4000 (10.24 seconds) means you can't just set the interval to 30 seconds. However, you could have the advertising timeout like you do, but have a 30 second application timer that would trigger another call to sd_ble_gap_adv_start for you. Then you could avoid the forced reset.

    Take a look at the timer library documentation in the SDK documentation, it is in the Libraries section. Also look at app_timer.c.

Reply
  • I understand that the limitation of the advertising interval to 0x4000 (10.24 seconds) means you can't just set the interval to 30 seconds. However, you could have the advertising timeout like you do, but have a 30 second application timer that would trigger another call to sd_ble_gap_adv_start for you. Then you could avoid the forced reset.

    Take a look at the timer library documentation in the SDK documentation, it is in the Libraries section. Also look at app_timer.c.

Children
Related