At the first, please get the token from Stewgate.
Dependencies: EthernetInterface HTTPClient mbed-rtos mbed
Revision 0:b9bca57825b4, committed 2014-08-28
- Comitter:
- y_notsu
- Date:
- Thu Aug 28 01:04:17 2014 +0000
- Commit message:
- Stewgate Tweet sample
Changed in this revision
diff -r 000000000000 -r b9bca57825b4 EthernetInterface.lib --- /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
diff -r 000000000000 -r b9bca57825b4 HTTPClient.lib --- /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
diff -r 000000000000 -r b9bca57825b4 main.cpp --- /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; + } + +}
diff -r 000000000000 -r b9bca57825b4 mbed-rtos.lib --- /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
diff -r 000000000000 -r b9bca57825b4 mbed.bld --- /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