coreMQTT Agent v1.0.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.0.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/* MQTT Agent include. */
31#include "core_mqtt_agent.h"
32
58#ifndef MQTT_AGENT_FUNCTION_TABLE
59 /* Designated initializers are only in C99+. */
60 #if defined( __STDC_VERSION__ ) && ( __STDC_VERSION__ >= 199901L )
61 #define MQTT_AGENT_FUNCTION_TABLE \
62 { \
63 [ NONE ] = MQTTAgentCommand_ProcessLoop, \
64 [ PROCESSLOOP ] = MQTTAgentCommand_ProcessLoop, \
65 [ PUBLISH ] = MQTTAgentCommand_Publish, \
66 [ SUBSCRIBE ] = MQTTAgentCommand_Subscribe, \
67 [ UNSUBSCRIBE ] = MQTTAgentCommand_Unsubscribe, \
68 [ PING ] = MQTTAgentCommand_Ping, \
69 [ CONNECT ] = MQTTAgentCommand_Connect, \
70 [ DISCONNECT ] = MQTTAgentCommand_Disconnect, \
71 [ TERMINATE ] = MQTTAgentCommand_Terminate \
72 }
73 #else /* if defined( __STDC_VERSION__ ) && ( __STDC_VERSION__ >= 199901L ) */
74
75/* If not using designated initializers, this must correspond
76 * to the order of MQTTAgentCommandType_t commands. */
77 #define MQTT_AGENT_FUNCTION_TABLE \
78 { \
79 MQTTAgentCommand_ProcessLoop, \
80 MQTTAgentCommand_ProcessLoop, \
81 MQTTAgentCommand_Publish, \
82 MQTTAgentCommand_Subscribe, \
83 MQTTAgentCommand_Unsubscribe, \
84 MQTTAgentCommand_Ping, \
85 MQTTAgentCommand_Connect, \
86 MQTTAgentCommand_Disconnect, \
87 MQTTAgentCommand_Terminate \
88 }
89 #endif /* if defined( __STDC_VERSION__ ) && ( __STDC_VERSION__ >= 199901L ) */
90#endif /* ifndef MQTT_AGENT_FUNCTION_TABLE */
91
92/*-----------------------------------------------------------*/
93
99typedef struct MQTTAgentCommandFuncReturns
100{
101 uint16_t packetId;
102 bool endLoop;
106
119typedef MQTTStatus_t (* MQTTAgentCommandFunc_t ) ( MQTTAgentContext_t * pMqttAgentContext,
120 void * pArgs,
122
123/*-----------------------------------------------------------*/
124
139 void * pUnusedArg,
140 MQTTAgentCommandFuncReturns_t * pReturnFlags );
141
156 void * pPublishArg,
157 MQTTAgentCommandFuncReturns_t * pReturnFlags );
158
173 void * pVoidSubscribeArgs,
174 MQTTAgentCommandFuncReturns_t * pReturnFlags );
175
190 void * pVoidSubscribeArgs,
191 MQTTAgentCommandFuncReturns_t * pReturnFlags );
192
205 void * pVoidConnectArgs,
206 MQTTAgentCommandFuncReturns_t * pReturnFlags );
207
221 void * pUnusedArg,
222 MQTTAgentCommandFuncReturns_t * pReturnFlags );
223
237 void * pUnusedArg,
238 MQTTAgentCommandFuncReturns_t * pReturnFlags );
239
254 void * pUnusedArg,
255 MQTTAgentCommandFuncReturns_t * pReturnFlags );
256
257#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:119
MQTTStatus_t
A structure of values and flags expected to be returned by command functions.
Definition: core_mqtt_agent_command_functions.h:100
bool addAcknowledgment
Flag to indicate an acknowledgment should be tracked.
Definition: core_mqtt_agent_command_functions.h:103
bool runProcessLoop
Flag to indicate MQTT_ProcessLoop() should be called after this command.
Definition: core_mqtt_agent_command_functions.h:104
uint16_t packetId
Packet ID of packet sent by command.
Definition: core_mqtt_agent_command_functions.h:101
bool endLoop
Flag to indicate command loop should terminate.
Definition: core_mqtt_agent_command_functions.h:102
Information used by each MQTT agent. A context will be initialized by MQTTAgent_Init(),...
Definition: core_mqtt_agent.h:179