Example program streaming accelerometer data to a websocket server over a Sprint Mobile Broadband connection
Dependencies: MMA7660 SprintUSBModem WebSocketClient mbed-rtos mbed
Revision 2:9304861e65d6, committed 2012-10-10
- Comitter:
- donatien
- Date:
- Wed Oct 10 08:34:59 2012 +0000
- Parent:
- 1:853199f4d5db
- Child:
- 3:e4db133a4f59
- Commit message:
- Sprint lib update
Changed in this revision
| SprintUSBModem_bleedingedge.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/SprintUSBModem_bleedingedge.lib Thu Sep 27 09:01:06 2012 +0000 +++ b/SprintUSBModem_bleedingedge.lib Wed Oct 10 08:34:59 2012 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/donatien/code/SprintUSBModem_bleedingedge/#9dd2b131afa0 +http://mbed.org/users/donatien/code/SprintUSBModem_bleedingedge/#a2a739fc2bed
--- a/main.cpp Thu Sep 27 09:01:06 2012 +0000
+++ b/main.cpp Wed Oct 10 08:34:59 2012 +0000
@@ -16,21 +16,21 @@
int ret = modem.connect();
if(ret)
{
- printf("Could not connect\n");
+ printf("Could not connect\r\n");
return;
}
//GET data
- printf("Trying to fetch page...\n");
+ printf("Trying to fetch page...\r\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);
+ printf("Page fetched successfully - read %d characters\r\n", strlen(str));
+ printf("Result: %s\r\n", str);
}
else
{
- printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
+ printf("Error - ret = %d - HTTP return code = %d\r\n", ret, http.getHTTPResponseCode());
}
//POST data
@@ -38,21 +38,27 @@
HTTPText text(str, 512);
map.put("Hello", "World");
map.put("test", "1234");
- printf("Trying to post data...\n");
+ printf("Trying to post data...\r\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);
+ printf("Executed POST successfully - read %d characters\r\n", strlen(str));
+ printf("Result: %s\r\n", str);
}
else
{
- printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
+ printf("Error - ret = %d - HTTP return code = %d\r\n", ret, http.getHTTPResponseCode());
}
+ printf("Disconnecting\r\n");
+
modem.disconnect();
+ printf("Disconnected\r\n");
+
modem.power(false);
+
+ printf("Powered off\n");
while(1) {
}