Changed to use domain name instead of IP address

Fork of IFTTT by Austin Blackstone

Committer:
okano
Date:
Sat Sep 10 07:28:49 2016 +0000
Revision:
9:e24a0eb41b4e
Parent:
8:935972c2f628
Changed to use domain name instead of IP address. This can eliminate effort of updating/editing IP address each time when it is changed

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
okano 9:e24a0eb41b4e 30 //#define IFTTT_IP "50.16.216.115"
okano 9:e24a0eb41b4e 31 #define IFTTT_IP "maker.ifttt.com"
mbedAustin 0:4f7b5d6048b3 32 #define IFTTT_PORT 80
mbedAustin 0:4f7b5d6048b3 33
mbedAustin 3:c916e13a269a 34 #define IFTTT_GET 0
mbedAustin 3:c916e13a269a 35 #define IFTTT_POST 1
mbedAustin 0:4f7b5d6048b3 36
mbedAustin 0:4f7b5d6048b3 37
mbedAustin 0:4f7b5d6048b3 38 /**
mbedAustin 0:4f7b5d6048b3 39 * The IFTTT class (if this then that)
mbedAustin 0:4f7b5d6048b3 40 */
mbedAustin 0:4f7b5d6048b3 41 class IFTTT
mbedAustin 0:4f7b5d6048b3 42 {
mbedAustin 0:4f7b5d6048b3 43
mbedAustin 0:4f7b5d6048b3 44 public:
mbedAustin 0:4f7b5d6048b3 45
mbedAustin 0:4f7b5d6048b3 46 /**
mbedAustin 0:4f7b5d6048b3 47 * Constructor, initialize the Event Name and Secret Key to be used
mbedAustin 0:4f7b5d6048b3 48 *
mbedAustin 0:4f7b5d6048b3 49 * @param event event name of trigger
mbedAustin 0:4f7b5d6048b3 50 * @param key secret key provided by the maker channel for your event
mbedAustin 0:4f7b5d6048b3 51 */
mbedAustin 0:4f7b5d6048b3 52 IFTTT(const char * event, const char * key, TCPSocketConnection * s = NULL);
mbedAustin 0:4f7b5d6048b3 53
mbedAustin 0:4f7b5d6048b3 54 /**
mbedAustin 3:c916e13a269a 55 * Add ingredients (values) to be sent to maker.ifttt.com
mbedAustin 0:4f7b5d6048b3 56 *
mbedAustin 0:4f7b5d6048b3 57 * @param v1 value 1 to send
mbedAustin 0:4f7b5d6048b3 58 * @param v2 value 2 to send
mbedAustin 0:4f7b5d6048b3 59 * @param v3 value 3 to send
mbedAustin 0:4f7b5d6048b3 60 *
mbedAustin 0:4f7b5d6048b3 61 * @return true if successful, false if failed
mbedAustin 0:4f7b5d6048b3 62 */
mbedAustin 3:c916e13a269a 63 bool addIngredients(char * v1 = NULL, char * v2 = NULL, char * v3 = NULL);
mbedAustin 0:4f7b5d6048b3 64
mbedAustin 0:4f7b5d6048b3 65 /**
mbedAustin 3:c916e13a269a 66 * Add ingredients (values) to be sent to maker.ifttt.com
mbedAustin 0:4f7b5d6048b3 67 *
mbedAustin 0:4f7b5d6048b3 68 * @param v1 value 1 to send
mbedAustin 0:4f7b5d6048b3 69 * @param v2 value 2 to send
mbedAustin 0:4f7b5d6048b3 70 * @param v3 value 3 to send
mbedAustin 0:4f7b5d6048b3 71 *
mbedAustin 0:4f7b5d6048b3 72 * @return true if successful, false if failed
mbedAustin 0:4f7b5d6048b3 73 */
mbedAustin 3:c916e13a269a 74 bool addIngredients(int v1 = NULL, int v2 = NULL, int v3 = NULL);
mbedAustin 3:c916e13a269a 75
mbedAustin 3:c916e13a269a 76 /**
mbedAustin 3:c916e13a269a 77 * Send data via POST or GET to maker.ifttt.com
mbedAustin 3:c916e13a269a 78 *
mbedAustin 3:c916e13a269a 79 * @param iftttType specifies how to send the data. POST by default, GET optional.
mbedAustin 3:c916e13a269a 80 *
mbedAustin 3:c916e13a269a 81 * @return true if successful, false if failed
mbedAustin 3:c916e13a269a 82 */
mbedAustin 3:c916e13a269a 83 bool trigger(int triggerType = IFTTT_POST);
mbedAustin 0:4f7b5d6048b3 84
mbedAustin 0:4f7b5d6048b3 85 private:
mbedAustin 0:4f7b5d6048b3 86
mbedAustin 0:4f7b5d6048b3 87 /**
mbedAustin 0:4f7b5d6048b3 88 * Send data to maker.ifttt.com via GET Query parameters
mbedAustin 0:4f7b5d6048b3 89 *
mbedAustin 0:4f7b5d6048b3 90 * @param name explanation
mbedAustin 0:4f7b5d6048b3 91 *
mbedAustin 0:4f7b5d6048b3 92 * @return true if successful, false if failed
mbedAustin 0:4f7b5d6048b3 93 */
mbedAustin 0:4f7b5d6048b3 94 bool get();
mbedAustin 0:4f7b5d6048b3 95
mbedAustin 0:4f7b5d6048b3 96 /**
mbedAustin 0:4f7b5d6048b3 97 * Send data to maker.ifttt.com via POST payload, encoded as JSON
mbedAustin 0:4f7b5d6048b3 98 *
mbedAustin 0:4f7b5d6048b3 99 * @param name explanation
mbedAustin 0:4f7b5d6048b3 100 *
mbedAustin 0:4f7b5d6048b3 101 * @return true if successful, false if failed
mbedAustin 0:4f7b5d6048b3 102 */
mbedAustin 0:4f7b5d6048b3 103 bool post();
mbedAustin 0:4f7b5d6048b3 104
mbedAustin 0:4f7b5d6048b3 105 TCPSocketConnection * socket;
mbedAustin 0:4f7b5d6048b3 106 char eventName[IFTTT_MAX_SIZE_EVENTNAME];
mbedAustin 0:4f7b5d6048b3 107 char secretKey[IFTTT_MAX_SIZE_SECRETKEY];
mbedAustin 0:4f7b5d6048b3 108 const char * v1;
mbedAustin 0:4f7b5d6048b3 109 const char * v2;
mbedAustin 0:4f7b5d6048b3 110 const char * v3;
mbedAustin 0:4f7b5d6048b3 111 const char * host;
mbedAustin 0:4f7b5d6048b3 112 int port;
mbedAustin 3:c916e13a269a 113
mbedAustin 0:4f7b5d6048b3 114 };
mbedAustin 0:4f7b5d6048b3 115
mbedAustin 0:4f7b5d6048b3 116 #endif // IFTTT_H