Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: HTTPClient WiflyInterface mbed
Revision 0:cba63cb4bbf9, committed 2012-08-24
- Comitter:
- samux
- Date:
- Fri Aug 24 15:21:55 2012 +0000
- Commit message:
- HTTPClient with the mbed_official WiflyInterface
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HTTPClient.lib Fri Aug 24 15:21:55 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/donatien/code/HTTPClient/#be61104f4e91
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/WiflyInterface.lib Fri Aug 24 15:21:55 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/WiflyInterface/#fb4494783863
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Fri Aug 24 15:21:55 2012 +0000
@@ -0,0 +1,52 @@
+#include "mbed.h"
+#include "WiflyInterface.h"
+#include "HTTPClient.h"
+
+/* wifly interface:
+* - p9 and p10 are for the serial communication
+* - p19 is for the reset pin
+* - p26 is for the connection status
+* - "mbed" is the ssid of the network
+* - "password" is the password
+* - WPA is the security
+*/
+WiflyInterface wifly(p9, p10, p19, p26, "mbed", "password", WPA);
+
+HTTPClient http;
+char str[512];
+
+int main()
+{
+ wifly.init(); //Use DHCP
+
+ wifly.connect();
+
+ //GET data
+ printf("Trying to fetch page...\n");
+ int 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());
+ }
+
+ wifly.disconnect();
+
+ while(1) {
+ }
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Aug 24 15:21:55 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/10b9abbe79a6 \ No newline at end of file