whatever
Dependencies: C027 C027_Support M2XStreamClient PowerControl jsonlite mbed-rtos mbed
Fork of PONY_Ph0-uAXIS by
Diff: main.cpp
- Revision:
- 42:8e6e647cb7d5
- Parent:
- 41:f603d76dc6fe
- Child:
- 43:80aa0c933e1a
--- a/main.cpp Tue Dec 29 06:56:52 2015 +0000 +++ b/main.cpp Tue Dec 29 07:00:35 2015 +0000 @@ -1,41 +1,24 @@ #include "mbed.h" //------------------------------------------------------------------------------------ -/* This example was tested on C027-U20 and C027-G35 with the on board modem. - - Additionally it was tested with a shield where the SARA-G350/U260/U270 RX/TX/PWRON - is connected to D0/D1/D4 and the GPS SCL/SDA is connected D15/D15. In this - configuration the following platforms were tested (it is likely that others - will work as well) - - U-BLOX: C027-G35, C027-U20, C027-C20 (for shield set define C027_FORCE_SHIELD) - - NXP: LPC1549v2, LPC4088qsb - - Freescale: FRDM-KL05Z, FRDM-KL25Z, FRDM-KL46Z, FRDM-K64F - - STM: NUCLEO-F401RE, NUCLEO-F030R8 - mount resistors SB13/14 1k, SB62/63 0R -*/ - // C027 Support Libraries #include "GPS.h" #include "MDM.h" +// M2X Support Libraries #include <jsonlite.h> #include "M2XStreamClient.h" +// PONY-specific config support libraries #include "LIS331.h" +#include "PONY_Loc.h" // PONY Location Code #include "PONY_sense.h" - - //---- // DEBUG DEFINITIONS - #define THROWAWAY - //#define MDMDEBUG - - - //------------------------------------------------------------------------------------ // Cellular modem/SIM parameters #define SIMPIN "1111" //!SIMPIN is 1111 by default for AT&T SIMs. @@ -43,8 +26,6 @@ #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) - - //------------------------------------------------------------------------------------ // AT&T M2X Kekys @@ -63,13 +44,6 @@ //------------------------------------------------------------------------------------ - -#include "PONY_Loc.h" // PONY Location Code -#include "H3LIS331DL.h" // Accelerometer library - - - - // PIN Config DigitalIn jostle(P2_13); @@ -83,41 +57,39 @@ LIS331 axle(P0_0, P0_1); // Library object - -// GLOBALS +//------------------------------------------------------------------------------------ +// GLOBAL VARIABLES Ticker flipper; - +// M2X Drivers Client client; M2XStreamClient m2xClient(&client, M2XAPIKEY); int M2X_response; // For m2x message responses + char statusBuf[145] = ""; - +// Location reading unsigned int kReadingDelay = 3 * 60 * 1000; // How many seconds to wait between reads unsigned int kReadingDelayClimb = 15000; // How many seconds to add to the wait period when sitting idle unsigned int kReadingDelayMax = 5 * 60000; // What's the maximum time between readings? - - double kLaLoDiffMin = 0.01; double kAltDiffMin = 2.00; +// Temperature reads float kTemp; +// Loop drivers unsigned int kIdleSpins = 0; -//uint16_t kSysSeconds; +// System time time_t kSysSeconds = time(NULL); bool kSysClockSet = false; tm kFormatTime; - -void parseM2XLocation2(const char* name, double latitude, double longitude, double elevation, const char* timestamp, int index, void* context) { - printf("\n\n\n\n\n\n\n\n\n\n\n\n\nparseM2XLocation2\r\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); -} +// Global function definitions void flip() { led1 = !led1; @@ -134,12 +106,7 @@ #ifdef THROWAWAY printf("Using THROWAWAY M2X device\r\n"); #endif - - //int ret = 0; - //int len = 0; - //char buf[2048] = ""; - MDMSerial mdm; MDMParser::DevStatus devStatus = {}; MDMParser::NetStatus netStatus = {}; @@ -148,13 +115,7 @@ //mdm.setDebug(4); #endif - //------------------------------------------------ - //------------------------------------------------ - // I2C TESTING - // Acceleromter object - //char ax[2]; - - + // ACCELEROMETER //printf("Set up accelerometer\r\n"); @@ -188,7 +149,7 @@ - + // LOCATION READING // Open modem connection @@ -204,19 +165,10 @@ // Cell location data MDMSerial::CellLocData ponyLoc, thisLoc; - printf("Configure deep scan mode\r\n"); int locConf = mdm.cellLocConfigSensor(1); // Set deep scan mode - // Set CellLocate server connection - //printf("\033[33mConnect to CellLocate server...\033[39m\r\n"); - //if (!mdm.cellLocSrvHttp("tFpJ8NlWXUa8keKu3UY4AQ")) - // mdm.cellLocSrvUdp(); - - // Set URCs? - //printf("Congifure URCs\r\n"); - //mdm.cellLocUnsolIndication(1); // Loop driving variables bool locLock; @@ -226,13 +178,9 @@ int loopIter = 0; int locAccLower = 50; // Immediately accept locations with uncertainty lower than this int locAccUpper = 5000; // Don't accept locations with uncertainty greater than this - - // NO DIFF - //printf("Waiting one minute for cell location to lock.\r\n"); - //delay(60000); // Wait one minute after booting to see if that makes our first cell loc calls give better data - + // ----------------------- // Location reporting loop while(true) {