インターフェース2014年10月号のu-blox C027で3G通信する記事で使用したプログラム。   CQ publishing Interface 2014.10 issue, C027 3G test program.

Dependencies:   C027_Support C027_SupportTest mbed picojson

Fork of C027_SupportTest by u-blox

インターフェース2014年10月号のu-blox C027で3G通信する記事で使用したプログラムです。

Files at this revision

API Documentation at this revision

Comitter:
mazgch
Date:
Tue May 13 09:35:14 2014 +0000
Parent:
14:ab7c8627f950
Child:
16:43f6de7bc38b
Commit message:
update libs

Changed in this revision

C027_Support.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/C027_Support.lib	Mon May 12 07:29:13 2014 +0000
+++ b/C027_Support.lib	Tue May 13 09:35:14 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/teams/ublox/code/C027_Support/#e7b81c31baec
+http://mbed.org/teams/ublox/code/C027_Support/#869bd35f44cc
--- 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];