@@ -57,21 +57,22 @@ static bool sta_config_equal(const station_config& lhs, const station_config& rh
57
57
* @return equal
58
58
*/
59
59
static 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 ) {
61
61
return false ;
62
+ }
62
63
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 ) {
64
65
return false ;
66
+ }
65
67
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
+ }
69
71
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 ) {
74
74
return false ;
75
+ }
75
76
}
76
77
77
78
return true ;
@@ -178,39 +179,15 @@ wl_status_t ESP8266WiFiSTAClass::begin() {
178
179
}
179
180
180
181
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
-
206
182
/* *
207
183
* Change IP configuration settings disabling the dhcp client
208
184
* @param local_ip Static ip configuration
209
185
* @param gateway Static gateway configuration
210
186
* @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
212
189
*/
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 ) {
214
191
215
192
if (!WiFi.enableSTA (true )) {
216
193
return false ;
@@ -227,11 +204,19 @@ bool ESP8266WiFiSTAClass::config(IPAddress local_ip, IPAddress gateway, IPAddres
227
204
} else {
228
205
return false ;
229
206
}
230
-
231
- // Set DNS-Server
232
207
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
+ }
235
220
236
221
return true ;
237
222
}
@@ -617,7 +602,7 @@ void ESP8266WiFiSTAClass::_smartConfigCallback(uint32_t st, void* result) {
617
602
wifi_station_disconnect ();
618
603
wifi_station_connect ();
619
604
620
- WiFi. _smartConfigDone = true ;
605
+ _smartConfigDone = true ;
621
606
} else if (status == SC_STATUS_LINK_OVER) {
622
607
WiFi.stopSmartConfig ();
623
608
}
0 commit comments