mirror of
https://github.com/richonguzman/LoRa_APRS_iGate.git
synced 2026-08-08 18:03:02 +02:00
querys update
This commit is contained in:
+9
-22
@@ -10,6 +10,7 @@
|
||||
#include "aprs_is_utils.h"
|
||||
#include "gps_utils.h"
|
||||
#include "station_utils.h"
|
||||
#include "query_utils.h"
|
||||
#include "utils.h"
|
||||
|
||||
/*#include <AsyncTCP.h>
|
||||
@@ -38,20 +39,7 @@ std::vector<String> lastHeardStation_temp;
|
||||
|
||||
String firstLine, secondLine, thirdLine, fourthLine, iGateBeaconPacket;
|
||||
|
||||
String createAPRSPacket(String unprocessedPacket) {
|
||||
String callsign_and_path_tracker, payload_tracker, processedPacket;
|
||||
int dotsPosition = unprocessedPacket.indexOf(':');
|
||||
callsign_and_path_tracker = unprocessedPacket.substring(3, dotsPosition);
|
||||
payload_tracker = unprocessedPacket.substring(dotsPosition);
|
||||
if (Config.loramodule.enableTx) {
|
||||
processedPacket = callsign_and_path_tracker + ",qAR," + Config.callsign + payload_tracker + "\n";
|
||||
} else {
|
||||
processedPacket = callsign_and_path_tracker + ",qAO," + Config.callsign + payload_tracker + "\n";
|
||||
}
|
||||
return processedPacket;
|
||||
}
|
||||
|
||||
String processQueryAnswer(String query, String station, String queryOrigin) {
|
||||
/*String processQueryAnswer(String query, String station, String queryOrigin) {
|
||||
String processedQuery, queryAnswer;
|
||||
if (query=="?APRS?" || query=="?aprs?" || query=="?Aprs?" || query=="H" || query=="h" || query=="Help" || query=="help" || query=="?") {
|
||||
processedQuery = "?APRSV ?APRSP ?APRSL ?APRSH ?WHERE callsign";
|
||||
@@ -72,7 +60,7 @@ String processQueryAnswer(String query, String station, String queryOrigin) {
|
||||
// agregar callsign para completar donde esta X callsign
|
||||
Serial.println("estaciones escuchadas directo (ultimos 30 min)");
|
||||
processedQuery = "WHERE";
|
||||
}*/
|
||||
}
|
||||
for(int i = station.length(); i < 9; i++) {
|
||||
station += ' ';
|
||||
}
|
||||
@@ -82,7 +70,7 @@ String processQueryAnswer(String query, String station, String queryOrigin) {
|
||||
queryAnswer = Config.callsign + ">APLR10,RFONLY::" + station + ":" + processedQuery;
|
||||
}
|
||||
return queryAnswer;
|
||||
}
|
||||
}*/
|
||||
|
||||
void checkReceivedPacket(String packet) {
|
||||
bool queryMessage = false;
|
||||
@@ -113,28 +101,27 @@ void checkReceivedPacket(String packet) {
|
||||
}
|
||||
if (receivedMessage.indexOf("?") == 0) {
|
||||
queryMessage = true;
|
||||
String queryAnswer = processQueryAnswer(receivedMessage, Sender, "LoRa");
|
||||
//String queryAnswer = QUERY_Utils::process(receivedMessage, Sender, "LoRa");
|
||||
delay(2000);
|
||||
if (!Config.display.alwaysOn) {
|
||||
display_toggle(true);
|
||||
}
|
||||
LoRaUtils::sendNewPacket("APRS", QUERY_Utils::process(receivedMessage, Sender, "LoRa"));
|
||||
lastRxTxTime = millis();
|
||||
LoRaUtils::sendNewPacket("APRS", queryAnswer);
|
||||
//LoRaUtils::sendNewPacket("APRS", queryAnswer);
|
||||
show_display(firstLine, secondLine, "Callsign = " + Sender, "TYPE --> QUERY", 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!queryMessage) {
|
||||
aprsPacket = createAPRSPacket(packet);
|
||||
aprsPacket = APRS_IS_Utils::createPacket(packet);
|
||||
if (!Config.display.alwaysOn) {
|
||||
display_toggle(true);
|
||||
}
|
||||
lastRxTxTime = millis();
|
||||
espClient.write(aprsPacket.c_str());
|
||||
Serial.println(" ---> Uploaded to APRS-IS");
|
||||
//STATION_Utils::deleteNotHeardStation();
|
||||
//updateLastHeardStation(Sender);
|
||||
STATION_Utils::updateLastHeard(Sender);
|
||||
if (aprsPacket.indexOf("::") >= 10) {
|
||||
show_display(firstLine, secondLine, "Callsign = " + Sender, "TYPE --> MESSAGE", 1000);
|
||||
@@ -261,7 +248,7 @@ void loop() {
|
||||
}
|
||||
if (receivedMessage.indexOf("?") == 0) {
|
||||
Serial.println("Received Query APRS-IS : " + aprsisPacket);
|
||||
String queryAnswer = processQueryAnswer(receivedMessage, Sender, "APRSIS");
|
||||
String queryAnswer = QUERY_Utils::process(receivedMessage, Sender, "APRSIS");
|
||||
Serial.println("---> QUERY Answer : " + queryAnswer.substring(0,queryAnswer.indexOf("\n")));
|
||||
if (!Config.display.alwaysOn) {
|
||||
display_toggle(true);
|
||||
|
||||
@@ -57,6 +57,14 @@ String checkStatus() {
|
||||
return "WiFi: " + wifiState + "/ APRS-IS: " + aprsisState;
|
||||
}
|
||||
|
||||
String createPacket(String packet) {
|
||||
if (Config.loramodule.enableTx) {
|
||||
return packet.substring(3, packet.indexOf(':')) + ",qAR," + Config.callsign + packet.substring(packet.indexOf(':')) + "\n";
|
||||
} else {
|
||||
return packet.substring(3, packet.indexOf(':')) + ",qAO," + Config.callsign + packet.substring(packet.indexOf(':')) + "\n";
|
||||
}
|
||||
}
|
||||
|
||||
/*void processSplitedMessage(String addressee, String message1, String message2) {
|
||||
espClient.write((Config.callsign + ">APRS,qAC::" + addressee + ":" + message1 + "\n").c_str());
|
||||
Serial.println("-------> " + message1);
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace APRS_IS_Utils {
|
||||
|
||||
void connect();
|
||||
String checkStatus();
|
||||
String createPacket(String unprocessedPacket);
|
||||
//void processSplitedMessage(String addressee, String message1, String message2);
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -3,8 +3,8 @@
|
||||
|
||||
extern Configuration Config;
|
||||
extern WiFi_AP *currentWiFi;
|
||||
extern int myWiFiAPIndex;
|
||||
extern int myWiFiAPSize;
|
||||
//extern int myWiFiAPIndex;
|
||||
//extern int myWiFiAPSize;
|
||||
|
||||
namespace GPS_Utils {
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
#include "query_utils.h"
|
||||
#include "configuration.h"
|
||||
|
||||
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") {
|
||||
answer = Config.aprs_is.softwareName + " " + Config.aprs_is.softwareVersion;
|
||||
} 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") {
|
||||
return Config.callsign + ">APLR10,TCPIP,qAC::" + station + ":" + answer + "\n";
|
||||
} else { //} if (queryOrigin == "LoRa") {
|
||||
return Config.callsign + ">APLR10,RFONLY::" + station + ":" + answer;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
#ifndef QUERY_UTILS_H_
|
||||
#define QUERY_UTILS_H_
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
namespace QUERY_Utils {
|
||||
|
||||
String process(String query, String station, String queryOrigin);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user