new buildPacketToTx

This commit is contained in:
richonguzman 2024-05-21 00:00:23 -04:00
parent 7022046f21
commit 8be573e2b6
2 changed files with 34 additions and 9 deletions

View File

@ -107,12 +107,39 @@ namespace APRS_IS_Utils {
} }
} }
String buildPacketToTx(const String& aprsisPacket) { String buildPacketToTx(const String& aprsisPacket, uint8_t packetType) {
String packet = aprsisPacket; String packet = aprsisPacket;
packet.trim(); packet.trim();
String firstPart = packet.substring(0, packet.indexOf(",")); String outputPacket = packet.substring(0, packet.indexOf(",")) + ",TCPIP,WIDE1-1," + Config.callsign;
String messagePart = packet.substring(packet.indexOf("::") + 2); switch (packetType) {
return firstPart + ",TCPIP,WIDE1-1," + Config.callsign + "::" + messagePart; case 0: // gps
if (packet.indexOf(":=") > 0) {
outputPacket += packet.substring(packet.indexOf(":="));
} else {
outputPacket += packet.substring(packet.indexOf(":!"));
}
break;
case 1: // messages
outputPacket += packet.substring(packet.indexOf("::"));
break;
case 2: // status
outputPacket += packet.substring(packet.indexOf(":>"));
break;
case 3: // telemetry
outputPacket += packet.substring(packet.indexOf("::"));
break;
case 4: // mic-e
if (packet.indexOf(":`") > 0) {
outputPacket += packet.substring(packet.indexOf(":`"));
} else {
outputPacket += packet.substring(packet.indexOf(":'"));
}
break;
case 5: // object
outputPacket += packet.substring(packet.indexOf(":;"));
break;
}
return outputPacket;
} }
bool processReceivedLoRaMessage(const String& sender, const String& packet) { bool processReceivedLoRaMessage(const String& sender, const String& packet) {
@ -243,7 +270,7 @@ namespace APRS_IS_Utils {
Utils::print("Received Message from APRS-IS : " + packet); Utils::print("Received Message from APRS-IS : " + packet);
if (STATION_Utils::wasHeard(Addressee)) { if (STATION_Utils::wasHeard(Addressee)) {
STATION_Utils::addToOutputPacketBuffer(buildPacketToTx(packet)); STATION_Utils::addToOutputPacketBuffer(buildPacketToTx(packet, 1));
display_toggle(true); display_toggle(true);
lastScreenOn = millis(); lastScreenOn = millis();
Utils::typeOfPacket(packet, 1); // APRS-LoRa Utils::typeOfPacket(packet, 1); // APRS-LoRa
@ -252,9 +279,7 @@ namespace APRS_IS_Utils {
show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0); show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0);
} else if (Config.aprs_is.objectsToRF && packet.indexOf(":;") > 0) { } else if (Config.aprs_is.objectsToRF && packet.indexOf(":;") > 0) {
Utils::println("Received Object from APRS-IS : " + packet); Utils::println("Received Object from APRS-IS : " + packet);
// STATION_Utils::addToOutputPacketBuffer(buildPacketToTx(packet, 5));
// revisar que se enviara del output buffer!!!
//STATION_Utils::addToOutputPacketBuffer(buildPacketToTx(packet));
display_toggle(true); display_toggle(true);
lastScreenOn = millis(); lastScreenOn = millis();
Utils::typeOfPacket(packet, 1); // APRS-LoRa Utils::typeOfPacket(packet, 1); // APRS-LoRa

View File

@ -10,7 +10,7 @@ namespace APRS_IS_Utils {
void connect(); void connect();
void checkStatus(); void checkStatus();
String buildPacketToUpload(const String& packet); String buildPacketToUpload(const String& packet);
String buildPacketToTx(const String& aprsisPacket); String buildPacketToTx(const String& aprsisPacket, uint8_t packetType);
bool processReceivedLoRaMessage(const String& sender, const String& packet); bool processReceivedLoRaMessage(const String& sender, const String& packet);
void processLoRaPacket(const String& packet); void processLoRaPacket(const String& packet);
void processAPRSISPacket(const String& packet); void processAPRSISPacket(const String& packet);