Page 1 of 1

How to get Wifi / IP events in every place / class in code

Posted: Mon Jul 25, 2022 3:57 pm
by tomacaster
Hi,

I don't unfortunately search engine doesn't work (I get white screen every time) so can't find the solution. I've created http client class for requests and I want to check internet connection before any req send, but I can't get any wifi / ip event. If register event handler instance
ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT, ESP_EVENT_ANY_ID, event_handler, NULL, NULL));
In handler I've got switch with Wifi events but don't get any of it. Can somebody explain me what I'm doing wrong?

Thanks a lot! :)

Re: How to get Wifi / IP events in every place / class in code

Posted: Tue Jul 26, 2022 6:53 am
by tomacaster
Ok, I found another solution - get info from tcpip_adapter_get_ip_info(), but it doesn't look so elegant as event handlers. I can't resume sending requests in automated way.

Thanks!

Re: How to get Wifi / IP events in every place / class in code

Posted: Wed Jul 27, 2022 10:44 pm
by chegewara
But you know you can register for events multiple times in every place of code you want?

Code: Select all

ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT, ESP_EVENT_ANY_ID, event_handler, NULL, NULL));