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

grzegorz_kr
Posts: 6
Joined: Sun Apr 11, 2021 6:34 pm

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

Postby grzegorz_kr » Sun Jun 06, 2021 10:06 pm

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.

ESP_Sprite
Posts: 9766
Joined: Thu Nov 26, 2015 4:08 am

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

Postby ESP_Sprite » Mon Jun 07, 2021 2:45 am

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.

Who is online

Users browsing this forum: Baidu [Spider], Majestic-12 [Bot] and 137 guests