TCPIP get/set hostname always fails
Posted: Tue Nov 12, 2019 11:02 pm
I noticed since upgrading to ESP-IDF v4.0-beta2 from v3.2 that my calls to tcpip_adapter_{get,set}_hostname now fail. The error code for getting the hostname is ESP_ERR_TCPIP_ADAPTER_INVALID_PARAMS and for setting it is ESP_ERR_TCPIP_ADAPTER_IF_NOT_READY, though I can say with confidence that in both cases the error is because p_netif within the IDF TCPIP/LWIP code ends up as NULL.
My code works somewhat as follows:
My code works somewhat as follows:
- Create default event loop and register handler for WIFI_EVENT and IP_EVENT groups
-
Code: Select all
tcpip_adapter_init()
- (each statement is error-checked)
Code: Select all
esp_wifi_init(WIFI_INIT_CONFIG_DEFAULT()); esp_wifi_set_storage(WIFI_STORAGE_RAM); esp_wifi_set_mode(WIFI_MODE_STA);
- In WiFi/IP event handler:
Code: Select all
switch(event_id) { case WIFI_EVENT_STA_START: tcpip_adapter_set_hostname(TCPIP_ADAPTER_IF_STA, [hostname]) break; [...] }