mirror of
https://github.com/lwvmobile/dsd-fme.git
synced 2026-11-21 05:05:38 -05:00
DMR - Inplement LIP; Reorganize Various GPS Reports;
This commit is contained in:
106
src/p25_lcw.c
106
src/p25_lcw.c
@@ -448,110 +448,4 @@ void p25_lcw (dsd_opts * opts, dsd_state * state, uint8_t LCW_bits[], uint8_t ir
|
||||
|
||||
}
|
||||
|
||||
//This Function has been redone and variables fixed to mirror SDRTrunk
|
||||
//my earlier assumption that this was the same format as DMR Embedded GPS was incorrect
|
||||
void apx_embedded_gps (dsd_opts * opts, dsd_state * state, uint8_t lc_bits[])
|
||||
{
|
||||
|
||||
fprintf (stderr, "%s", KYEL);
|
||||
fprintf (stderr, " GPS:");
|
||||
uint8_t slot = state->currentslot;
|
||||
uint8_t pf = lc_bits[0];
|
||||
uint8_t res_a = lc_bits[1];
|
||||
uint8_t res_b = (uint8_t)ConvertBitIntoBytes(&lc_bits[16], 7);
|
||||
uint8_t expired = lc_bits[23]; //this bit seems to indicate that the GPS coordinates are out of date or fresh
|
||||
|
||||
char deg_glyph[4];
|
||||
sprintf (deg_glyph, "%s", "°");
|
||||
|
||||
uint32_t lon_sign = lc_bits[48];
|
||||
uint32_t lon = (uint32_t)ConvertBitIntoBytes(&lc_bits[49], 23);
|
||||
uint32_t lat_sign = lc_bits[24];
|
||||
uint32_t lat = (uint32_t)ConvertBitIntoBytes(&lc_bits[25], 23);
|
||||
//todo: acquire more samples for additional validation
|
||||
double lat_unit = 90.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 lonstr[3];
|
||||
char valid[9];
|
||||
sprintf (latstr, "%s", "N");
|
||||
sprintf (lonstr, "%s", "E");
|
||||
sprintf (valid, "%s", "Current");
|
||||
|
||||
double latitude = 0;
|
||||
double longitude = 0;
|
||||
|
||||
if (pf) fprintf (stderr, " Protected");
|
||||
else
|
||||
{
|
||||
if (lat_sign)
|
||||
{
|
||||
sprintf (latstr, "%s", "S");
|
||||
lat_sf = -1.0f;
|
||||
}
|
||||
latitude = ((double)lat * lat_unit);
|
||||
|
||||
if (lon_sign)
|
||||
{
|
||||
sprintf (lonstr, "%s", "W");
|
||||
lon_sf = -1.0f;
|
||||
}
|
||||
longitude = ((double)lon * lon_unit);
|
||||
|
||||
//sanity check
|
||||
if (abs (latitude) < 90 && abs(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);
|
||||
|
||||
if (expired)
|
||||
{
|
||||
fprintf (stderr, "Expired; ");
|
||||
sprintf (valid, "%s", "Expired");
|
||||
}
|
||||
else if (!expired)
|
||||
fprintf (stderr, "Current; ");
|
||||
|
||||
if (res_a)
|
||||
fprintf (stderr, "RES_A: %d; ", res_a);
|
||||
|
||||
if (res_b)
|
||||
fprintf (stderr, "RES_B: %02X; ", res_b);
|
||||
|
||||
//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);
|
||||
|
||||
//save to LRRP report for mapping/logging
|
||||
FILE * pFile; //file pointer
|
||||
if (opts->lrrp_file_output == 1)
|
||||
{
|
||||
int src = 0;
|
||||
if (slot == 0) src = state->lastsrc;
|
||||
if (slot == 1) src = state->lastsrcR;
|
||||
|
||||
//open file by name that is supplied in the ncurses terminal, or cli
|
||||
pFile = fopen (opts->lrrp_out_file, "a");
|
||||
fprintf (pFile, "%s\t", getDateL() );
|
||||
fprintf (pFile, "%s\t", getTimeL() );
|
||||
fprintf (pFile, "%08d\t", src);
|
||||
fprintf (pFile, "%.5lf\t", latitude);
|
||||
fprintf (pFile, "%.5lf\t", longitude);
|
||||
fprintf (pFile, "0\t " ); //zero for velocity
|
||||
fprintf (pFile, "0\t " ); //zero for azimuth
|
||||
fprintf (pFile, "\n");
|
||||
fclose (pFile);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
fprintf (stderr, "%s", KNRM);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user