whatever
Dependencies: C027 C027_Support M2XStreamClient PowerControl jsonlite mbed-rtos mbed
Fork of PONY_Ph0-uAXIS by
Diff: main.cpp
- Revision:
- 37:71ab32b61dfb
- Parent:
- 36:258f3bb1c6a4
- Child:
- 38:d86e744166b6
--- a/main.cpp Tue Dec 01 23:25:20 2015 +0000 +++ b/main.cpp Wed Dec 02 01:57:56 2015 +0000 @@ -19,7 +19,6 @@ #include "MDM.h" - //------------------------------------------------------------------------------------ // Cellular modem/SIM parameters #define SIMPIN "1111" //!SIMPIN is 1111 by default for AT&T SIMs. @@ -34,29 +33,82 @@ //------------------------------------------------------------------------------------ +//#define CELLOCATE -#define CELLOCATE - +//------------------------------------------------------------------------------------ +//------------------------------------------------------------------------------------ +//------------------------------------------------------------------------------------ int main(void) { + + printf("\r\n\n\n\n-----\r\nI'm alive!\r\n\n"); + int ret; -#ifdef LARGE_DATA char buf[2048] = ""; -#else - char buf[512] = ""; -#endif + + // Create the GPS object + GPSI2C gps; + + + //----- MODEM UP!!! + printf("Waiting 15s for boot or what-not\r\n"); + wait(15); + + printf("Open modem object mdm\r\n"); + + MDMSerial mdm; + mdm.setDebug(4); // enable this for debugging issues + + + // Create status objects + MDMParser::DevStatus devStatus = {}; + MDMParser::NetStatus netStatus = {}; + + bool mdmOk = mdm.init(SIMPIN, &devStatus); + + // How we doing so far? + printf("\r\n-- mdm.init status dump\r\n"); + mdm.dumpDevStatus(&devStatus); + + if (mdmOk) { + // wait until we are connected (SGM: Not sure what this means, since this isn't a loop... + mdmOk = mdm.registerNet(&netStatus); + mdm.dumpNetStatus(&netStatus); + + } + + printf("-- mdm.registerNet status dump\r\n"); + + // Open a data connecction + if(mdmOk) { + + MDMParser::IP ip = mdm.join(APN,USERNAME,PASSWORD); + printf("-- mdm.join dump\r\n"); + + + // If we secure an IP address, keep going! + + if (ip != NOIP) { + + printf("\n\n\rWe got's an IP address!\r\n"); + mdm.dumpIp(ip); + + } + } + + /* - // Create the GPS object - GPSI2C gps; + + + // Create the modem object MDMSerial mdm; - //mdm.setDebug(4); // enable this for debugging issues - + mdm.setDebug(4); // enable this for debugging issues // initialize the modem MDMParser::DevStatus devStatus = {}; @@ -67,25 +119,12 @@ if (mdmOk) { -#if 0 - // file system API - const char* filename = "File"; - char buf[] = "Hello World"; - printf("writeFile \"%s\"\r\n", buf); - if (mdm.writeFile(filename, buf, sizeof(buf))) - { - memset(buf, 0, sizeof(buf)); - int len = mdm.readFile(filename, buf, sizeof(buf)); - if (len >= 0) - printf("readFile %d \"%.*s\"\r\n", len, len, buf); - mdm.delFile(filename); - } -#endif // wait until we are connected mdmOk = mdm.registerNet(&netStatus); mdm.dumpNetStatus(&netStatus); } + if (mdmOk) { // http://www.geckobeach.com/cellular/secrets/gsmcodes.php @@ -251,6 +290,8 @@ } } #endif + + #ifdef CELLOCATE if (mdmOk && (j++ == submitPeriod * 1000/wait)) { j=0; @@ -271,39 +312,12 @@ if (cellLocWait && (j%100 == 0 )) printf("Waiting for CellLocate...\r\n"); #endif - if (mdmOk && (i++ == 5000/wait)) { - i = 0; - // check the network status - if (mdm.checkNetStatus(&netStatus)) { - mdm.dumpNetStatus(&netStatus, fprintf, stdout); - } - - // checking unread sms - int ix[8]; - int n = mdm.smsList("REC UNREAD", ix, 8); - if (8 < n) n = 8; - while (0 < n--) - { - char num[32]; - printf("Unread SMS at index %d\r\n", ix[n]); - if (mdm.smsRead(ix[n], num, buf, sizeof(buf))) { - printf("Got SMS from \"%s\" with text \"%s\"\r\n", num, buf); - printf("Delete SMS at index %d\r\n", ix[n]); - mdm.smsDelete(ix[n]); - // provide a reply - const char* reply = "Hello my friend"; - if (strstr(buf, /*w*/"here are you")) - reply = *link ? link : "I don't know"; // reply wil location link - else if (strstr(buf, /*s*/"hutdown")) - abort = true, reply = "bye bye"; - printf("Send SMS reply \"%s\" to \"%s\"\r\n", reply, num); - mdm.smsSend(num, reply); - } - } - } - wait_ms(wait); + + } gps.powerOff(); mdm.powerOff(); return 0; + + */ }