From b688391a0e60940d45512ba50fd088ccd577ff04 Mon Sep 17 00:00:00 2001 From: richonguzman Date: Wed, 1 Jan 2025 21:42:37 -0300 Subject: [PATCH] wildcard and two stations blacklisted OK --- data/igate_conf.json | 6 +++--- data_embed/index.html | 41 +++++++++++++++++++++++++++++++++++++++++ data_embed/script.js | 3 +++ src/configuration.cpp | 4 ++-- src/station_utils.cpp | 18 ++++++------------ src/web_utils.cpp | 2 ++ 6 files changed, 57 insertions(+), 17 deletions(-) diff --git a/data/igate_conf.json b/data/igate_conf.json index 7244880..8f7c46e 100644 --- a/data/igate_conf.json +++ b/data/igate_conf.json @@ -90,8 +90,8 @@ "lowVoltageCutOff": 0, "backupDigiMode": false, "rebootMode": false, - "rebootModeTime": 6, - "blackList": "" + "rebootModeTime": 6 }, - "personalNote": "" + "personalNote": "", + "blackList": "" } \ No newline at end of file diff --git a/data_embed/index.html b/data_embed/index.html index 4c252a5..43cdb82 100644 --- a/data_embed/index.html +++ b/data_embed/index.html @@ -573,6 +573,47 @@

+
+
+
+ + + + Black List +
+ Add Callsigns with space between them to Black List them (* wild card allowed) +
+
+
+
+ + +
+
+
+
+
+
diff --git a/data_embed/script.js b/data_embed/script.js index 80f11c5..9ad3d7b 100644 --- a/data_embed/script.js +++ b/data_embed/script.js @@ -137,6 +137,9 @@ function loadSettings(settings) { document.getElementById("beacon.gpsActive").checked = settings.beacon.gpsActive; document.getElementById("beacon.gpsAmbiguity").checked = settings.beacon.gpsAmbiguity; + // Black List + document.getElementById("blackList").value = settings.blackList; + // Digi document.getElementById("digi.mode").value = settings.digi.mode; document.getElementById("digi.ecoMode").checked = settings.digi.ecoMode; diff --git a/src/configuration.cpp b/src/configuration.cpp index f79cce6..de6b08e 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -221,9 +221,9 @@ bool Configuration::readFile() { rebootMode = data["other"]["rebootMode"] | false; rebootModeTime = data["other"]["rebootModeTime"] | 6; - personalNote = data["personalNote"] | "personal note here..."; + personalNote = data["personalNote"] | "personal note here"; - blackList = data["blackList"] | ""; + blackList = data["blackList"] | "station callsign"; 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; diff --git a/src/station_utils.cpp b/src/station_utils.cpp index fd5e535..8084027 100644 --- a/src/station_utils.cpp +++ b/src/station_utils.cpp @@ -35,23 +35,17 @@ namespace STATION_Utils { } 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++) { + for (int i = 0; i < blackList.size(); i++) { + if (blackList[i].indexOf("*") >= 0) { // use wild card + String wildCard = blackList[i].substring(0, blackList[i].indexOf("*")); + if (callsign.startsWith(wildCard))return true; + } else { if (blackList[i] == callsign) return true; - } + } } return false; } diff --git a/src/web_utils.cpp b/src/web_utils.cpp index d3bae52..3181cca 100644 --- a/src/web_utils.cpp +++ b/src/web_utils.cpp @@ -206,6 +206,8 @@ namespace WEB_Utils { Config.personalNote = request->getParam("personalNote", true)->value(); + Config.blackList = request->getParam("blackList", true)->value(); + Config.webadmin.active = request->hasParam("webadmin.active", true); if (Config.webadmin.active) { Config.webadmin.username = request->getParam("webadmin.username", true)->value();