@@ -85,6 +85,7 @@ void WiFiClass::handleEvent(uint8_t u8MsgType, void *pvMsg)
8585 _localip = 0 ;
8686 _submask = 0 ;
8787 _gateway = 0 ;
88+ _dnsip = 0 ;
8889 }
8990 // Close sockets to clean state
9091 // Clients will need to reconnect once the physical link will be re-established
@@ -110,6 +111,7 @@ void WiFiClass::handleEvent(uint8_t u8MsgType, void *pvMsg)
110111 _localip = pstrIPCfg->u32StaticIP ;
111112 _submask = pstrIPCfg->u32SubnetMask ;
112113 _gateway = pstrIPCfg->u32Gateway ;
114+ _dnsip = pstrIPCfg->u32DNS ;
113115
114116 _status = WL_CONNECTED;
115117
@@ -150,6 +152,7 @@ void WiFiClass::handleEvent(uint8_t u8MsgType, void *pvMsg)
150152 _localip = 0 ;
151153 _submask = 0 ;
152154 _gateway = 0 ;
155+ _dnsip = 0 ;
153156 m2m_wifi_connect ((char *)pstrProvInfo->au8SSID , strlen ((char *)pstrProvInfo->au8SSID ),
154157 pstrProvInfo->u8SecType , pstrProvInfo->au8Password , M2M_WIFI_CH_ALL);
155158 } else {
@@ -306,6 +309,7 @@ int WiFiClass::init()
306309 _localip = 0 ;
307310 _submask = 0 ;
308311 _gateway = 0 ;
312+ _dnsip = 0 ;
309313 _dhcp = 1 ;
310314 _resolve = 0 ;
311315 _remoteMacAddress = 0 ;
@@ -369,6 +373,7 @@ uint8_t WiFiClass::begin()
369373 _localip = 0 ;
370374 _submask = 0 ;
371375 _gateway = 0 ;
376+ _dnsip = 0 ;
372377 }
373378 if (m2m_wifi_default_connect () < 0 ) {
374379 _status = WL_CONNECT_FAILED;
@@ -431,6 +436,7 @@ uint8_t WiFiClass::startConnect(const char *ssid, uint8_t u8SecType, const void
431436 _localip = 0 ;
432437 _submask = 0 ;
433438 _gateway = 0 ;
439+ _dnsip = 0 ;
434440 }
435441 if (m2m_wifi_connect ((char *)ssid, strlen (ssid), u8SecType, (void *)pvAuthInfo, M2M_WIFI_CH_ALL) < 0 ) {
436442 _status = WL_CONNECT_FAILED;
@@ -553,6 +559,7 @@ uint8_t WiFiClass::startAP(const char *ssid, uint8_t u8SecType, const void *pvAu
553559 m2m_memcpy ((uint8 *)&_localip, (uint8 *)&strM2MAPConfig.au8DHCPServerIP [0 ], 4 );
554560 _submask = 0x00FFFFFF ;
555561 _gateway = _localip;
562+ _dnsip = _localip;
556563
557564#ifdef CONF_PERIPH
558565 // WiFi led ON (rev A then rev B).
@@ -619,6 +626,7 @@ uint8_t WiFiClass::startProvision(const char *ssid, const char *url, uint8_t cha
619626 m2m_memcpy ((uint8 *)&_localip, (uint8 *)&strM2MAPConfig.au8DHCPServerIP [0 ], 4 );
620627 _submask = 0x00FFFFFF ;
621628 _gateway = _localip;
629+ _dnsip = _localip;
622630
623631#ifdef CONF_PERIPH
624632 // WiFi led ON (rev A then rev B).
@@ -674,6 +682,7 @@ void WiFiClass::config(IPAddress local_ip, IPAddress dns_server, IPAddress gatew
674682 _localip = conf.u32StaticIP ;
675683 _submask = conf.u32SubnetMask ;
676684 _gateway = conf.u32Gateway ;
685+ _dnsip = conf.u32DNS ;
677686}
678687
679688void WiFiClass::hostname (const char * name)
@@ -763,6 +772,13 @@ uint32_t WiFiClass::gatewayIP()
763772 return _gateway;
764773}
765774
775+ uint32_t WiFiClass::dnsIP (int n)
776+ {
777+ if (n > 0 )
778+ return IPAddress (0 , 0 , 0 , 0 );
779+ return _dnsip;
780+ }
781+
766782char * WiFiClass::SSID ()
767783{
768784 if (_status == WL_CONNECTED || _status == WL_AP_LISTENING || _status == WL_AP_CONNECTED) {
0 commit comments