公式ホームページのPlogramでエラーが発生してビルドに失敗するので作成しました。
Dependencies: C12832 EthernetInterface HTTPClient mbed-rtos mbed
Revision 0:16eef181c81e, committed 2014-04-05
- Comitter:
- txracing
- Date:
- Sat Apr 05 04:47:58 2014 +0000
- Commit message:
- test
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/C12832.lib Sat Apr 05 04:47:58 2014 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/chris/code/C12832/#7de323fa46fe
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/EthernetInterface.lib Sat Apr 05 04:47:58 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/EthernetInterface/#6a67d2bddc7c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HTTPClient.lib Sat Apr 05 04:47:58 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/donatien/code/HTTPClient/#1f743885e7de
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Apr 05 04:47:58 2014 +0000 @@ -0,0 +1,109 @@ +#include "mbed.h" +#include "EthernetInterface.h" +#include "HTTPClient.h" +#include "C12832.h" + +EthernetInterface eth; +HTTPClient http; +char str[512]; + +C12832 lcd(p5, p7, p6, p8, p11); + +int main() +{ + eth.init(); //Use DHCP + + eth.connect(); + + + + //GET data + + lcd.cls(); + lcd.locate(0,3); + lcd.printf("\nTrying to fetch page...\n"); + int ret = http.get("http://mbed.org/media/uploads/donatien/hello.txt", str, 128); + if (!ret) + { + lcd.cls(); + lcd.locate(0,3); + lcd.printf("Page fetched successfully - read %d characters\n", strlen(str)); + printf("Result: %s\n", str); + } + else + { + lcd.cls(); + lcd.locate(0,3); + lcd.printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode()); + } + + //POST data + HTTPMap map; + HTTPText inText(str, 512); + map.put("Hello", "World"); + map.put("test", "1234"); + lcd.cls(); + lcd.locate(0,3); + lcd.printf("\nTrying to post data...\n"); + ret = http.post("http://httpbin.org/post", map, &inText); + if (!ret) + { + lcd.cls(); + lcd.locate(0,3); + lcd.printf("Executed POST successfully - read %d characters\n", strlen(str)); + lcd.printf("Result: %s\n", str); + } + else + { + lcd.cls(); + lcd.locate(0,3); + lcd.printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode()); + } + + //PUT data + strcpy(str, "This is a PUT test!"); + HTTPText outText(str); + //HTTPText inText(str, 512); + lcd.cls(); + lcd.locate(0,3); + lcd.printf("\nTrying to put resource...\n"); + ret = http.put("http://httpbin.org/put", outText, &inText); + if (!ret) + { + lcd.cls(); + lcd.locate(0,3); + lcd.printf("Executed PUT successfully - read %d characters\n", strlen(str)); + lcd.printf("Result: %s\n", str); + } + else + { + lcd.cls(); + lcd.locate(0,3); + lcd.printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode()); + } + + //DELETE data + //HTTPText inText(str, 512); + lcd.cls(); + lcd.locate(0,3); + lcd.printf("\nTrying to delete resource...\n"); + ret = http.del("http://httpbin.org/delete", &inText); + if (!ret) + { + lcd.cls(); + lcd.locate(0,3); + lcd.printf("Executed DELETE successfully - read %d characters\n", strlen(str)); + lcd.printf("Result: %s\n", str); + } + else + { + lcd.cls(); + lcd.locate(0,3); + lcd.printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode()); + } + + eth.disconnect(); + + while(1) { + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-rtos.lib Sat Apr 05 04:47:58 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed-rtos/#420a92812cd1
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sat Apr 05 04:47:58 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/7d30d6019079 \ No newline at end of file