ESP Event Loops

mjmorrison
Posts: 26
Joined: Thu Nov 03, 2016 9:06 pm

ESP Event Loops

Postby mjmorrison » Tue Jan 10, 2017 11:30 pm

Hey All,

I'm poking around and I found this use of

Code: Select all

 esp_event_loop_init(NULL, NULL); 


right here: https://github.com/espressif/esp-idf/bl ... ain.c#L131

IDK about y'all but this looks pretty odd, and it's the only example that I have found that uses this function in this way.

What purpose does starting the event loop in this case? Does it have interactions with freeRTOS tasks? Or does the ethernet driver require access to the stream of events?

ESP_igrr
Posts: 2067
Joined: Tue Dec 01, 2015 8:37 am

Re: ESP Event Loops

Postby ESP_igrr » Wed Jan 11, 2017 4:04 am

When some events from network driver (WiFi or ethernet) happen, we need to tell the IP stack about these events.
For example, when Ethernet link is up, we need to start a DHCP client.

This default behavior for many events is implemented in components/esp32/event_default_handlers.c. When the ethernet example initializes event loop without a callback function, it essentially tells that the default event handlers need to be run in the event task, but the application is not interested in receiving callbacks when these events happen.

We will extend the example to pass some event callback function to esp_event_loop_init, which is probably more representative of the real usage.

mjmorrison
Posts: 26
Joined: Thu Nov 03, 2016 9:06 pm

Re: ESP Event Loops

Postby mjmorrison » Wed Jan 11, 2017 5:42 pm

Ok, thanks much. This is more clear.

I posted recently here http://www.esp32.com/viewtopic.php?f=2&t=883 about my event handler for Mongoose not receiving events. This looks like it could be related! I will try over the next day or so to add a call to esp_event_loop(my_handler, NULL); and see if that does the trick.

mjmorrison
Posts: 26
Joined: Thu Nov 03, 2016 9:06 pm

Re: ESP Event Loops

Postby mjmorrison » Wed Jan 11, 2017 8:04 pm

Looking at this example: https://github.com/espressif/esp-idf/bl ... est.c#L156

In the above example, there seem to be two tests going on at the same time. Is the event handler "uart_task" necessary for the "uart_echo_test" function at the bottom?

First instinct says no, because its initialized in the other test, but this is unclear from the example.

For context I'm trying to communicate to an external transceiver which uses flow control. It seems that I might want some of the functionality provided by an event handler, but is this necessary for querying a register on an external device and then waiting for and recording the reply?

Who is online

Users browsing this forum: Google [Bot] and 132 guests