P25p1: Fix Moto APX GPS LCW;

This commit is contained in:
lwvmobile
2025-03-17 13:57:12 -04:00
parent 7ed1a79b5b
commit 237cb3ffa5

View File

@@ -656,8 +656,8 @@ void dmr_embedded_gps (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[])
fprintf (stderr, "%s", KNRM); fprintf (stderr, "%s", KNRM);
} }
//This Function has been redone and variables fixed to mirror SDRTrunk //This Function needs testing, is tested working for NW and NE lat and
//my earlier assumption that this was the same format as DMR Embedded GPS was incorrect //long coordinates, but not for SE and SW coordinates
void apx_embedded_gps (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[]) void apx_embedded_gps (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[])
{ {
@@ -676,18 +676,16 @@ void apx_embedded_gps (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[])
uint32_t lon = (uint32_t)ConvertBitIntoBytes(&lc_bits[49], 23); uint32_t lon = (uint32_t)ConvertBitIntoBytes(&lc_bits[49], 23);
uint32_t lat_sign = lc_bits[24]; uint32_t lat_sign = lc_bits[24];
uint32_t lat = (uint32_t)ConvertBitIntoBytes(&lc_bits[25], 23); uint32_t lat = (uint32_t)ConvertBitIntoBytes(&lc_bits[25], 23);
//todo: acquire more samples for additional validation
double lat_unit = 90.0f / 0x7FFFFF; double lat_unit = 90.0f / 0x7FFFFF;
double lon_unit = 180.0f / 0x7FFFFF; double lon_unit = 180.0f / 0x7FFFFF;
double lon_sf = 1.0f; //float value we can multiple longitude with
double lat_sf = 1.0f; //float value we can multiple latitude with
char latstr[3]; char latstr[3];
char lonstr[3]; char lonstr[3];
char valid[9]; char valid[12];
sprintf (latstr, "%s", "N"); sprintf (latstr, "%s", "N");
sprintf (lonstr, "%s", "E"); sprintf (lonstr, "%s", "E");
sprintf (valid, "%s", "Current"); sprintf (valid, "%s", "Current Fix");
double latitude = 0; double latitude = 0;
double longitude = 0; double longitude = 0;
@@ -695,32 +693,33 @@ void apx_embedded_gps (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[])
if (pf) fprintf (stderr, " Protected"); if (pf) fprintf (stderr, " Protected");
else else
{ {
latitude = ((double)lat * lat_unit);
if (lat_sign) if (lat_sign)
{ {
latitude -= 90.0f;
sprintf (latstr, "%s", "S"); sprintf (latstr, "%s", "S");
lat_sf = -1.0f;
} }
latitude = ((double)lat * lat_unit);
longitude = ((double)lon * lon_unit);
if (lon_sign) if (lon_sign)
{ {
longitude -= 180.0f;
sprintf (lonstr, "%s", "W"); sprintf (lonstr, "%s", "W");
lon_sf = -1.0f;
} }
longitude = ((double)lon * lon_unit);
//sanity check //sanity check
if (abs (latitude) < 90 && abs(longitude) < 180) if (fabs ((float)latitude) < 90 && fabs((float)longitude) < 180)
{ {
fprintf (stderr, " Lat: %.5lf%s%s Lon: %.5lf%s%s (%.5lf, %.5lf) ", latitude, deg_glyph, latstr, longitude, deg_glyph, lonstr, latitude * lat_sf, longitude * lon_sf); fprintf (stderr, " Lat: %.5lf%s%s Lon: %.5lf%s%s (%.5lf, %.5lf) ", latitude, deg_glyph, latstr, longitude, deg_glyph, lonstr, latitude, longitude);
if (expired) if (expired)
{ {
fprintf (stderr, "Expired; "); fprintf (stderr, "Last Fix; ");
sprintf (valid, "%s", "Expired"); sprintf (valid, "%s", "Last Fix");
} }
else if (!expired) else if (!expired)
fprintf (stderr, "Current; "); fprintf (stderr, "Current Fix; ");
if (res_a) if (res_a)
fprintf (stderr, "RES_A: %d; ", res_a); fprintf (stderr, "RES_A: %d; ", res_a);
@@ -729,7 +728,7 @@ void apx_embedded_gps (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[])
fprintf (stderr, "RES_B: %02X; ", res_b); fprintf (stderr, "RES_B: %02X; ", res_b);
//save to array for ncurses //save to array for ncurses
sprintf (state->dmr_embedded_gps[slot], "GPS: %lf%s%s %lf%s%s %s", latitude, deg_glyph, latstr, longitude, deg_glyph, lonstr, valid); sprintf (state->dmr_embedded_gps[slot], "GPS: %lf%s%s %lf%s%s (%lf, %lf) %s", latitude, deg_glyph, latstr, longitude, deg_glyph, lonstr, latitude, longitude, valid);
//save to LRRP report for mapping/logging //save to LRRP report for mapping/logging
FILE * pFile; //file pointer FILE * pFile; //file pointer