Skip to content

Commit

Permalink
Queries for DigiEcoMode
Browse files Browse the repository at this point in the history
  • Loading branch information
richonguzman committed Oct 8, 2024
1 parent bf0a0d6 commit a786d83
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/aprs_is_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ namespace APRS_IS_Utils {
//Serial.println(ackMessage);

String addToBuffer = Config.callsign;
addToBuffer += ">APLRG1,RFONLY";
addToBuffer += ">APLRG1";
if (!thirdParty) addToBuffer += ",RFONLY";
if (Config.beacon.path != "") {
addToBuffer += ",";
addToBuffer += Config.beacon.path;
Expand Down
11 changes: 11 additions & 0 deletions src/query_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "query_utils.h"
#include "lora_utils.h"


extern Configuration Config;
extern std::vector<LastHeardStation> lastHeardStations;
extern String versionDate;
Expand Down Expand Up @@ -50,6 +51,16 @@ namespace QUERY_Utils {
// agregar callsign para completar donde esta X callsign --> posicion
Serial.println("estaciones escuchadas directo (ultimos 30 min)");
answer.concat("?WHERE on development 73!");
} else if (queryQuestion.indexOf("?APRSEEM") == 0) { // Exit DigiRepeater EcoMode
answer = "DigiEcoMode:Stop";
Config.digi.ecoMode = false;
Config.display.alwaysOn = true;
Config.display.timeout = 10;
} else if (queryQuestion.indexOf("?APRSSEM") == 0) { // Start DigiRepeater EcoMode
answer = "DigiEcoMode:Start";
Config.digi.ecoMode = true;
} else if (queryQuestion.indexOf("?APRSEMS") == 0) { // DigiRepeater EcoMode Status
answer = (Config.digi.ecoMode) ? "DigiEcoMode:ON" : "DigiEcoMode:OFF";
}

String queryAnswer = Config.callsign;
Expand Down
17 changes: 14 additions & 3 deletions src/station_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "aprs_is_utils.h"
#include "configuration.h"
#include "lora_utils.h"
#include "display.h"
#include "utils.h"
#include <vector>

Expand Down Expand Up @@ -100,11 +101,16 @@ namespace STATION_Utils {
}

void processOutputPacketBuffer() {
int timeToWait = 3 * 1000; // 3 segs between packet Tx and also Rx ???
uint32_t lastRx = millis() - lastRxTime;
uint32_t lastTx = millis() - lastTxTime;
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 @@ -115,6 +121,11 @@ namespace STATION_Utils {
delay(4000);
}
}
if (saveNewDigiEcoModeConfig) {
Config.writeFile();
displayToggle(false);
ESP.restart();
}
}

void addToOutputPacketBuffer(const String& packet) {
Expand Down
1 change: 1 addition & 0 deletions src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ namespace Utils {
digitalWrite(INTERNAL_LED_PIN,HIGH);
#endif
Serial.println("\nStarting Station: " + Config.callsign + " Version: " + versionDate);
Serial.println((Config.digi.ecoMode) ? "(DigiEcoMode: ON)" : "(DigiEcoMode: OFF)");
displayShow(" LoRa APRS", "", "", " ( iGATE & DIGI )", "", "" , " CA2RXU " + versionDate, 4000);
#ifdef INTERNAL_LED_PIN
digitalWrite(INTERNAL_LED_PIN,LOW);
Expand Down

0 comments on commit a786d83

Please sign in to comment.