From dc2b6bacc2d1a918f11f0de85e2ca22999d1ffbb Mon Sep 17 00:00:00 2001 From: Arpad Magosanyi <m4gw4s@gmail.com> Date: Fri, 30 Dec 2022 19:27:50 +0100 Subject: [PATCH 1/3] 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 From 769cbc730d13d420013e4073e5401e7d1e55aa95 Mon Sep 17 00:00:00 2001 From: Arpad Magosanyi <m4gw4s@gmail.com> Date: Sun, 1 Jan 2023 18:06:32 +0100 Subject: [PATCH 2/3] Added MY_EXTERNAL_WIFIMANAGER_USED to keywords --- keywords.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/keywords.txt b/keywords.txt index 0889219f1..ad9b1a1bb 100755 --- a/keywords.txt +++ b/keywords.txt @@ -47,6 +47,7 @@ MY_SLEEP_NOT_POSSIBLE LITERAL1 MY_SPLASH_SCREEN_DISABLED LITERAL1 MY_WAKE_UP_BY_TIMER LITERAL1 MY_SLEEP_HANDLER LITERAL1 +MY_EXTERNAL_WIFIMANAGER_USED LITERAL1 # transport AUTO LITERAL1 From c70c0ce9e4ceb8a8a07b4ab13b54801771507505 Mon Sep 17 00:00:00 2001 From: Arpad Magosanyi <m4gw4s@gmail.com> Date: Mon, 2 Jan 2023 09:04:26 +0100 Subject: [PATCH 3/3] fix cppcheck issue --- core/MyGatewayTransportMQTTClient.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/MyGatewayTransportMQTTClient.cpp b/core/MyGatewayTransportMQTTClient.cpp index 56950413c..9a19c1b5a 100644 --- a/core/MyGatewayTransportMQTTClient.cpp +++ b/core/MyGatewayTransportMQTTClient.cpp @@ -219,7 +219,10 @@ bool reconnectMQTT(void) GATEWAY_DEBUG(PSTR("!GWT:RMQ:FAIL\n")); #if defined(MY_GATEWAY_ESP8266_SECURE) char sslErr[256]; - int errID = _MQTT_ethClient.getLastSSLError(sslErr, sizeof(sslErr)); +#if defined(MY_DEBUG_VERBOSE_GATEWAY) + int errID = +#endif + _MQTT_ethClient.getLastSSLError(sslErr, sizeof(sslErr)); GATEWAY_DEBUG(PSTR("!GWT:RMQ:(%d) %s\n"), errID, sslErr); #endif return false;