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: EthernetInterface TMP175 mbed-rtos mbed
Fork of HTTP_POST by
main.cpp
- Committer:
- stefan1691
- Date:
- 2015-06-08
- Revision:
- 7:4972e81b4b17
- Parent:
- 6:48a4698a3416
- Child:
- 8:2ecceb32e68b
File content as of revision 7:4972e81b4b17:
/** HTTP POST Beispiel */ #include "mbed.h" #include "HTTPClient.h" #include "HTTPText.h" #include "EthernetInterface.h" EthernetInterface eth; // HTTPClient Hilfsklasse HTTPClient http; // I/O Buffer char str[512]; DigitalOut myled(LED1); int main() { printf("HTTP Client - POST\n"); eth.init(); eth.connect(); while(1) { myled = 1; // Hilfsklasse um die Response vom Server zu formatieren HTTPText inText(str, 512); // MAP (Argument=Wert) HTTPMap map; map.put("DigitalOut", "LED1"); map.put("write", "1"); int ret = http.post("http://httpbin.org/post", map, &inText); // lokale Variante mit CGI-Script auf Raspberry Pi. Wenn nicht Funktioniert: raspi2x durch IP-Adresse ersetzen // int ret = http.post("http://raspi2x/cgi-bin/rest", map, &inText); 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()); } myled = 0; wait(10); } //eth.disconnect(); }