mbed 5.4 with sleep mode
Dependencies: C027_Support mbed-dev
Fork of C027_SupportTest_coap by
Diff: main.cpp
- Revision:
- 15:ea10b6cf8c85
- Parent:
- 14:ab7c8627f950
- Child:
- 16:43f6de7bc38b
--- a/main.cpp Mon May 12 07:29:13 2014 +0000 +++ b/main.cpp Tue May 13 09:35:14 2014 +0000 @@ -41,6 +41,17 @@ #ifdef C027_USEONBOARD #include "C027.h" C027 c027; +#elif TARGET_LPC4088 + // mapping for use with the EA QSB base board + #define GPSSCL p20 + #define GPSSDA p19 + #define GPSADR (66<<1) // GPS I2C Address + #define MDMPWRON p33 + #define MDMTXD p9 + #define MDMRXD p10 + #define MDMCTS NC + #define MDMRTS NC + #define MDMBAUD 115200 #else #define GPSSCL D15 #define GPSSDA D14 @@ -54,51 +65,8 @@ #endif // no tracing if serial is shared with the VCP -#define TRACE ((USBRX==MDMRXD)||(USBTX==MDMTXD))?:printf - -void printDeviceStatus(MDMParser::DevStatus* status) { - TRACE("Device Status:\r\n"); - const char* txtDev[] = { "Unknown", "SARA-G350", "LISA-U200", "LISA-C200" }; - if (status->dev < sizeof(txtDev)/sizeof(*txtDev) && (status->dev != MDMParser::DEV_UNKNOWN)) - TRACE(" Device: %s\r\n", txtDev[status->dev]); - const char* txtLpm[] = { "Disabled", "Enabled", "Active" }; - if (status->lpm < sizeof(txtLpm)/sizeof(*txtLpm)) - TRACE(" Power Save: %s\r\n", txtLpm[status->lpm]); - const char* txtSim[] = { "Unknown", "Pin", "Ready" }; - if (status->sim < sizeof(txtSim)/sizeof(*txtSim) && (status->sim != MDMParser::SIM_UNKNOWN)) - TRACE(" SIM: %s\r\n", txtSim[status->sim]); - if (*status->ccid) - TRACE(" CCID: %s\r\n", status->ccid); - if (*status->imei) - TRACE(" IMEI: %s\r\n", status->imei); - if (*status->imsi) - TRACE(" IMSI: %s\r\n", status->imsi); - if (*status->meid) - TRACE(" MEID: %s\r\n", status->meid); - if (*status->manu) - TRACE(" Manufacturer: %s\r\n", status->manu); - if (*status->model) - TRACE(" Model: %s\r\n", status->model); - if (*status->ver) - TRACE(" Version: %s\r\n", status->ver); -} - -void printNetStatus(MDMParser::NetStatus *status) -{ - TRACE("Network Status:\r\n"); - const char* txtReg[] = { "Unknown", "Denied", "None", "Home", "Roaming" }; - if (status->reg < sizeof(txtReg)/sizeof(*txtReg) && (status->reg != MDMParser::REG_UNKNOWN)) - TRACE(" Registration: %s\r\n", txtReg[status->reg]); - const char* txtAct[] = { "Unknown", "GSM", "Edge", "3G", "CDMA" }; - if (status->act < sizeof(txtAct)/sizeof(*txtAct) && (status->act != MDMParser::ACT_UNKNOWN)) - TRACE(" Access Technology: %s\r\n", txtAct[status->act]); - if (status->rssi) - TRACE(" Signal Strength: %d dBm\r\n", status->rssi); - if (*status->opr) - TRACE(" Operator: %s\r\n", status->opr); - if (*status->num) - TRACE(" Phone Number: %s\r\n", status->num); -} +#define DOTRACE ((USBRX!=MDMRXD)&&(USBTX!=MDMTXD)) +#define TRACE (!DOTRACE)?:printf int main(void) { @@ -106,7 +74,7 @@ char buf[512] = ""; // only trace if the serial is different from our modem port - if ((USBRX!=MDMRXD)&&(USBTX!=MDMTXD)) { + if (DOTRACE) { Serial pc(USBTX,USBRX); pc.baud(115200); } @@ -150,21 +118,21 @@ bool mdmOk = mdm.init(SIMPIN, &devStatus); if (mdmOk) { - printDeviceStatus(&devStatus); + if (DOTRACE) mdm.dumpDevStatus(&devStatus); // wait until we are connected TRACE("Network Check\r\n"); while (!mdm.checkNetStatus(&netStatus)) wait_ms(1000); - printNetStatus(&netStatus); + if (DOTRACE) mdm.dumpNetStatus(&netStatus); TRACE("Network Join\r\n"); // join the internet connection MDMParser::IP ip = mdm.join(APN,USERNAME,PASSWORD); if (ip != NOIP) { - TRACE(" IP Address: " IPSTR "\r\n", IPNUM(ip)); + if (DOTRACE) mdm.dumpIp(ip); TRACE("Socket Create\r\n"); int socket = mdm.socketSocket(MDMParser::IPPROTO_TCP); if (socket >= 0) @@ -234,8 +202,9 @@ if (mdmOk && (i++ == 10000/wait)) { i = 0; // check the network status - if (mdm.checkNetStatus(&netStatus)) - printNetStatus(&netStatus); + if (mdm.checkNetStatus(&netStatus)) { + if (DOTRACE) mdm.dumpNetStatus(&netStatus); + } // checking unread sms int ix[8];