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 /* NOTE: io.adafruit.com TLS/SSL certificate changes every 6months, and pinning
119 certificates is no longer recommended. Migrate to a larger MCU like ESP32
120 which can accomodate root certificates and verify chains of trust. */
121 /* For older devices like ESP8266 you can generate the latest fingerprint with:
122 echo | openssl s_client -connect io.adafruit.com:443 | openssl x509 -fingerprint
123 -noout
124 */
125 #define AIO_SSL_FINGERPRINT \
126  "47 D2 CB 14 DF 38 97 59 C6 65 1A 1F 3E 00 1E 53 CC A5 17 E0"
127 
131 #define AIO_FEED_NAME_LENGTH \
132  258
133 
135 #define AIO_DATA_LENGTH \
136  45
137 #define AIO_CSV_LENGTH \
138  AIO_FEED_NAME_LENGTH + \
139  4
140 
142 typedef enum {
143 
144  AIO_IDLE = 0, // Waiting for connection establishement
145  AIO_NET_DISCONNECTED = 1, // Network disconnected
146  AIO_DISCONNECTED = 2, // Disconnected from Adafruit IO
147  AIO_FINGERPRINT_UNKOWN = 3, // Unknown AIO_SSL_FINGERPRINT
148 
149  AIO_NET_CONNECT_FAILED = 10, // Failed to connect to network
150  AIO_CONNECT_FAILED = 11, // Failed to connect to Adafruit IO
151  AIO_FINGERPRINT_INVALID = 12, // Unknown AIO_SSL_FINGERPRINT
152  AIO_AUTH_FAILED = 13, // Invalid Adafruit IO login credentials provided.
153  AIO_SSID_INVALID =
154  14, // SSID is "" or otherwise invalid, connection not attempted
155 
156  AIO_NET_CONNECTED = 20, // Connected to Adafruit IO
157  AIO_CONNECTED = 21, // Connected to network
158  AIO_CONNECTED_INSECURE = 22, // Insecurely (non-SSL) connected to network
159  AIO_FINGERPRINT_UNSUPPORTED = 23, // Unsupported AIO_SSL_FINGERPRINT
160  AIO_FINGERPRINT_VALID = 24 // Valid AIO_SSL_FINGERPRINT
161 
162 } aio_status_t;
163 
165 typedef enum {
166 
167  AIO_TIME_SECONDS = 0, // Seconds MQTT feed
168  AIO_TIME_MILLIS = 1, // Milisecond MQTT feed
169  AIO_TIME_ISO = 2 // ISO8601 MQTT Feed
170 
172 
173 #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:169
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:146
AdafruitIOGroupCallback * next_cb
Definition: AdafruitIO_Definitions.h:67
AdafruitIOGroupCallback(AdafruitIODataCallbackType cb)
Sets up MQTT Group callbacks.
Definition: AdafruitIO_Definitions.h:58