![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
whatever
Dependencies: C027 C027_Support M2XStreamClient PowerControl jsonlite mbed-rtos mbed
Fork of PONY_Ph0-uAXIS by
main.cpp
- Committer:
- sgmcb
- Date:
- 2015-11-21
- Revision:
- 31:f94b8f987b62
- Parent:
- 30:f9bb5aba1155
- Child:
- 32:4b94cb22d338
File content as of revision 31:f94b8f987b62:
#include "mbed.h" #include <string.h> // ublox C027 support libraries #include "GPS.h" // GPS support #include "MDM.h" // Modem support // AT&T Support //------------------------------------------------------------------------------------ // Cellular modem/SIM parameters #define SIMPIN "1111" //!SIMPIN is 1111 by default for AT&T SIMs. #define APN "m2m.com.attz" // Defined AT&T M2M APN #define USERNAME NULL //! Set the user name for your APN, or NULL if not needed (which, apparently, it isn't) #define PASSWORD NULL //! Set the password for your APN, or NULL if not needed (which, apparently, it isn't) //------------------------------------------------------------------------------------ // Set pinout for LED DigitalOut myled(LED); int main(void) { printf("\n\n\r----------\r\nI'm alive!\r\n"); // Loading wait for(int i = 0; i < 10; i++) { myled = !myled;; wait(0.2); } int ret; // Integer returns // Not 100% sure where this LARGE_DATA flag is being set, but I think we might be using it... (SGM) #ifdef LARGE_DATA char buf[2048] = ""; #else char buf[512] = ""; #endif if(sizeof(buf) > 600) printf("(Using LARGE_DATA)\r\n"); else printf("(Not using large data)\r\n"); printf("\r\nBegin test loop\r\n"); GPSI2C gps; // Initialize GPS object printf("GPS initialized...\r\n"); while( (ret = gps.getMessage(buf, sizeof(buf))) < 1 ) { if (ret<0) printf("WAIT received from GPS\r\n"); if (ret==0) printf("NOT FOUND received from GPS\r\n"); myled = !myled; wait(1.0); } float locationLoopWait = 1.0; int locationLoopIter = 0; // Get a good GPS message int len = LENGTH(ret); while(true) { locationLoopIter++; ret = gps.getMessage(buf, sizeof(buf)); // Test for location data in this priority: GLL, RMC, GGA if ( strstr(buf, "GLL") ) { char ch = '-'; // FIX: The getNmeaItem isn't working to capture the check character in a valid GLL code, which is unusual; the workaround seems to be that invalid GLL values DOES find a "V" if(!gps.getNmeaItem(6,buf,len,ch)) { printf("\n\n\rHave GLL location data after %i seconds and %i requests:\r\n", ( (int) locationLoopWait * locationLoopIter), locationLoopIter ); printf(buf); break; } else { printf("Received invalid GLL data\r\n"); printf(buf); } } else if ( strstr(buf, "RMC") ) { printf("RMC loc..."); //printf(buf); printf("\r\n\n"); } else if ( strstr(buf, "GGA") ) { printf("GGA loc..."); //printf(buf); printf("\r\n\n"); } else { printf("\n\rNo location data this message\r\n"); } wait(locationLoopWait); }// LOOP THAT MOFO // Begin parsing our GPS value double la = 0, lo = 0; // Declare latitude and longitude variables gps.getNmeaAngle(1,buf,len,la); gps.getNmeaAngle(3,buf,len,lo); printf("\r\n\nLatitude: %G\r\nLongitude: %G\r\n", la, lo); /* if ((PROTOCOL(ret) == GPSParser::NMEA) && (len > 6)) { // Check if we're getting an NMEA protocol response printf("Indeed, an NMEA protocol response!\r\n"); // Check the talker if( (buf[0] == '$') || (buf[1] == 'G' ) ) { char talkerID[30] = ""; sprintf(talkerID, "We've got a valid talker=%c%c\r\n", buf[0], buf[1]); printf(talkerID); } } */ }