diff --git a/platformio.ini b/platformio.ini index e025176..a9abc41 100644 --- a/platformio.ini +++ b/platformio.ini @@ -38,10 +38,10 @@ build_flags = lib_deps = # Switched to forks for better version control. # Using local copy of these libraries #https://github.com/jrowberg/i2cdevlib.git# - https://github.com/mp-se/ESP_WiFiManager#v1.9.0 # https://github.com/khoih-prog/ESP_WiFiManager - https://github.com/mp-se/ESP_DoubleResetDetector#v1.2.1 # https://github.com/khoih-prog/ESP_DoubleResetDetector #https://github.com/PaulStoffregen/OneWire #https://github.com/milesburton/Arduino-Temperature-Control-Library + https://github.com/mp-se/ESP_WiFiManager#v1.9.0 # https://github.com/khoih-prog/ESP_WiFiManager + https://github.com/mp-se/ESP_DoubleResetDetector#v1.2.1 # https://github.com/khoih-prog/ESP_DoubleResetDetector https://github.com/mp-se/tinyexpr # https://github.com/codeplea/tinyexpr https://github.com/mp-se/incbin # https://github.com/graphitemaster/incbin https://github.com/mp-se/Arduino-Log#1.1.1 # https://github.com/thijse/Arduino-Log diff --git a/src/helper.cpp b/src/helper.cpp index d8f69f0..b8c441c 100644 --- a/src/helper.cpp +++ b/src/helper.cpp @@ -318,7 +318,7 @@ void PerfLogging::pushInflux() { if (!myConfig.isInfluxDb2Active()) return; if (myConfig.isInfluxSSL()) { - Log.warning(F("PERF: InfluxDB2 with SSL is not supported when pushing performance data, skipping" CR); + Log.warning(F("PERF: InfluxDB2 with SSL is not supported when pushing performance data, skipping" CR)); return; } diff --git a/src/main.cpp b/src/main.cpp index eb04ab1..3f8e6b1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -32,6 +32,8 @@ SOFTWARE. #include #include +//#define FORCE_GRAVITY_MODE + // Define constats for this program #ifdef DEACTIVATE_SLEEPMODE const int interval = 1000; // ms, time to wait between changes to output @@ -46,8 +48,6 @@ uint32_t runtimeMillis; // Used to calculate the total time since start/wakeup uint32_t stableGyroMillis; // Used to calculate the total time since last // stable gyro reading -enum RunMode { gravityMode = 0, configurationMode = 1, wifiSetupMode = 2 }; - RunMode runMode = RunMode::gravityMode; // @@ -63,6 +63,7 @@ void checkSleepMode(float angle, float volt) { #if defined(FORCE_GRAVITY_MODE) Log.notice(F("MAIN: Forcing device into gravity mode for debugging" CR)); runMode = RunMode::gravityMode; + return; #endif const RawGyroData &g = myConfig.getGyroCalibration(); diff --git a/src/main.hpp b/src/main.hpp index 0a87558..2fc68d5 100644 --- a/src/main.hpp +++ b/src/main.hpp @@ -29,6 +29,9 @@ SOFTWARE. #include #include +enum RunMode { gravityMode = 0, configurationMode = 1, wifiSetupMode = 2 }; +extern RunMode runMode; + #if defined(ESP8266) #include #define ESP_RESET ESP.reset diff --git a/src/pushtarget.cpp b/src/pushtarget.cpp index 7d7a362..524a270 100644 --- a/src/pushtarget.cpp +++ b/src/pushtarget.cpp @@ -204,12 +204,18 @@ void PushTarget::sendInfluxDb2(TemplatingEngine& engine, bool isSecure) { String auth = "Token " + String(myConfig.getInfluxDb2PushToken()); if (isSecure) { + if (runMode == RunMode::configurationMode) { + Log.notice(F("PUSH: Skipping InfluxDB since SSL is enabled and we are in config mode." CR)); + return; + } + Log.notice(F("PUSH: InfluxDB, SSL enabled without validation." CR)); _wifiSecure.setInsecure(); probeMaxFragement(serverPath); _httpSecure.setTimeout(myAdvancedConfig.getPushTimeout() * 1000); _httpSecure.begin(_wifiSecure, serverPath); - _httpSecure.addHeader(F("Authorization"), auth.c_str()); + _httpSecure.addHeader(F("Authorization"), auth.c_str()); + _httpSecure.setReuse(true); _lastCode = _httpSecure.POST(doc); } else { _http.setTimeout(myAdvancedConfig.getPushTimeout() * 1000); @@ -284,6 +290,11 @@ void PushTarget::sendHttpPost(TemplatingEngine& engine, bool isSecure, #endif if (isSecure) { + if (runMode == RunMode::configurationMode) { + Log.notice(F("PUSH: Skipping HTTP since SSL is enabled and we are in config mode." CR)); + return; + } + Log.notice(F("PUSH: HTTP, SSL enabled without validation." CR)); _wifiSecure.setInsecure(); probeMaxFragement(serverPath); @@ -353,6 +364,11 @@ void PushTarget::sendHttpGet(TemplatingEngine& engine, bool isSecure) { #endif if (isSecure) { + if (runMode == RunMode::configurationMode) { + Log.notice(F("PUSH: Skipping HTTP since SSL is enabled and we are in config mode." CR)); + return; + } + Log.notice(F("PUSH: HTTP, SSL enabled without validation." CR)); _wifiSecure.setInsecure(); probeMaxFragement(serverPath); @@ -399,6 +415,11 @@ void PushTarget::sendMqtt(TemplatingEngine& engine, bool isSecure) { int port = myConfig.getMqttPort(); if (myConfig.isMqttSSL()) { + if (runMode == RunMode::configurationMode) { + Log.notice(F("PUSH: Skipping MQTT since SSL is enabled and we are in config mode." CR)); + return; + } + Log.notice(F("PUSH: MQTT, SSL enabled without validation." CR)); _wifiSecure.setInsecure();