Skip to content

Commit

Permalink
digiEcoMode fix
Browse files Browse the repository at this point in the history
  • Loading branch information
richonguzman committed Dec 31, 2024
1 parent 92bc0a7 commit ad5a5cc
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/LoRa_APRS_iGate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ ___________________________________________________________________*/
#include "A7670_utils.h"
#endif

String versionDate = "2024.12.30";
String versionDate = "2024.12.31";
Configuration Config;
WiFiClient espClient;
#ifdef HAS_GPS
Expand Down
15 changes: 11 additions & 4 deletions src/query_utils.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "configuration.h"
#include "battery_utils.h"
#include "station_utils.h"
#include "query_utils.h"
#include "lora_utils.h"
Expand All @@ -10,6 +11,8 @@ extern String versionDate;
extern int rssi;
extern float snr;
extern int freqError;
extern bool shouldSleepLowVoltage;
extern bool saveNewDigiEcoModeConfig;


namespace QUERY_Utils {
Expand Down Expand Up @@ -53,12 +56,16 @@ namespace QUERY_Utils {
answer.concat("?WHERE on development 73!");
} else if (queryQuestion.indexOf("?APRSEEM") == 0 && Config.digi.ecoMode == true) { // Exit Digipeater EcoMode
answer = "DigiEcoMode:Stop";
Config.digi.ecoMode = false;
Config.display.alwaysOn = true;
Config.display.timeout = 10;
Config.digi.ecoMode = false;
Config.display.alwaysOn = true;
Config.display.timeout = 10;
shouldSleepLowVoltage = true; // to make sure all packets in outputPacketBuffer are sended before restart.
saveNewDigiEcoModeConfig = true;
} else if (queryQuestion.indexOf("?APRSSEM") == 0 && Config.digi.ecoMode == false) { // Start Digipeater EcoMode
answer = "DigiEcoMode:Start";
Config.digi.ecoMode = true;
Config.digi.ecoMode = true;
shouldSleepLowVoltage = true; // to make sure all packets in outputPacketBuffer are sended before restart.
saveNewDigiEcoModeConfig = true;
} else if (queryQuestion.indexOf("?APRSEMS") == 0) { // Digipeater EcoMode Status
answer = (Config.digi.ecoMode) ? "DigiEcoMode:ON" : "DigiEcoMode:OFF";
}
Expand Down
9 changes: 4 additions & 5 deletions src/station_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ std::vector<LastHeardStation> lastHeardStations;
std::vector<String> outputPacketBuffer;
std::vector<Packet25SegBuffer> packet25SegBuffer;

bool saveNewDigiEcoModeConfig = false;


namespace STATION_Utils {

Expand Down Expand Up @@ -92,13 +94,8 @@ namespace STATION_Utils {
int timeToWait = 3 * 1000; // 3 segs between packet Tx and also Rx ???
uint32_t lastRx = millis() - lastRxTime;
uint32_t lastTx = millis() - lastTxTime;
bool saveNewDigiEcoModeConfig = false;
if (outputPacketBuffer.size() > 0 && lastTx > timeToWait && lastRx > timeToWait) {
LoRa_Utils::sendNewPacket(outputPacketBuffer[0]);
if (outputPacketBuffer[0].indexOf("DigiEcoMode:Start") != -1 || outputPacketBuffer[0].indexOf("DigiEcoMode:Stop") != -1) {
saveNewDigiEcoModeConfig = true;
shouldSleepLowVoltage = true; // to make sure all packets in outputPacketBuffer are sended before restart.
}
outputPacketBuffer.erase(outputPacketBuffer.begin());
lastTxTime = millis();
}
Expand All @@ -110,7 +107,9 @@ namespace STATION_Utils {
}
}
if (saveNewDigiEcoModeConfig) {
setCpuFrequencyMhz(80);
Config.writeFile();
delay(1000);
displayToggle(false);
ESP.restart();
}
Expand Down

0 comments on commit ad5a5cc

Please sign in to comment.