Page 1 of 1

espnow example in esp-idf/examples/wifi/espnow

Posted: Sun Jun 06, 2021 10:06 pm
by grzegorz_kr
Hi, why the task function
static void example_espnow_task(void *pvParameter) {....}
in the espnow_example_main.c doesn't have an infinite loop inside?
As I understand, according to FreeRTOS documentation, all task functions must be implemented with the infinite loop and never return.

Re: espnow example in esp-idf/examples/wifi/espnow

Posted: Mon Jun 07, 2021 2:45 am
by ESP_Sprite
The infinite loop is here:

Code: Select all

while (xQueueReceive(s_example_espnow_queue, &evt, portMAX_DELAY) == pdTRUE)
xQueueReceive will return pdTRUE if there's an event and pdFALSE if there is a timeout. However, as the timeout period is set to portMAX_DELAY, there will never be a timeout, and as such the loop is essentially infinite.