m10: json aprs-id, json framecount based on gps seconds

pull/18/head
Zilog80 2019-09-26 18:12:39 +02:00
rodzic 354c58da2e
commit 6dc3061186
2 zmienionych plików z 18 dodań i 2 usunięć

Wyświetl plik

@ -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];

Wyświetl plik

@ -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);