Official reference client implementation for Cumulocity SmartREST on u-blox C027.

Dependencies:   C027_Support C12832 LM75B MMA7660 MbedSmartRest mbed-rtos mbed

Fork of MbedSmartRestMain by Vincent Wochnik

Files at this revision

API Documentation at this revision

Comitter:
vwochnik
Date:
Fri Jan 24 21:06:09 2014 +0000
Child:
1:f37f692db40d
Commit message:
program

Changed in this revision

C027.lib Show annotated file Show diff for this revision Revisions of this file
MbedSmartRest.lib Show annotated file Show diff for this revision Revisions of this file
UbloxUSBModem.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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/C027.lib	Fri Jan 24 21:06:09 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/teams/ublox/code/C027/#bc9e2eb5daa8
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MbedSmartRest.lib	Fri Jan 24 21:06:09 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/vwochnik/code/MbedSmartRest/#ce2f116369bd
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UbloxUSBModem.lib	Fri Jan 24 21:06:09 2014 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/mbed_official/code/UbloxUSBModem/#6e9d98f8c237
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Jan 24 21:06:09 2014 +0000
@@ -0,0 +1,66 @@
+#include "mbed.h"
+#include "C027.h"
+#include "UbloxUSBGSMModem.h"
+#include "UbloxUSBCDMAModem.h"
+
+#include "HTTPClient.h"
+
+C027 c027;
+
+void test(void const*)
+{
+    c027.mdmPower(true);
+    UbloxUSBGSMModem modem; // for LISA-C use the UbloxUSBCDMAModem instead
+    HTTPClient http;
+    char str[512];
+
+    int ret = modem.connect("internet"); // eventaully set another apn here
+    if(ret)
+    {
+        printf("Could not connect %d\n", ret);
+        return;
+    }
+    
+    //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());
+    }
+
+    //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());
+    }
+
+    modem.disconnect();
+    c027.mdmPower(false);
+    
+    while(1) {
+    }
+}
+
+
+int main()
+{
+    Thread testTask(test, NULL, osPriorityNormal, 1024 * 4);
+    DigitalOut led(LED); // on rev A you should reasign the signal to A0
+    while(1) {
+        led=!led;
+        Thread::wait(1000);
+    }
+
+    return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Jan 24 21:06:09 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/a9913a65894f
\ No newline at end of file