Created
December 23, 2017 07:55
-
-
Save hoon/a414a24952d2991e3536b361ceaae108 to your computer and use it in GitHub Desktop.
Correct place to call tcpip_adapter_set_hostname() to set Wi-Fi client host name in ESP-IDF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ESP_ERROR_CHECK( esp_wifi_set_config(WIFI_IF_STA, &sta_config) ); | |
ESP_ERROR_CHECK( esp_wifi_start() ); | |
ESP_ERROR_CHECK( | |
tcpip_adapter_set_hostname(TCPIP_ADAPTER_IF_STA, "custom-hostname") ); | |
ESP_ERROR_CHECK( esp_wifi_connect() ); |
Thanks! That saved me a lot of time.
OK, I had some problems with that. You cannot run this function twice - it leads to panic. But there are other ways:
- set
CONFIG_LWIP_LOCAL_HOSTNAME
value inmenuconfig
(Component Config -> LWIP -> Local netif hostname) or - use
tcpip_adapter_set_hostname
function.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The correct place to call
is after
esp_wifi_start()
is called but beforeesp_wifi_connect()
is called.