Set hostname

bud.de
Posts: 2
Joined: Wed Nov 30, 2016 12:09 pm

Set hostname

Postby bud.de » Tue Dec 06, 2016 3:32 pm

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() );

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: Set hostname

Postby ESP_Angus » Tue Dec 06, 2016 8:34 pm

You can call tcpip_adapter_set_hostname, something like:

Code: Select all

tcpip_adapter_set_hostname(TCPIP_ADAPTER_IF_STA, "myhostname");

snahmad75
Posts: 445
Joined: Wed Jan 24, 2018 6:32 pm

Re: Set hostname

Postby snahmad75 » Wed May 09, 2018 9:29 pm

Does this works?

Who is online

Users browsing this forum: Bing [Bot] and 413 guests