Changed to use domain name instead of IP address

Fork of IFTTT by Austin Blackstone

Committer:
mbedAustin
Date:
Tue Oct 13 16:03:41 2015 +0000
Revision:
7:416f902512f4
Parent:
3:c916e13a269a
Child:
8:935972c2f628
updating the IP of the IFTTT Server

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbedAustin 0:4f7b5d6048b3 1 /* mbed Microcontroller Library
mbedAustin 0:4f7b5d6048b3 2 * Copyright (c) 2006-2013 ARM Limited
mbedAustin 0:4f7b5d6048b3 3 *
mbedAustin 0:4f7b5d6048b3 4 * Licensed under the Apache License, Version 2.0 (the "License");
mbedAustin 0:4f7b5d6048b3 5 * you may not use this file except in compliance with the License.
mbedAustin 0:4f7b5d6048b3 6 * You may obtain a copy of the License at
mbedAustin 0:4f7b5d6048b3 7 *
mbedAustin 0:4f7b5d6048b3 8 * http://www.apache.org/licenses/LICENSE-2.0
mbedAustin 0:4f7b5d6048b3 9 *
mbedAustin 0:4f7b5d6048b3 10 * Unless required by applicable law or agreed to in writing, software
mbedAustin 0:4f7b5d6048b3 11 * distributed under the License is distributed on an "AS IS" BASIS,
mbedAustin 0:4f7b5d6048b3 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
mbedAustin 0:4f7b5d6048b3 13 * See the License for the specific language governing permissions and
mbedAustin 0:4f7b5d6048b3 14 * limitations under the License.
mbedAustin 0:4f7b5d6048b3 15 */
mbedAustin 0:4f7b5d6048b3 16 #ifndef IFTTT_H
mbedAustin 0:4f7b5d6048b3 17 #define IFTTT_H
mbedAustin 0:4f7b5d6048b3 18
mbedAustin 0:4f7b5d6048b3 19 #include "mbed.h"
mbedAustin 0:4f7b5d6048b3 20 #include "TCPSocketConnection.h"
mbedAustin 0:4f7b5d6048b3 21
mbedAustin 0:4f7b5d6048b3 22 #define IFTTT_FAIL -1
mbedAustin 0:4f7b5d6048b3 23 #define IFTTT_SUCCESS 0
mbedAustin 0:4f7b5d6048b3 24
mbedAustin 0:4f7b5d6048b3 25 #define IFTTT_MAX_RETRY 5
mbedAustin 0:4f7b5d6048b3 26 #define IFTTT_MAX_SIZE_SECRETKEY 50
mbedAustin 0:4f7b5d6048b3 27 #define IFTTT_MAX_SIZE_EVENTNAME 50
mbedAustin 0:4f7b5d6048b3 28 #define IFTTT_MAX_SIZE_STRING 512
mbedAustin 0:4f7b5d6048b3 29
mbedAustin 7:416f902512f4 30 #define IFTTT_IP "23.23.151.248"
mbedAustin 0:4f7b5d6048b3 31 #define IFTTT_PORT 80
mbedAustin 0:4f7b5d6048b3 32
mbedAustin 3:c916e13a269a 33 #define IFTTT_GET 0
mbedAustin 3:c916e13a269a 34 #define IFTTT_POST 1
mbedAustin 0:4f7b5d6048b3 35
mbedAustin 0:4f7b5d6048b3 36
mbedAustin 0:4f7b5d6048b3 37 /**
mbedAustin 0:4f7b5d6048b3 38 * The IFTTT class (if this then that)
mbedAustin 0:4f7b5d6048b3 39 */
mbedAustin 0:4f7b5d6048b3 40 class IFTTT
mbedAustin 0:4f7b5d6048b3 41 {
mbedAustin 0:4f7b5d6048b3 42
mbedAustin 0:4f7b5d6048b3 43 public:
mbedAustin 0:4f7b5d6048b3 44
mbedAustin 0:4f7b5d6048b3 45 /**
mbedAustin 0:4f7b5d6048b3 46 * Constructor, initialize the Event Name and Secret Key to be used
mbedAustin 0:4f7b5d6048b3 47 *
mbedAustin 0:4f7b5d6048b3 48 * @param event event name of trigger
mbedAustin 0:4f7b5d6048b3 49 * @param key secret key provided by the maker channel for your event
mbedAustin 0:4f7b5d6048b3 50 */
mbedAustin 0:4f7b5d6048b3 51 IFTTT(const char * event, const char * key, TCPSocketConnection * s = NULL);
mbedAustin 0:4f7b5d6048b3 52
mbedAustin 0:4f7b5d6048b3 53 /**
mbedAustin 3:c916e13a269a 54 * Add ingredients (values) to be sent to maker.ifttt.com
mbedAustin 0:4f7b5d6048b3 55 *
mbedAustin 0:4f7b5d6048b3 56 * @param v1 value 1 to send
mbedAustin 0:4f7b5d6048b3 57 * @param v2 value 2 to send
mbedAustin 0:4f7b5d6048b3 58 * @param v3 value 3 to send
mbedAustin 0:4f7b5d6048b3 59 *
mbedAustin 0:4f7b5d6048b3 60 * @return true if successful, false if failed
mbedAustin 0:4f7b5d6048b3 61 */
mbedAustin 3:c916e13a269a 62 bool addIngredients(char * v1 = NULL, char * v2 = NULL, char * v3 = NULL);
mbedAustin 0:4f7b5d6048b3 63
mbedAustin 0:4f7b5d6048b3 64 /**
mbedAustin 3:c916e13a269a 65 * Add ingredients (values) to be sent to maker.ifttt.com
mbedAustin 0:4f7b5d6048b3 66 *
mbedAustin 0:4f7b5d6048b3 67 * @param v1 value 1 to send
mbedAustin 0:4f7b5d6048b3 68 * @param v2 value 2 to send
mbedAustin 0:4f7b5d6048b3 69 * @param v3 value 3 to send
mbedAustin 0:4f7b5d6048b3 70 *
mbedAustin 0:4f7b5d6048b3 71 * @return true if successful, false if failed
mbedAustin 0:4f7b5d6048b3 72 */
mbedAustin 3:c916e13a269a 73 bool addIngredients(int v1 = NULL, int v2 = NULL, int v3 = NULL);
mbedAustin 3:c916e13a269a 74
mbedAustin 3:c916e13a269a 75 /**
mbedAustin 3:c916e13a269a 76 * Send data via POST or GET to maker.ifttt.com
mbedAustin 3:c916e13a269a 77 *
mbedAustin 3:c916e13a269a 78 * @param iftttType specifies how to send the data. POST by default, GET optional.
mbedAustin 3:c916e13a269a 79 *
mbedAustin 3:c916e13a269a 80 * @return true if successful, false if failed
mbedAustin 3:c916e13a269a 81 */
mbedAustin 3:c916e13a269a 82 bool trigger(int triggerType = IFTTT_POST);
mbedAustin 0:4f7b5d6048b3 83
mbedAustin 0:4f7b5d6048b3 84 private:
mbedAustin 0:4f7b5d6048b3 85
mbedAustin 0:4f7b5d6048b3 86 /**
mbedAustin 0:4f7b5d6048b3 87 * Send data to maker.ifttt.com via GET Query parameters
mbedAustin 0:4f7b5d6048b3 88 *
mbedAustin 0:4f7b5d6048b3 89 * @param name explanation
mbedAustin 0:4f7b5d6048b3 90 *
mbedAustin 0:4f7b5d6048b3 91 * @return true if successful, false if failed
mbedAustin 0:4f7b5d6048b3 92 */
mbedAustin 0:4f7b5d6048b3 93 bool get();
mbedAustin 0:4f7b5d6048b3 94
mbedAustin 0:4f7b5d6048b3 95 /**
mbedAustin 0:4f7b5d6048b3 96 * Send data to maker.ifttt.com via POST payload, encoded as JSON
mbedAustin 0:4f7b5d6048b3 97 *
mbedAustin 0:4f7b5d6048b3 98 * @param name explanation
mbedAustin 0:4f7b5d6048b3 99 *
mbedAustin 0:4f7b5d6048b3 100 * @return true if successful, false if failed
mbedAustin 0:4f7b5d6048b3 101 */
mbedAustin 0:4f7b5d6048b3 102 bool post();
mbedAustin 0:4f7b5d6048b3 103
mbedAustin 0:4f7b5d6048b3 104 TCPSocketConnection * socket;
mbedAustin 0:4f7b5d6048b3 105 char eventName[IFTTT_MAX_SIZE_EVENTNAME];
mbedAustin 0:4f7b5d6048b3 106 char secretKey[IFTTT_MAX_SIZE_SECRETKEY];
mbedAustin 0:4f7b5d6048b3 107 const char * v1;
mbedAustin 0:4f7b5d6048b3 108 const char * v2;
mbedAustin 0:4f7b5d6048b3 109 const char * v3;
mbedAustin 0:4f7b5d6048b3 110 const char * host;
mbedAustin 0:4f7b5d6048b3 111 int port;
mbedAustin 3:c916e13a269a 112
mbedAustin 0:4f7b5d6048b3 113 };
mbedAustin 0:4f7b5d6048b3 114
mbedAustin 0:4f7b5d6048b3 115 #endif // IFTTT_H