USSDTest, working with SARA-G350 on C027

Dependencies:   C027 UbloxUSBModem mbed

Fork of C027_HTTPClientTest by u-blox

Files at this revision

API Documentation at this revision

Comitter:
omega256
Date:
Sat Mar 08 17:15:00 2014 +0000
Parent:
14:b2b75c8a01fa
Commit message:
Example C027 with SARA-G350 for USSD

Changed in this revision

HTTPClient.lib Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r b2b75c8a01fa -r 6fdc76603237 HTTPClient.lib
--- a/HTTPClient.lib	Mon Mar 03 08:02:32 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/donatien/code/HTTPClient/#1f743885e7de
diff -r b2b75c8a01fa -r 6fdc76603237 main.cpp
--- a/main.cpp	Mon Mar 03 08:02:32 2014 +0000
+++ b/main.cpp	Sat Mar 08 17:15:00 2014 +0000
@@ -2,77 +2,31 @@
 #include "C027.h"
 #include "UbloxModem.h"
 
-#include "HTTPClient.h"
-
-C027 c027;
-
-#ifndef MODEM_APN
-#warning APN not specified, using "internet"
-#define MODEM_APN "internet"
-#endif
+#define USSD_COMMAND "*100#"
+/*
+ * Modified USSD example, working with SARA-G350
+ * Based on USSDTest and HTTP Test from u-blox
+ * Output to PC via USB Serial Port, 9600 Baud
+ */
 
-#ifndef MODEM_USERNAME
-#warning username not specified
-#define MODEM_USERNAME NULL
-#endif
-
-#ifndef MODEM_PASSWORD
-#warning password not specified
-#define MODEM_PASSWORD NULL
-#endif
+Serial pc(USBTX, USBRX);
+C027 c027;
 
 void test(void const*)
 {
-#if 1 // Switch this to select between the Serial and USB interface
-    // Serial is supported by LISA-C, LISA-U and SARA-G
     c027.mdmPower(true);
-    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];
+    UbloxSerModem modem; // for LISA-C use the UbloxUSBCDMAModem instead
+    char result[128];
 
-    int ret;
-    for (;;) 
-    {
-        ret = modem.connect(MODEM_APN, MODEM_USERNAME, MODEM_PASSWORD); // eventaully set another apn here
-        if (!ret)
-            break;
-        wait_ms(1000);
-    }
-    
-    //GET data
-    printf("Trying to fetch page...\n");
-    ret = http.get("http://mbed.org/media/uploads/donatien/hello.txt", str, 128);
-    if (!ret) {
-        printf("Page fetched successfully - read %d characters\n", strlen(str));
-        printf("Result: %s\n", str);
-    } else {
-        printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
+    pc.printf("Sending %s on USSD channel\n", USSD_COMMAND);
+
+    int ret = modem.sendUSSD(USSD_COMMAND, result, sizeof(result));
+    if(ret) {
+        pc.printf("Send USSD command returned %d\n", ret);
     }
 
-    //POST data
-    HTTPMap map;
-    HTTPText text(str, 512);
-    map.put("Hello", "World");
-    map.put("test", "1234");
-    printf("Trying to post data...\n");
-    ret = http.post("http://httpbin.org/post", map, &text);
-    if (!ret) {
-        printf("Executed POST successfully - read %d characters\n", strlen(str));
-        printf("Result: %s\n", str);
-    } else {
-        printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
-    }
+    pc.printf("Result of command: %s\n", result);
 
-    modem.disconnect();
     c027.mdmPower(false);
     
     while(1) {