Hi I managed to successfully implement a busy-wait using nrf_delay_ms(). However, I read that nrf_delay_ms() uses more power than app_timer's RTC. So I am trying to use app_timer to do a busy_wait for 10 seconds before calling the rest of the code after peer_manager_init() is called in main().
My busy_wait code works by checking whether m_custom_value is >= 10 before calling services_init() and the other functions.
The issue with my busy-wait code is services_init() and the other functions are never called (so no BLE advertising on the NRF). I have also tried using a while loop instead of the if conditional, but that did not work either. m_custom_value is incremented every second by a repeated app_timer which is initialized and starts before the busy-wait code.
Is this an issue with app_timer when main is called or am I just not creating the busy-wait correctly? Thanks!
int main(void) { bool erase_bonds; // Initialize. log_init(); timers_init(); application_timers_start(); buttons_leds_init(&erase_bonds); power_management_init(); ble_stack_init(); gap_params_init(); gatt_init(); peer_manager_init(); //nrf_delay_ms(10000); if (m_custom_value >= 10){ services_init(); advertising_init(); conn_params_init(); NRF_LOG_INFO("Template example started."); advertising_start(erase_bonds); } /* // Enter main loop. for (;;) { idle_state_handle(); }*/ }