2023-09-21 07:08:10 +02:00
|
|
|
#include <WiFi.h>
|
2023-06-07 23:25:50 +02:00
|
|
|
#include "configuration.h"
|
2023-06-19 06:52:40 +02:00
|
|
|
#include "station_utils.h"
|
2023-09-21 07:08:10 +02:00
|
|
|
#include "aprs_is_utils.h"
|
2024-03-18 14:38:16 +01:00
|
|
|
#include "query_utils.h"
|
2023-06-08 05:55:31 +02:00
|
|
|
#include "digi_utils.h"
|
2023-09-21 07:08:10 +02:00
|
|
|
#include "wifi_utils.h"
|
2023-07-31 05:53:59 +02:00
|
|
|
#include "gps_utils.h"
|
2023-06-08 05:55:31 +02:00
|
|
|
#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-08 05:55:31 +02:00
|
|
|
extern uint32_t lastScreenOn;
|
2023-07-31 05:53:59 +02:00
|
|
|
extern String iGateBeaconPacket;
|
|
|
|
|
extern String firstLine;
|
|
|
|
|
extern String secondLine;
|
|
|
|
|
extern String thirdLine;
|
|
|
|
|
extern String fourthLine;
|
|
|
|
|
extern String fifthLine;
|
|
|
|
|
extern String sixthLine;
|
|
|
|
|
extern String seventhLine;
|
2024-05-22 21:29:00 +02:00
|
|
|
extern bool backUpDigiMode;
|
2023-06-07 23:25:50 +02:00
|
|
|
|
2024-02-25 16:00:44 +01:00
|
|
|
|
2023-06-07 23:25:50 +02:00
|
|
|
namespace DIGI_Utils {
|
|
|
|
|
|
2024-06-20 20:06:14 +02:00
|
|
|
String buildPacket(const String& path, const String& packet, bool thirdParty) {
|
|
|
|
|
String packetToRepeat = packet.substring(0, packet.indexOf(",") + 1);
|
|
|
|
|
String tempPath = path;
|
|
|
|
|
tempPath.replace(Config.beacon.path, Config.callsign + "*");
|
|
|
|
|
packetToRepeat += tempPath;
|
|
|
|
|
if (thirdParty) {
|
|
|
|
|
packetToRepeat += APRS_IS_Utils::checkForStartingBytes(packet.substring(packet.indexOf(":}")));
|
|
|
|
|
} else {
|
|
|
|
|
packetToRepeat += APRS_IS_Utils::checkForStartingBytes(packet.substring(packet.indexOf(":")));
|
2024-06-21 08:13:34 +02:00
|
|
|
}
|
2024-06-20 20:06:14 +02:00
|
|
|
return packetToRepeat;
|
|
|
|
|
}
|
2024-05-30 22:27:07 +02:00
|
|
|
|
2024-06-20 20:06:14 +02:00
|
|
|
String generateDigiRepeatedPacket(const String& packet, bool thirdParty){
|
2024-06-21 03:12:54 +02:00
|
|
|
String temp;
|
2024-06-20 20:06:14 +02:00
|
|
|
if (thirdParty) { // only header is used
|
2024-06-21 03:12:54 +02:00
|
|
|
const String& header = packet.substring(0, packet.indexOf(":}"));
|
2024-06-20 20:06:14 +02:00
|
|
|
temp = header.substring(header.indexOf(">") + 1);
|
|
|
|
|
} else {
|
|
|
|
|
temp = packet.substring(packet.indexOf(">") + 1, packet.indexOf(":"));
|
|
|
|
|
}
|
|
|
|
|
if (temp.indexOf(",") > 2) { // checks for path
|
2024-06-21 08:13:34 +02:00
|
|
|
const String& path = temp.substring(temp.indexOf(",") + 1); // after tocall
|
2024-06-20 20:06:14 +02:00
|
|
|
if (path.indexOf(Config.beacon.path) != -1) {
|
|
|
|
|
return buildPacket(path, packet, thirdParty);
|
2024-06-03 06:02:43 +02:00
|
|
|
} else {
|
2024-03-07 17:46:38 +01:00
|
|
|
return "";
|
2024-01-12 05:36:04 +01:00
|
|
|
}
|
2024-06-03 06:02:43 +02:00
|
|
|
} else {
|
2024-03-07 17:46:38 +01:00
|
|
|
return "";
|
2024-01-12 05:36:04 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-21 03:12:54 +02:00
|
|
|
void processLoRaPacket(const String& packet) {
|
2023-09-21 03:27:02 +02:00
|
|
|
if (packet != "") {
|
2024-03-17 12:21:11 +01:00
|
|
|
if ((packet.substring(0, 3) == "\x3c\xff\x01") && (packet.indexOf("NOGATE") == -1)) {
|
2024-06-21 03:12:54 +02:00
|
|
|
bool thirdPartyPacket = false;
|
|
|
|
|
String temp, Sender;
|
2024-06-24 16:32:58 +02:00
|
|
|
int firstColonIndex = packet.indexOf(":");
|
2024-06-24 19:25:30 +02:00
|
|
|
if (firstColonIndex > 5 && firstColonIndex < (packet.length() - 1) && packet[firstColonIndex + 1] == '}' && packet.indexOf("TCPIP") > 0) { // 3rd Party
|
2024-06-21 03:12:54 +02:00
|
|
|
thirdPartyPacket = true;
|
|
|
|
|
temp = packet.substring(packet.indexOf(":}") + 2);
|
|
|
|
|
Sender = temp.substring(0, temp.indexOf(">"));
|
|
|
|
|
} else {
|
|
|
|
|
temp = packet.substring(3);
|
|
|
|
|
Sender = packet.substring(3, packet.indexOf(">"));
|
|
|
|
|
}
|
|
|
|
|
if (Sender != Config.callsign) { // Avoid listening to own packets
|
|
|
|
|
if (!thirdPartyPacket && !Utils::checkValidCallsign(Sender)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (STATION_Utils::check25SegBuffer(Sender, temp.substring(temp.indexOf(":") + 2))) {
|
|
|
|
|
STATION_Utils::updateLastHeard(Sender);
|
|
|
|
|
Utils::typeOfPacket(temp, 2); // Digi
|
|
|
|
|
bool queryMessage = false;
|
|
|
|
|
if (temp.indexOf("::") > 10) { // it's a message
|
|
|
|
|
String AddresseeAndMessage = temp.substring(temp.indexOf("::") + 2);
|
|
|
|
|
String Addressee = AddresseeAndMessage.substring(0, AddresseeAndMessage.indexOf(":"));
|
|
|
|
|
Addressee.trim();
|
|
|
|
|
if (Addressee == Config.callsign) { // it's a message for me!
|
|
|
|
|
queryMessage = APRS_IS_Utils::processReceivedLoRaMessage(Sender, AddresseeAndMessage);
|
2024-06-20 20:06:14 +02:00
|
|
|
}
|
2024-05-14 03:00:42 +02:00
|
|
|
}
|
2024-06-21 03:12:54 +02:00
|
|
|
if (!queryMessage) {
|
|
|
|
|
String loraPacket = generateDigiRepeatedPacket(packet.substring(3), thirdPartyPacket);
|
|
|
|
|
if (loraPacket != "") {
|
|
|
|
|
STATION_Utils::addToOutputPacketBuffer(loraPacket);
|
|
|
|
|
display_toggle(true);
|
|
|
|
|
lastScreenOn = millis();
|
2024-05-14 03:00:42 +02:00
|
|
|
}
|
2024-03-21 19:19:30 +01:00
|
|
|
}
|
2024-03-17 12:21:11 +01:00
|
|
|
}
|
2024-06-21 03:12:54 +02:00
|
|
|
}
|
2024-03-17 12:21:11 +01:00
|
|
|
}
|
2023-06-07 23:25:50 +02:00
|
|
|
}
|
|
|
|
|
}
|
2023-07-31 05:53:59 +02:00
|
|
|
|
2023-06-07 23:25:50 +02:00
|
|
|
}
|