USSDTest, working with SARA-G350 on C027

Dependencies:   C027 UbloxUSBModem mbed

Fork of C027_HTTPClientTest by u-blox

Revision:
12:88552ae75244
Parent:
10:e2315bcdd7be
Child:
13:9350ec2ec1cd
--- a/main.cpp	Wed Nov 06 10:49:08 2013 +0000
+++ b/main.cpp	Mon Mar 03 07:49:48 2014 +0000
@@ -1,20 +1,54 @@
 #include "mbed.h"
 #include "C027.h"
-#include "UbloxUSBGSMModem.h"
-#include "UbloxUSBCDMAModem.h"
+#include "UbloxModem.h"
 
 #include "HTTPClient.h"
 
 C027 c027;
 
+#define MODEM_APN "gprs.swisscom.ch"
+
+#ifndef MODEM_APN
+#warning APN not specified, using "internet"
+#define MODEM_APN "internet"
+#endif
+
+#ifndef MODEM_USERNAME
+#warning username not specified
+#define MODEM_USERNAME NULL
+#endif
+
+#ifndef MODEM_PASSWORD
+#warning password not specified
+#define MODEM_PASSWORD NULL
+#endif
+
 void test(void const*)
 {
+#if 1
+    // Serial is supported by LISA-C, LISA-U and SARA-G
     c027.mdmPower(true);
-    UbloxUSBGSMModem modem; // for LISA-C use the UbloxUSBCDMAModem instead
+    wait_ms(5000);
+    UbloxSerModem modem;
+#else
+    // USB is supported by LISA-C or LISA-U
+    c027.mdmUsbEnable(true);
+    c027.mdmPower(true);
+    wait_ms(5000);
+    UbloxUSBModem modem;
+#endif
+
     HTTPClient http;
     char str[512];
 
-    int ret = modem.connect("internet"); // eventaully set another apn here
+    int ret;
+    for (;;) 
+    {
+        ret = modem.connect(MODEM_APN, MODEM_USERNAME, MODEM_PASSWORD); // eventaully set another apn here
+        if (!ret)
+            break;
+        wait_ms(1000);
+    }
     if(ret)
     {
         printf("Could not connect %d\n", ret);