coreMQTT Agent v1.2.0
Thread safe MQTT 3.1.1 Client
core_mqtt_agent_command_functions.h File Reference

Functions for processing an MQTT agent command. More...

#include "core_mqtt_agent.h"

Go to the source code of this file.

Data Structures

struct  MQTTAgentCommandFuncReturns_t
 A structure of values and flags expected to be returned by command functions. More...
 

Macros

#define MQTT_AGENT_FUNCTION_TABLE
 An array of function pointers mapping command types to a function to execute. Configurable to allow a linker to remove unneeded functions. More...
 

Typedefs

typedef MQTTStatus_t(* MQTTAgentCommandFunc_t) (MQTTAgentContext_t *pMqttAgentContext, void *pArgs, MQTTAgentCommandFuncReturns_t *pFlags)
 Function prototype for a command. More...
 

Functions

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, but instead sets a flag to indicate it should be called. More...
 
MQTTStatus_t MQTTAgentCommand_Publish (MQTTAgentContext_t *pMqttAgentContext, void *pPublishArg, MQTTAgentCommandFuncReturns_t *pReturnFlags)
 Function to execute for a PUBLISH command. More...
 
MQTTStatus_t MQTTAgentCommand_Subscribe (MQTTAgentContext_t *pMqttAgentContext, void *pVoidSubscribeArgs, MQTTAgentCommandFuncReturns_t *pReturnFlags)
 Function to execute for a SUBSCRIBE command. More...
 
MQTTStatus_t MQTTAgentCommand_Unsubscribe (MQTTAgentContext_t *pMqttAgentContext, void *pVoidSubscribeArgs, MQTTAgentCommandFuncReturns_t *pReturnFlags)
 Function to execute for an UNSUBSCRIBE command. More...
 
MQTTStatus_t MQTTAgentCommand_Connect (MQTTAgentContext_t *pMqttAgentContext, void *pVoidConnectArgs, MQTTAgentCommandFuncReturns_t *pReturnFlags)
 Function to execute for a CONNECT command. More...
 
MQTTStatus_t MQTTAgentCommand_Disconnect (MQTTAgentContext_t *pMqttAgentContext, void *pUnusedArg, MQTTAgentCommandFuncReturns_t *pReturnFlags)
 Function to execute for a DISCONNECT command. More...
 
MQTTStatus_t MQTTAgentCommand_Ping (MQTTAgentContext_t *pMqttAgentContext, void *pUnusedArg, MQTTAgentCommandFuncReturns_t *pReturnFlags)
 Function to execute for a PING command. More...
 
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 commands with MQTTRecvFailed. More...
 

Detailed Description

Functions for processing an MQTT agent command.

Macro Definition Documentation

◆ MQTT_AGENT_FUNCTION_TABLE

#define MQTT_AGENT_FUNCTION_TABLE
Value:
{ \
MQTTAgentCommand_ProcessLoop, \
MQTTAgentCommand_ProcessLoop, \
MQTTAgentCommand_Publish, \
MQTTAgentCommand_Subscribe, \
MQTTAgentCommand_Unsubscribe, \
MQTTAgentCommand_Ping, \
MQTTAgentCommand_Connect, \
MQTTAgentCommand_Disconnect, \
MQTTAgentCommand_Terminate \
}

An array of function pointers mapping command types to a function to execute. Configurable to allow a linker to remove unneeded functions.

Note
This array controls the behavior of each command. Altering the array would allow a linker to discard unused MQTT functions if desired. The size of this array MUST equal NUM_COMMANDS and the order MUST correspond to MQTTAgentCommandType_t commands if not using C99 designated initializers. If any function is desired not to be linked, it may be set to MQTTAgentCommand_ProcessLoop or a custom function matching an MQTTAgentCommandFunc_t prototype.

Default value:

{
}
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:60
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:202
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:224
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:181
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:147
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:91
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:44
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:119
@ CONNECT
Call MQTT_Connect().
Definition: core_mqtt_agent.h:57
@ DISCONNECT
Call MQTT_Disconnect().
Definition: core_mqtt_agent.h:58
@ PING
Call MQTT_Ping().
Definition: core_mqtt_agent.h:56
@ UNSUBSCRIBE
Call MQTT_Unsubscribe().
Definition: core_mqtt_agent.h:55
@ PROCESSLOOP
Call MQTT_ProcessLoop().
Definition: core_mqtt_agent.h:52
@ TERMINATE
Exit the command loop and stop processing commands.
Definition: core_mqtt_agent.h:59
@ SUBSCRIBE
Call MQTT_Subscribe().
Definition: core_mqtt_agent.h:54
@ PUBLISH
Call MQTT_Publish().
Definition: core_mqtt_agent.h:53
@ NONE
No command received. Must be zero (its memset() value).
Definition: core_mqtt_agent.h:51

Typedef Documentation

◆ MQTTAgentCommandFunc_t

