ESP Event Loops
Posted: Tue Jan 10, 2017 11:30 pm
by mjmorrison
Hey All,
I'm poking around and I found this use of
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?
Re: ESP Event Loops
Posted: Wed Jan 11, 2017 4:04 am
by ESP_igrr
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.
Re: ESP Event Loops
Posted: Wed Jan 11, 2017 5:42 pm
by mjmorrison
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.
Re: ESP Event Loops
Posted: Wed Jan 11, 2017 8:04 pm
by mjmorrison
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?