C027_Support library test

Dependencies:   C027_Support

Dependents:   C027_SupportTest_xively_location software_test_v1

Fork of Seeed_GPRS_Library_HelloWorld by wei zou

When running this example make sure you have:

  • edited the SIM PIN, APN, USER and PASSWORD for you network operator
  • have inserted a SIM card with enough credits
  • the antennas connected
  • have good reception (especially for GPS)
  • installed the mbed CDC drivers if you run windows
  • connected a terminal program, such as teraterm

The example will connect the modem to the network and attach it. I will place a post request to download a file from mbed website. It will do a USSD request and finally wait for incoming SMS. It will try to answer your SMS (try asking "where are you").

You should see a similar output in your preferred console program:

C027 Support Example
Device Init
Device Status:
  Device:       SARA-G350
  Power Save:   Active
  SIM:          Ready
  CCID:         xxxxxxxxxxxxxxxxxxxxxxxxxxx
  IMEI:         xxxxxxxxxxxxxxxxxxx
  IMSI:         xxxxxxxxxxxxxxxxxxx
  Manufacturer: u-blox
  Model:        SARA-G350
  Version:      08.49
Network Check
Network Status:
  Registration:       Home
  Signal Strength:    -87 dBm
  Operator:           Swisscom
  Phone Number:       +41xxxxxxxxxxx
Network Join
  IP Address: xx.xx.xx.xx
Socket Create
Socket Connect
Make a Http Post Request
Socket Send
Socket Recving
Socket 0: 337 bytes pending
Socket 0: 145 bytes pending
Socket 0: closed by remote host
Socket Recv "HTTP/1.1 200 OK
Server: nginx/1.1.19
Date: Thu, 10 Apr 2014 13:09:02 GMT
Content-Type: text/plain
Connection: close
Last-Modified: Fri, 27 Jul 2012 13:30:34 GMT
Cache-Control: max-age=36000
Expires: Thu, 10 Apr 2014 20:43:53 GMT
Vary: Accept-Encoding
X-Mystery-Header: 260358892
X-be: web0_prod_sjc
Age: 8709

Hello world!
"
Socket Close
Socket Free
Network Disconnect
Send Ussd Command *#134#
Got Ussd Answer: "UNKNOWN APPLICATION"
Checking SMS and GPS
GPS Location: 47.28xxx 8.56xxx
GPS Location: 47.28xxx 8.56xxx
...
GPS Location: 47.28xxx 8.56xxx
GPS Location: 47.28xxx 8.56xxx
Network Status:
  Registration:       Home
  Signal Strength:    -89 dBm
  Operator:           Swisscom
  Phone Number:       +41xxxxxxxxx
GPS Location: 47.28xxx 8.56xxx
GPS Location: 47.28xxx 8.56xxx
...
Revision:
6:71f6214d595e
Parent:
5:5366d39d3719
Child:
7:e000317ddef6
--- a/main.cpp	Wed Apr 09 11:48:52 2014 +0000
+++ b/main.cpp	Wed Apr 09 13:04:06 2014 +0000
@@ -7,18 +7,24 @@
 
 void printDeviceStatus(MDMParser::DevStatus* status) {
     printf("Device Status:\r\n");
-    const char* txtModel[] = { "Unknown", "SARA-G350", "LISA-U200", "LISA-C200" };
-    if (status->model < sizeof(txtModel)/sizeof(*txtModel) && (status->model != MDMParser::MODEL_UNKNOWN))
-        printf("  Model: %s\r\n", txtModel[status->model]);
+    const char* txtDev[] = { "Unknown", "SARA-G350", "LISA-U200", "LISA-C200" };
+    if (status->dev < sizeof(txtDev)/sizeof(*txtDev) && (status->dev != MDMParser::DEV_UNKNOWN))
+        printf("  Device:       %s\r\n", txtDev[status->dev]);
     const char* txtSim[] = { "Unknown", "Pin", "Ready" };
     if (status->sim < sizeof(txtSim)/sizeof(*txtSim) && (status->sim != MDMParser::SIM_UNKNOWN))
-        printf("  SIM:   %s\r\n", txtSim[status->sim]);
-    if (status->ccid)  
-        printf("  CCID:  %s\r\n", status->ccid);
-    if (status->imei) 
-        printf("  IMEI:  %s\r\n", status->imei);
-    if (status->imsi)  
-        printf("  IMSI:  %s\r\n", status->imsi);
+        printf("  SIM:          %s\r\n", txtSim[status->sim]);
+    if (*status->ccid)  
+        printf("  CCID:         %s\r\n", status->ccid);
+    if (*status->imei) 
+        printf("  IMEI:         %s\r\n", status->imei);
+    if (*status->imsi)  
+        printf("  IMSI:         %s\r\n", status->imsi);
+    if (*status->manu) 
+        printf("  Manufacturer: %s\r\n", status->manu);
+    if (*status->model)  
+        printf("  Model:        %s\r\n", status->model);
+    if (*status->ver)  
+        printf("  Version:      %s\r\n", status->ver);
 }
 
 void printNetStatus(MDMParser::NetStatus *status)
@@ -32,9 +38,9 @@
         printf("  Access Technology:  %s\r\n", txtAct[status->act]);
     if (status->rssi) 
         printf("  Signal Strength:    %d dBm\r\n", status->rssi);
-    if (status->opr)  
+    if (*status->opr)  
         printf("  Operator:           %s\r\n", status->opr);
-    if (status->num)  
+    if (*status->num)  
         printf("  Phone Number:       %s\r\n", status->num);
 }
 
@@ -61,7 +67,7 @@
                 );
                 
     // initialize the modem 
-    printf("Init\r\n");
+    printf("Device Init\r\n");
     MDMParser::DevStatus devStatus;
     MDMParser::NetStatus netStatus;
     if (mdm.init(/* SIM PIN = */ NULL, &devStatus))
@@ -82,7 +88,7 @@
                      /* PASSWORD = */ NULL);
         if (ip != NOIP)
         {
-            printf("IP Address: " IPSTR "\r\n", IPNUM(ip));
+            printf("  IP Address: " IPSTR "\r\n", IPNUM(ip));
             printf("Socket Create\r\n");
             int socket = mdm.socketSocket(MDMParser::IPPROTO_TCP);
             if (socket >= 0)