Skip to content

Commit

Permalink
Tune the GPS JSON status
Browse files Browse the repository at this point in the history
  • Loading branch information
pascal-fb-martin committed Oct 13, 2019
1 parent c6b1293 commit 00fbe52
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
16 changes: 12 additions & 4 deletions hc_http.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
5 changes: 3 additions & 2 deletions hc_nmea.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions hc_nmea.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 00fbe52

Please sign in to comment.