typedef MQTTStatus_t(* MQTTAgentCommandFunc_t) (MQTTAgentContext_t *pMqttAgentContext, void *pArgs, MQTTAgentCommandFuncReturns_t *pFlags)

Function prototype for a command.

Note
These functions should only be called from within MQTTAgent_CommandLoop.
Parameters
[in]pMqttAgentContextMQTT Agent context.
[in]pArgsArguments for the command.
[out]pFlagsReturn flags set by the function.
Returns
Return code of MQTT call.

Function Documentation

◆ MQTTAgentCommand_ProcessLoop()

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, but instead sets a flag to indicate it should be called.

This sets the following flags to true:

Parameters
[in]pMqttAgentContextMQTT Agent context information.
[in]pUnusedArgUnused NULL argument.
[out]pReturnFlagsFlags set to indicate actions the MQTT agent should take.
Returns
MQTTSuccess.

◆ MQTTAgentCommand_Publish()

MQTTStatus_t MQTTAgentCommand_Publish ( MQTTAgentContext_t pMqttAgentContext,
void *  pPublishArg,
MQTTAgentCommandFuncReturns_t pReturnFlags 
)

Function to execute for a PUBLISH command.

This sets the following flags to true:

Parameters
[in]pMqttAgentContextMQTT Agent context information.
[in]pPublishArgPublish information for MQTT_Publish().
[out]pReturnFlagsFlags set to indicate actions the MQTT agent should take.
Returns
Status code of MQTT_Publish().

◆ MQTTAgentCommand_Subscribe()

MQTTStatus_t MQTTAgentCommand_Subscribe ( MQTTAgentContext_t pMqttAgentContext,
void *  pVoidSubscribeArgs,
MQTTAgentCommandFuncReturns_t pReturnFlags 
)

Function to execute for a SUBSCRIBE command.

This sets the following flags to true:

Parameters
[in]pMqttAgentContextMQTT Agent context information.
[in]pVoidSubscribeArgsArguments for MQTT_Subscribe().
[out]pReturnFlagsFlags set to indicate actions the MQTT agent should take.
Returns
Status code of MQTT_Subscribe().

◆ MQTTAgentCommand_Unsubscribe()

MQTTStatus_t MQTTAgentCommand_Unsubscribe ( MQTTAgentContext_t pMqttAgentContext,
void *  pVoidSubscribeArgs,
MQTTAgentCommandFuncReturns_t pReturnFlags 
)

Function to execute for an UNSUBSCRIBE command.

This sets the following flags to true:

Parameters
[in]pMqttAgentContextMQTT Agent context information.
[in]pVoidSubscribeArgsArguments for MQTT_Unsubscribe().
[out]pReturnFlagsFlags set to indicate actions the MQTT agent should take.
Returns
Status code of MQTT_Unsubscribe().

◆ MQTTAgentCommand_Connect()

MQTTStatus_t MQTTAgentCommand_Connect ( MQTTAgentContext_t pMqttAgentContext,
void *  pVoidConnectArgs,
MQTTAgentCommandFuncReturns_t pReturnFlags 
)

Function to execute for a CONNECT command.

This sets all return flags to false.

Parameters
[in]pMqttAgentContextMQTT Agent context information.
[in]pVoidConnectArgsArguments for MQTT_Connect().
[out]pReturnFlagsFlags set to indicate actions the MQTT agent should take.
Returns
Status code of MQTT_Connect().

◆ MQTTAgentCommand_Disconnect()

MQTTStatus_t MQTTAgentCommand_Disconnect ( MQTTAgentContext_t pMqttAgentContext,
void *  pUnusedArg,
MQTTAgentCommandFuncReturns_t pReturnFlags 
)

Function to execute for a DISCONNECT command.

This sets the following flags to true:

Parameters
[in]pMqttAgentContextMQTT Agent context information.
[in]pUnusedArgUnused NULL argument.
[out]pReturnFlagsFlags set to indicate actions the MQTT agent should take.
Returns
Status code of MQTT_Disconnect().

◆ MQTTAgentCommand_Ping()

MQTTStatus_t MQTTAgentCommand_Ping ( MQTTAgentContext_t pMqttAgentContext,
void *  pUnusedArg,
MQTTAgentCommandFuncReturns_t pReturnFlags 
)

Function to execute for a PING command.

This sets the following flags to true:

Parameters
[in]pMqttAgentContextMQTT Agent context information.
[in]pUnusedArgUnused NULL argument.
[out]pReturnFlagsFlags set to indicate actions the MQTT agent should take.
Returns
Status code of MQTT_Ping().

◆ MQTTAgentCommand_Terminate()

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 commands with MQTTRecvFailed.

This sets the following flags to true:

Parameters
[in]pMqttAgentContextMQTT Agent context information.
[in]pUnusedArgUnused NULL argument.
[out]pReturnFlagsFlags set to indicate actions the MQTT agent should take.
Returns
MQTTSuccess.