2023-06-07 23:25:50 +02:00
|
|
|
#include "configuration.h"
|
2023-06-08 01:34:18 +02:00
|
|
|
#include "lora_utils.h"
|
2023-06-08 05:55:31 +02:00
|
|
|
#include "digi_utils.h"
|
|
|
|
|
#include "display.h"
|
2023-06-09 07:12:13 +02:00
|
|
|
#include "utils.h"
|
2023-06-07 23:25:50 +02:00
|
|
|
|
|
|
|
|
extern Configuration Config;
|
2023-06-09 07:12:13 +02:00
|
|
|
//extern String thirdLine;
|
|
|
|
|
//extern String fourthLine;
|
2023-06-07 23:25:50 +02:00
|
|
|
extern int stationMode;
|
2023-06-08 05:55:31 +02:00
|
|
|
extern uint32_t lastScreenOn;
|
2023-06-07 23:25:50 +02:00
|
|
|
|
|
|
|
|
namespace DIGI_Utils {
|
|
|
|
|
|
2023-06-09 07:12:13 +02:00
|
|
|
/*void typeOfPacket(String packet) {
|
2023-06-07 23:25:50 +02:00
|
|
|
String Sender = packet.substring(3,packet.indexOf(">"));
|
|
|
|
|
if (packet.indexOf("::") >= 10) {
|
|
|
|
|
thirdLine = "Callsign = " + Sender;
|
|
|
|
|
fourthLine = "TYPE ----> MESSAGE";
|
|
|
|
|
} else if (packet.indexOf(":>") >= 10) {
|
|
|
|
|
thirdLine = "Callsign = " + Sender;
|
|
|
|
|
fourthLine = "TYPE ----> NEW STATUS";
|
|
|
|
|
} else if (packet.indexOf(":!") >= 10 || packet.indexOf(":=") >= 10) {
|
|
|
|
|
thirdLine = "Callsign = " + Sender;
|
|
|
|
|
fourthLine = "TYPE ----> GPS BEACON";
|
|
|
|
|
} else {
|
|
|
|
|
thirdLine = "Callsign = " + Sender;
|
|
|
|
|
fourthLine = "TYPE ----> ??????????";
|
|
|
|
|
}
|
2023-06-09 07:12:13 +02:00
|
|
|
}*/
|
2023-06-07 23:25:50 +02:00
|
|
|
|
2023-06-08 03:25:31 +02:00
|
|
|
void processPacket(String packet) {
|
2023-06-09 01:31:27 +02:00
|
|
|
String firstPart, lastPart, loraPacket;
|
2023-06-07 23:25:50 +02:00
|
|
|
if (packet != "") {
|
2023-06-08 01:34:18 +02:00
|
|
|
Serial.print("Received Lora Packet : " + String(packet));
|
2023-06-09 06:23:11 +02:00
|
|
|
if ((packet.substring(0, 3) == "\x3c\xff\x01") && (packet.indexOf("NOGATE") == -1)) {
|
2023-06-08 01:34:18 +02:00
|
|
|
Serial.println(" ---> APRS LoRa Packet");
|
2023-06-09 06:23:11 +02:00
|
|
|
if ((stationMode==3) && (packet.indexOf("WIDE1-1") > 10)) {
|
2023-06-09 07:12:13 +02:00
|
|
|
utils::typeOfPacket(packet);
|
2023-06-09 06:23:11 +02:00
|
|
|
firstPart = packet.substring(3,packet.indexOf(",")+1);
|
|
|
|
|
lastPart = packet.substring(packet.indexOf(":"));
|
|
|
|
|
loraPacket = firstPart + Config.callsign + "*" + lastPart;
|
|
|
|
|
delay(500);
|
|
|
|
|
LoRa_Utils::sendNewPacket("APRS", loraPacket);
|
|
|
|
|
display_toggle(true);
|
|
|
|
|
lastScreenOn = millis();
|
|
|
|
|
} else { // stationMode = 4
|
2023-06-09 07:12:13 +02:00
|
|
|
utils::typeOfPacket(packet);
|
2023-06-09 06:23:11 +02:00
|
|
|
firstPart = packet.substring(3,packet.indexOf(",")+1);
|
|
|
|
|
lastPart = packet.substring(packet.indexOf(",")+1);
|
|
|
|
|
loraPacket = firstPart + Config.callsign + lastPart; // se agrega "*"" ???
|
|
|
|
|
delay(500);
|
|
|
|
|
if (stationMode == 4) { // Digirepeating with Freq Rx != Tx
|
|
|
|
|
LoRa_Utils::changeFreqTx();
|
|
|
|
|
}
|
|
|
|
|
LoRa_Utils::sendNewPacket("APRS", loraPacket);
|
|
|
|
|
if (stationMode == 4) {
|
|
|
|
|
LoRa_Utils::changeFreqRx();
|
|
|
|
|
}
|
|
|
|
|
display_toggle(true);
|
|
|
|
|
lastScreenOn = millis();
|
2023-06-08 02:55:38 +02:00
|
|
|
}
|
2023-06-07 23:25:50 +02:00
|
|
|
} else {
|
2023-06-08 01:34:18 +02:00
|
|
|
Serial.println(" ---> LoRa Packet Ignored (first 3 bytes or NOGATE)\n");
|
2023-06-07 23:25:50 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|