Changed to use domain name instead of IP address

Fork of IFTTT by Austin Blackstone

Committer:
mbedAustin
Date:
Fri Jul 10 21:43:50 2015 +0000
Revision:
0:4f7b5d6048b3
Child:
3:c916e13a269a
Initial Commit. Get and Post methods working. No Security.

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