Skip to content

Commit

Permalink
super mods
Browse files Browse the repository at this point in the history
  • Loading branch information
richonguzman committed Dec 19, 2024
1 parent e718a05 commit fa90d20
Show file tree
Hide file tree
Showing 12 changed files with 401 additions and 500 deletions.
742 changes: 348 additions & 394 deletions lib/APRSPacketLib/APRSPacketLib.cpp

Large diffs are not rendered by default.

46 changes: 7 additions & 39 deletions lib/APRSPacketLib/APRSPacketLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
#include <Arduino.h>

struct APRSPacket {
String header;
String sender;
String tocall;
String header; // (if packet is Third-Packet)
String sender; // Source Address = sender
String tocall; // Destination Address = tocall
String path;
String addressee;
String message;
String payload;
int type;
String symbol;
String overlay;
Expand Down Expand Up @@ -40,47 +40,15 @@ struct gpsLongitudeStruct {

namespace APRSPacketLib {

String doubleToString(double n, int ndec);
String gpsDecimalToDegreesLatitude(double lat);
String gpsDecimalToDegreesLongitude(double lon);

void encodeMiceAltitude(uint8_t *buf, uint32_t alt_m);
void encodeMiceCourseSpeed(uint8_t *buf, uint32_t speed_kt, uint32_t course_deg);
void encodeMiceLongitude(uint8_t *buf, gpsLongitudeStruct *lon);
void encodeMiceDestinationField(const String& msgType, uint8_t *buf, const gpsLatitudeStruct *lat, const gpsLongitudeStruct *lon);

gpsLatitudeStruct gpsDecimalToDegreesMiceLatitude(float latitude);
gpsLongitudeStruct gpsDecimalToDegreesMiceLongitude(float longitude);
String generateMiceGPSBeacon(const String& miceMsgType, const String& callsign, const String& symbol, const String& overlay, const String& path, float latitude, float longitude, float course, float speed, int altitude);

String generateBasePacket(const String& callsign, const String& tocall, const String& path);
String generateStatusPacket(const String& callsign, const String& tocall, const String& path, const String& status);
String generateMessagePacket(const String& callsign, const String& tocall, const String& path, const String& addressee, const String& message);

String buildDigiPacket(const String& packet, const String& callsign, const String& path, bool thirdParty);
String generateDigipeatedPacket(const String& packet, const String &callsign, const String& path);

char *ax25_base91enc(char *s, uint8_t n, uint32_t v);
String encodeGPS(float latitude, float longitude, float course, float speed, const String& symbol, bool sendAltitude, int altitude, bool sendStandingUpdate, const String& packetType);
String generateGPSBeaconPacket(const String& callsign, const String& tocall, const String& path, const String& overlay, const String& gpsData);

float decodeEncodedLatitude(const String& receivedPacket);
float decodeEncodedLongitude(const String& receivedPacket);
float decodeLatitude(const String& receivedPacket);
float decodeLongitude(const String& receivedPacket);
int decodeSpeed(const String& speed);
int decodeAltitude(const String& altitude);
String encodeGPSIntoBase91(float latitude, float longitude, float course, float speed, const String& symbol, bool sendAltitude = false, int altitude = 0, bool sendStandingUpdate = false, const String& packetType = "GPS");
String generateBase91GPSBeaconPacket(const String& callsign, const String& tocall, const String& path, const String& overlay, const String& gpsData);

String decodeMiceMsgType(const String& tocall);
String decodeMiceSymbol(const String& informationField);
String decodeMiceOverlay(const String& informationField);
int decodeMiceSpeed(const String& informationField);
int decodeMiceCourse(const String& informationField);
int decodeMiceAltitude(const String& informationField);
float gpsDegreesToDecimalLatitude(const String& degreesLatitude);
float gpsDegreesToDecimalLongitude(const String& degreesLongitude);
float decodeMiceLatitude(const String& destinationField);
float decodeMiceLongitude(const String& destinationField, const String& informationField);
String generateMiceGPSBeaconPacket(const String& miceMsgType, const String& callsign, const String& symbol, const String& overlay, const String& path, float latitude, float longitude, float course, float speed, int altitude);

APRSPacket processReceivedPacket(const String& receivedPacket, int rssi, float snr, int freqError);

Expand Down
2 changes: 1 addition & 1 deletion src/LoRa_APRS_Tracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ TinyGPSPlus gps;
BluetoothSerial SerialBT;
#endif

String versionDate = "2024.12.15";
String versionDate = "2024.12.18";

uint8_t myBeaconsIndex = 0;
int myBeaconsSize = Config.beacons.size();
Expand Down
8 changes: 1 addition & 7 deletions src/battery_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,7 @@ namespace BATTERY_Utils {

String getPercentVoltageBattery(float voltage) {
int percent = ((voltage - 3.0) / (4.2 - 3.0)) * 100;
if (percent < 10) {
return " " + String(percent);
} else if (percent >= 10 && percent < 100) {
return " " + String(percent);
} else {
return "100";
}
return (percent < 100) ? (((percent < 10) ? " ": " ") + String(percent)) : "100";
}

void checkVoltageWithoutGPSFix() {
Expand Down
12 changes: 3 additions & 9 deletions src/gps_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ namespace GPS_Utils {

void getData() {
if (disableGPS) return;
while (gpsSerial.available() > 0) {
gps.encode(gpsSerial.read());
}
while (gpsSerial.available() > 0) gps.encode(gpsSerial.read());
}

void setDateFromData() {
Expand Down Expand Up @@ -131,18 +129,14 @@ namespace GPS_Utils {
bearing += "(";
bearing += center;
bearing += ").....";
if (right.length() == 1 && center.length() != 2) {
bearing += ".";
}
if (right.length() == 1 && center.length() != 2) bearing += ".";
bearing += right;
bearing += ".<";
return bearing;
}

String getCardinalDirection(float course) {
if (gps.speed.kmph() > 0.5) {
bearing = course;
}
if (gps.speed.kmph() > 0.5) bearing = course;

if (bearing >= 354.375 || bearing < 5.625) return ">.NW.....(N).....NE.<"; // N
if (bearing >= 5.675 && bearing < 16.875) return ">.......N.|.....NE..<";
Expand Down
6 changes: 3 additions & 3 deletions src/keyboard_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ namespace KEYBOARD_Utils {
}
} else if (menuDisplay == 120) {
MSG_Utils::deleteFile(0);
displayShow("___INFO___", "", "ALL MESSAGES DELETED!", 2000);
displayShow(" INFO", "", "ALL MESSAGES DELETED!", 2000);
MSG_Utils::loadNumMessages();
menuDisplay = 12;
} else if (menuDisplay == 130) {
Expand Down Expand Up @@ -388,7 +388,7 @@ namespace KEYBOARD_Utils {
menuDisplay = 50111;
} else if (menuDisplay == 50111) {
MSG_Utils::deleteFile(1);
displayShow("___INFO___", "", " ALL MAILS DELETED!", 2000);
displayShow(" INFO", "", " ALL MAILS DELETED!", 2000);
MSG_Utils::loadNumMessages();
if (winlinkStatus == 0) {
#ifdef HAS_JOYSTICK
Expand Down Expand Up @@ -682,7 +682,7 @@ namespace KEYBOARD_Utils {
} else if (key == 13 && messageText.length() > 0) {
messageText.trim();
if (messageText.length() > 67) messageText = messageText.substring(0, 67);
String packet = APRSPacketLib::generateGPSBeaconPacket(currentBeacon->callsign, "APLRT1", Config.path, currentBeacon->overlay, APRSPacketLib::encodeGPS(gps.location.lat(),gps.location.lng(), gps.course.deg(), gps.speed.knots(), currentBeacon->symbol, Config.sendAltitude, gps.altitude.feet(), sendStandingUpdate, "GPS"));
String packet = APRSPacketLib::generateBase91GPSBeaconPacket(currentBeacon->callsign, "APLRT1", Config.path, currentBeacon->overlay, APRSPacketLib::encodeGPSIntoBase91(gps.location.lat(),gps.location.lng(), gps.course.deg(), gps.speed.knots(), currentBeacon->symbol, Config.sendAltitude, gps.altitude.feet(), sendStandingUpdate, "GPS"));
packet += messageText;
displayShow("<<< TX >>>", "", packet,100);
LoRa_Utils::sendNewPacket(packet);
Expand Down
8 changes: 2 additions & 6 deletions src/kiss_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,8 @@ namespace KISS_Utils {
int ssid = address.substring(separatorIndex + 1).toInt();
String kissAddress = "";
for (int i = 0; i < 6; ++i) {
char addressChar;
if (address.length() > i && i < separatorIndex) {
addressChar = address.charAt(i);
} else {
addressChar = ' ';
}
char addressChar = ' ';
if (address.length() > i && i < separatorIndex) addressChar = address.charAt(i);
kissAddress += (char)(addressChar << 1);
}
kissAddress += (char)((ssid << 1) | 0b01100000 | (hasBeenDigipited ? HAS_BEEN_DIGIPITED_MASK : 0));
Expand Down
2 changes: 1 addition & 1 deletion src/lora_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ bool transmitFlag = true;
#if defined(HAS_SX1276)
SX1276 radio = new Module(RADIO_CS_PIN, RADIO_BUSY_PIN, RADIO_RST_PIN);
#endif
#if defined(HAS_LLCC68) //LLCC68 supports spreading factor only in range of 5-11!
#if defined(HAS_LLCC68) // LLCC68 supports spreading factor only in range of 5-11!
LLCC68 radio = new Module(RADIO_CS_PIN, RADIO_DIO1_PIN, RADIO_RST_PIN, RADIO_BUSY_PIN);
#endif

Expand Down
4 changes: 2 additions & 2 deletions src/menu_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,9 +362,9 @@ namespace MENU_Utils {

displayShow(firstLineDecoder, "GPS " + String(lastReceivedPacket.latitude,3) + " " + String(lastReceivedPacket.longitude,3), courseSpeedAltitude, "D:" + String(distanceKm) + "km " + String(courseTo,0), pathDec, "< RSSI:" + String(lastReceivedPacket.rssi) + " SNR:" + String(lastReceivedPacket.snr));
} else if (lastReceivedPacket.type == 1) { // message
displayShow(firstLineDecoder, "ADDRESSEE: " + lastReceivedPacket.addressee, "MSG: " + lastReceivedPacket.message, "", "", "< RSSI:" + String(lastReceivedPacket.rssi) + " SNR:" + String(lastReceivedPacket.snr));
displayShow(firstLineDecoder, "ADDRESSEE: " + lastReceivedPacket.addressee, "MSG: " + lastReceivedPacket.payload, "", "", "< RSSI:" + String(lastReceivedPacket.rssi) + " SNR:" + String(lastReceivedPacket.snr));
} else if (lastReceivedPacket.type == 2) { // status
displayShow(firstLineDecoder, "-------STATUS-------", lastReceivedPacket.message, "", "", "< RSSI:" + String(lastReceivedPacket.rssi) + " SNR:" + String(lastReceivedPacket.snr));
displayShow(firstLineDecoder, "-------STATUS-------", lastReceivedPacket.payload, "", "", "< RSSI:" + String(lastReceivedPacket.rssi) + " SNR:" + String(lastReceivedPacket.snr));
} else if (lastReceivedPacket.type == 3) { // telemetry
displayShow(firstLineDecoder, "------TELEMETRY------", "", "", "", "< RSSI:" + String(lastReceivedPacket.rssi) + " SNR:" + String(lastReceivedPacket.snr));
} else if (lastReceivedPacket.type == 5) { // object
Expand Down
Loading

0 comments on commit fa90d20

Please sign in to comment.