This is an example for sending data to IFTTT using WizFi250

Dependencies:   IFTTT WizFi250Interface mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "WizFi250Interface.h"
00003 #include "ifttt.h"
00004 
00005 #define SECURE WizFi250::SEC_AUTO
00006 #define SSID "ssid"
00007 #define PASS "password"
00008 
00009 #define YourEventName "YourEventName"
00010 #define YourSecretKey "YourSecretKey"
00011 
00012     WizFi250Interface wizfi250(D1,D0,D7,D8,PA_12,NC,115200);
00013     TCPSocketConnection sock;
00014     Serial pc(USBTX, USBRX); // tx, rx
00015     
00016 int main()
00017 { 
00018     pc.baud(115200);
00019    
00020     pc.printf("WizFi250_IFTTT Send example. \r\n");
00021     wizfi250.init();
00022     wizfi250.connect(SECURE, SSID, PASS);
00023     pc.printf("IP Address is %s\r\n", wizfi250.getIPAddress());
00024 
00025     // Initialize ifttt object, add up to 3 optional values, trigger event.
00026     IFTTT ifttt(YourEventName,YourSecretKey, &sock); // EventName, Secret Key, socket to use
00027     ifttt.addIngredients("this is awesome","test-ing","data!!!");     // 3 optional Values to send along with trigger.
00028     ifttt.trigger();
00029 
00030     // Send data using GET
00031     ifttt.addIngredients("Sending","GET","data");
00032     ifttt.trigger(IFTTT_GET);
00033 
00034     // Send Data using POST
00035     ifttt.addIngredients("Sending","POST","things");
00036     ifttt.trigger(IFTTT_POST);
00037     
00038     sock.close();
00039     wizfi250.disconnect();
00040     
00041     while(1) {
00042     }
00043 }
00044