Skip to content

Commit

Permalink
Fix for ESP8266 Gateway with static IP
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tobof committed Apr 3, 2018
1 parent b5a2fc2 commit ab57f29
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 3 additions & 3 deletions core/MyGatewayTransportEthernet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,6 @@ bool gatewayTransportInit(void)
#if defined(MY_ESP8266_HOSTNAME)
WiFi.hostname(MY_ESP8266_HOSTNAME);
#endif /* End of MY_ESP8266_HOSTNAME */
#if defined(MY_IP_ADDRESS)
WiFi.config(_ethernetGatewayIP, _gatewayIp, _subnetIp);
#endif /* End of MY_IP_ADDRESS */
#ifndef MY_ESP8266_BSSID
#define MY_ESP8266_BSSID NULL
#endif
Expand All @@ -136,6 +133,9 @@ bool gatewayTransportInit(void)
}
GATEWAY_DEBUG(PSTR("GWT:TIN:IP=%s\n"), WiFi.localIP().toString().c_str());
#endif /* End of MY_ESP8266_SSID */
#if defined(MY_IP_ADDRESS)
WiFi.config(_ethernetGatewayIP, _gatewayIp, _subnetIp);
#endif /* End of MY_IP_ADDRESS */
#elif defined(MY_GATEWAY_LINUX) /* Elif part of MY_GATEWAY_ESP8266 */
// Nothing to do here
#else /* Else part of MY_GATEWAY_ESP8266 */
Expand Down
4 changes: 1 addition & 3 deletions core/MyGatewayTransportMQTTClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ bool gatewayTransportConnect(void)
GATEWAY_DEBUG(PSTR("GWT:TPC:IP=%s\n"),WiFi.localIP().toString().c_str());
#elif defined(MY_GATEWAY_LINUX) /* Elif part of MY_GATEWAY_ESP8266 */
#if defined(MY_IP_ADDRESS)
WiFi.config(_MQTT_clientIp, _gatewayIp, _subnetIp);
_MQTT_ethClient.bind(_MQTT_clientIp);
#endif /* End of MY_IP_ADDRESS */
#else /* Else part of MY_GATEWAY_ESP8266 */
Expand Down Expand Up @@ -151,9 +152,6 @@ bool gatewayTransportInit(void)
#if defined(MY_ESP8266_HOSTNAME)
WiFi.hostname(MY_ESP8266_HOSTNAME);
#endif /* End of MY_ESP8266_HOSTNAME */
#if defined(MY_IP_ADDRESS)
WiFi.config(_MQTT_clientIp, _gatewayIp, _subnetIp);
#endif /* End of MY_IP_ADDRESS */
#ifndef MY_ESP8266_BSSID
#define MY_ESP8266_BSSID NULL
#endif
Expand Down

0 comments on commit ab57f29

Please sign in to comment.