Own fork of MbedSmartRestMain
Dependencies: C027_Support C12832 LM75B MMA7660 MbedSmartRest mbed-rtos mbed
Fork of MbedSmartRestMain by
Diff: main.cpp
- Revision:
- 23:0a48eebaaba8
- Parent:
- 20:ef9cc1b42e9d
- Child:
- 24:8f9b678a7932
--- a/main.cpp Thu Feb 20 14:38:53 2014 +0000 +++ b/main.cpp Mon Mar 24 09:58:46 2014 +0000 @@ -1,10 +1,12 @@ #include "common.h" +#include "apndb.h" #include "io.h" #include "ATResultBuffer.h" C027 c027; ATCommandsInterface *cmdIface = NULL; char cIMEI[21] = ""; +char cIMSI[16] = ""; char cCellId[9] = ""; char cICCID[24] = ""; sigq_t sigQ = {0, 0}; @@ -24,9 +26,26 @@ cmdIface = modem.getATCommandsInterface(); puts("Connecting..."); - if (modem.connect("public4.m2minternet.com")) { - puts("GPRS connection failure."); - return 2; + if (modem.connect("")) { + puts("Searching for login..."); + // get imsi number + printf("IMSI: %s\n", imsi()); + apndb_t *apn = apndb_get(imsi()); + if (apn == NULL) + puts("No APN found."); + else + printf("APN: %s\n", apn->apn); + + if (modem.connect("public4.m2minternet.com")) { + puts("GPRS connection failure."); + return 2; + } + printf("IMSI: %s\n", imsi()); + apn = apndb_get(imsi()); + if (apn == NULL) + puts("No APN found."); + else + printf("APN: %s\n", apn->apn); } // get before starting program as they're permanent @@ -34,6 +53,9 @@ puts("Couldn't read IMEI or ICCID."); return 2; } + + // Shown on display + signalQuality(); puts("Starting program..."); @@ -67,6 +89,23 @@ return cIMEI; } +const char * imsi() +{ + ATCommandsInterface::ATResult result; + ATResultBuffer buffer; + + if ((cmdIface == NULL) || (strlen(cIMSI))) + return cIMSI; + + cmdIface->execute("AT+CIMI", &buffer, &result); + if (ATCommandsInterface::ATResult::AT_OK == result.result) + strcpy(cIMSI, buffer.getLastLine()); + else + cIMSI[0] = '\0'; + + return cIMSI; +} + const char * cellId() { int len; uint32_t cellId;