Demo application for using the AT&T IoT Starter Kit Powered by AWS.

Dependencies:   SDFileSystem

Fork of ATT_AWS_IoT_demo by Anthony Phillips

IoT Starter Kit Powered by AWS Demo

This program demonstrates the AT&T IoT Starter Kit sending data directly into AWS IoT. It's explained and used in the Getting Started with the IoT Starter Kit Powered by AWS on starterkit.att.com.

What's required

  • AT&T IoT LTE Add-on (also known as the Cellular Shield)
  • NXP K64F - for programming
  • microSD card - used to store your AWS security credentials
  • AWS account
  • Python, locally installed

If you don't already have an IoT Starter Kit, you can purchase a kit here. The IoT Starter Kit Powered by AWS includes the LTE cellular shield, K64F, and a microSD card.

Committer:
rfinn
Date:
Tue Feb 07 16:18:57 2017 +0000
Revision:
27:2f486c766854
Parent:
15:6f2798e45099
changed SDFileSystem library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ampembeng 15:6f2798e45099 1 /*
ampembeng 15:6f2798e45099 2 * Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
ampembeng 15:6f2798e45099 3 *
ampembeng 15:6f2798e45099 4 * Licensed under the Apache License, Version 2.0 (the "License").
ampembeng 15:6f2798e45099 5 * You may not use this file except in compliance with the License.
ampembeng 15:6f2798e45099 6 * A copy of the License is located at
ampembeng 15:6f2798e45099 7 *
ampembeng 15:6f2798e45099 8 * http://aws.amazon.com/apache2.0
ampembeng 15:6f2798e45099 9 *
ampembeng 15:6f2798e45099 10 * or in the "license" file accompanying this file. This file is distributed
ampembeng 15:6f2798e45099 11 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
ampembeng 15:6f2798e45099 12 * express or implied. See the License for the specific language governing
ampembeng 15:6f2798e45099 13 * permissions and limitations under the License.
ampembeng 15:6f2798e45099 14 */
ampembeng 15:6f2798e45099 15
ampembeng 15:6f2798e45099 16 /**
ampembeng 15:6f2798e45099 17 * @file aws_iot_mqtt_interface.h
ampembeng 15:6f2798e45099 18 * @brief Interface definition for MQTT client.
ampembeng 15:6f2798e45099 19 */
ampembeng 15:6f2798e45099 20
ampembeng 15:6f2798e45099 21 #ifndef AWS_IOT_SDK_SRC_IOT_MQTT_INTERFACE_H_
ampembeng 15:6f2798e45099 22 #define AWS_IOT_SDK_SRC_IOT_MQTT_INTERFACE_H_
ampembeng 15:6f2798e45099 23
ampembeng 15:6f2798e45099 24 #include "stddef.h"
ampembeng 15:6f2798e45099 25 #include "stdbool.h"
ampembeng 15:6f2798e45099 26 #include "stdint.h"
ampembeng 15:6f2798e45099 27 #include "aws_iot_error.h"
ampembeng 15:6f2798e45099 28
ampembeng 15:6f2798e45099 29 /**
ampembeng 15:6f2798e45099 30 * @brief MQTT Version Type
ampembeng 15:6f2798e45099 31 *
ampembeng 15:6f2798e45099 32 * Defining an MQTT version type.
ampembeng 15:6f2798e45099 33 *
ampembeng 15:6f2798e45099 34 */
ampembeng 15:6f2798e45099 35 typedef enum {
ampembeng 15:6f2798e45099 36 MQTT_3_1 = 3, ///< MQTT 3.1 (protocol message byte = 3)
ampembeng 15:6f2798e45099 37 MQTT_3_1_1 = 4 ///< MQTT 3.1.1 (protocol message byte = 4)
ampembeng 15:6f2798e45099 38 } MQTT_Ver_t;
ampembeng 15:6f2798e45099 39
ampembeng 15:6f2798e45099 40 /**
ampembeng 15:6f2798e45099 41 * @brief Quality of Service Type
ampembeng 15:6f2798e45099 42 *
ampembeng 15:6f2798e45099 43 * Defining a QoS type.
ampembeng 15:6f2798e45099 44 * @note QoS 2 is \b NOT supported by the AWS IoT Service at the time of this SDK release.
ampembeng 15:6f2798e45099 45 *
ampembeng 15:6f2798e45099 46 */
ampembeng 15:6f2798e45099 47 typedef enum {
ampembeng 15:6f2798e45099 48 QOS_0, ///< QoS 0 = at most once delivery
ampembeng 15:6f2798e45099 49 QOS_1, ///< QoS 1 = at least once delivery
ampembeng 15:6f2798e45099 50 QOS_2 ///< QoS 2 is NOT supported
ampembeng 15:6f2798e45099 51 } QoSLevel;
ampembeng 15:6f2798e45099 52
ampembeng 15:6f2798e45099 53 /**
ampembeng 15:6f2798e45099 54 * @brief Last Will and Testament Definition
ampembeng 15:6f2798e45099 55 *
ampembeng 15:6f2798e45099 56 * Defining a type for LWT parameters.
ampembeng 15:6f2798e45099 57 * @note Retained messages are \b NOT supported by the AWS IoT Service at the time of this SDK release.
ampembeng 15:6f2798e45099 58 *
ampembeng 15:6f2798e45099 59 */
ampembeng 15:6f2798e45099 60 typedef struct {
ampembeng 15:6f2798e45099 61 const char *pTopicName; ///< LWT Topic
ampembeng 15:6f2798e45099 62 const char *pMessage; ///< Message to be delivered as LWT
ampembeng 15:6f2798e45099 63 bool isRetained; ///< NOT supported
ampembeng 15:6f2798e45099 64 QoSLevel qos; ///< QoS of LWT message
ampembeng 15:6f2798e45099 65 } MQTTwillOptions;
ampembeng 15:6f2798e45099 66 extern const MQTTwillOptions MQTTwillOptionsDefault;
ampembeng 15:6f2798e45099 67
ampembeng 15:6f2798e45099 68 /**
ampembeng 15:6f2798e45099 69 * @brief Disconnect Callback Handler Type
ampembeng 15:6f2798e45099 70 *
ampembeng 15:6f2798e45099 71 * Defining a TYPE for definition of disconnect callback function pointers.
ampembeng 15:6f2798e45099 72 *
ampembeng 15:6f2798e45099 73 */
ampembeng 15:6f2798e45099 74 typedef void (*iot_disconnect_handler)(void);
ampembeng 15:6f2798e45099 75
ampembeng 15:6f2798e45099 76 /**
ampembeng 15:6f2798e45099 77 * @brief MQTT Connection Parameters
ampembeng 15:6f2798e45099 78 *
ampembeng 15:6f2798e45099 79 * Defining a type for MQTT connection parameters. Passed into client when establishing a connection.
ampembeng 15:6f2798e45099 80 *
ampembeng 15:6f2798e45099 81 */
ampembeng 15:6f2798e45099 82 typedef struct {
ampembeng 15:6f2798e45099 83 uint8_t enableAutoReconnect; ///< Set to true to enable auto reconnect
ampembeng 15:6f2798e45099 84 char *pHostURL; ///< Pointer to a string defining the endpoint for the MQTT service
ampembeng 15:6f2798e45099 85 uint16_t port; ///< MQTT service listening port
ampembeng 15:6f2798e45099 86 char *pRootCALocation; ///< Pointer to a string defining the Root CA file (full file, not path)
ampembeng 15:6f2798e45099 87 char *pDeviceCertLocation; ///< Pointer to a string defining the device identity certificate file (full file, not path)
ampembeng 15:6f2798e45099 88 char *pDevicePrivateKeyLocation; ///< Pointer to a string defining the device private key file (full file, not path)
ampembeng 15:6f2798e45099 89 char *pClientID; ///< Pointer to a string defining the MQTT client ID (this needs to be unique \b per \b device across your AWS account)
ampembeng 15:6f2798e45099 90 char *pUserName; ///< Not used in the AWS IoT Service
ampembeng 15:6f2798e45099 91 char *pPassword; ///< Not used in the AWS IoT Service
ampembeng 15:6f2798e45099 92 MQTT_Ver_t MQTTVersion; ///< Desired MQTT version used during connection
ampembeng 15:6f2798e45099 93 uint16_t KeepAliveInterval_sec; ///< MQTT keep alive interval in seconds. Defines inactivity time allowed before determining the connection has been lost.
ampembeng 15:6f2798e45099 94 bool isCleansession; ///< MQTT clean session. True = this session is to be treated as clean. Previous server state is cleared and no stated is retained from this connection.
ampembeng 15:6f2798e45099 95 bool isWillMsgPresent; ///< Is there a LWT associated with this connection?
ampembeng 15:6f2798e45099 96 MQTTwillOptions will; ///< MQTT LWT parameters.
ampembeng 15:6f2798e45099 97 uint32_t mqttCommandTimeout_ms; ///< Timeout for MQTT blocking calls. In milliseconds.
ampembeng 15:6f2798e45099 98 uint32_t tlsHandshakeTimeout_ms; ///< TLS handshake timeout. In milliseconds.
ampembeng 15:6f2798e45099 99 bool isSSLHostnameVerify; ///< Client should perform server certificate hostname validation.
ampembeng 15:6f2798e45099 100 iot_disconnect_handler disconnectHandler; ///< Callback to be invoked upon connection loss.
ampembeng 15:6f2798e45099 101 } MQTTConnectParams;
ampembeng 15:6f2798e45099 102 extern const MQTTConnectParams MQTTConnectParamsDefault;
ampembeng 15:6f2798e45099 103
ampembeng 15:6f2798e45099 104 /**
ampembeng 15:6f2798e45099 105 * @brief MQTT Message Parameters
ampembeng 15:6f2798e45099 106 *
ampembeng 15:6f2798e45099 107 * Defines a type for properties of MQTT messages including topic, payload an QoS.
ampembeng 15:6f2798e45099 108 *
ampembeng 15:6f2798e45099 109 */
ampembeng 15:6f2798e45099 110 typedef struct {
ampembeng 15:6f2798e45099 111 QoSLevel qos; ///< Message Quality of Service
ampembeng 15:6f2798e45099 112 bool isRetained; ///< Retained messages are \b NOT supported by the AWS IoT Service at the time of this SDK release.
ampembeng 15:6f2798e45099 113 bool isDuplicate; ///< Is this message a duplicate QoS > 0 message? Handled automatically by the MQTT client.
ampembeng 15:6f2798e45099 114 uint16_t id; ///< Message sequence identifier. Handled automatically by the MQTT client.
ampembeng 15:6f2798e45099 115 void *pPayload; ///< Pointer to MQTT message payload (bytes).
ampembeng 15:6f2798e45099 116 uint32_t PayloadLen; ///< Length of MQTT payload.
ampembeng 15:6f2798e45099 117 } MQTTMessageParams;
ampembeng 15:6f2798e45099 118 extern const MQTTMessageParams MQTTMessageParamsDefault;
ampembeng 15:6f2798e45099 119 /**
ampembeng 15:6f2798e45099 120 * @brief MQTT Callback Function Parameters
ampembeng 15:6f2798e45099 121 *
ampembeng 15:6f2798e45099 122 * Defines a type for parameters returned to the user upon receipt of a publish message on a subscribed topic.
ampembeng 15:6f2798e45099 123 *
ampembeng 15:6f2798e45099 124 */
ampembeng 15:6f2798e45099 125 typedef struct {
ampembeng 15:6f2798e45099 126 char *pTopicName; ///< Pointer to the topic string on which the message was delivered. In the case of a wildcard subscription this is the actual topic, not the wildcard filter.
ampembeng 15:6f2798e45099 127 uint16_t TopicNameLen; ///< Length of the topic string.
ampembeng 15:6f2798e45099 128 MQTTMessageParams MessageParams; ///< Message parameters structure.
ampembeng 15:6f2798e45099 129 } MQTTCallbackParams;
ampembeng 15:6f2798e45099 130 extern const MQTTCallbackParams MQTTCallbackParamsDefault;
ampembeng 15:6f2798e45099 131
ampembeng 15:6f2798e45099 132 /**
ampembeng 15:6f2798e45099 133 * @brief MQTT Callback Function
ampembeng 15:6f2798e45099 134 *
ampembeng 15:6f2798e45099 135 * Defines a type for the function pointer which stores the message callback function.
ampembeng 15:6f2798e45099 136 * A pointer to the desired callback function to be invoked upon receipt of a message on a subscribed toipc.
ampembeng 15:6f2798e45099 137 * Supplied upon subscribing to a topic.
ampembeng 15:6f2798e45099 138 *
ampembeng 15:6f2798e45099 139 */
ampembeng 15:6f2798e45099 140 typedef int32_t (*iot_message_handler)(MQTTCallbackParams params);
ampembeng 15:6f2798e45099 141
ampembeng 15:6f2798e45099 142 /**
ampembeng 15:6f2798e45099 143 * @brief MQTT Subscription Parameters
ampembeng 15:6f2798e45099 144 *
ampembeng 15:6f2798e45099 145 * Defines the parameters needed when subscribing to an MQTT topic.
ampembeng 15:6f2798e45099 146 *
ampembeng 15:6f2798e45099 147 */
ampembeng 15:6f2798e45099 148 typedef struct {
ampembeng 15:6f2798e45099 149 char *pTopic; ///< Pointer to the string defining the desired subscription topic.
ampembeng 15:6f2798e45099 150 QoSLevel qos; ///< Quality of service of the subscription.
ampembeng 15:6f2798e45099 151 iot_message_handler mHandler; ///< Callback to be invoked upon receipt of a message on the subscribed topic.
ampembeng 15:6f2798e45099 152 } MQTTSubscribeParams;
ampembeng 15:6f2798e45099 153 extern const MQTTSubscribeParams MQTTSubscribeParamsDefault;
ampembeng 15:6f2798e45099 154
ampembeng 15:6f2798e45099 155 /**
ampembeng 15:6f2798e45099 156 * @brief MQTT Publish Parameters
ampembeng 15:6f2798e45099 157 *
ampembeng 15:6f2798e45099 158 * Defines a type for parameters supplied when publishing an MQTT message.
ampembeng 15:6f2798e45099 159 *
ampembeng 15:6f2798e45099 160 */
ampembeng 15:6f2798e45099 161 typedef struct {
ampembeng 15:6f2798e45099 162 char *pTopic; ///< Pointer to the string defining the desired publishing topic.
ampembeng 15:6f2798e45099 163 MQTTMessageParams MessageParams; ///< Parameters defining the message to be published.
ampembeng 15:6f2798e45099 164 } MQTTPublishParams;
ampembeng 15:6f2798e45099 165 extern const MQTTPublishParams MQTTPublishParamsDefault;
ampembeng 15:6f2798e45099 166
ampembeng 15:6f2798e45099 167 /**
ampembeng 15:6f2798e45099 168 * @brief MQTT Connection Function
ampembeng 15:6f2798e45099 169 *
ampembeng 15:6f2798e45099 170 * Called to establish an MQTT connection with the AWS IoT Service
ampembeng 15:6f2798e45099 171 *
ampembeng 15:6f2798e45099 172 * @param pParams Pointer to MQTT connection parameters
ampembeng 15:6f2798e45099 173 * @return An IoT Error Type defining successful/failed connection
ampembeng 15:6f2798e45099 174 */
ampembeng 15:6f2798e45099 175 IoT_Error_t aws_iot_mqtt_connect(MQTTConnectParams *pParams);
ampembeng 15:6f2798e45099 176
ampembeng 15:6f2798e45099 177 /**
ampembeng 15:6f2798e45099 178 * @brief Publish an MQTT message on a topic
ampembeng 15:6f2798e45099 179 *
ampembeng 15:6f2798e45099 180 * Called to publish an MQTT message on a topic.
ampembeng 15:6f2798e45099 181 * @note Call is blocking. In the case of a QoS 0 message the function returns
ampembeng 15:6f2798e45099 182 * after the message was successfully passed to the TLS layer. In the case of QoS 1
ampembeng 15:6f2798e45099 183 * the function returns after the receipt of the PUBACK control packet.
ampembeng 15:6f2798e45099 184 *
ampembeng 15:6f2798e45099 185 * @param pParams Pointer to MQTT publish parameters
ampembeng 15:6f2798e45099 186 * @return An IoT Error Type defining successful/failed publish
ampembeng 15:6f2798e45099 187 */
ampembeng 15:6f2798e45099 188 IoT_Error_t aws_iot_mqtt_publish(MQTTPublishParams *pParams);
ampembeng 15:6f2798e45099 189
ampembeng 15:6f2798e45099 190 /**
ampembeng 15:6f2798e45099 191 * @brief Subscribe to an MQTT topic.
ampembeng 15:6f2798e45099 192 *
ampembeng 15:6f2798e45099 193 * Called to send a subscribe message to the broker requesting a subscription
ampembeng 15:6f2798e45099 194 * to an MQTT topic.
ampembeng 15:6f2798e45099 195 * @note Call is blocking. The call returns after the receipt of the SUBACK control packet.
ampembeng 15:6f2798e45099 196 *
ampembeng 15:6f2798e45099 197 * @param pParams Pointer to MQTT subscribe parameters
ampembeng 15:6f2798e45099 198 * @return An IoT Error Type defining successful/failed subscription
ampembeng 15:6f2798e45099 199 */
ampembeng 15:6f2798e45099 200 IoT_Error_t aws_iot_mqtt_subscribe(MQTTSubscribeParams *pParams);
ampembeng 15:6f2798e45099 201
ampembeng 15:6f2798e45099 202 /**
ampembeng 15:6f2798e45099 203 * @brief Unsubscribe to an MQTT topic.
ampembeng 15:6f2798e45099 204 *
ampembeng 15:6f2798e45099 205 * Called to send an usubscribe message to the broker requesting removal of a subscription
ampembeng 15:6f2798e45099 206 * to an MQTT topic.
ampembeng 15:6f2798e45099 207 * @note Call is blocking. The call returns after the receipt of the UNSUBACK control packet.
ampembeng 15:6f2798e45099 208 *
ampembeng 15:6f2798e45099 209 * @param pTopic Pointer to the requested topic string. Ensure the string is null terminated
ampembeng 15:6f2798e45099 210 * @return An IoT Error Type defining successful/failed unsubscription
ampembeng 15:6f2798e45099 211 */
ampembeng 15:6f2798e45099 212 IoT_Error_t aws_iot_mqtt_unsubscribe(char *pTopic);
ampembeng 15:6f2798e45099 213
ampembeng 15:6f2798e45099 214 /**
ampembeng 15:6f2798e45099 215 * @brief MQTT Manual Re-Connection Function
ampembeng 15:6f2798e45099 216 *
ampembeng 15:6f2798e45099 217 * Called to establish an MQTT connection with the AWS IoT Service
ampembeng 15:6f2798e45099 218 * using parameters from the last time a connection was attempted
ampembeng 15:6f2798e45099 219 * Use after disconnect to start the reconnect process manually
ampembeng 15:6f2798e45099 220 * Makes only one reconnect attempt
ampembeng 15:6f2798e45099 221 *
ampembeng 15:6f2798e45099 222 * @return An IoT Error Type defining successful/failed connection
ampembeng 15:6f2798e45099 223 */
ampembeng 15:6f2798e45099 224 IoT_Error_t aws_iot_mqtt_attempt_reconnect(void);
ampembeng 15:6f2798e45099 225
ampembeng 15:6f2798e45099 226 /**
ampembeng 15:6f2798e45099 227 * @brief Disconnect an MQTT Connection
ampembeng 15:6f2798e45099 228 *
ampembeng 15:6f2798e45099 229 * Called to send a disconnect message to the broker.
ampembeng 15:6f2798e45099 230 *
ampembeng 15:6f2798e45099 231 * @return An IoT Error Type defining successful/failed send of the disconnect control packet.
ampembeng 15:6f2798e45099 232 */
ampembeng 15:6f2798e45099 233 IoT_Error_t aws_iot_mqtt_disconnect(void);
ampembeng 15:6f2798e45099 234
ampembeng 15:6f2798e45099 235 /**
ampembeng 15:6f2798e45099 236 * @brief Yield to the MQTT client
ampembeng 15:6f2798e45099 237 *
ampembeng 15:6f2798e45099 238 * Called to yield the current thread to the underlying MQTT client. This time is used by
ampembeng 15:6f2798e45099 239 * the MQTT client to manage PING requests to monitor the health of the TCP connection as
ampembeng 15:6f2798e45099 240 * well as periodically check the socket receive buffer for subscribe messages. Yield()
ampembeng 15:6f2798e45099 241 * must be called at a rate faster than the keepalive interval. It must also be called
ampembeng 15:6f2798e45099 242 * at a rate faster than the incoming message rate as this is the only way the client receives
ampembeng 15:6f2798e45099 243 * processing time to manage incoming messages.
ampembeng 15:6f2798e45099 244 *
ampembeng 15:6f2798e45099 245 * @param timeout Maximum number of milliseconds to pass thread execution to the client.
ampembeng 15:6f2798e45099 246 * @return An IoT Error Type defining successful/failed client processing.
ampembeng 15:6f2798e45099 247 * If this call results in an error it is likely the MQTT connection has dropped.
ampembeng 15:6f2798e45099 248 * iot_is_mqtt_connected can be called to confirm.
ampembeng 15:6f2798e45099 249 */
ampembeng 15:6f2798e45099 250 IoT_Error_t aws_iot_mqtt_yield(int timeout);
ampembeng 15:6f2798e45099 251
ampembeng 15:6f2798e45099 252 /**
ampembeng 15:6f2798e45099 253 * @brief Is the MQTT client currently connected?
ampembeng 15:6f2798e45099 254 *
ampembeng 15:6f2798e45099 255 * Called to determine if the MQTT client is currently connected. Used to support logic
ampembeng 15:6f2798e45099 256 * in the device application around reconnecting and managing offline state.
ampembeng 15:6f2798e45099 257 *
ampembeng 15:6f2798e45099 258 * @return true = connected, false = not currently connected
ampembeng 15:6f2798e45099 259 */
ampembeng 15:6f2798e45099 260 bool aws_iot_is_mqtt_connected(void);
ampembeng 15:6f2798e45099 261
ampembeng 15:6f2798e45099 262 /**
ampembeng 15:6f2798e45099 263 * @brief Is the MQTT client set to reconnect automatically?
ampembeng 15:6f2798e45099 264 *
ampembeng 15:6f2798e45099 265 * Called to determine if the MQTT client is set to reconnect automatically.
ampembeng 15:6f2798e45099 266 * Used to support logic in the device application around reconnecting
ampembeng 15:6f2798e45099 267 *
ampembeng 15:6f2798e45099 268 * @return true = enabled, false = disabled
ampembeng 15:6f2798e45099 269 */
ampembeng 15:6f2798e45099 270 bool aws_iot_is_autoreconnect_enabled(void);
ampembeng 15:6f2798e45099 271
ampembeng 15:6f2798e45099 272 /**
ampembeng 15:6f2798e45099 273 * @brief Enable or Disable AutoReconnect on Network Disconnect
ampembeng 15:6f2798e45099 274 *
ampembeng 15:6f2798e45099 275 * Called to enable or disabled the auto reconnect features provided with the SDK
ampembeng 15:6f2798e45099 276 *
ampembeng 15:6f2798e45099 277 * @param value set to true for enabling and false for disabling
ampembeng 15:6f2798e45099 278 *
ampembeng 15:6f2798e45099 279 * @return IoT_Error_t Type defining successful/failed API call
ampembeng 15:6f2798e45099 280 */
ampembeng 15:6f2798e45099 281 IoT_Error_t aws_iot_mqtt_autoreconnect_set_status(bool value);
ampembeng 15:6f2798e45099 282
ampembeng 15:6f2798e45099 283 typedef IoT_Error_t (*pConnectFunc_t)(MQTTConnectParams *pParams);
ampembeng 15:6f2798e45099 284 typedef IoT_Error_t (*pPublishFunc_t)(MQTTPublishParams *pParams);
ampembeng 15:6f2798e45099 285 typedef IoT_Error_t (*pSubscribeFunc_t)(MQTTSubscribeParams *pParams);
ampembeng 15:6f2798e45099 286 typedef IoT_Error_t (*pUnsubscribeFunc_t)(char *pTopic);
ampembeng 15:6f2798e45099 287 typedef IoT_Error_t (*pDisconnectFunc_t)(void);
ampembeng 15:6f2798e45099 288 typedef IoT_Error_t (*pYieldFunc_t)(int timeout);
ampembeng 15:6f2798e45099 289 typedef bool (*pIsConnectedFunc_t)(void);
ampembeng 15:6f2798e45099 290 typedef bool (*pIsAutoReconnectEnabledFunc_t)(void);
ampembeng 15:6f2798e45099 291 typedef IoT_Error_t (*pReconnectFunc_t)();
ampembeng 15:6f2798e45099 292 typedef IoT_Error_t (*pSetAutoReconnectStatusFunc_t)(bool);
ampembeng 15:6f2798e45099 293 /**
ampembeng 15:6f2798e45099 294 * @brief MQTT Client Type Definition
ampembeng 15:6f2798e45099 295 *
ampembeng 15:6f2798e45099 296 * Defines a structure of function pointers, each implementing a corresponding iot_mqtt_*
ampembeng 15:6f2798e45099 297 * function. In this way any MQTT client which implements the iot_mqtt_* interface
ampembeng 15:6f2798e45099 298 * can be swapped in under the MQTT/Shadow layer.
ampembeng 15:6f2798e45099 299 *
ampembeng 15:6f2798e45099 300 */
ampembeng 15:6f2798e45099 301 typedef struct{
ampembeng 15:6f2798e45099 302 pConnectFunc_t connect; ///< function implementing the iot_mqtt_connect function
ampembeng 15:6f2798e45099 303 pPublishFunc_t publish; ///< function implementing the iot_mqtt_publish function
ampembeng 15:6f2798e45099 304 pSubscribeFunc_t subscribe; ///< function implementing the iot_mqtt_subscribe function
ampembeng 15:6f2798e45099 305 pUnsubscribeFunc_t unsubscribe; ///< function implementing the iot_mqtt_unsubscribe function
ampembeng 15:6f2798e45099 306 pDisconnectFunc_t disconnect; ///< function implementing the iot_mqtt_disconnect function
ampembeng 15:6f2798e45099 307 pYieldFunc_t yield; ///< function implementing the iot_mqtt_yield function
ampembeng 15:6f2798e45099 308 pIsConnectedFunc_t isConnected; ///< function implementing the iot_is_mqtt_connected function
ampembeng 15:6f2798e45099 309 pReconnectFunc_t reconnect; ///< function implementing the iot_mqtt_reconnect function
ampembeng 15:6f2798e45099 310 pIsAutoReconnectEnabledFunc_t isAutoReconnectEnabled; ///< function implementing the iot_is_autoreconnect_enabled function
ampembeng 15:6f2798e45099 311 pSetAutoReconnectStatusFunc_t setAutoReconnectStatus; ///< function implementing the iot_mqtt_autoreconnect_set_status function
ampembeng 15:6f2798e45099 312 }MQTTClient_t;
ampembeng 15:6f2798e45099 313
ampembeng 15:6f2798e45099 314
ampembeng 15:6f2798e45099 315 /**
ampembeng 15:6f2798e45099 316 * @brief Set the MQTT client
ampembeng 15:6f2798e45099 317 *
ampembeng 15:6f2798e45099 318 * This function provides a way to pass in an MQTT client implementation to the
ampembeng 15:6f2798e45099 319 * AWS IoT MQTT wrapper layer. This is done through function pointers to the
ampembeng 15:6f2798e45099 320 * interface functions.
ampembeng 15:6f2798e45099 321 *
ampembeng 15:6f2798e45099 322 */
ampembeng 15:6f2798e45099 323 void aws_iot_mqtt_init(MQTTClient_t *pClient);
ampembeng 15:6f2798e45099 324
ampembeng 15:6f2798e45099 325
ampembeng 15:6f2798e45099 326 #endif /* AWS_IOT_SDK_SRC_IOT_MQTT_INTERFACE_H_ */
ampembeng 15:6f2798e45099 327
ampembeng 15:6f2798e45099 328