Can not toggle LED using scheduler

#1

Hi, the idea is to toggle green led using scheduler without SD


void change_mode(void* data, uint16_t length)
{
nrf_gpio_pin_toggle(LED_GREEN);
}
ret_code_t button_press_handler(const ruuvi_standard_message_t message)
{
app_sched_event_put (NULL, 0,change_mode);
return NRF_SUCCESS;
}
static void power_manage(void)
{
sd_app_evt_wait();
watchdog_feed();
}
int main(void)
{
init_watchdog(NULL);
init_leds();
nrf_gpio_pin_clear(LED_RED);
//Button press: Start interrupts first and Initialize button.
pin_interrupt_init();
pin_interrupt_enable(BSP_BUTTON_0, NRF_GPIOTE_POLARITY_HITOLO, button_press_handler);

//timers_init();
APP_TIMER_APPSH_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, true);
//scheduler_init();
APP_SCHED_INIT(SCHED_MAX_EVENT_DATA_SIZE, SCHED_QUEUE_SIZE);
// Enter main loop.
for (;;)
{
	app_sched_execute();
  		power_manage();
}

}

#2

This function requires softdevice. Nordic SDK has at least from 15 onwards a function which checks if softdevice is enabled and works both with and without SD.

#3

Thanks!
In this test case I just want simply to toggle LED using button (no BLE communication needed at al)
Hence, if I use sd_app_evt_wait with SDK < 15 for deep slipping I must start SD right?
Is there a similar function to sd_app_evt_wait that does not needs SD?

#4

nrf_pwr_mgmt_run();Is probably the function you’re looking for. I don’t remember right away if it was already present in SDK12.3

#5

It seems that it does not exists in SDK 12.3.
I am going to try it starting SD.
Thanks a lot