less memory fixes too

This commit is contained in:
Ricardo Guzman (Richonguzman)
2026-02-20 17:36:26 -03:00
parent c887689406
commit f26ded5b5c
2 changed files with 33 additions and 31 deletions

View File

@@ -1,17 +1,17 @@
/* Copyright (C) 2025 Ricardo Guzman - CA2RXU /* Copyright (C) 2025 Ricardo Guzman - CA2RXU
* *
* This file is part of LoRa APRS iGate. * This file is part of LoRa APRS iGate.
* *
* LoRa APRS iGate is free software: you can redistribute it and/or modify * LoRa APRS iGate is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* LoRa APRS iGate is distributed in the hope that it will be useful, * LoRa APRS iGate is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with LoRa APRS iGate. If not, see <https://www.gnu.org/licenses/>. * along with LoRa APRS iGate. If not, see <https://www.gnu.org/licenses/>.
*/ */
@@ -24,7 +24,7 @@
██║ ██║ ██║██╔══██╗██╔══██║ ██╔══██║██╔═══╝ ██╔══██╗╚════██║ ██║ ██║ ██║██╔══██╗██╔══██║ ██╔══██║██╔═══╝ ██╔══██╗╚════██║
███████╗╚██████╔╝██║ ██║██║ ██║ ██║ ██║██║ ██║ ██║███████║ ███████╗╚██████╔╝██║ ██║██║ ██║ ██║ ██║██║ ██║ ██║███████║
╚══════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝╚══════╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝╚══════╝
██╗ ██████╗ █████╗ ████████╗███████╗ ██╗ ██████╗ █████╗ ████████╗███████╗
██║██╔════╝ ██╔══██╗╚══██╔══╝██╔════╝ ██║██╔════╝ ██╔══██╗╚══██╔══╝██╔════╝
██║██║ ███╗███████║ ██║ █████╗ ██║██║ ███╗███████║ ██║ █████╗
@@ -67,7 +67,7 @@ ___________________________________________________________________*/
#endif #endif
String versionDate = "2026-02-16"; String versionDate = "2026-02-20";
String versionNumber = "3.2"; String versionNumber = "3.2";
Configuration Config; Configuration Config;
WiFiClient aprsIsClient; WiFiClient aprsIsClient;
@@ -138,7 +138,7 @@ void loop() {
ElegantOTA.loop(); ElegantOTA.loop();
return; // Don't process IGate and Digi during OTA update return; // Don't process IGate and Digi during OTA update
} }
#ifdef HAS_GPS #ifdef HAS_GPS
if (Config.beacon.gpsActive) { if (Config.beacon.gpsActive) {
if (millis() - gpsSatelliteTime > 5000) { if (millis() - gpsSatelliteTime > 5000) {
@@ -174,7 +174,7 @@ void loop() {
Utils::checkDisplayInterval(); Utils::checkDisplayInterval();
Utils::checkBeaconInterval(); Utils::checkBeaconInterval();
APRS_IS_Utils::checkStatus(); // Need that to update display, maybe split this and send APRSIS status to display func? APRS_IS_Utils::checkStatus(); // Need that to update display, maybe split this and send APRSIS status to display func?
String packet = ""; String packet = "";

View File

@@ -44,37 +44,38 @@ extern bool backupDigiMode;
namespace DIGI_Utils { namespace DIGI_Utils {
String buildPacket(const String& path, const String& packet, bool thirdParty, bool crossFreq) { String buildPacket(const String& path, const String& packet, bool thirdParty, bool crossFreq) {
String stationCallsign = (Config.tacticalCallsign == "" ? Config.callsign : Config.tacticalCallsign);
if (!crossFreq) { if (!crossFreq) {
String packetToRepeat = packet.substring(0, packet.indexOf(",") + 1); String packetToRepeat = packet.substring(0, packet.indexOf(",") + 1);
String tempPath = path; String tempPath = path;
int digiMode = Config.digi.mode;
if (path.indexOf("WIDE1-1") != -1 && (Config.digi.mode == 2 || Config.digi.mode == 3)) { if (path.indexOf("WIDE1-1") != -1 && (digiMode == 2 || digiMode == 3)) {
tempPath.replace("WIDE1-1", (Config.tacticalCallsign == "" ? Config.callsign : Config.tacticalCallsign) + "*"); tempPath.replace("WIDE1-1", stationCallsign + "*");
} else if (path.indexOf("WIDE2-") != -1 && Config.digi.mode == 3) { } else if (path.indexOf("WIDE2-") != -1 && digiMode == 3) {
if (path.indexOf(",WIDE1*") != -1) { int wide1AsteriskIndex = path.indexOf(",WIDE1*"); // less memory than: tempPath.replace(",WIDE1*", "");
tempPath.remove(path.indexOf(",WIDE1*"), 7); if (wide1AsteriskIndex != -1) {
tempPath.remove(wide1AsteriskIndex, 7);
} }
if (path.indexOf("*") != -1) { int asteriskIndex = path.indexOf("*"); // less memory than: tempPath.replace("*", "");
tempPath.remove(path.indexOf("*"), 1); if (asteriskIndex != -1) {
tempPath.remove(asteriskIndex, 1);
} }
if (path.indexOf("WIDE2-1") != -1) { if (path.indexOf("WIDE2-1") != -1) {
tempPath.replace("WIDE2-1", (Config.tacticalCallsign == "" ? Config.callsign : Config.tacticalCallsign) + "*"); tempPath.replace("WIDE2-1", stationCallsign + "*");
} else if (path.indexOf("WIDE2-2") != -1) { } else if (path.indexOf("WIDE2-2") != -1) {
tempPath.replace("WIDE2-2", (Config.tacticalCallsign == "" ? Config.callsign : Config.tacticalCallsign) + "*,WIDE2-1"); tempPath.replace("WIDE2-2", stationCallsign + "*,WIDE2-1");
} else { } else {
return ""; return "";
} }
} }
packetToRepeat += tempPath; packetToRepeat += tempPath;
if (thirdParty) { packetToRepeat += APRS_IS_Utils::checkForStartingBytes(packet.substring(packet.indexOf(thirdParty ? ":}" : ":")));
packetToRepeat += APRS_IS_Utils::checkForStartingBytes(packet.substring(packet.indexOf(":}")));
} else {
packetToRepeat += APRS_IS_Utils::checkForStartingBytes(packet.substring(packet.indexOf(":")));
}
return packetToRepeat; return packetToRepeat;
} else { // CrossFreq Digipeater } else { // CrossFreq Digipeater
String suffix = thirdParty ? ":}" : ":"; String suffix = thirdParty ? ":}" : ":";
String packetToRepeat = packet.substring(0, packet.indexOf(suffix)); int suffixIndex = packet.indexOf(suffix);
String packetToRepeat = packet.substring(0, suffixIndex);
String terms[] = {",WIDE1*", ",WIDE2*", "*"}; String terms[] = {",WIDE1*", ",WIDE2*", "*"};
for (String term : terms) { for (String term : terms) {
@@ -84,9 +85,9 @@ namespace DIGI_Utils {
} }
} }
packetToRepeat += ","; packetToRepeat += ",";
packetToRepeat += (Config.tacticalCallsign == "" ? Config.callsign : Config.tacticalCallsign); packetToRepeat += stationCallsign;
packetToRepeat += "*"; packetToRepeat += "*";
packetToRepeat += APRS_IS_Utils::checkForStartingBytes(packet.substring(packet.indexOf(suffix))); packetToRepeat += APRS_IS_Utils::checkForStartingBytes(packet.substring(suffixIndex));
return packetToRepeat; return packetToRepeat;
} }
} }
@@ -149,19 +150,20 @@ namespace DIGI_Utils {
Sender = packet.substring(3, packet.indexOf(">")); Sender = packet.substring(3, packet.indexOf(">"));
} }
if (Sender == (Config.tacticalCallsign == "" ? Config.callsign : Config.tacticalCallsign)) return; // Avoid listening to self packets String stationCallsign = Config.tacticalCallsign == "" ? Config.callsign : Config.tacticalCallsign;
if (Sender == stationCallsign) return; // Avoid listening to self packets
if (!thirdPartyPacket && Config.tacticalCallsign == "" && !Utils::callsignIsValid(Sender)) return; // No thirdParty + no tactical y no valid callsign if (!thirdPartyPacket && Config.tacticalCallsign == "" && !Utils::callsignIsValid(Sender)) return; // No thirdParty + no tactical y no valid callsign
if (STATION_Utils::check25SegBuffer(Sender, temp.substring(temp.indexOf(":") + 2))) { if (STATION_Utils::check25SegBuffer(Sender, temp.substring(temp.indexOf(":") + 2))) {
STATION_Utils::updateLastHeard(Sender); STATION_Utils::updateLastHeard(Sender);
Utils::typeOfPacket(temp, 2); // Digi Utils::typeOfPacket(temp, 2); // Digi
bool queryMessage = false; bool queryMessage = false;
int doubleColonIndex = temp.indexOf("::"); int doubleColonIndex = temp.indexOf("::");
if (doubleColonIndex > 10) { // it's a message if (doubleColonIndex > 10) { // it's a message
String AddresseeAndMessage = temp.substring(doubleColonIndex + 2); String AddresseeAndMessage = temp.substring(doubleColonIndex + 2);
String Addressee = AddresseeAndMessage.substring(0, AddresseeAndMessage.indexOf(":")); String Addressee = AddresseeAndMessage.substring(0, AddresseeAndMessage.indexOf(":"));
Addressee.trim(); Addressee.trim();
if (Addressee == (Config.tacticalCallsign == "" ? Config.callsign : Config.tacticalCallsign)) { // it's a message for me! if (Addressee == stationCallsign) { // it's a message for me!
queryMessage = APRS_IS_Utils::processReceivedLoRaMessage(Sender, AddresseeAndMessage, thirdPartyPacket); queryMessage = APRS_IS_Utils::processReceivedLoRaMessage(Sender, AddresseeAndMessage, thirdPartyPacket);
} }
} }