diff --git a/data/igate_conf.json b/data/igate_conf.json index e8e8fab..7244880 100644 --- a/data/igate_conf.json +++ b/data/igate_conf.json @@ -90,7 +90,8 @@ "lowVoltageCutOff": 0, "backupDigiMode": false, "rebootMode": false, - "rebootModeTime": 6 + "rebootModeTime": 6, + "blackList": "" }, "personalNote": "" } \ No newline at end of file diff --git a/include/configuration.h b/include/configuration.h index 160c0ce..41aba67 100644 --- a/include/configuration.h +++ b/include/configuration.h @@ -50,7 +50,6 @@ public: bool ecoMode; }; - class LoraModule { public: long txFreq; @@ -135,6 +134,7 @@ public: bool rebootMode; int rebootModeTime; String personalNote; + String blackList; std::vector wifiAPs; WiFi_Auto_AP wifiAutoAP; BEACON beacon; diff --git a/include/station_utils.h b/include/station_utils.h index 0782e8d..604110c 100644 --- a/include/station_utils.h +++ b/include/station_utils.h @@ -18,6 +18,8 @@ struct LastHeardStation { namespace STATION_Utils { + void loadBlackList(); + bool checkBlackList(const String& callsign); void deleteNotHeard(); void updateLastHeard(const String& station); bool wasHeard(const String& station); diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index 617c2c2..99ef198 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -48,7 +48,7 @@ ___________________________________________________________________*/ #include "A7670_utils.h" #endif -String versionDate = "2024.12.31"; +String versionDate = "2025.01.01"; Configuration Config; WiFiClient espClient; #ifdef HAS_GPS @@ -79,6 +79,7 @@ void setup() { LoRa_Utils::setup(); Utils::validateFreqs(); GPS_Utils::setup(); + STATION_Utils::loadBlackList(); #ifdef STARTUP_DELAY // (TEST) just to wait for WiFi init of Routers displayShow("", " STARTUP DELAY ...", "", "", 0); diff --git a/src/aprs_is_utils.cpp b/src/aprs_is_utils.cpp index 0643680..ef6afdc 100644 --- a/src/aprs_is_utils.cpp +++ b/src/aprs_is_utils.cpp @@ -178,7 +178,7 @@ namespace APRS_IS_Utils { int firstColonIndex = packet.indexOf(":"); if (firstColonIndex > 5 && firstColonIndex < (packet.length() - 1) && packet[firstColonIndex + 1] != '}' && packet.indexOf("TCPIP") == -1) { const String& Sender = packet.substring(3, packet.indexOf(">")); - if (Sender != Config.callsign && Utils::checkValidCallsign(Sender)) { + if (Sender != Config.callsign && Utils::checkValidCallsign(Sender) && !STATION_Utils::checkBlackList(Sender)) { STATION_Utils::updateLastHeard(Sender); Utils::typeOfPacket(packet.substring(3), 0); // LoRa-APRS const String& AddresseeAndMessage = packet.substring(packet.indexOf("::") + 2); diff --git a/src/configuration.cpp b/src/configuration.cpp index 59170b7..f79cce6 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -99,6 +99,8 @@ void Configuration::writeFile() { data["personalNote"] = personalNote; + data["blackList"] = blackList; + data["webadmin"]["active"] = webadmin.active; data["webadmin"]["username"] = webadmin.username; data["webadmin"]["password"] = webadmin.password; @@ -221,6 +223,8 @@ bool Configuration::readFile() { personalNote = data["personalNote"] | "personal note here..."; + blackList = data["blackList"] | ""; + if (wifiAPs.size() == 0) { // If we don't have any WiFi's from config we need to add "empty" SSID for AUTO AP WiFi_AP wifiap; wifiap.ssid = ""; @@ -327,6 +331,8 @@ void Configuration::init() { personalNote = ""; + blackList = ""; + webadmin.active = false; webadmin.username = "admin"; webadmin.password = ""; diff --git a/src/digi_utils.cpp b/src/digi_utils.cpp index 1b0e007..d5ed999 100644 --- a/src/digi_utils.cpp +++ b/src/digi_utils.cpp @@ -130,7 +130,7 @@ namespace DIGI_Utils { temp = packet.substring(3); Sender = packet.substring(3, packet.indexOf(">")); } - if (Sender != Config.callsign) { // Avoid listening to own packets + if (Sender != Config.callsign && !STATION_Utils::checkBlackList(Sender)) { // Avoid listening to own packets if (!thirdPartyPacket && !Utils::checkValidCallsign(Sender)) { return; } diff --git a/src/station_utils.cpp b/src/station_utils.cpp index 1bae7a5..fd5e535 100644 --- a/src/station_utils.cpp +++ b/src/station_utils.cpp @@ -16,12 +16,47 @@ uint32_t lastTxTime = millis(); std::vector lastHeardStations; std::vector outputPacketBuffer; std::vector packet25SegBuffer; +std::vector blackList; bool saveNewDigiEcoModeConfig = false; namespace STATION_Utils { + void loadBlackList() { + if (Config.blackList != "") { + String callsigns = Config.blackList; + int spaceIndex = callsigns.indexOf(" "); + + while (spaceIndex >= 0) { + blackList.push_back(callsigns.substring(0, spaceIndex)); + callsigns = callsigns.substring(spaceIndex + 1); + spaceIndex = callsigns.indexOf(" "); + } + callsigns.trim(); + if (callsigns.length() > 0) blackList.push_back(callsigns); // Add the last word if available + + + // Print the vector + if (!blackList.empty()) { + for (int i = 0; i < blackList.size(); i++) { + Serial.println(blackList[i]); + } + } + // + } + } + + bool checkBlackList(const String& callsign) { + if (!blackList.empty()) { + for (int i = 0; i < blackList.size(); i++) { + if (blackList[i] == callsign) return true; + } + } + return false; + } + + void deleteNotHeard() { std::vector lastHeardStation_temp; for (int i = 0; i < lastHeardStations.size(); i++) { @@ -72,6 +107,7 @@ namespace STATION_Utils { Utils::println(" ---> Station not Heard for last 30 min (Not Tx)\n"); return false; } + void clean25SegBuffer() { if (!packet25SegBuffer.empty() && (millis() - packet25SegBuffer[0].receivedTime) > 25 * 1000) packet25SegBuffer.erase(packet25SegBuffer.begin()); }