At the first, please get the token from Stewgate.

Dependencies:   EthernetInterface HTTPClient mbed-rtos mbed

Files at this revision

API Documentation at this revision

Comitter:
y_notsu
Date:
Thu Aug 28 01:04:17 2014 +0000
Commit message:
Stewgate Tweet sample

Changed in this revision

EthernetInterface.lib Show annotated file Show diff for this revision Revisions of this file
HTTPClient.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-rtos.lib 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/EthernetInterface.lib	Thu Aug 28 01:04:17 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/EthernetInterface/#f69b81aa9eb1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HTTPClient.lib	Thu Aug 28 01:04:17 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/donatien/code/HTTPClient/#277279a1891e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Aug 28 01:04:17 2014 +0000
@@ -0,0 +1,61 @@
+#include "mbed.h"
+#include "EthernetInterface.h"
+#include "HTTPClient.h"
+#include "rtos.h"
+
+DigitalOut myled(LED1);
+
+int main() {
+    EthernetInterface eth;
+    int retEth;
+    HTTPClient http;
+    int rethttp;
+    //EthernetInterface eth;
+    //HTTPClient http;
+    char str[512];
+    
+    
+    printf("Setting up ...\r\n");
+    //ネットワークの初期設定DCHPを利用してネットワークを自動で設定している
+    eth.init();
+    retEth = eth.connect();
+    
+    //ネットワークの状況をprintfで表示
+    if(!retEth)
+    {
+        printf("Network Setup OK\r\n");
+            //POSTメソッドでstewgateにDataを送信
+        //POST data
+        HTTPMap map;
+        HTTPText inText(str, 512);
+        map.put("_t","your_token");
+        map.put("msg","Tweet from mbed!! using stewgate");
+        printf("\nTrying to post data...\n");
+        rethttp = http.post("http://stewgate-u.appspot.com/api/post/", map, &inText);
+        if (!rethttp)
+        {
+            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", rethttp,http.getHTTPResponseCode());
+        }
+    }
+    else
+    {
+        printf("Network Error %d\r\n",retEth);
+        
+    }
+    
+
+
+    eth.disconnect();  
+ 
+    while(1) {
+        myled=0;
+        wait(0.5);
+        myled=1;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Thu Aug 28 01:04:17 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-rtos/#34e80e862021
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Aug 28 01:04:17 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/6213f644d804
\ No newline at end of file