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 HTTPClient mbed-rtos mbed
main.cpp
00001 #include "mbed.h" 00002 #include "EthernetInterface.h" 00003 #include "HTTPClient.h" 00004 00005 EthernetInterface eth; 00006 HTTPClient http; 00007 char str[512]; 00008 HTTPText inData(str, 512); 00009 Serial pc(USBTX, USBRX); 00010 int ret; 00011 00012 int main() 00013 { 00014 00015 eth.init(); 00016 ret = eth.connect(); 00017 00018 if (!ret) { 00019 pc.printf("ip: %s, %s, %s\r\n", eth.getIPAddress(), eth.getNetworkMask(), eth.getGateway()); 00020 } else { 00021 pc.printf("Ethernet connect failed. ret: %d\r\n", ret); 00022 return -1; 00023 } 00024 00025 HTTPMap map; 00026 map.put("value1", "Hello World."); 00027 ret = http.post("http://maker.ifttt.com/trigger/button_pressed/with/key/YOUR_SECRET_KEY", map, &inData); 00028 00029 if (!ret) { 00030 pc.printf("HTTP request succeeded.\r\n"); 00031 pc.printf("%s\r\n", str); 00032 } else { 00033 pc.printf("HTTP request failed. ret: %d, code: %d\r\n", ret, http.getHTTPResponseCode()); 00034 } 00035 00036 eth.disconnect(); 00037 00038 while(1) { 00039 } 00040 }
Generated on Wed Jul 13 2022 00:53:18 by
1.7.2