Real-time bike tracker using Adafruit Ultimate GPS, Huzzah wifi, and Pubnub
Dependencies: MBed_Adafruit-GPS-Library mbed
Diff: main.cpp
- Revision:
- 4:e20e2500914f
- Parent:
- 3:ceca81e8ac2b
- Child:
- 5:786cb04aaecc
--- a/main.cpp Fri Apr 21 00:07:54 2017 +0000 +++ b/main.cpp Fri Apr 21 00:37:35 2017 +0000 @@ -2,7 +2,7 @@ #include "MBed_Adafruit_GPS.h" #include "math.h" #include "PubNub.h" - +#include "Watchdog.h" string pubkey("pub-c-f9091d93-c3a8-41a6-80c2-c6e3f840504f"); string subkey("sub-c-f558e36c-130b-11e7-b59a-02ee2ddab7fe"); @@ -18,6 +18,8 @@ char tx_buffer[4096]; char rx_buffer[4096]; +Watchdog wdt; + Serial * gps_Serial; Serial pc (USBTX, USBRX); //Set-up for debugging @@ -62,6 +64,7 @@ int main() { + wdt.kick(8.0); pc.baud(115200); //Set PC baud rate pnub.huz.setssid("Verizon-SM-G900V-258B"); pnub.huz.setpwd("trnd533)"); @@ -94,16 +97,16 @@ wait(1); refresh_Timer.start(); //starts the clock on the timer while(true) { - c = myGPS.read(); //queries the GPS - + c = myGPS.read(); //queries the GPS + //if (c) { pc.printf("%c", c); } //this line will echo the GPS data if not paused //If GPS has data, parse it - - //check if we recieved a new message from GPS, if so, attempt to parse it, + + //check if we recieved a new message from GPS, if so, attempt to parse it, if ( myGPS.newNMEAreceived() ) { if ( !myGPS.parse(myGPS.lastNMEA()) ) { - continue; - } + continue; + } } //check if enough time has passed to warrant sending new GPS data @@ -127,5 +130,6 @@ pc.printf("No Satelite Fix\r\n"); } } + wdt.kick(); } } \ No newline at end of file