@@ -57,21 +57,22 @@ static bool sta_config_equal(const station_config& lhs, const station_config& rh
5757 * @return equal
5858 */
5959static bool sta_config_equal (const station_config& lhs, const station_config& rhs) {
60- if (strcmp (reinterpret_cast <const char *>(lhs.ssid ), reinterpret_cast <const char *>(rhs.ssid )) != 0 )
60+ if (strcmp (reinterpret_cast <const char *>(lhs.ssid ), reinterpret_cast <const char *>(rhs.ssid )) != 0 ) {
6161 return false ;
62+ }
6263
63- if (strcmp (reinterpret_cast <const char *>(lhs.password ), reinterpret_cast <const char *>(rhs.password )) != 0 )
64+ if (strcmp (reinterpret_cast <const char *>(lhs.password ), reinterpret_cast <const char *>(rhs.password )) != 0 ) {
6465 return false ;
66+ }
6567
66- if (lhs.bssid_set ) {
67- if (!rhs. bssid_set )
68- return false ;
68+ if (lhs.bssid_set != rhs. bssid_set ) {
69+ return false ;
70+ }
6971
70- if (memcmp (lhs.bssid , rhs.bssid , 6 ) != 0 )
71- return false ;
72- } else {
73- if (rhs.bssid_set )
72+ if (lhs.bssid_set ) {
73+ if (memcmp (lhs.bssid , rhs.bssid , 6 ) != 0 ) {
7474 return false ;
75+ }
7576 }
7677
7778 return true ;
@@ -178,39 +179,15 @@ wl_status_t ESP8266WiFiSTAClass::begin() {
178179}
179180
180181
181- /* *
182- * Change IP configuration settings disabling the dhcp client
183- * @param local_ip Static ip configuration
184- * @param gateway Static gateway configuration
185- * @param subnet Static Subnet mask
186- */
187- bool ESP8266WiFiSTAClass::config (IPAddress local_ip, IPAddress gateway, IPAddress subnet) {
188-
189- if (!WiFi.enableSTA (true )) {
190- return false ;
191- }
192-
193- struct ip_info info;
194- info.ip .addr = static_cast <uint32_t >(local_ip);
195- info.gw .addr = static_cast <uint32_t >(gateway);
196- info.netmask .addr = static_cast <uint32_t >(subnet);
197-
198- wifi_station_dhcpc_stop ();
199- if (wifi_set_ip_info (STATION_IF, &info)) {
200- _useStaticIp = true ;
201- return true ;
202- }
203- return false ;
204- }
205-
206182/* *
207183 * Change IP configuration settings disabling the dhcp client
208184 * @param local_ip Static ip configuration
209185 * @param gateway Static gateway configuration
210186 * @param subnet Static Subnet mask
211- * @param dns Static DNS server
187+ * @param dns1 Static DNS server 1
188+ * @param dns2 Static DNS server 2
212189 */
213- bool ESP8266WiFiSTAClass::config (IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns ) {
190+ bool ESP8266WiFiSTAClass::config (IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1, IPAddress dns2 ) {
214191
215192 if (!WiFi.enableSTA (true )) {
216193 return false ;
@@ -227,11 +204,19 @@ bool ESP8266WiFiSTAClass::config(IPAddress local_ip, IPAddress gateway, IPAddres
227204 } else {
228205 return false ;
229206 }
230-
231- // Set DNS-Server
232207 ip_addr_t d;
233- d.addr = static_cast <uint32_t >(dns);
234- dns_setserver (0 , &d);
208+
209+ if (dns1 != (uint32_t )0x00000000 ) {
210+ // Set DNS1-Server
211+ d.addr = static_cast <uint32_t >(dns1);
212+ dns_setserver (0 , &d);
213+ }
214+
215+ if (dns2 != (uint32_t )0x00000000 ) {
216+ // Set DNS2-Server
217+ d.addr = static_cast <uint32_t >(dns2);
218+ dns_setserver (1 , &d);
219+ }
235220
236221 return true ;
237222}
@@ -617,7 +602,7 @@ void ESP8266WiFiSTAClass::_smartConfigCallback(uint32_t st, void* result) {
617602 wifi_station_disconnect ();
618603 wifi_station_connect ();
619604
620- WiFi. _smartConfigDone = true ;
605+ _smartConfigDone = true ;
621606 } else if (status == SC_STATUS_LINK_OVER) {
622607 WiFi.stopSmartConfig ();
623608 }
0 commit comments