Page 1 of 1

Set hostname

Posted: Tue Dec 06, 2016 3:32 pm
by bud.de
Can anyone tell me how to set the device hostname on the ESP32?
The only sources I could find is about resolving a remote host.
I initialize the wifi with the code from the examples:

Code: Select all

tcpip_adapter_init();
wifi_event_group = xEventGroupCreate();
ESP_ERROR_CHECK( esp_event_loop_init(event_handler, NULL) );
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK( esp_wifi_init(&cfg) );
ESP_ERROR_CHECK( esp_wifi_set_storage(WIFI_STORAGE_RAM) );
wifi_config_t wifi_config = {
    .sta = {
        .ssid = WIFI_SSID,
        .password = WIFI_PASS,
    },
};
ESP_LOGI(TAG, "Setting WiFi configuration SSID %s...", wifi_config.sta.ssid);
ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_STA) );
ESP_ERROR_CHECK( esp_wifi_set_config(WIFI_IF_STA, &wifi_config) );
ESP_ERROR_CHECK( esp_wifi_start() );

Re: Set hostname

Posted: Tue Dec 06, 2016 8:34 pm
by ESP_Angus
You can call tcpip_adapter_set_hostname, something like:

Code: Select all

tcpip_adapter_set_hostname(TCPIP_ADAPTER_IF_STA, "myhostname");

Re: Set hostname

Posted: Wed May 09, 2018 9:29 pm
by snahmad75
Does this works?