Skip to content

Commit ab57f29

Browse files
committed
Fix for ESP8266 Gateway with static IP
According to this: esp8266/Arduino#128 Wifi.config() needs to be called after Wifi.begin(). Otherwise the static IP issn't used by the ESP8266 gateway.
1 parent b5a2fc2 commit ab57f29

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

core/MyGatewayTransportEthernet.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,6 @@ bool gatewayTransportInit(void)
123123
#if defined(MY_ESP8266_HOSTNAME)
124124
WiFi.hostname(MY_ESP8266_HOSTNAME);
125125
#endif /* End of MY_ESP8266_HOSTNAME */
126-
#if defined(MY_IP_ADDRESS)
127-
WiFi.config(_ethernetGatewayIP, _gatewayIp, _subnetIp);
128-
#endif /* End of MY_IP_ADDRESS */
129126
#ifndef MY_ESP8266_BSSID
130127
#define MY_ESP8266_BSSID NULL
131128
#endif
@@ -136,6 +133,9 @@ bool gatewayTransportInit(void)
136133
}
137134
GATEWAY_DEBUG(PSTR("GWT:TIN:IP=%s\n"), WiFi.localIP().toString().c_str());
138135
#endif /* End of MY_ESP8266_SSID */
136+
#if defined(MY_IP_ADDRESS)
137+
WiFi.config(_ethernetGatewayIP, _gatewayIp, _subnetIp);
138+
#endif /* End of MY_IP_ADDRESS */
139139
#elif defined(MY_GATEWAY_LINUX) /* Elif part of MY_GATEWAY_ESP8266 */
140140
// Nothing to do here
141141
#else /* Else part of MY_GATEWAY_ESP8266 */

core/MyGatewayTransportMQTTClient.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ bool gatewayTransportConnect(void)
112112
GATEWAY_DEBUG(PSTR("GWT:TPC:IP=%s\n"),WiFi.localIP().toString().c_str());
113113
#elif defined(MY_GATEWAY_LINUX) /* Elif part of MY_GATEWAY_ESP8266 */
114114
#if defined(MY_IP_ADDRESS)
115+
WiFi.config(_MQTT_clientIp, _gatewayIp, _subnetIp);
115116
_MQTT_ethClient.bind(_MQTT_clientIp);
116117
#endif /* End of MY_IP_ADDRESS */
117118
#else /* Else part of MY_GATEWAY_ESP8266 */
@@ -151,9 +152,6 @@ bool gatewayTransportInit(void)
151152
#if defined(MY_ESP8266_HOSTNAME)
152153
WiFi.hostname(MY_ESP8266_HOSTNAME);
153154
#endif /* End of MY_ESP8266_HOSTNAME */
154-
#if defined(MY_IP_ADDRESS)
155-
WiFi.config(_MQTT_clientIp, _gatewayIp, _subnetIp);
156-
#endif /* End of MY_IP_ADDRESS */
157155
#ifndef MY_ESP8266_BSSID
158156
#define MY_ESP8266_BSSID NULL
159157
#endif

0 commit comments

Comments
 (0)