A simple sample program to trigger Maker Channel of IFTTT from mbed LPC1114FN28.
Dependencies: W5500Interface mbed
Fork of AxedaGo-mbedNXP_WIZ550io by
Revision 8:fdf9f583358f, committed 2015-06-29
- Comitter:
- ytsuboi
- Date:
- Mon Jun 29 03:36:46 2015 +0000
- Parent:
- 7:880cc185d511
- Commit message:
- First version
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 880cc185d511 -r fdf9f583358f main.cpp --- a/main.cpp Wed Mar 04 10:33:10 2015 +0000 +++ b/main.cpp Mon Jun 29 03:36:46 2015 +0000 @@ -22,9 +22,10 @@ int main() { - char *MODEL = "mbed"; - char *SERIAL_NUM = "nlr__embeddist_gmail_com___343881"; - float DEADBAND = 0.015; +// YOU NEED TO TYPE THESE TWO VALUES + char *EVENT = "PUT YOUR EVENT NAME HERE"; + char *KEY = "PUT YOUT SECRET KEY HERE"; +// char* ip; @@ -70,36 +71,8 @@ #endif printf(" - IP address:%s\r\n", ip); - float oil_level = 0.0; - float oil_level2= 0.0; - float oldPotVal = -2.0; - float oldPotVal2 = -2.0; - - while(1) { - - oil_level = pot1.read(); -#if defined(TARGET_LPC1768) - oil_level2=pot2.read(); -#endif - //if ( abs(oil_level - oldPotVal) < DEADBAND && abs(oil_level2 - oldPotVal2) < DEADBAND) //LPC1768 - if ( abs(oil_level - oldPotVal) < DEADBAND) //LPC1114 - { - continue; - } - else - { - //led4 = 1; - oldPotVal = oil_level; -#if defined(TARGET_LPC1768) - oldPotVal2 = oil_level2; -#endif - printf("Sending Value for well1 %.2f\n\r", oil_level); -#if defined(TARGET_LPC1768) - printf("Sending Value for well2 %.2f\n\r", oil_level2); -#endif - sock.connect("toolbox-connect.axeda.com", 80); - - snprintf(http_cmd, http_cmd_sz, "POST /ammp/data/1/%s!%s HTTP/1.1\r\nContent-Type: application/json\r\nContent-Length: 65\r\n\r\n{\"data\":[{\"di\":{\"oil_level\":%.2f, \"oil_level2\":%.2f}}]}\r\n\r\n", MODEL, SERIAL_NUM, oil_level, oil_level2); + sock.connect("maker.ifttt.com", 80); + snprintf(http_cmd, http_cmd_sz, "GET /trigger/%s/with/key/%s HTTP/1.1\r\nHost: maker.ifttt.com\r\n\r\n", EVENT, KEY); sock.send_all(http_cmd, http_cmd_sz-1); while ( (returnCode = sock.receive(buffer, buffer_sz-1)) > 0) @@ -107,10 +80,5 @@ buffer[returnCode] = '\0'; printf("Received %d chars from server:\n\r%s\n", returnCode, buffer); } - //led4 = returnCode; sock.close(); - } - - } - }