1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-09-27 15:26:33 -04:00

Fixed ASCII Range for Latitude Direction and compacted code, fixed escape char in Altitude Regexp

This commit is contained in:
Peter Beckman 2022-01-20 15:20:16 -05:00
parent f75c77f47c
commit f4e2226fb4

View File

@ -1034,8 +1034,9 @@ bool APRSPacket::parseMicE(QString& info, int& idx, QString& dest)
QString messageBits = ""; QString messageBits = "";
int messageType = 0; // 0 = Standard, 1 = Custom int messageType = 0; // 0 = Standard, 1 = Custom
int longitudeOffset = 0; int longitudeOffset = 0;
float latitudeDirection = 1; // Assume North // Assume South & East, as North & West are encoded using consecutive Characters, easier and shorter to code
float longitudeDirection = -1; // Assume West float latitudeDirection = -1; // South
float longitudeDirection = 1; // East
QHash<QString, QString> messageTypeLookup = { QHash<QString, QString> messageTypeLookup = {
{"111", "Off Duty"}, {"111", "Off Duty"},
@ -1060,38 +1061,35 @@ bool APRSPacket::parseMicE(QString& info, int& idx, QString& dest)
} else if (inRange(80, 89, charInt)) { } else if (inRange(80, 89, charInt)) {
latDigits.append(QString::number(charInt % 80)); latDigits.append(QString::number(charInt % 80));
} else { } else {
latDigits.append('0'); latDigits.append('0'); // Standard states "space" but we put a zero for math
} }
// Message Type is encoded in 3 bits // Message Type is encoded in 3 bits
if (i < 3) { if (i < 3) {
if (inRange(48, 57, charInt) || charInt == 76) { // 0-9 or L if (inRange(48, 57, charInt) || charInt == 76) { // 0-9 or L
messageBits.append('0'); messageBits.append('0');
} else if (inRange(80, 90, charInt)) { // A-K, Standard } else if (inRange(80, 90, charInt)) { // P-Z, Standard
messageBits.append('1'); messageBits.append('1');
messageType = 0; messageType = 0;
} else if (inRange(65, 75, charInt)) { // P-Z, Custom } else if (inRange(65, 75, charInt)) { // A-K, Custom
messageBits.append('1'); messageBits.append('1');
messageType = 1; messageType = 1;
} }
} }
// Latitude Direction // Latitude Direction
if (i == 3) { if (i == 3 && inRange(80, 90, charInt)) {
if (!inRange(65, 75, charInt)) latitudeDirection = 1; // North
latitudeDirection = -1;
} }
// Longitude Offset // Longitude Offset
if (i == 4) { if (i == 4 && inRange(80, 90, charInt)) {
if (inRange(65, 75, charInt)) longitudeOffset = 100;
longitudeOffset = 100;
} }
// Longitude Direction // Longitude Direction
if (i == 5) { if (i == 5 && inRange(80, 90, charInt)) {
if (!inRange(65, 75, charInt)) longitudeDirection = -1; // West
longitudeDirection = 1;
} }
} }
@ -1172,7 +1170,7 @@ bool APRSPacket::parseMicE(QString& info, int& idx, QString& dest)
// 4-5 bytes, we only need the 3 to get altitude, e.g. "4T} // 4-5 bytes, we only need the 3 to get altitude, e.g. "4T}
// Some HTs prefix the altitude with ']' or '>', so we match that optionally but ignore it // Some HTs prefix the altitude with ']' or '>', so we match that optionally but ignore it
QRegularExpression re_mice_altitude("[\]>]?(.{3})}"); QRegularExpression re_mice_altitude("[\\]>]?(.{3})}");
QRegularExpressionMatch altitude_str = re_mice_altitude.match(info); QRegularExpressionMatch altitude_str = re_mice_altitude.match(info);
if (altitude_str.hasMatch()) { if (altitude_str.hasMatch()) {
QList<int> micEAltitudeMultipliers = {91 * 91, 91, 1}; QList<int> micEAltitudeMultipliers = {91 * 91, 91, 1};