diff --git a/hc_http.c b/hc_http.c index 6219af1..8568088 100644 --- a/hc_http.c +++ b/hc_http.c @@ -75,11 +75,19 @@ static const char *hc_http_status (const char *method, const char *uri, status_db->longitude, status_db->hemisphere[1]); snprintf (buffer, sizeof(buffer), - "{\"gps\":{\"fix\":%s,\"time\":\"%s\",\"date\":\"%s\"" - ",\"latitude\":%s,\"longitude\":%s}}", + "{\"gps\":{\"fix\":%s" + ",\"time\":[%c%c,%c%c,%c%c],\"date\":[%d,%c%c,%c%c]" + ",\"latitude\":%s,\"longitude\":%s,\"timestamp\":%zd.%03d}}", status_db->fix?"true":"false", - status_db->time, status_db->date, - latitude, longitude); + status_db->time[0], status_db->time[1], + status_db->time[2], status_db->time[3], + status_db->time[4], status_db->time[5], + 2000 + (status_db->date[4]-'0')*10 + (status_db->date[5]-'0'), + status_db->date[2], status_db->date[3], + status_db->date[0], status_db->date[1], + latitude, longitude, + (size_t) (status_db->timestamp.tv_sec), + status_db->timestamp.tv_usec/1000); echttp_content_type_json(); return buffer; } diff --git a/hc_nmea.c b/hc_nmea.c index ca0ddb5..9927f07 100644 --- a/hc_nmea.c +++ b/hc_nmea.c @@ -315,8 +315,9 @@ static void hc_nmea_record (const char *sentence, decoded->flags = 0; } -static void hc_nmea_mark (int flags) { +static void hc_nmea_mark (int flags, const struct timeval *timestamp) { gpsHistory[gpsLatest].flags = flags; + hc_nmea_status_db->timestamp = *timestamp; } static void hc_nmea_store_position (char **fields) { @@ -491,7 +492,7 @@ int hc_nmea_process (const struct timeval *received) { flags |= hc_nmea_decode (gpsBuffer+start); - hc_nmea_mark (flags); + hc_nmea_mark (flags, &bursttiming); if (hc_nmea_ready(flags)) { struct timeval gmt; diff --git a/hc_nmea.h b/hc_nmea.h index 6752ccf..4bc54ac 100644 --- a/hc_nmea.h +++ b/hc_nmea.h @@ -36,6 +36,7 @@ typedef struct { char latitude[20]; char longitude[20]; char hemisphere[2]; + struct timeval timestamp; } hc_nmea_status; void hc_nmea_convert (char *buffer, int size,