From a26708b06e88dc3ed63977a14861d0b05c43141e Mon Sep 17 00:00:00 2001 From: Arpad Magosanyi Date: Fri, 30 Dec 2022 19:27:50 +0100 Subject: [PATCH] make it possible to use external wifi manager by defining MY_EXTERNAL_WIFIMANAGER_USED --- core/MyGatewayTransportEthernet.cpp | 4 +++- core/MyGatewayTransportMQTTClient.cpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/core/MyGatewayTransportEthernet.cpp b/core/MyGatewayTransportEthernet.cpp index fb148687d..e2347840f 100644 --- a/core/MyGatewayTransportEthernet.cpp +++ b/core/MyGatewayTransportEthernet.cpp @@ -48,7 +48,7 @@ extern MyMessage _msgTmp; #endif #if defined(MY_GATEWAY_ESP8266) || defined(MY_GATEWAY_ESP32) -#if !defined(MY_WIFI_SSID) +#if !defined(MY_WIFI_SSID) && !defined(MY_EXTERNAL_WIFIMANAGER_USED) #error ESP8266/ESP32 gateway: MY_WIFI_SSID not defined! #endif #endif @@ -171,12 +171,14 @@ bool gatewayTransportInit(void) #ifdef MY_IP_ADDRESS WiFi.config(_ethernetGatewayIP, _gatewayIp, _subnetIp); #endif +#if !defined(MY_EXTERNAL_WIFIMANAGER_USED) (void)WiFi.begin(MY_WIFI_SSID, MY_WIFI_PASSWORD, 0, MY_WIFI_BSSID); while (WiFi.status() != WL_CONNECTED) { delay(1000); GATEWAY_DEBUG(PSTR("GWT:TIN:CONNECTING...\n")); } GATEWAY_DEBUG(PSTR("GWT:TIN:IP: %s\n"), WiFi.localIP().toString().c_str()); +#endif #elif defined(MY_GATEWAY_LINUX) // Nothing to do here #else diff --git a/core/MyGatewayTransportMQTTClient.cpp b/core/MyGatewayTransportMQTTClient.cpp index dbf9cc1bc..56950413c 100644 --- a/core/MyGatewayTransportMQTTClient.cpp +++ b/core/MyGatewayTransportMQTTClient.cpp @@ -85,7 +85,7 @@ #endif #if defined(MY_GATEWAY_ESP8266) || defined(MY_GATEWAY_ESP8266_SECURE) || defined(MY_GATEWAY_ESP32) -#if !defined(MY_WIFI_SSID) +#if !defined(MY_WIFI_SSID) && !defined(MY_EXTERNAL_WIFIMANAGER_USED) #error ESP8266/ESP32 MQTT gateway: MY_WIFI_SSID not defined! #endif #endif @@ -323,8 +323,10 @@ bool gatewayTransportInit(void) #if defined(MY_IP_ADDRESS) WiFi.config(_MQTT_clientIp, _gatewayIp, _subnetIp); #endif /* End of MY_IP_ADDRESS */ +#if !defined(MY_EXTERNAL_WIFIMANAGER_USED) (void)WiFi.begin(MY_WIFI_SSID, MY_WIFI_PASSWORD, 0, MY_WIFI_BSSID); #endif +#endif #if defined(MY_GATEWAY_ESP8266_SECURE) // Certificate Authorities are stored in the X509 list