A basic library for the Adafruit Ultimate GPS module. (MTK3339) http://www.adafruit.com/products/746
Fork of GPS by
Revision 6:bcbfe060c93e, committed 2016-03-15
- Comitter:
- GlessConsult
- Date:
- Tue Mar 15 16:58:07 2016 +0000
- Parent:
- 5:96d5736d9613
- Commit message:
- Ad a new function to save GPS data in a JSON structure.
Changed in this revision
GPS.cpp | Show annotated file Show diff for this revision Revisions of this file |
GPS.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/GPS.cpp Sun Jan 19 08:47:38 2014 +0000 +++ b/GPS.cpp Tue Mar 15 16:58:07 2016 +0000 @@ -86,6 +86,25 @@ } } +int GPS::structJSON(char * content) { + + + char contentTemplate[] = "{ \ + \"datetime\": \"%04d-%02d-%02dT%02d:%02d:%02.3fZ\",\ + \"coordinates\": {\ + \"lat\": %f,\ + \"lng\": %f},\ + \"utc_time\": \"%04d-%02d-%02dT%02d:%02d:%02.3fZ\",\ + \"satellites_used\": %d,\ + \"gps_quality_indicator\": %d,\ + \"altitude\": %d}\0"; + + if (0 == parseData()) { + return 0; + } + sprintf(content, contentTemplate, year, month, day, hours, minutes, seconds, latitude, longitude, year, month, day, hours, minutes, seconds, satellites, fixtype, (int)altitude); + return 1; +} float GPS::trunc(float v) {
--- a/GPS.h Sun Jan 19 08:47:38 2014 +0000 +++ b/GPS.h Tue Mar 15 16:58:07 2016 +0000 @@ -28,6 +28,7 @@ GPS(PinName tx, PinName rx); void Init(); int parseData(); + int structJSON(char * content); float time; // UTC time int hours; int minutes;