Skip to content

Instantly share code, notes, and snippets.

@hoon
Created December 23, 2017 07:55
Show Gist options
  • Save hoon/a414a24952d2991e3536b361ceaae108 to your computer and use it in GitHub Desktop.
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
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() );
@pitrk
Copy link

pitrk commented Aug 29, 2020

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 in menuconfig (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