Skip to content

Commit

Permalink
update in APRS listening
Browse files Browse the repository at this point in the history
  • Loading branch information
richonguzman committed Mar 27, 2024
1 parent 110c6d6 commit 1365ae6
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 37 deletions.
6 changes: 5 additions & 1 deletion src/LoRa_APRS_iGate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ void loop() {

if (packet != "") {
if (Config.aprs_is.active) { // If APRSIS enabled
APRS_IS_Utils::loop(packet); // Send received packet to APRSIS
APRS_IS_Utils::processLoRaPacket(packet); // Send received packet to APRSIS
}

if (Config.digi.mode == 2) { // If Digi enabled
Expand All @@ -140,5 +140,9 @@ void loop() {
}
}

if (Config.aprs_is.active) { // If APRSIS enabled
APRS_IS_Utils::listenAPRSIS(); // listen received packet from APRSIS
}

show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0);
}
66 changes: 31 additions & 35 deletions src/aprs_is_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,33 +131,35 @@ namespace APRS_IS_Utils {
}

void processLoRaPacket(String packet) {
bool queryMessage = false;
String aprsPacket, Sender, AddresseeAndMessage, Addressee;
if (packet != "") {
if ((packet.substring(0, 3) == "\x3c\xff\x01") && (packet.indexOf("TCPIP") == -1) && (packet.indexOf("NOGATE") == -1) && (packet.indexOf("RFONLY") == -1)) {
Sender = packet.substring(3, packet.indexOf(">"));
STATION_Utils::updateLastHeard(Sender);
//STATION_Utils::updatePacketBuffer(packet);
Utils::typeOfPacket(aprsPacket, "LoRa-APRS");
if (Sender != Config.callsign) { // avoid listening yourself by digirepeating
AddresseeAndMessage = packet.substring(packet.indexOf("::") + 2);
Addressee = AddresseeAndMessage.substring(0, AddresseeAndMessage.indexOf(":"));
Addressee.trim();

if (packet.indexOf("::") > 10 && Addressee == Config.callsign) { // its a message for me!
queryMessage = processReceivedLoRaMessage(Sender, AddresseeAndMessage);
}
if (!queryMessage) {
aprsPacket = createPacket(packet);
if (!Config.display.alwaysOn) {
display_toggle(true);
if (espClient.connected()) {
bool queryMessage = false;
String aprsPacket, Sender, AddresseeAndMessage, Addressee;
if (packet != "") {
if ((packet.substring(0, 3) == "\x3c\xff\x01") && (packet.indexOf("TCPIP") == -1) && (packet.indexOf("NOGATE") == -1) && (packet.indexOf("RFONLY") == -1)) {
Sender = packet.substring(3, packet.indexOf(">"));
STATION_Utils::updateLastHeard(Sender);
//STATION_Utils::updatePacketBuffer(packet);
Utils::typeOfPacket(aprsPacket, "LoRa-APRS");
if (Sender != Config.callsign) { // avoid listening yourself by digirepeating
AddresseeAndMessage = packet.substring(packet.indexOf("::") + 2);
Addressee = AddresseeAndMessage.substring(0, AddresseeAndMessage.indexOf(":"));
Addressee.trim();

if (packet.indexOf("::") > 10 && Addressee == Config.callsign) { // its a message for me!
queryMessage = processReceivedLoRaMessage(Sender, AddresseeAndMessage);
}
if (!queryMessage) {
aprsPacket = createPacket(packet);
if (!Config.display.alwaysOn) {
display_toggle(true);
}
lastScreenOn = millis();
upload(aprsPacket);
Utils::println("---> Uploaded to APRS-IS");
STATION_Utils::updateLastHeard(Sender);
Utils::typeOfPacket(aprsPacket, "LoRa-APRS");
show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0);
}
lastScreenOn = millis();
upload(aprsPacket);
Utils::println("---> Uploaded to APRS-IS");
STATION_Utils::updateLastHeard(Sender);
Utils::typeOfPacket(aprsPacket, "LoRa-APRS");
show_display(firstLine, secondLine, thirdLine, fourthLine, fifthLine, sixthLine, seventhLine, 0);
}
}
}
Expand All @@ -183,8 +185,7 @@ namespace APRS_IS_Utils {
String ackPacket = Config.callsign + ">APLRG1,TCPIP,qAC::" + Sender + ":" + ackMessage;// + "\n";
upload(ackPacket);
receivedMessage = AddresseeAndMessage.substring(AddresseeAndMessage.indexOf(":") + 1, AddresseeAndMessage.indexOf("{"));
}
else {
} else {
receivedMessage = AddresseeAndMessage.substring(AddresseeAndMessage.indexOf(":") + 1);
}
if (receivedMessage.indexOf("?") == 0) {
Expand All @@ -206,8 +207,7 @@ namespace APRS_IS_Utils {
sixthLine += "> " + Sender;
seventhLine = "QUERY = " + receivedMessage;
}
}
else {
} else {
Utils::print("Received from APRS-IS : " + packet);

if (Config.aprs_is.toRF && STATION_Utils::wasHeard(Addressee)) {
Expand All @@ -222,15 +222,11 @@ namespace APRS_IS_Utils {
}
}

void loop(String packet) {
void listenAPRSIS() {
if (espClient.connected()) {
processLoRaPacket(packet);

if (espClient.available()) {
String aprsisPacket = espClient.readStringUntil('\r');

// Serial.println(aprsisPacket);

processAPRSISPacket(aprsisPacket);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/aprs_is_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace APRS_IS_Utils {
bool processReceivedLoRaMessage(String sender, String packet);
void processLoRaPacket(String packet);
void processAPRSISPacket(String packet);
void loop(String packet);
void listenAPRSIS();

}

Expand Down

0 comments on commit 1365ae6

Please sign in to comment.