coreMQTT Agent v1.1.0
Thread safe MQTT 3.1.1 Client
core_mqtt_agent_command_functions.h
Go to the documentation of this file.
1/*
2 * coreMQTT Agent v1.1.0
3 * Copyright (C) 2021 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
27#ifndef CORE_MQTT_AGENT_COMMAND_FUNCTIONS_H
28#define CORE_MQTT_AGENT_COMMAND_FUNCTIONS_H
29
30/* *INDENT-OFF* */
31#ifdef __cplusplus
32 extern "C" {
33#endif
34/* *INDENT-ON* */
35
36/* MQTT Agent include. */
37#include "core_mqtt_agent.h"
38
64#ifndef MQTT_AGENT_FUNCTION_TABLE
65 /* Designated initializers are only in C99+. */
66 #if defined( __STDC_VERSION__ ) && ( __STDC_VERSION__ >= 199901L )
67 #define MQTT_AGENT_FUNCTION_TABLE \
68 { \
69 [ NONE ] = MQTTAgentCommand_ProcessLoop, \
70 [ PROCESSLOOP ] = MQTTAgentCommand_ProcessLoop, \
71 [ PUBLISH ] = MQTTAgentCommand_Publish, \
72 [ SUBSCRIBE ] = MQTTAgentCommand_Subscribe, \
73 [ UNSUBSCRIBE ] = MQTTAgentCommand_Unsubscribe, \
74 [ PING ] = MQTTAgentCommand_Ping, \
75 [ CONNECT ] = MQTTAgentCommand_Connect, \
76 [ DISCONNECT ] = MQTTAgentCommand_Disconnect, \
77 [ TERMINATE ] = MQTTAgentCommand_Terminate \
78 }
79 #else /* if defined( __STDC_VERSION__ ) && ( __STDC_VERSION__ >= 199901L ) */
80
81/* If not using designated initializers, this must correspond
82 * to the order of MQTTAgentCommandType_t commands. */
83 #define MQTT_AGENT_FUNCTION_TABLE \
84 { \
85 MQTTAgentCommand_ProcessLoop, \
86 MQTTAgentCommand_ProcessLoop, \
87 MQTTAgentCommand_Publish, \
88 MQTTAgentCommand_Subscribe, \
89 MQTTAgentCommand_Unsubscribe, \
90 MQTTAgentCommand_Ping, \
91 MQTTAgentCommand_Connect, \
92 MQTTAgentCommand_Disconnect, \
93 MQTTAgentCommand_Terminate \
94 }
95 #endif /* if defined( __STDC_VERSION__ ) && ( __STDC_VERSION__ >= 199901L ) */
96#endif /* ifndef MQTT_AGENT_FUNCTION_TABLE */
97
98/*-----------------------------------------------------------*/
99
105typedef struct MQTTAgentCommandFuncReturns
106{
107 uint16_t packetId;
108 bool endLoop;
112
125typedef MQTTStatus_t (* MQTTAgentCommandFunc_t ) ( MQTTAgentContext_t * pMqttAgentContext,
126 void * pArgs,
128
129/*-----------------------------------------------------------*/
130
145 void * pUnusedArg,
146 MQTTAgentCommandFuncReturns_t * pReturnFlags );
147
162 void * pPublishArg,
163 MQTTAgentCommandFuncReturns_t * pReturnFlags );
164
179 void * pVoidSubscribeArgs,
180 MQTTAgentCommandFuncReturns_t * pReturnFlags );
181
196 void * pVoidSubscribeArgs,
197 MQTTAgentCommandFuncReturns_t * pReturnFlags );
198
211 void * pVoidConnectArgs,
212 MQTTAgentCommandFuncReturns_t * pReturnFlags );
213
227 void * pUnusedArg,
228 MQTTAgentCommandFuncReturns_t * pReturnFlags );
229
243 void * pUnusedArg,
244 MQTTAgentCommandFuncReturns_t * pReturnFlags );
245
260 void * pUnusedArg,
261 MQTTAgentCommandFuncReturns_t * pReturnFlags );
262
263/* *INDENT-OFF* */
264#ifdef __cplusplus
265 }
266#endif
267/* *INDENT-ON* */
268
269#endif /* CORE_MQTT_AGENT_COMMAND_FUNCTIONS_H */
Functions for running a coreMQTT client in a dedicated thread.
MQTTStatus_t MQTTAgentCommand_Publish(MQTTAgentContext_t *pMqttAgentContext, void *pPublishArg, MQTTAgentCommandFuncReturns_t *pReturnFlags)
Function to execute for a PUBLISH command.
Definition: core_mqtt_agent_command_functions.c:57
MQTTStatus_t MQTTAgentCommand_Ping(MQTTAgentContext_t *pMqttAgentContext, void *pUnusedArg, MQTTAgentCommandFuncReturns_t *pReturnFlags)
Function to execute for a PING command.
Definition: core_mqtt_agent_command_functions.c:199
MQTTStatus_t MQTTAgentCommand_Terminate(MQTTAgentContext_t *pMqttAgentContext, void *pUnusedArg, MQTTAgentCommandFuncReturns_t *pReturnFlags)
Function to execute for a TERMINATE command. Calls MQTTAgent_CancelAll to terminate all unfinished co...
Definition: core_mqtt_agent_command_functions.c:221
MQTTStatus_t MQTTAgentCommand_Disconnect(MQTTAgentContext_t *pMqttAgentContext, void *pUnusedArg, MQTTAgentCommandFuncReturns_t *pReturnFlags)
Function to execute for a DISCONNECT command.
Definition: core_mqtt_agent_command_functions.c:178
MQTTStatus_t MQTTAgentCommand_Connect(MQTTAgentContext_t *pMqttAgentContext, void *pVoidConnectArgs, MQTTAgentCommandFuncReturns_t *pReturnFlags)
Function to execute for a CONNECT command.
Definition: core_mqtt_agent_command_functions.c:144
MQTTStatus_t MQTTAgentCommand_Subscribe(MQTTAgentContext_t *pMqttAgentContext, void *pVoidSubscribeArgs, MQTTAgentCommandFuncReturns_t *pReturnFlags)
Function to execute for a SUBSCRIBE command.
Definition: core_mqtt_agent_command_functions.c:88
MQTTStatus_t MQTTAgentCommand_ProcessLoop(MQTTAgentContext_t *pMqttAgentContext, void *pUnusedArg, MQTTAgentCommandFuncReturns_t *pReturnFlags)
Function to execute for a NONE command. This function does not call MQTT_ProcessLoop itself,...
Definition: core_mqtt_agent_command_functions.c:41
MQTTStatus_t MQTTAgentCommand_Unsubscribe(MQTTAgentContext_t *pMqttAgentContext, void *pVoidSubscribeArgs, MQTTAgentCommandFuncReturns_t *pReturnFlags)
Function to execute for an UNSUBSCRIBE command.
Definition: core_mqtt_agent_command_functions.c:116
MQTTStatus_t(* MQTTAgentCommandFunc_t)(MQTTAgentContext_t *pMqttAgentContext, void *pArgs, MQTTAgentCommandFuncReturns_t *pFlags)
Function prototype for a command.
Definition: core_mqtt_agent_command_functions.h:125
MQTTStatus_t
A structure of values and flags expected to be returned by command functions.
Definition: core_mqtt_agent_command_functions.h:106
bool addAcknowledgment
Flag to indicate an acknowledgment should be tracked.
Definition: core_mqtt_agent_command_functions.h:109
bool runProcessLoop
Flag to indicate MQTT_ProcessLoop() should be called after this command.
Definition: core_mqtt_agent_command_functions.h:110
uint16_t packetId
Packet ID of packet sent by command.
Definition: core_mqtt_agent_command_functions.h:107
bool endLoop
Flag to indicate command loop should terminate.
Definition: core_mqtt_agent_command_functions.h:108
Information used by each MQTT agent. A context will be initialized by MQTTAgent_Init(),...
Definition: core_mqtt_agent.h:185