#include "configuration.h"
#include "ota_utils.h"
+#include "serial_ports.h"
#include "web_utils.h"
#include "display.h"
#include "utils.h"
@@ -115,7 +116,7 @@ namespace WEB_Utils {
}
void handleWriteConfiguration(AsyncWebServerRequest *request) {
- Serial.println("Got new Configuration Data from www");
+ DEBUG_PRINTLN("Got new Configuration Data from www");
auto getParamStringSafe = [&](const String& name, const String& defaultValue = "") -> String {
if (request->hasParam(name, true)) {
@@ -303,7 +304,7 @@ namespace WEB_Utils {
bool saveSuccess = Config.writeFile();
if (saveSuccess) {
- Serial.println("Configuration saved successfully");
+ DEBUG_PRINTLN("Configuration saved successfully");
AsyncWebServerResponse *response = request->beginResponse(302, "text/html", "");
response->addHeader("Location", "/?success=1");
request->send(response);
@@ -312,7 +313,7 @@ namespace WEB_Utils {
delay(500);
ESP.restart();
} else {
- Serial.println("Error saving configuration!");
+ DEBUG_PRINTLN("Error saving configuration!");
String errorPage = "Error";
errorPage += "Configuration Error:
";
errorPage += "Couldn't save new configuration. Please try again.
";
diff --git a/src/wifi_utils.cpp b/src/wifi_utils.cpp
index acb291a..536ae5b 100644
--- a/src/wifi_utils.cpp
+++ b/src/wifi_utils.cpp
@@ -19,6 +19,7 @@
#include
#include "configuration.h"
#include "board_pinout.h"
+#include "serial_ports.h"
#include "wifi_utils.h"
#include "display.h"
#include "utils.h"
@@ -46,19 +47,19 @@ namespace WIFI_Utils {
if (backUpDigiMode) {
uint32_t WiFiCheck = millis() - lastBackupDigiTime;
if (WiFi.status() != WL_CONNECTED && WiFiCheck >= 15 * 60 * 1000) {
- Serial.println("*** Stopping BackUp Digi Mode ***");
+ DEBUG_PRINTLN("*** Stopping BackUp Digi Mode ***");
backUpDigiMode = false;
wifiCounter = 0;
} else if (WiFi.status() == WL_CONNECTED) {
- Serial.println("*** WiFi Reconnect Success (Stopping Backup Digi Mode) ***");
+ DEBUG_PRINTLN("*** WiFi Reconnect Success (Stopping Backup Digi Mode) ***");
backUpDigiMode = false;
wifiCounter = 0;
}
}
if (!backUpDigiMode && (WiFi.status() != WL_CONNECTED) && ((millis() - previousWiFiMillis) >= 30 * 1000) && !WiFiAutoAPStarted) {
- Serial.print(millis());
- Serial.println("Reconnecting to WiFi...");
+ DEBUG_PRINT(millis());
+ DEBUG_PRINTLN("Reconnecting to WiFi...");
WiFi.disconnect();
WIFI_Utils::startWiFi();
previousWiFiMillis = millis();
@@ -67,7 +68,7 @@ namespace WIFI_Utils {
wifiCounter++;
}
if (wifiCounter >= 2) {
- Serial.println("*** Starting BackUp Digi Mode ***");
+ DEBUG_PRINTLN("*** Starting BackUp Digi Mode ***");
backUpDigiMode = true;
lastBackupDigiTime = millis();
}
@@ -98,14 +99,14 @@ namespace WIFI_Utils {
delay(500);
unsigned long start = millis();
displayShow("", "Connecting to WiFi:", "", currentWiFi->ssid + " ...", 0);
- Serial.print("\nConnecting to WiFi '"); Serial.print(currentWiFi->ssid); Serial.print("' ");
+ DEBUG_PRINT("\nConnecting to WiFi '"); DEBUG_PRINT(currentWiFi->ssid); DEBUG_PRINT("' ");
WiFi.begin(currentWiFi->ssid.c_str(), currentWiFi->password.c_str());
while (WiFi.status() != WL_CONNECTED && wifiCounterssid); Serial.println("' ...");
+ DEBUG_PRINT("\nConnecting to WiFi '"); DEBUG_PRINT(currentWiFi->ssid); DEBUG_PRINTLN("' ...");
displayShow("", "Connecting to WiFi:", "", currentWiFi->ssid + " ...", 0);
WiFi.disconnect();
WiFi.begin(currentWiFi->ssid.c_str(), currentWiFi->password.c_str());
@@ -132,20 +133,20 @@ namespace WIFI_Utils {
digitalWrite(INTERNAL_LED_PIN,LOW);
#endif
if (WiFi.status() == WL_CONNECTED) {
- Serial.print("\nConnected as ");
- Serial.print(WiFi.localIP());
- Serial.print(" / MAC Address: ");
- Serial.println(WiFi.macAddress());
+ DEBUG_PRINT("\nConnected as ");
+ DEBUG_PRINT(WiFi.localIP());
+ DEBUG_PRINT(" / MAC Address: ");
+ DEBUG_PRINTLN(WiFi.macAddress());
displayShow("", " Connected!!", "" , " loading ...", 1000);
} else if (WiFi.status() != WL_CONNECTED) {
startAP = true;
- Serial.println("\nNot connected to WiFi! Starting Auto AP");
+ DEBUG_PRINTLN("\nNot connected to WiFi! Starting Auto AP");
displayShow("", " WiFi Not Connected!", "" , " loading ...", 1000);
}
WiFiConnected = !startAP;
if (startAP) {
- Serial.println("\nNot connected to WiFi! Starting Auto AP");
+ DEBUG_PRINTLN("\nNot connected to WiFi! Starting Auto AP");
displayShow("", " Starting Auto AP", " Please connect to it " , " loading ...", 1000);
startAutoAP();
@@ -160,12 +161,12 @@ namespace WIFI_Utils {
if (WiFiAutoAPTime == 0) {
WiFiAutoAPTime = millis();
} else if ((millis() - WiFiAutoAPTime) > Config.wifiAutoAP.timeout * 60 * 1000) {
- Serial.println("Stopping auto AP");
+ DEBUG_PRINTLN("Stopping auto AP");
WiFiAutoAPStarted = false;
WiFi.softAPdisconnect(true);
- Serial.println("Auto AP stopped (timeout)");
+ DEBUG_PRINTLN("Auto AP stopped (timeout)");
}
}
}
diff --git a/src/wx_utils.cpp b/src/wx_utils.cpp
index 27d7b59..dbf56d0 100644
--- a/src/wx_utils.cpp
+++ b/src/wx_utils.cpp
@@ -22,6 +22,7 @@
#endif
#include "configuration.h"
#include "board_pinout.h"
+#include "serial_ports.h"
#include "wx_utils.h"
#include "display.h"
@@ -74,7 +75,7 @@ namespace WX_Utils {
#endif
delay(5);
if (err == 0) {
- //Serial.println(addr); //this shows any connected board to I2C
+ //DEBUG_PRINTLN(addr); //this shows any connected board to I2C
if (addr == 0x76 || addr == 0x77) { // BME or BMP
wxModuleAddress = addr;
return;
@@ -97,19 +98,19 @@ namespace WX_Utils {
if (wxModuleAddress == 0x76 || wxModuleAddress == 0x77) {
#if defined(HELTEC_V3) || defined(HELTEC_V3_2) || defined(HELTEC_WSL_V3) || defined(HELTEC_WSL_V3_DISPLAY)
if (bme280.begin(wxModuleAddress, &Wire1)) {
- Serial.println("BME280 sensor found");
+ DEBUG_PRINTLN("BME280 sensor found");
wxModuleType = 1;
wxModuleFound = true;
}
#else
if (bme280.begin(wxModuleAddress)) {
- Serial.println("BME280 sensor found");
+ DEBUG_PRINTLN("BME280 sensor found");
wxModuleType = 1;
wxModuleFound = true;
}
if (!wxModuleFound) {
if (bme680.begin(wxModuleAddress)) {
- Serial.println("BME680 sensor found");
+ DEBUG_PRINTLN("BME680 sensor found");
wxModuleType = 3;
wxModuleFound = true;
}
@@ -117,18 +118,18 @@ namespace WX_Utils {
#endif
if (!wxModuleFound) {
if (bmp280.begin(wxModuleAddress)) {
- Serial.println("BMP280 sensor found");
+ DEBUG_PRINTLN("BMP280 sensor found");
wxModuleType = 2;
wxModuleFound = true;
if (aht20.begin()) {
- Serial.println("AHT20 sensor found");
+ DEBUG_PRINTLN("AHT20 sensor found");
if (wxModuleType == 2) wxModuleType = 6;
}
}
}
} else if (wxModuleAddress == 0x40 && Config.battery.useExternalI2CSensor == false) {
if(si7021.begin()) {
- Serial.println("Si7021 sensor found");
+ DEBUG_PRINTLN("Si7021 sensor found");
wxModuleType = 4;
wxModuleFound = true;
}
@@ -136,7 +137,7 @@ namespace WX_Utils {
#ifdef LIGHTGATEWAY_PLUS_1_0
else if (wxModuleAddress == 0x70) {
if (shtc3.begin()) {
- Serial.println("SHTC3 sensor found");
+ DEBUG_PRINTLN("SHTC3 sensor found");
wxModuleType = 5;
wxModuleFound = true;
}
@@ -144,7 +145,7 @@ namespace WX_Utils {
#endif
if (!wxModuleFound) {
displayShow("ERROR", "", "BME/BMP/Si7021/SHTC3 sensor active", "but no sensor found...", 2000);
- Serial.println("BME/BMP/Si7021/SHTC3 sensor Active in config but not found! Check Wiring");
+ DEBUG_PRINTLN("BME/BMP/Si7021/SHTC3 sensor Active in config but not found! Check Wiring");
} else {
switch (wxModuleType) {
case 1:
@@ -154,7 +155,7 @@ namespace WX_Utils {
Adafruit_BME280::SAMPLING_X1,
Adafruit_BME280::FILTER_OFF
);
- Serial.println("BME280 Module init done!");
+ DEBUG_PRINTLN("BME280 Module init done!");
break;
case 2:
bmp280.setSampling(Adafruit_BMP280::MODE_FORCED,
@@ -162,7 +163,7 @@ namespace WX_Utils {
Adafruit_BMP280::SAMPLING_X1,
Adafruit_BMP280::FILTER_OFF
);
- Serial.println("BMP280 Module init done!");
+ DEBUG_PRINTLN("BMP280 Module init done!");
break;
case 3:
#if !defined(HELTEC_V3) && !defined(HELTEC_V3_2)
@@ -170,7 +171,7 @@ namespace WX_Utils {
bme680.setHumidityOversampling(BME680_OS_1X);
bme680.setPressureOversampling(BME680_OS_1X);
bme680.setIIRFilterSize(BME680_FILTER_SIZE_0);
- Serial.println("BMP680 Module init done!");
+ DEBUG_PRINTLN("BMP680 Module init done!");
#endif
break;
}
@@ -293,7 +294,7 @@ namespace WX_Utils {
}
if (isnan(newTemp) || isnan(newHum) || isnan(newPress)) {
- Serial.println("BME/BMP/Si7021 Module data failed");
+ DEBUG_PRINTLN("BME/BMP/Si7021 Module data failed");
fifthLine = "";
return ".../...g...t...";
} else {