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; [...] }