2023-06-06 21:53:06 +02:00
|
|
|
#include "configuration.h"
|
2023-06-08 06:58:10 +02:00
|
|
|
#include "query_utils.h"
|
2023-06-06 21:53:06 +02:00
|
|
|
|
|
|
|
|
extern Configuration Config;
|
|
|
|
|
extern std::vector<String> lastHeardStation;
|
2023-06-09 14:34:34 +02:00
|
|
|
extern String versionDate;
|
2023-06-06 21:53:06 +02:00
|
|
|
|
2024-02-25 16:00:44 +01:00
|
|
|
|
2023-06-06 21:53:06 +02:00
|
|
|
namespace QUERY_Utils {
|
|
|
|
|
|
2024-05-15 23:47:29 +02:00
|
|
|
String process(const String& query, const String& station, uint8_t queryOrigin) {
|
2024-02-24 14:09:05 +01:00
|
|
|
String answer;
|
|
|
|
|
if (query=="?APRS?" || query=="?aprs?" || query=="?Aprs?" || query=="H" || query=="h" || query=="HELP" || query=="Help" || query=="help" || query=="?") {
|
|
|
|
|
answer = "?APRSV ?APRSP ?APRSL ?APRSH ?WHERE callsign";
|
|
|
|
|
} else if (query=="?APRSV" || query=="?aprsv" || query=="?Aprsv") {
|
2024-03-07 17:46:38 +01:00
|
|
|
answer = "CA2RXU_LoRa_iGate 1.3 v" + versionDate;
|
2024-02-24 14:09:05 +01:00
|
|
|
} else if (query=="?APRSP" || query=="?aprsp" || query=="?Aprsp") {
|
2024-03-07 17:46:38 +01:00
|
|
|
answer = "iGate QTH: " + String(Config.beacon.latitude,2) + " " + String(Config.beacon.longitude,2);
|
2024-02-24 14:09:05 +01:00
|
|
|
} else if (query=="?APRSL" || query=="?aprsl" || query=="?Aprsl") {
|
|
|
|
|
if (lastHeardStation.size() == 0) {
|
|
|
|
|
answer = "No Station Listened in the last " + String(Config.rememberStationTime) + "min.";
|
|
|
|
|
} else {
|
|
|
|
|
for (int i=0; i<lastHeardStation.size(); i++) {
|
|
|
|
|
answer += lastHeardStation[i].substring(0,lastHeardStation[i].indexOf(",")) + " ";
|
|
|
|
|
}
|
|
|
|
|
answer.trim();
|
|
|
|
|
}
|
|
|
|
|
} else if (query.indexOf("?APRSH") == 0 || query.indexOf("?aprsh") == 0 || query.indexOf("?Aprsh") == 0) {
|
|
|
|
|
// sacar callsign despues de ?APRSH
|
|
|
|
|
Serial.println("escuchaste a X estacion? en las ultimas 24 o 8 horas?");
|
|
|
|
|
answer = "APRSH on development 73!";
|
|
|
|
|
} else if (query.indexOf("?WHERE") == 0) {
|
|
|
|
|
// agregar callsign para completar donde esta X callsign --> posicion
|
|
|
|
|
Serial.println("estaciones escuchadas directo (ultimos 30 min)");
|
|
|
|
|
answer = "?WHERE on development 73!";
|
|
|
|
|
}
|
2024-05-15 23:47:29 +02:00
|
|
|
String processedStation = station;
|
2024-02-24 14:09:05 +01:00
|
|
|
for(int i = station.length(); i < 9; i++) {
|
2024-05-15 23:47:29 +02:00
|
|
|
processedStation += ' ';
|
2024-02-24 14:09:05 +01:00
|
|
|
}
|
2024-05-15 23:47:29 +02:00
|
|
|
if (queryOrigin == 1) { // from APRS-IS
|
|
|
|
|
return Config.callsign + ">APLRG1,TCPIP,qAC::" + processedStation + ":" + answer;
|
|
|
|
|
} else { // else == 0 , from LoRa
|
2024-04-04 20:54:49 +02:00
|
|
|
if (Config.beacon.path == "") {
|
2024-05-15 23:47:29 +02:00
|
|
|
return Config.callsign + ">APLRG1,RFONLY::" + processedStation + ":" + answer;
|
2024-04-04 20:54:49 +02:00
|
|
|
} else {
|
2024-05-15 23:47:29 +02:00
|
|
|
return Config.callsign + ">APLRG1,RFONLY," + Config.beacon.path + "::" + processedStation + ":" + answer;
|
2024-04-04 20:54:49 +02:00
|
|
|
}
|
2024-01-03 02:12:10 +01:00
|
|
|
}
|
2023-06-06 21:53:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|