FreeRTOS
aws_mqtt_agent.h
Go to the documentation of this file.
1 /*
2  * FreeRTOS
3  * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of
6  * this software and associated documentation files (the "Software"), to deal in
7  * the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9  * the Software, and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in all
13  * copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  *
22  * http://aws.amazon.com/freertos
23  * http://www.FreeRTOS.org
24  */
25 
26 
32 #ifndef _AWS_MQTT_AGENT_H_
33 #define _AWS_MQTT_AGENT_H_
34 
35 /* FreeRTOS includes. */
36 #include "FreeRTOS.h"
37 
38 /* MQTT lib includes. */
39 #include "aws_mqtt_lib.h"
40 
41 /* Library initialization definition include */
42 #include "aws_lib_init.h"
43 
52 typedef void * MQTTAgentHandle_t;
53 
59 typedef enum
60 {
68 
77 typedef enum
78 {
82 
91 {
93  /* This union is here for future support. */
94  union
95  {
97  } u;
99 
122 typedef BaseType_t ( * MQTTAgentCallback_t ) ( void * pvUserData,
123  const MQTTAgentCallbackParams_t * const pxCallbackParams );
124 
128 #define mqttagentURL_IS_IP_ADDRESS 0x00000001
129 #define mqttagentREQUIRE_TLS 0x00000002
130 #define mqttagentUSE_AWS_IOT_ALPN_443 0x00000004
135 typedef struct MQTTAgentConnectParams
136 {
137  const char * pcURL;
138  BaseType_t xFlags;
139  BaseType_t xURLIsIPAddress;
140  uint16_t usPort;
141  const uint8_t * pucClientId;
142  uint16_t usClientIdLength;
143  BaseType_t xSecuredConnection;
144  void * pvUserData;
147  char * pcCertificate;
148  uint32_t ulCertificateSize;
150 
155 {
156  const uint8_t * pucTopic;
157  uint16_t usTopicLength;
159  #if( mqttconfigENABLE_SUBSCRIPTION_MANAGEMENT == 1 )
160  void * pvPublishCallbackContext;
161  MQTTPublishCallback_t pxPublishCallback;
165  #endif /* mqttconfigENABLE_SUBSCRIPTION_MANAGEMENT */
167 
172 {
173  const uint8_t * pucTopic;
174  uint16_t usTopicLength;
176 
181 {
182  const uint8_t * pucTopic;
183  uint16_t usTopicLength;
185  const void * pvData;
186  uint32_t ulDataLength;
188 
197 lib_initDECLARE_LIB_INIT( MQTT_AGENT_Init );
198 
215 
229 
246  const MQTTAgentConnectParams_t * const pxConnectParams,
247  TickType_t xTimeoutTicks );
248 
264  TickType_t xTimeoutTicks );
265 
301  const MQTTAgentSubscribeParams_t * const pxSubscribeParams,
302  TickType_t xTimeoutTicks );
303 
320  const MQTTAgentUnsubscribeParams_t * const pxUnsubscribeParams,
321  TickType_t xTimeoutTicks );
322 
339  const MQTTAgentPublishParams_t * const pxPublishParams,
340  TickType_t xTimeoutTicks );
341 
357  MQTTBufferHandle_t xBufferHandle );
358 
359 #endif /* _AWS_MQTT_AGENT_H_ */
struct MQTTAgentSubscribeParams MQTTAgentSubscribeParams_t
Parameters passed to the MQTT_AGENT_Subscribe API.
struct MQTTAgentPublishParams MQTTAgentPublishParams_t
Parameters passed to the MQTT_AGENT_Publish API.
struct MQTTAgentConnectParams MQTTAgentConnectParams_t
Parameters passed to the MQTT_AGENT_Connect API.
const uint8_t * pucTopic
MQTTAgentReturnCode_t MQTT_AGENT_Delete(MQTTAgentHandle_t xMQTTHandle)
Deletes the already created MQTT client.
MQTTAgentReturnCode_t MQTT_AGENT_ReturnBuffer(MQTTAgentHandle_t xMQTTHandle, MQTTBufferHandle_t xBufferHandle)
Returns the buffer provided in the publish callback.
The data sent by the MQTT library in the user supplied callback when a publish message from the broke...
Definition: aws_mqtt_lib.h:252
void * MQTTAgentHandle_t
Opaque handle to represent an MQTT client.
MQTTQoS_t
Quality of Service (QoS).
Definition: aws_mqtt_lib.h:153
struct MQTTAgentCallbackParams MQTTAgentCallbackParams_t
Passed by the library in the callback to inform the user of various events.
MQTTAgentEvent_t xMQTTEvent
MQTTAgentReturnCode_t MQTT_AGENT_Subscribe(MQTTAgentHandle_t xMQTTHandle, const MQTTAgentSubscribeParams_t *const pxSubscribeParams, TickType_t xTimeoutTicks)
Subscribes to a given topic.
const uint8_t * pucClientId
MQTTAgentReturnCode_t MQTT_AGENT_Publish(MQTTAgentHandle_t xMQTTHandle, const MQTTAgentPublishParams_t *const pxPublishParams, TickType_t xTimeoutTicks)
Publishes a message to a given topic.
MQTT Core Library interface.
BaseType_t(* MQTTAgentCallback_t)(void *pvUserData, const MQTTAgentCallbackParams_t *const pxCallbackParams)
Signature of the callback registered by the user to get notified of various events.
Parameters passed to the MQTT_AGENT_Publish API.
Passed by the library in the callback to inform the user of various events.
MQTTAgentReturnCode_t MQTT_AGENT_Unsubscribe(MQTTAgentHandle_t xMQTTHandle, const MQTTAgentUnsubscribeParams_t *const pxUnsubscribeParams, TickType_t xTimeoutTicks)
Unsubscribes from a given topic.
struct MQTTAgentUnsubscribeParams MQTTAgentUnsubscribeParams_t
Parameters passed to the MQTT_AGENT_Unsubscribe API.
Parameters passed to the MQTT_AGENT_Connect API.
MQTTAgentReturnCode_t MQTT_AGENT_Create(MQTTAgentHandle_t *const pxMQTTHandle)
Creates a new MQTT client.
MQTTAgentReturnCode_t MQTT_AGENT_Disconnect(MQTTAgentHandle_t xMQTTHandle, TickType_t xTimeoutTicks)
Disconnects the connection with the MQTT broker.
Parameters passed to the MQTT_AGENT_Unsubscribe API.
Parameters passed to the MQTT_AGENT_Subscribe API.
MQTTAgentReturnCode_t
Return codes.
MQTTPublishData_t xPublishData
MQTTAgentReturnCode_t MQTT_AGENT_Connect(MQTTAgentHandle_t xMQTTHandle, const MQTTAgentConnectParams_t *const pxConnectParams, TickType_t xTimeoutTicks)
Establishes a connection with the MQTT broker.
MQTTAgentCallback_t pxCallback
lib_initDECLARE_LIB_INIT(MQTT_AGENT_Init)
MQTT library Init function.
const uint8_t * pucTopic
MQTTAgentEvent_t
Various events reported by the library in the callback.