diff --git a/demod/mod/m10mod.c b/demod/mod/m10mod.c index d328be0..90a53a6 100644 --- a/demod/mod/m10mod.c +++ b/demod/mod/m10mod.c @@ -89,6 +89,7 @@ typedef struct { /* -------------------------------------------------------------------------- */ +#define SECONDS_IN_WEEK (604800.0) // 7*86400 /* * Convert GPS Week and Seconds to Modified Julian Day. * - Adapted from sci.astro FAQ. @@ -769,6 +770,7 @@ static int print_pos(gpx_t *gpx, int csOK) { int j; char sn_id[4+12] = "M10-"; ui8_t aprs_id[4]; + double sec_gps0 = (double)gpx->week*SECONDS_IN_WEEK + gpx->tow_ms/1e3; // UTC = GPS - UTC_OFS (ab 1.1.2017: UTC_OFS=18sec) int utc_s = gpx->gpssec - gpx->utc_ofs; int utc_week = gpx->week; @@ -788,7 +790,9 @@ static int print_pos(gpx_t *gpx, int csOK) { sn_id[15] = '\0'; for (j = 0; sn_id[j]; j++) { if (sn_id[j] == ' ') sn_id[j] = '-'; } - fprintf(stdout, "{ \"id\": \"%s\", \"datetime\": \"%04d-%02d-%02dT%02d:%02d:%06.3fZ\", \"lat\": %.5f, \"lon\": %.5f, \"alt\": %.5f, \"vel_h\": %.5f, \"heading\": %.5f, \"vel_v\": %.5f, \"sats\": %d", + fprintf(stdout, "{ "); + fprintf(stdout, "\"frame\": %lu ,", (unsigned long)(sec_gps0+0.5)); + fprintf(stdout, "\"id\": \"%s\", \"datetime\": \"%04d-%02d-%02dT%02d:%02d:%06.3fZ\", \"lat\": %.5f, \"lon\": %.5f, \"alt\": %.5f, \"vel_h\": %.5f, \"heading\": %.5f, \"vel_v\": %.5f, \"sats\": %d", sn_id, utc_jahr, utc_monat, utc_tag, utc_std, utc_min, utc_sek, gpx->lat, gpx->lon, gpx->alt, gpx->vH, gpx->vD, gpx->vV, gpx->numSV); // APRS id, 9 characters aprs_id[0] = gpx->frame_bytes[pos_SN+2]; diff --git a/demod/multi/m10base.c b/demod/multi/m10base.c index f17035d..04d361d 100644 --- a/demod/multi/m10base.c +++ b/demod/multi/m10base.c @@ -88,6 +88,7 @@ typedef struct { /* -------------------------------------------------------------------------- */ +#define SECONDS_IN_WEEK (604800.0) // 7*86400 /* * Convert GPS Week and Seconds to Modified Julian Day. * - Adapted from sci.astro FAQ. @@ -767,6 +768,8 @@ static int print_pos(gpx_t *gpx, int csOK) { if (csOK) { int j; char sn_id[4+12] = "M10-"; + ui8_t aprs_id[4]; + double sec_gps0 = (double)gpx->week*SECONDS_IN_WEEK + gpx->tow_ms/1e3; // UTC = GPS - UTC_OFS (ab 1.1.2017: UTC_OFS=18sec) int utc_s = gpx->gpssec - gpx->utc_ofs; int utc_week = gpx->week; @@ -786,8 +789,17 @@ static int print_pos(gpx_t *gpx, int csOK) { sn_id[15] = '\0'; for (j = 0; sn_id[j]; j++) { if (sn_id[j] == ' ') sn_id[j] = '-'; } - fprintf(stdout, "{ \"id\": \"%s\", \"datetime\": \"%04d-%02d-%02dT%02d:%02d:%06.3fZ\", \"lat\": %.5f, \"lon\": %.5f, \"alt\": %.5f, \"vel_h\": %.5f, \"heading\": %.5f, \"vel_v\": %.5f, \"sats\": %d", + fprintf(stdout, "{ "); + fprintf(stdout, "\"frame\": %lu ,", (unsigned long)(sec_gps0+0.5)); + fprintf(stdout, "\"id\": \"%s\", \"datetime\": \"%04d-%02d-%02dT%02d:%02d:%06.3fZ\", \"lat\": %.5f, \"lon\": %.5f, \"alt\": %.5f, \"vel_h\": %.5f, \"heading\": %.5f, \"vel_v\": %.5f, \"sats\": %d", sn_id, utc_jahr, utc_monat, utc_tag, utc_std, utc_min, utc_sek, gpx->lat, gpx->lon, gpx->alt, gpx->vH, gpx->vD, gpx->vV, gpx->numSV); + // APRS id, 9 characters + aprs_id[0] = gpx->frame_bytes[pos_SN+2]; + aprs_id[1] = gpx->frame_bytes[pos_SN] & 0xF; + aprs_id[2] = gpx->frame_bytes[pos_SN+4]; + aprs_id[3] = gpx->frame_bytes[pos_SN+3]; + fprintf(stdout, ", \"aprsid\": \"ME%02X%1X%02X%02X\"", aprs_id[0], aprs_id[1], aprs_id[2], aprs_id[3]); + // temperature if (gpx->option.ptu) { float t = get_Temp(gpx, 0); if (t > -273.0) fprintf(stdout, ", \"temp\": %.1f", t);