Get DNS Server IP

guruschmuru
Posts: 1
Joined: Wed Feb 01, 2017 9:56 pm

Get DNS Server IP

Postby guruschmuru » Wed Feb 01, 2017 10:23 pm

It would be very useful to have access to the DNS server addresses assigned to the DHCP client when the ESP8266 is connected in STA mode. Ideally these addresses would either be returned in the ip_info struct via wifi_get_ip_info or alternatively via a dedicated API (for example espconn_dns_getserver).

Her Majesty
Posts: 128
Joined: Mon Oct 27, 2014 11:09 am

Re: Get DNS Server IP

Postby Her Majesty » Fri Mar 24, 2017 1:18 pm

Maybe call API wifi_set_event_handler_cb, the gateway in event EVENT_STAMODE_GOT_IP can be used.

Code: Select all

void wifi_handle_event_cb(System_Event_t *evt)
{
   os_printf("event %x\n", evt->event);
   switch (evt->event) {
       case EVENT_STAMODE_GOT_IP:
          os_printf("ip:" IPSTR ",mask:" IPSTR ",gw:" IPSTR,
                     IP2STR(&evt->event_info.got_ip.ip),
                     IP2STR(&evt->event_info.got_ip.mask),
                     IP2STR(&evt->event_info.got_ip.gw));
          os_printf("\n");
          break;
       default:
          break;
   }
}
void user_init(void)
{
    // TODO: add your own code here....
    wifi_set_event_handler_cb(wifi_handle_event_cb);
}


Who is online

Users browsing this forum: No registered users and 7 guests