Skip to content

Commit 527267d

Browse files
committed
[Static IP] Work-around for set _use_static_ip
See [this bug report](esp8266/Arduino#4114), which is not fixed in 2.4.0. This work-around will make sure no dhcp-client will be started when connecting to a network. The active DHCP client could result in IP conflicts, difficulty in reconnect and other strange issues.
1 parent 7f393af commit 527267d

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

src/ESPEasy.ino

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ void setup()
9898
{
9999
WiFi.persistent(false); // Do not use SDK storage of SSID/WPA parameters
100100
WiFi.setAutoReconnect(false);
101+
setWifiMode(WIFI_OFF);
101102

102103
checkRAM(F("setup"));
103104
#if defined(ESP32)
@@ -111,7 +112,7 @@ void setup()
111112
// Serial.print("\n\n\nBOOOTTT\n\n\n");
112113

113114
initLog();
114-
setWifiMode(WIFI_STA);
115+
115116

116117
#if defined(ESP32)
117118
WiFi.onEvent((WiFiEventFullCb)WiFiEvent);
@@ -179,6 +180,8 @@ void setup()
179180
fileSystemCheck();
180181
progMemMD5check();
181182
LoadSettings();
183+
setUseStaticIP(useStaticIP());
184+
setWifiMode(WIFI_STA);
182185
checkRuleSets();
183186

184187
ExtraTaskSettings.TaskIndex = 255; // make sure this is an unused nr to prevent cache load on boot

src/ESPEasyWiFiEvent.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,30 @@
1+
//********************************************************************************
2+
// Work-around for setting _useStaticIP
3+
// See reported issue: https://github.com/esp8266/Arduino/issues/4114
4+
//********************************************************************************
5+
#ifdef ESP32
6+
class WiFi_Access_Static_IP: public WiFiSTAClass {
7+
public:
8+
void set_use_static_ip(bool enabled) {
9+
_useStaticIp = enabled;
10+
}
11+
};
12+
#else
13+
class WiFi_Access_Static_IP: public ESP8266WiFiSTAClass {
14+
public:
15+
void set_use_static_ip(bool enabled) {
16+
_useStaticIp = enabled;
17+
}
18+
};
19+
#endif
20+
21+
22+
void setUseStaticIP(bool enabled) {
23+
WiFi_Access_Static_IP tmp_wifi;
24+
tmp_wifi.set_use_static_ip(enabled);
25+
}
26+
27+
128
void markGotIP() {
229
lastGetIPmoment = millis();
330
wifiStatus = ESPEASY_WIFI_GOT_IP;

0 commit comments

Comments
 (0)