tcpip_adapter_set_hostname() not working
Posted: Mon Oct 19, 2020 8:53 pm
Hi, all -
I've looked at other posts on this topic; it seems like I'm doing it correctly, but I'm getting the error:
Can someone see what I'm doing wrong? Thanks. Oh: v4.0.1 of the IDF; running on a ROVER.
I've looked at other posts on this topic; it seems like I'm doing it correctly, but I'm getting the error:
This code is in my WiFi event handler:E (7312) Wifi: event_handler(): tcpip_adapter_set_hostname() returned ESP_ERR_TCPIP_ADAPTER_IF_NOT_READY.
Code: Select all
if (l_event_base == WIFI_EVENT)
{
switch(l_event_id)
{
case WIFI_EVENT_STA_START:
// step 3.3 in https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/wifi.html
ESP_LOGI(TAG, "event_handler(): Wifi started at %s.", currentTime.c_str());
tasks->wifi->setCommsState(WIFI_STATE_STARTED);
// 2020 10 12 mzimmers: set the hostname after a start. TODO: get this working.
s = tasks->flash->get(NVS_KEY_DEVICE_NAME);
if ((err = tcpip_adapter_set_hostname(TCPIP_ADAPTER_IF_STA, s.c_str())) != ESP_OK)
{
ESP_LOGE(TAG, "event_handler(): tcpip_adapter_set_hostname() returned %s.",
esp_err_to_name(err));
}