Adafruit IO Arduino Library
AdafruitIO_Definitions.h
Go to the documentation of this file.
1 
16 #ifndef ADAFRUITIO_DEFINITIONS_H_
17 #define ADAFRUITIO_DEFINITIONS_H_
18 
19 #define ADAFRUITIO_VERSION_MAJOR 4
20 #define ADAFRUITIO_VERSION_MINOR 2
21 #define ADAFRUITIO_VERSION_PATCH 1
22 
23 // forward declaration
24 class AdafruitIO_Data;
25 
27  AdafruitIO_Data *data);
29 /**************************************************************************/
33 /**************************************************************************/
35 public:
36  /**************************************************************************/
44  /**************************************************************************/
46  feed = f;
47  dataCallback = cb;
48  next_cb = 0;
49  }
50 
51  /**************************************************************************/
57  /**************************************************************************/
59  feed = 0;
60  dataCallback = cb;
61  next_cb = 0;
62  }
63 
64  const char *feed;
68 };
69 
70 // Uncomment/comment to turn on/off debug output messages.
71 // #define AIO_DEBUG
72 // Uncomment/comment to turn on/off error output
73 // #define AIO_ERROR
74 
75 // note: if you're using something like Zero or Due, change the below to
76 // SerialUSB
77 #define AIO_PRINTER Serial
78 
79 // Define actual debug output functions when necessary.
80 #ifdef AIO_DEBUG
81 #define AIO_DEBUG_PRINT(...) \
82  { AIO_PRINTER.print(__VA_ARGS__); }
83 #define AIO_DEBUG_PRINTLN(...) \
84  { AIO_PRINTER.println(__VA_ARGS__); }
85 #else
86 #define AIO_DEBUG_PRINT(...) \
87  {}
88 #define AIO_DEBUG_PRINTLN(...) \
89  {}
90 #endif
91 
92 // Define actual error output functions when necessary.
93 #ifdef AIO_ERROR
94 #define AIO_ERROR_PRINT(...) \
95  { AIO_PRINTER.print(__VA_ARGS__); }
96 #define AIO_ERROR_PRINTLN(...) \
97  { AIO_PRINTER.println(__VA_ARGS__); }
98 #else
99 #define AIO_ERROR_PRINT(...) \
100  {}
101 #define AIO_ERROR_PRINTLN(...) \
102  {}
103 #endif
105 #define AIO_PING_INTERVAL 60000
106 #define AIO_THROTTLE_RECONNECT_INTERVAL \
107  60000
108 #define AIO_MQTT_CONNECTION_TIMEOUT \
109  60000
110 #define AIO_NET_CONNECTION_TIMEOUT \
111  60000
112 #define AIO_NET_DISCONNECT_WAIT \
113  300
115 #define AIO_ERROR_TOPIC "/errors"
116 #define AIO_THROTTLE_TOPIC "/throttle"
117 
118 // latest fingerprint can be generated with
119 // echo | openssl s_client -connect io.adafruit.com:443 | openssl x509
120 // -fingerprint -noout
121 #define AIO_SSL_FINGERPRINT \
122  "4E C1 52 73 24 A8 36 D6 7A 4C 67 C7 91 0C 0A 22 B9 2D 5B CA"
123 
127 #define AIO_FEED_NAME_LENGTH \
128  258
129 
131 #define AIO_DATA_LENGTH \
132  45
133 #define AIO_CSV_LENGTH \
134  AIO_FEED_NAME_LENGTH + \
135  4
136 
138 typedef enum {
139 
140  AIO_IDLE = 0, // Waiting for connection establishement
141  AIO_NET_DISCONNECTED = 1, // Network disconnected
142  AIO_DISCONNECTED = 2, // Disconnected from Adafruit IO
143  AIO_FINGERPRINT_UNKOWN = 3, // Unknown AIO_SSL_FINGERPRINT
144 
145  AIO_NET_CONNECT_FAILED = 10, // Failed to connect to network
146  AIO_CONNECT_FAILED = 11, // Failed to connect to Adafruit IO
147  AIO_FINGERPRINT_INVALID = 12, // Unknown AIO_SSL_FINGERPRINT
148  AIO_AUTH_FAILED = 13, // Invalid Adafruit IO login credentials provided.
149  AIO_SSID_INVALID =
150  14, // SSID is "" or otherwise invalid, connection not attempted
151 
152  AIO_NET_CONNECTED = 20, // Connected to Adafruit IO
153  AIO_CONNECTED = 21, // Connected to network
154  AIO_CONNECTED_INSECURE = 22, // Insecurely (non-SSL) connected to network
155  AIO_FINGERPRINT_UNSUPPORTED = 23, // Unsupported AIO_SSL_FINGERPRINT
156  AIO_FINGERPRINT_VALID = 24 // Valid AIO_SSL_FINGERPRINT
157 
158 } aio_status_t;
159 
161 typedef enum {
162 
163  AIO_TIME_SECONDS = 0, // Seconds MQTT feed
164  AIO_TIME_MILLIS = 1, // Milisecond MQTT feed
165  AIO_TIME_ISO = 2 // ISO8601 MQTT Feed
166 
168 
169 #endif /* ADAFRUITIO_DEFINITIONS_H_ */
AdafruitIOGroupCallback(const char *f, AdafruitIODataCallbackType cb)
Sets up MQTT Group callbacks.
Definition: AdafruitIO_Definitions.h:45
aio_time_format_t
Definition: AdafruitIO_Definitions.h:165
const char * feed
Definition: AdafruitIO_Definitions.h:64
void(* AdafruitIODataCallbackType)(AdafruitIO_Data *data)
Definition: AdafruitIO_Definitions.h:26
Class that contains methods for Adafruit IO MQTT callbacks.
Definition: AdafruitIO_Definitions.h:34
AdafruitIODataCallbackType dataCallback
Definition: AdafruitIO_Definitions.h:66
Class for interacting with Adafruit IO Data Records. https://io.adafruit.com/api/docs/#data.
Definition: AdafruitIO_Data.h:30
aio_status_t
Definition: AdafruitIO_Definitions.h:142
AdafruitIOGroupCallback * next_cb
Definition: AdafruitIO_Definitions.h:67
AdafruitIOGroupCallback(AdafruitIODataCallbackType cb)
Sets up MQTT Group callbacks.
Definition: AdafruitIO_Definitions.h:58