diff --git a/src/aprs_is_utils.cpp b/src/aprs_is_utils.cpp
index 7f94f0a..c1dc801 100644
--- a/src/aprs_is_utils.cpp
+++ b/src/aprs_is_utils.cpp
@@ -47,6 +47,8 @@ extern String versionNumber;
uint32_t lastRxTime = millis();
bool passcodeValid = false;
+uint32_t lastServerCheck = 0;
+
#ifdef HAS_A7670
extern bool stationBeacon;
@@ -308,71 +310,78 @@ namespace APRS_IS_Utils {
passcodeValid = true;
}
}
- if (passcodeValid && !packet.startsWith("#")) {
- if (Config.aprs_is.messagesToRF && packet.indexOf("::") > 0) {
- String Sender = packet.substring(0, packet.indexOf(">"));
- const String& AddresseeAndMessage = packet.substring(packet.indexOf("::") + 2);
- String Addressee = AddresseeAndMessage.substring(0, AddresseeAndMessage.indexOf(":"));
- Addressee.trim();
- if (Addressee == Config.callsign) { // its for me!
- String receivedMessage;
- if (AddresseeAndMessage.indexOf("{") > 0) { // ack?
- processAckMessage(Sender, AddresseeAndMessage);
- receivedMessage = AddresseeAndMessage.substring(AddresseeAndMessage.indexOf(":") + 1, AddresseeAndMessage.indexOf("{"));
- } else {
- receivedMessage = AddresseeAndMessage.substring(AddresseeAndMessage.indexOf(":") + 1);
- }
- if (receivedMessage.indexOf("?") == 0) {
- Utils::println("Rx Query (APRS-IS) : " + packet);
- String queryAnswer = QUERY_Utils::process(receivedMessage, Sender, true, false);
- //Serial.println("---> QUERY Answer : " + queryAnswer.substring(0,queryAnswer.indexOf("\n")));
- if (!Config.display.alwaysOn && Config.display.timeout != 0) {
- displayToggle(true);
+ if (passcodeValid) {
+ uint32_t currentTime = millis();
+ if (packet.startsWith("#")) {
+ lastServerCheck = currentTime;
+ Utils::print("[DEBUG INFO] Server alive: ");
+ Utils::println(String(lastServerCheck));
+ } else {
+ if (Config.aprs_is.messagesToRF && packet.indexOf("::") > 0) {
+ String Sender = packet.substring(0, packet.indexOf(">"));
+ const String& AddresseeAndMessage = packet.substring(packet.indexOf("::") + 2);
+ String Addressee = AddresseeAndMessage.substring(0, AddresseeAndMessage.indexOf(":"));
+ Addressee.trim();
+ if (Addressee == Config.callsign) { // its for me!
+ String receivedMessage;
+ if (AddresseeAndMessage.indexOf("{") > 0) { // ack?
+ processAckMessage(Sender, AddresseeAndMessage);
+ receivedMessage = AddresseeAndMessage.substring(AddresseeAndMessage.indexOf(":") + 1, AddresseeAndMessage.indexOf("{"));
+ } else {
+ receivedMessage = AddresseeAndMessage.substring(AddresseeAndMessage.indexOf(":") + 1);
}
- lastScreenOn = millis();
- #ifdef HAS_A7670
- A7670_Utils::uploadToAPRSIS(queryAnswer);
- #else
- upload(queryAnswer);
- #endif
- SYSLOG_Utils::log(2, queryAnswer, 0, 0.0, 0); // APRSIS TX
- fifthLine = "APRS-IS ----> APRS-IS";
- sixthLine = Config.callsign;
- for (int j = sixthLine.length();j < 9;j++) {
- sixthLine += " ";
+ if (receivedMessage.indexOf("?") == 0) {
+ Utils::println("Rx Query (APRS-IS) : " + packet);
+ String queryAnswer = QUERY_Utils::process(receivedMessage, Sender, true, false);
+ //Serial.println("---> QUERY Answer : " + queryAnswer.substring(0,queryAnswer.indexOf("\n")));
+ if (!Config.display.alwaysOn && Config.display.timeout != 0) {
+ displayToggle(true);
+ }
+ lastScreenOn = currentTime;
+ #ifdef HAS_A7670
+ A7670_Utils::uploadToAPRSIS(queryAnswer);
+ #else
+ upload(queryAnswer);
+ #endif
+ SYSLOG_Utils::log(2, queryAnswer, 0, 0.0, 0); // APRSIS TX
+ fifthLine = "APRS-IS ----> APRS-IS";
+ sixthLine = Config.callsign;
+ for (int j = sixthLine.length();j < 9;j++) {
+ sixthLine += " ";
+ }
+ sixthLine += "> ";
+ sixthLine += Sender;
+ seventhLine = "QUERY = ";
+ seventhLine += receivedMessage;
}
- sixthLine += "> ";
- sixthLine += Sender;
- seventhLine = "QUERY = ";
- seventhLine += receivedMessage;
- }
- displayShow(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0);
- } else {
- Utils::print("Rx Message (APRS-IS): " + packet);
- if (STATION_Utils::wasHeard(Addressee) && packet.indexOf("EQNS.") == -1 && packet.indexOf("UNIT.") == -1 && packet.indexOf("PARM.") == -1) {
- STATION_Utils::addToOutputPacketBuffer(buildPacketToTx(packet, 1));
- displayToggle(true);
- lastScreenOn = millis();
- Utils::typeOfPacket(packet, 1); // APRS-LoRa
displayShow(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0);
+ } else {
+ Utils::print("Rx Message (APRS-IS): " + packet);
+ if (STATION_Utils::wasHeard(Addressee) && packet.indexOf("EQNS.") == -1 && packet.indexOf("UNIT.") == -1 && packet.indexOf("PARM.") == -1) {
+ STATION_Utils::addToOutputPacketBuffer(buildPacketToTx(packet, 1));
+ displayToggle(true);
+ lastScreenOn = currentTime;
+ Utils::typeOfPacket(packet, 1); // APRS-LoRa
+ displayShow(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0);
+ }
+ }
+ } else if (Config.aprs_is.objectsToRF && packet.indexOf(":;") > 0) {
+ Utils::print("Rx Object (APRS-IS) : " + packet);
+ if (STATION_Utils::checkObjectTime(packet)) {
+ STATION_Utils::addToOutputPacketBuffer(buildPacketToTx(packet, 5));
+ displayToggle(true);
+ lastScreenOn = currentTime;
+ Utils::typeOfPacket(packet, 1); // APRS-LoRa
+ Serial.println();
+ } else {
+ Serial.println(" ---> Rejected (Time): No Tx");
}
}
- } else if (Config.aprs_is.objectsToRF && packet.indexOf(":;") > 0) {
- Utils::print("Rx Object (APRS-IS) : " + packet);
- if (STATION_Utils::checkObjectTime(packet)) {
- STATION_Utils::addToOutputPacketBuffer(buildPacketToTx(packet, 5));
- displayToggle(true);
- lastScreenOn = millis();
- Utils::typeOfPacket(packet, 1); // APRS-LoRa
- Serial.println();
- } else {
- Serial.println(" ---> Rejected (Time): No Tx");
+ if (Config.tnc.aprsBridgeActive) {
+ if (Config.tnc.enableServer) TNC_Utils::sendToClients(packet); // Send received packet to TNC KISS
+ if (Config.tnc.enableSerial) TNC_Utils::sendToSerial(packet); // Send received packet to Serial KISS
}
}
- if (Config.tnc.aprsBridgeActive) {
- if (Config.tnc.enableServer) TNC_Utils::sendToClients(packet); // Send received packet to TNC KISS
- if (Config.tnc.enableSerial) TNC_Utils::sendToSerial(packet); // Send received packet to Serial KISS
- }
}
}
diff --git a/src/wifi_utils.cpp b/src/wifi_utils.cpp
index b167374..06ff792 100644
--- a/src/wifi_utils.cpp
+++ b/src/wifi_utils.cpp
@@ -16,7 +16,6 @@
* along with LoRa APRS iGate. If not, see .
*/
-#include
#include
#include "configuration.h"
#include "board_pinout.h"
@@ -31,6 +30,7 @@ extern uint8_t myWiFiAPIndex;
extern int myWiFiAPSize;
extern WiFi_AP *currentWiFi;
extern bool backUpDigiMode;
+extern uint32_t lastServerCheck;
bool WiFiConnected = false;
uint32_t WiFiAutoAPTime = millis();
@@ -38,36 +38,10 @@ bool WiFiAutoAPStarted = false;
uint8_t wifiCounter = 0;
uint32_t lastBackupDigiTime = millis();
uint32_t lastWiFiCheck = 0;
-uint32_t lastInternetCheck = 0;
namespace WIFI_Utils {
- bool checkInternetConnection() {
- HTTPClient http;
- String serverUrl = Config.aprs_is.server;
- if (!serverUrl.startsWith("http://") && !serverUrl.startsWith("https://")) {
- serverUrl = "http://" + serverUrl;
- }
- serverUrl += ":";
- serverUrl += String(Config.aprs_is.port);
- http.begin(serverUrl);
- //http.begin("http://connectivitycheck.gstatic.com/generate_204"); // Google Connectivity Detection Endpoint
- http.setTimeout(3000);
- http.setConnectTimeout(2000);
-
- int httpCode = http.GET();
- http.end();
- return (httpCode > 0 && httpCode < 400); // Accepting any 'OK' response
-
- /*if (httpCode == 204 || httpCode == HTTP_CODE_OK) {
- return true;
- } else {
- Serial.printf("Internet: FAIL (Code: %d)\n", httpCode);
- return false;
- }*/
- }
-
void checkWiFi() {
if (Config.digi.ecoMode != 0) return;
uint32_t currentTime = millis();
@@ -84,18 +58,14 @@ namespace WIFI_Utils {
}
}
- if (!backUpDigiMode && ((currentTime - lastWiFiCheck) >= 60 * 1000) && !WiFiAutoAPStarted) {
+ if (!backUpDigiMode && ((currentTime - lastWiFiCheck) >= 30 * 1000) && !WiFiAutoAPStarted) {
lastWiFiCheck = currentTime;
if (WiFi.status() == WL_CONNECTED) {
- if (Config.backupDigiMode && (currentTime - lastInternetCheck > 5 * 60 * 1000)) {
- lastInternetCheck = currentTime;
- bool internetOK = checkInternetConnection();
- if (!internetOK && Config.backupDigiMode) {
- Serial.println("*** Internet LOST → Backup Digi Mode ***");
- backUpDigiMode = true;
- WiFi.disconnect();
- lastBackupDigiTime = currentTime;
- }
+ if (Config.backupDigiMode && (currentTime - lastServerCheck > 60 * 1000)) {
+ Serial.println("*** Server Connection LOST → Backup Digi Mode ***");
+ backUpDigiMode = true;
+ WiFi.disconnect();
+ lastBackupDigiTime = currentTime;
}
} else {
Serial.println("Reconnecting to WiFi...");