This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

NRF_ERROR_NOT_FOUND from app_sched_event_get after button event

Hi,

after receiving button event application crashes. I get NRF_ERROR_NOT_FOUND from app_sched_event_get and device stop responding.

What can be the reason?

Thanks! Patriko

Buttons init:

		static app_button_cfg_t buttons[] =
	{
		{SHUTTER_UP_BUTTON, true, NRF_GPIO_PIN_PULLUP, button_event_handler},
		{SHUTTER_DOWN_BUTTON, true, NRF_GPIO_PIN_PULLUP, button_event_handler}
	};
	
	
APP_BUTTON_INIT(buttons, sizeof(buttons) / sizeof(buttons[0]),
BUTTON_DETECTION_DELAY, true);
app_button_enable();

event handler:

static void button_event_handler(uint8_t pin_no, uint8_t button_action)
{
uint32_t err_code;
shutter.desiredState = SHUTTER_STATE_STOP;
switch(pin_no)
{
case SHUTTER_UP_BUTTON:
	shutter.desiredState = SHUTTER_STATE_MOVE_UP;
	break;
case SHUTTER_DOWN_BUTTON:
	shutter.desiredState = SHUTTER_STATE_MOVE_DOWN;
	break;
	default:
//		APP_ERROR_HANDLER(pin_no);
	break;
}
check_and_change_shutter_state(&shutter);

}

  • Hi,

    app_sched_event_get() function will return NRF_ERROR_NOT_FOUND if the queue is empty:

    /**@brief Function for reading the next event from specified event queue.
     *
     * @param[out]  pp_event_data       Pointer to pointer to event data.
     * @param[out]  p_event_data_size   Pointer to size of event data.
     * @param[out]  p_event_handler     Pointer to event handler function pointer.
     *
     * @return      NRF_SUCCESS if new event, NRF_ERROR_NOT_FOUND if event queue is empty.
    

    To fetch the event, try using app_sched_execute() in your main loop instead.

Related