kopia lustrzana https://github.com/rs1729/RS
JSON output: added type key
rodzic
cc46553638
commit
aab4950853
|
@ -327,8 +327,8 @@ static void printJSON() {
|
|||
if (gpx.sn) {
|
||||
sprintf(json_sonde_id, "C50-%u", gpx.sn);
|
||||
}
|
||||
printf("{ ");
|
||||
printf("\"id\": \"%s\", ", json_sonde_id);
|
||||
printf("{ \"type\": \"%s\"", "C50");
|
||||
printf(", \"id\": \"%s\", ", json_sonde_id);
|
||||
printf("\"datetime\": \"%04d-%02d-%02dT%02d:%02d:%02dZ\", \"lat\": %.5f, \"lon\": %.5f, \"alt\": %.1f",
|
||||
gpx.jahr, gpx.monat, gpx.tag, gpx.std, gpx.min, gpx.sek, gpx.lat, gpx.lon, gpx.alt);
|
||||
if (option_ptu && (gpx.T > -273.0 || gpx.RH > -0.5)) {
|
||||
|
|
|
@ -747,7 +747,8 @@ static void print_gpx(gpx_t *gpx) {
|
|||
}
|
||||
|
||||
// Print JSON blob // valid sonde_ID?
|
||||
printf("{ \"frame\": %d, \"id\": \"%s\", \"datetime\": \"%04d-%02d-%02dT%02d:%02d:%06.3fZ\", \"lat\": %.5f, \"lon\": %.5f, \"alt\": %.5f, \"vel_h\": %.5f, \"heading\": %.5f, \"vel_v\": %.5f",
|
||||
printf("{ \"type\": \"%s\"", "DFM");
|
||||
printf(", \"frame\": %d, \"id\": \"%s\", \"datetime\": \"%04d-%02d-%02dT%02d:%02d:%06.3fZ\", \"lat\": %.5f, \"lon\": %.5f, \"alt\": %.5f, \"vel_h\": %.5f, \"heading\": %.5f, \"vel_v\": %.5f",
|
||||
gpx->frnr, json_sonde_id, gpx->jahr, gpx->monat, gpx->tag, gpx->std, gpx->min, gpx->sek, gpx->lat, gpx->lon, gpx->alt, gpx->horiV, gpx->dir, gpx->vertV);
|
||||
if (gpx->ptu_out >= 0xA && gpx->status[0] > 0) { // DFM>=09(P): Battery (STM32)
|
||||
printf(", \"batt\": %.2f", gpx->status[0]);
|
||||
|
|
|
@ -738,11 +738,13 @@ static void print_frame(gpx_t *gpx, int crc_err, int len) {
|
|||
// UTC oder GPS?
|
||||
char sntyp[] = "LMS6-";
|
||||
if (gpx->typ == 10) sntyp[3] = 'X';
|
||||
printf("{ \"frame\": %d, \"id\": \"%s%d\", \"datetime\": \"", gpx->frnr, sntyp, gpx->sn );
|
||||
printf("{ \"type\": \"%s\"", "LMS6");
|
||||
printf(", \"frame\": %d, \"id\": \"%s%d\", \"datetime\": \"", gpx->frnr, sntyp, gpx->sn );
|
||||
//if (gpx->week > 0) printf("%04d-%02d-%02dT", gpx->jahr, gpx->monat, gpx->tag );
|
||||
printf("%02d:%02d:%06.3fZ\", \"lat\": %.5f, \"lon\": %.5f, \"alt\": %.5f, \"vel_h\": %.5f, \"heading\": %.5f, \"vel_v\": %.5f",
|
||||
gpx->std, gpx->min, gpx->sek, gpx->lat, gpx->lon, gpx->alt, gpx->vH, gpx->vD, gpx->vV );
|
||||
printf(", \"gpstow\": %d", gpx->gpstow );
|
||||
printf(", \"subtype\": \"%c\"", sntyp[3]);
|
||||
printf(" }\n");
|
||||
printf("\n");
|
||||
}
|
||||
|
|
|
@ -753,11 +753,13 @@ static void print_frame(gpx_t *gpx, int crc_err, int len) {
|
|||
// UTC oder GPS?
|
||||
char sntyp[] = "LMS6-";
|
||||
if (gpx->typ == 10) sntyp[3] = 'X';
|
||||
printf("{ \"frame\": %d, \"id\": \"%s%d\", \"datetime\": \"", gpx->frnr, sntyp, gpx->sn );
|
||||
printf("{ \"type\": \"%s\"", "LMS6");
|
||||
printf(", \"frame\": %d, \"id\": \"%s%d\", \"datetime\": \"", gpx->frnr, sntyp, gpx->sn );
|
||||
//if (gpx->week > 0) printf("%04d-%02d-%02dT", gpx->jahr, gpx->monat, gpx->tag );
|
||||
printf("%02d:%02d:%06.3fZ\", \"lat\": %.5f, \"lon\": %.5f, \"alt\": %.5f, \"vel_h\": %.5f, \"heading\": %.5f, \"vel_v\": %.5f",
|
||||
gpx->std, gpx->min, gpx->sek, gpx->lat, gpx->lon, gpx->alt, gpx->vH, gpx->vD, gpx->vV );
|
||||
printf(", \"gpstow\": %d", gpx->gpstow );
|
||||
printf(", \"subtype\": \"%c\"", sntyp[3]);
|
||||
printf(" }\n");
|
||||
printf("\n");
|
||||
}
|
||||
|
|
|
@ -790,8 +790,8 @@ 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, "{ ");
|
||||
fprintf(stdout, "\"frame\": %lu ,", (unsigned long)(sec_gps0+0.5));
|
||||
fprintf(stdout, "{ \"type\": \"%s\"", "M10");
|
||||
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
|
||||
|
|
|
@ -720,7 +720,8 @@ int main(int argc, char **argv) {
|
|||
if (gpx.sn > 0 && gpx.sn < 1e9) {
|
||||
sprintf(id_str, "%.0f", gpx.sn);
|
||||
}
|
||||
printf("{ \"frame\": %d, \"id\": \"IMS100-%s\", \"datetime\": \"%04d-%02d-%02dT%02d:%02d:%06.3fZ\", \"lat\": %.5f, \"lon\": %.5f, \"alt\": %.5f, \"vel_h\": %.5f, \"heading\": %.5f }\n",
|
||||
printf("{ \"type\": \"%s\"", "IMS100");
|
||||
printf(", \"frame\": %d, \"id\": \"IMS100-%s\", \"datetime\": \"%04d-%02d-%02dT%02d:%02d:%06.3fZ\", \"lat\": %.5f, \"lon\": %.5f, \"alt\": %.5f, \"vel_h\": %.5f, \"heading\": %.5f }\n",
|
||||
gpx.frnr, id_str, gpx.jahr, gpx.monat, gpx.tag, gpx.std, gpx.min, gpx.sek, gpx.lat, gpx.lon, gpx.alt, gpx.vH, gpx.vD );
|
||||
printf("\n");
|
||||
}
|
||||
|
|
|
@ -1327,7 +1327,8 @@ static int print_position(gpx_t *gpx, int ec) {
|
|||
// Print out telemetry data as JSON
|
||||
if ((!err && !err1 && !err3) || (!err && encrypted)) { // frame-nb/id && gps-time && gps-position (crc-)ok; 3 CRCs, RS not needed
|
||||
// eigentlich GPS, d.h. UTC = GPS - 18sec (ab 1.1.2017)
|
||||
fprintf(stdout, "{ \"frame\": %d, \"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, \"bt\": %d, \"batt\": %.2f",
|
||||
fprintf(stdout, "{ \"type\": \"%s\"", "RS41");
|
||||
fprintf(stdout, ", \"frame\": %d, \"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, \"bt\": %d, \"batt\": %.2f",
|
||||
gpx->frnr, gpx->id, gpx->jahr, gpx->monat, gpx->tag, gpx->std, gpx->min, gpx->sek, gpx->lat, gpx->lon, gpx->alt, gpx->vH, gpx->vD, gpx->vV, gpx->numSV, gpx->conf_cd, gpx->batt );
|
||||
if (gpx->option.ptu && !err0 && gpx->T > -273.0) {
|
||||
fprintf(stdout, ", \"temp\": %.1f", gpx->T );
|
||||
|
|
|
@ -1177,7 +1177,9 @@ static int print_position(gpx_t *gpx, int ec) { // GPS-Hoehe ueber Ellipsoid
|
|||
// Print out telemetry data as JSON //even if we don't have a valid GPS lock
|
||||
if ((gpx->crc & (crc_FRAME | crc_GPS))==0 && (gpx->gps.almanac || gpx->gps.ephem)) //(!err1 && !err3)
|
||||
{ // eigentlich GPS, d.h. UTC = GPS - UTC_OFS (UTC_OFS=18sec ab 1.1.2017)
|
||||
fprintf(stdout, "\n{ \"frame\": %d, \"id\": \"%s\", \"datetime\": \"%04d-%02d-%02dT%02d:%02d:%06.3fZ\", \"lat\": %.5f, \"lon\": %.5f, \"alt\": %.5f, \"vel_h\": %.5f, \"heading\": %.5f, \"vel_v\": %.5f",
|
||||
fprintf(stdout, "\n");
|
||||
fprintf(stdout, "{ \"type\": \"%s\"", "RS92");
|
||||
fprintf(stdout, ", \"frame\": %d, \"id\": \"%s\", \"datetime\": \"%04d-%02d-%02dT%02d:%02d:%06.3fZ\", \"lat\": %.5f, \"lon\": %.5f, \"alt\": %.5f, \"vel_h\": %.5f, \"heading\": %.5f, \"vel_v\": %.5f",
|
||||
gpx->frnr, gpx->id, gpx->jahr, gpx->monat, gpx->tag, gpx->std, gpx->min, gpx->sek, gpx->lat, gpx->lon, gpx->alt, gpx->vH, gpx->vD, gpx->vU);
|
||||
if ((gpx->crc & crc_AUX)==0 && (gpx->aux[0] != 0 || gpx->aux[1] != 0 || gpx->aux[2] != 0 || gpx->aux[3] != 0)) {
|
||||
fprintf(stdout, ", \"aux\": \"%04x%04x%04x%04x\"", gpx->aux[0], gpx->aux[1], gpx->aux[2], gpx->aux[3]);
|
||||
|
|
|
@ -427,7 +427,8 @@ int print_frame(int len) {
|
|||
if (option_json) {
|
||||
if (gpx.gps_valid && gpx.ptu_valid) // frameNb part of PTU-pck
|
||||
{
|
||||
fprintf(stdout, "{ \"frame\": %d, \"id\": \"iMet\", \"datetime\": \"%02d:%02d:%02dZ\", \"lat\": %.5f, \"lon\": %.5f, \"alt\": %d, \"sats\": %d, \"temp\": %.2f, \"humidity\": %.2f, \"pressure\": %.2f, \"batt\": %.1f }\n",
|
||||
fprintf(stdout, "{ \"type\": \"%s\"", "IMET");
|
||||
fprintf(stdout, ", \"frame\": %d, \"id\": \"iMet\", \"datetime\": \"%02d:%02d:%02dZ\", \"lat\": %.5f, \"lon\": %.5f, \"alt\": %d, \"sats\": %d, \"temp\": %.2f, \"humidity\": %.2f, \"pressure\": %.2f, \"batt\": %.1f }\n",
|
||||
gpx.frame, gpx.hour, gpx.min, gpx.sec, gpx.lat, gpx.lon, gpx.alt, gpx.sats, gpx.temp, gpx.humidity, gpx.pressure, gpx.batt);
|
||||
}
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue