IP_EVENT for timeout on dhcp request ?
Posted: Fri Apr 14, 2023 6:51 pm
Hi all,
If got the following use case:
wifi credentials are properly configured and the code is connecting to the selected wifi SSID, but due to a strict dhcp setup, there will not be an answer to a dhcp-request (a combination of authoritative and ignore unknown-clients in ISC-DHCP). For an answer to the dhcp-request, the mac address will have to be added to the correct pool.
So, I like to give a notice to the user, that the dhcp-request was not answered in a timely fashion, but I'm kinda stuck here.
I've setup an event handler with card blanche:
And the events are printed in the event_handler in the expected order, when the dhcp-request is answered by the dhcp-server
My question: is there any better solution but starting a timer after calling esp_wifi_connect() to wait for a predefined time for an ip address / IP_EVENT_STA_GOT_IP event?
Regards.
If got the following use case:
wifi credentials are properly configured and the code is connecting to the selected wifi SSID, but due to a strict dhcp setup, there will not be an answer to a dhcp-request (a combination of authoritative and ignore unknown-clients in ISC-DHCP). For an answer to the dhcp-request, the mac address will have to be added to the correct pool.
So, I like to give a notice to the user, that the dhcp-request was not answered in a timely fashion, but I'm kinda stuck here.
I've setup an event handler with card blanche:
Code: Select all
esp_event_handler_instance_register(ESP_EVENT_ANY_BASE, ESP_EVENT_ANY_ID, event_handler, ....
But, in this use case, when the mac address hasn't been added to the reservation list of the dhcp server, it will never get an answer and the events end with WIFI_EVENT_STA_CONNECTED.WIFI_EVENT / WIFI_EVENT_STA_START
WIFI_EVENT / WIFI_EVENT_SCAN_DONE
WIFI_EVENT / WIFI_EVENT_STA_CONNECTED
IP_EVENT / IP_EVENT_STA_GOT_IP
My question: is there any better solution but starting a timer after calling esp_wifi_connect() to wait for a predefined time for an ip address / IP_EVENT_STA_GOT_IP event?
Regards.