diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index dcd8cc1..decd815 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -96,9 +96,7 @@ void loop() { return; // Don't process IGate and Digi during OTA update } - if (BATTERY_Utils::checkIfShouldSleep()) { - ESP.deepSleep(1800000000); // 30 min sleep (60s = 60e6) - } + BATTERY_Utils::checkIfShouldSleep(); thirdLine = Utils::getLocalIP(); diff --git a/src/battery_utils.cpp b/src/battery_utils.cpp index 9d46017..53820da 100644 --- a/src/battery_utils.cpp +++ b/src/battery_utils.cpp @@ -1,6 +1,7 @@ #include "battery_utils.h" #include "configuration.h" #include "pins_config.h" +//#include "lora_utils.h" // Uncomment if you want to monitor voltage and sleep if voltage is too low (<3.15V) //#define LOW_VOLTAGE_CUTOFF @@ -63,7 +64,7 @@ namespace BATTERY_Utils { // return mapVoltage(voltage, 5.05, 6.32, 4.5, 5.5); // mapped voltage } - bool checkIfShouldSleep() { + void checkIfShouldSleep() { #ifdef LOW_VOLTAGE_CUTOFF if (lastBatteryCheck == 0 || millis() - lastBatteryCheck >= 15 * 60 * 1000) { lastBatteryCheck = millis(); @@ -71,12 +72,17 @@ namespace BATTERY_Utils { float voltage = checkBattery(); if (voltage < cutOffVoltage) { - return true; + /* Send message over APRS-IS or over LoRa??? + + APRS_IS_Utils::upload("battery is low = sleeping") + + LoRa_Utils::sendNewMessage("battery is low = sleeping"); + + */ + ESP.deepSleep(1800000000); // 30 min sleep (60s = 60e6) } } #endif - - return false; } } \ No newline at end of file diff --git a/src/battery_utils.h b/src/battery_utils.h index 6dd1794..fd50532 100644 --- a/src/battery_utils.h +++ b/src/battery_utils.h @@ -8,7 +8,7 @@ namespace BATTERY_Utils { float checkBattery(); float checkExternalVoltage(); - bool checkIfShouldSleep(); + void checkIfShouldSleep(); }