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 IFTTT mbed-rtos mbed
Fork of TCPSocket_Ethernet by
main.cpp
00001 #include "mbed.h" 00002 #include "EthernetInterface.h" 00003 #include "TCPSocketConnection.h" 00004 #include "ifttt.h" 00005 00006 EthernetInterface eth; 00007 RawSerial pc(USBTX, USBRX); // tx, rx 00008 00009 int main() 00010 { 00011 pc.baud(9600); 00012 eth.init(); //Use DHCP 00013 eth.connect(); 00014 printf("IP Address is %s \n\r", eth.getIPAddress()); 00015 TCPSocketConnection socket; 00016 00017 socket.connect("httpbin.org", 80); 00018 00019 char http_cmd[] = "GET /get?helloworld HTTP/1.0\r\n\r\n"; 00020 socket.send_all(http_cmd, sizeof(http_cmd)-1); 00021 00022 char buffer[300]; 00023 int ret; 00024 while (true) { 00025 ret = socket.receive(buffer, sizeof(buffer)-1); 00026 if (ret <= 0) 00027 break; 00028 buffer[ret] = '\0'; 00029 printf("Received %d chars from server:\n%s\n", ret, buffer); 00030 } 00031 00032 printf("DONE!\n"); 00033 // Initialize ifttt object, add up to 3 optional values, trigger event. 00034 IFTTT ifttt("hellowordmbed","ExqSjQiwzZINRMFTOgo--", &socket); // EventName, Secret Key, socket to use 00035 ifttt.addIngredients("this is awesome","test-ing","data!!!"); // 3 optional Values to send along with trigger. 00036 ifttt.trigger(); 00037 00038 // Send data using GET 00039 ifttt.addIngredients("Sending","GET","data"); 00040 ifttt.trigger(IFTTT_GET); 00041 00042 // Send Data using POST 00043 ifttt.addIngredients("Sending","POST","things"); 00044 ifttt.trigger(IFTTT_POST); 00045 00046 00047 00048 socket.close(); 00049 00050 eth.disconnect(); 00051 00052 while(1) { 00053 } 00054 } 00055 extern "C" void mbed_mac_address(char *mac) 00056 { 00057 mac[0] = 0xD4; 00058 mac[1] = 0x3D; 00059 mac[2] = 0x7E; 00060 mac[3] = 0x2C; 00061 mac[4] = 0x7E; 00062 mac[5] = 0x1C; 00063 };
Generated on Sat Jul 16 2022 01:27:31 by
1.7.2
