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 WiFi_AP *currentWiFi;
|
|
|
|
|
extern std::vector<String> lastHeardStation;
|
|
|
|
|
extern std::vector<String> lastHeardStation_temp;
|
|
|
|
|
|
|
|
|
|
namespace QUERY_Utils {
|
|
|
|
|
|
|
|
|
|
String process(String query, String station, String queryOrigin) {
|
|
|
|
|
String answer;
|
|
|
|
|
if (query=="?APRS?" || query=="?aprs?" || query=="?Aprs?" || query=="H" || query=="h" || query=="Help" || query=="help" || query=="?") {
|
|
|
|
|
answer = "?APRSV ?APRSP ?APRSL ?APRSH ?WHERE callsign";
|
|
|
|
|
} else if (query=="?APRSV" || query=="?aprsv" || query=="?Aprsv") {
|
2023-06-09 01:31:27 +02:00
|
|
|
answer = "CD2RXU_LoRa_iGate 1.2";
|
2023-06-06 21:53:06 +02:00
|
|
|
} else if (query=="?APRSP" || query=="?aprsp" || query=="?Aprsp") {
|
|
|
|
|
answer = "iGate QTH: " + String(currentWiFi->latitude,2) + " " + String(currentWiFi->longitude,2);
|
|
|
|
|
} else if (query=="?APRSL" || query=="?aprsl" || query=="?Aprsl") {
|
|
|
|
|
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("?aprsv") == 0 || query.indexOf("?Aprsv") == 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!";
|
|
|
|
|
}
|
|
|
|
|
for(int i = station.length(); i < 9; i++) {
|
|
|
|
|
station += ' ';
|
|
|
|
|
}
|
|
|
|
|
if (queryOrigin == "APRSIS") {
|
2023-06-06 23:25:50 +02:00
|
|
|
return Config.callsign + ">APLRG1,TCPIP,qAC::" + station + ":" + answer + "\n";
|
2023-06-06 21:53:06 +02:00
|
|
|
} else { //} if (queryOrigin == "LoRa") {
|
2023-06-06 23:25:50 +02:00
|
|
|
return Config.callsign + ">APLRG1,RFONLY::" + station + ":" + answer;
|
2023-06-06 21:53:06 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|