Rename MQTT Agent structs and files (#576)

This commit is contained in:
Archit Aggarwal 2021-04-26 11:29:50 -07:00 committed by GitHub
parent 1fe418dc9f
commit 43bd42db27
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 62 additions and 62 deletions

View file

@ -39,12 +39,12 @@
/* Header include. */
#include "freertos_agent_message.h"
#include "agent_message.h"
#include "core_mqtt_agent_message_interface.h"
/*-----------------------------------------------------------*/
bool Agent_MessageSend( const AgentMessageContext_t * pMsgCtx,
Command_t * const * pCommandToSend,
bool Agent_MessageSend( const MQTTAgentMessageContext_t * pMsgCtx,
MQTTAgentCommand_t * const * pCommandToSend,
uint32_t blockTimeMs )
{
BaseType_t queueStatus = pdFAIL;
@ -59,8 +59,8 @@ bool Agent_MessageSend( const AgentMessageContext_t * pMsgCtx,
/*-----------------------------------------------------------*/
bool Agent_MessageReceive( const AgentMessageContext_t * pMsgCtx,
Command_t ** pReceivedCommand,
bool Agent_MessageReceive( const MQTTAgentMessageContext_t * pMsgCtx,
MQTTAgentCommand_t ** pReceivedCommand,
uint32_t blockTimeMs )
{
BaseType_t queueStatus = pdFAIL;

View file

@ -51,15 +51,15 @@
* as PUBLISH or SUBSCRIBE) between the command being created by an API call and
* completion of the command by the execution of the command's callback.
*/
static Command_t commandStructurePool[ MQTT_COMMAND_CONTEXTS_POOL_SIZE ];
static MQTTAgentCommand_t commandStructurePool[ MQTT_COMMAND_CONTEXTS_POOL_SIZE ];
/**
* @brief The message context used to guard the pool of Command_t structures.
* @brief The message context used to guard the pool of MQTTAgentCommand_t structures.
* For FreeRTOS, this is implemented with a queue. Structures may be
* obtained by receiving a pointer from the queue, and returned by
* sending the pointer back into it.
*/
static AgentMessageContext_t commandStructMessageCtx;
static MQTTAgentMessageContext_t commandStructMessageCtx;
/**
* @brief Initialization status of the queue.
@ -71,8 +71,8 @@ static volatile uint8_t initStatus = QUEUE_NOT_INITIALIZED;
void Agent_InitializePool( void )
{
size_t i;
Command_t * pCommand;
static uint8_t staticQueueStorageArea[ MQTT_COMMAND_CONTEXTS_POOL_SIZE * sizeof( Command_t * ) ];
MQTTAgentCommand_t * pCommand;
static uint8_t staticQueueStorageArea[ MQTT_COMMAND_CONTEXTS_POOL_SIZE * sizeof( MQTTAgentCommand_t * ) ];
static StaticQueue_t staticQueueStructure;
bool commandAdded = false;
@ -80,7 +80,7 @@ void Agent_InitializePool( void )
{
memset( ( void * ) commandStructurePool, 0x00, sizeof( commandStructurePool ) );
commandStructMessageCtx.queue = xQueueCreateStatic( MQTT_COMMAND_CONTEXTS_POOL_SIZE,
sizeof( Command_t * ),
sizeof( MQTTAgentCommand_t * ),
staticQueueStorageArea,
&staticQueueStructure );
configASSERT( commandStructMessageCtx.queue );
@ -101,9 +101,9 @@ void Agent_InitializePool( void )
/*-----------------------------------------------------------*/
Command_t * Agent_GetCommand( uint32_t blockTimeMs )
MQTTAgentCommand_t * Agent_GetCommand( uint32_t blockTimeMs )
{
Command_t * structToUse = NULL;
MQTTAgentCommand_t * structToUse = NULL;
bool structRetrieved = false;
/* Check queue has been created. */
@ -122,7 +122,7 @@ Command_t * Agent_GetCommand( uint32_t blockTimeMs )
/*-----------------------------------------------------------*/
bool Agent_ReleaseCommand( Command_t * pCommandToRelease )
bool Agent_ReleaseCommand( MQTTAgentCommand_t * pCommandToRelease )
{
bool structReturned = false;

View file

@ -40,13 +40,13 @@
#include "queue.h"
/* Include MQTT agent messaging interface. */
#include "agent_message.h"
#include "core_mqtt_agent_message_interface.h"
/**
* @ingroup mqtt_agent_struct_types
* @brief Context with which tasks may deliver messages to the agent.
*/
struct AgentMessageContext
struct MQTTAgentMessageContext
{
QueueHandle_t queue;
};
@ -57,28 +57,28 @@ struct AgentMessageContext
* @brief Send a message to the specified context.
* Must be thread safe.
*
* @param[in] pMsgCtx An #AgentMessageContext_t.
* @param[in] pMsgCtx An #MQTTAgentMessageContext_t.
* @param[in] pCommandToSend Pointer to address to send to queue.
* @param[in] blockTimeMs Block time to wait for a send.
*
* @return `true` if send was successful, else `false`.
*/
bool Agent_MessageSend( const AgentMessageContext_t * pMsgCtx,
Command_t * const * pCommandToSend,
bool Agent_MessageSend( const MQTTAgentMessageContext_t * pMsgCtx,
MQTTAgentCommand_t * const * pCommandToSend,
uint32_t blockTimeMs );
/**
* @brief Receive a message from the specified context.
* Must be thread safe.
*
* @param[in] pMsgCtx An #AgentMessageContext_t.
* @param[in] pMsgCtx An #MQTTAgentMessageContext_t.
* @param[in] pReceivedCommand Pointer to write address of received command.
* @param[in] blockTimeMs Block time to wait for a receive.
*
* @return `true` if receive was successful, else `false`.
*/
bool Agent_MessageReceive( const AgentMessageContext_t * pMsgCtx,
Command_t ** pReceivedCommand,
bool Agent_MessageReceive( const MQTTAgentMessageContext_t * pMsgCtx,
MQTTAgentCommand_t ** pReceivedCommand,
uint32_t blockTimeMs );
#endif /* FREERTOS_AGENT_MESSAGE_H */

View file

@ -32,7 +32,7 @@
#define FREERTOS_COMMAND_POOL_H
/* MQTT agent includes. */
#include "mqtt_agent.h"
#include "core_mqtt_agent.h"
/**
* @brief Initialize the common task pool. Not thread safe.
@ -40,44 +40,44 @@
void Agent_InitializePool( void );
/**
* @brief Obtain a Command_t structure from the pool of structures managed by the agent.
* @brief Obtain a MQTTAgentCommand_t structure from the pool of structures managed by the agent.
*
* @note Command_t structures hold everything the MQTT agent needs to process a
* @note MQTTAgentCommand_t structures hold everything the MQTT agent needs to process a
* command that originates from application. Examples of commands are PUBLISH and
* SUBSCRIBE. The Command_t structure must persist for the duration of the command's
* SUBSCRIBE. The MQTTAgentCommand_t structure must persist for the duration of the command's
* operation so are obtained from a pool of statically allocated structures when a
* new command is created, and returned to the pool when the command is complete.
* The MQTT_COMMAND_CONTEXTS_POOL_SIZE configuration file constant defines how many
* structures the pool contains.
*
* @param[in] blockTimeMs The length of time the calling task should remain in the
* Blocked state (so not consuming any CPU time) to wait for a Command_t structure to
* Blocked state (so not consuming any CPU time) to wait for a MQTTAgentCommand_t structure to
* become available should one not be immediately at the time of the call.
*
* @return A pointer to a Command_t structure if one becomes available before
* @return A pointer to a MQTTAgentCommand_t structure if one becomes available before
* blockTimeMs time expired, otherwise NULL.
*/
Command_t * Agent_GetCommand( uint32_t blockTimeMs );
MQTTAgentCommand_t * Agent_GetCommand( uint32_t blockTimeMs );
/**
* @brief Give a Command_t structure back to the the pool of structures managed by
* @brief Give a MQTTAgentCommand_t structure back to the the pool of structures managed by
* the agent.
*
* @note Command_t structures hold everything the MQTT agent needs to process a
* @note MQTTAgentCommand_t structures hold everything the MQTT agent needs to process a
* command that originates from application. Examples of commands are PUBLISH and
* SUBSCRIBE. The Command_t structure must persist for the duration of the command's
* SUBSCRIBE. The MQTTAgentCommand_t structure must persist for the duration of the command's
* operation so are obtained from a pool of statically allocated structures when a
* new command is created, and returned to the pool when the command is complete.
* The MQTT_COMMAND_CONTEXTS_POOL_SIZE configuration file constant defines how many
* structures the pool contains.
*
* @param[in] pCommandToRelease A pointer to the Command_t structure to return to
* @param[in] pCommandToRelease A pointer to the MQTTAgentCommand_t structure to return to
* the pool. The structure must first have been obtained by calling
* Agent_GetCommand(), otherwise Agent_ReleaseCommand() will
* have no effect.
*
* @return true if the Command_t structure was returned to the pool, otherwise false.
* @return true if the MQTTAgentCommand_t structure was returned to the pool, otherwise false.
*/
bool Agent_ReleaseCommand( Command_t * pCommandToRelease );
bool Agent_ReleaseCommand( MQTTAgentCommand_t * pCommandToRelease );
#endif /* FREERTOS_COMMAND_POOL_H */

View file

@ -71,7 +71,7 @@
#include "core_mqtt.h"
/* MQTT agent include. */
#include "mqtt_agent.h"
#include "core_mqtt_agent.h"
/* MQTT Agent ports. */
#include "freertos_agent_message.h"
@ -359,7 +359,7 @@ MQTTAgentContext_t xGlobalMqttAgentContext;
static uint8_t xNetworkBuffer[ MQTT_AGENT_NETWORK_BUFFER_SIZE ];
static AgentMessageContext_t xCommandQueue;
static MQTTAgentMessageContext_t xCommandQueue;
/**
* @brief The global array of subscription elements.
@ -397,9 +397,9 @@ static MQTTStatus_t prvMQTTInit( void )
TransportInterface_t xTransport;
MQTTStatus_t xReturn;
MQTTFixedBuffer_t xFixedBuffer = { .pBuffer = xNetworkBuffer, .size = MQTT_AGENT_NETWORK_BUFFER_SIZE };
static uint8_t staticQueueStorageArea[ MQTT_AGENT_COMMAND_QUEUE_LENGTH * sizeof( Command_t * ) ];
static uint8_t staticQueueStorageArea[ MQTT_AGENT_COMMAND_QUEUE_LENGTH * sizeof( MQTTAgentCommand_t * ) ];
static StaticQueue_t staticQueueStructure;
AgentMessageInterface_t messageInterface =
MQTTAgentMessageInterface_t messageInterface =
{
.pMsgCtx = NULL,
.send = Agent_MessageSend,
@ -410,7 +410,7 @@ static MQTTStatus_t prvMQTTInit( void )
LogDebug( ( "Creating command queue." ) );
xCommandQueue.queue = xQueueCreateStatic( MQTT_AGENT_COMMAND_QUEUE_LENGTH,
sizeof( Command_t * ),
sizeof( MQTTAgentCommand_t * ),
staticQueueStorageArea,
&staticQueueStructure );
configASSERT( xCommandQueue.queue );
@ -531,7 +531,7 @@ static MQTTStatus_t prvHandleResubscribe( void )
/* These variables need to stay in scope until command completes. */
static MQTTAgentSubscribeArgs_t xSubArgs = { 0 };
static MQTTSubscribeInfo_t xSubInfo[ SUBSCRIPTION_MANAGER_MAX_SUBSCRIPTIONS ] = { 0 };
static CommandInfo_t xCommandParams = { 0 };
static MQTTAgentCommandInfo_t xCommandParams = { 0 };
/* Loop through each subscription in the subscription list and add a subscribe
* command to the command queue. */
@ -772,7 +772,7 @@ static BaseType_t prvSocketDisconnect( NetworkContext_t * pxNetworkContext )
static void prvMQTTClientSocketWakeupCallback( Socket_t pxSocket )
{
CommandInfo_t xCommandParams = { 0 };
MQTTAgentCommandInfo_t xCommandParams = { 0 };
/* Just to avoid compiler warnings. The socket is not used but the function
* prototype cannot be changed because this is a callback function. */

View file

@ -59,7 +59,7 @@
#include "core_mqtt.h"
/* MQTT agent include. */
#include "mqtt_agent.h"
#include "core_mqtt_agent.h"
/* Subscription manager header include. */
#include "subscription_manager.h"
@ -100,7 +100,7 @@
* @brief Defines the structure to use as the command callback context in this
* demo.
*/
struct CommandContext
struct MQTTAgentCommandContext
{
MQTTStatus_t xReturnStatus;
TaskHandle_t xTaskToNotify;
@ -141,7 +141,7 @@ static void prvSubscribeCommandCallback( void * pxCommandContext,
* @param[in] pxCommandContext Context of the initial command.
* @param[in].xReturnStatus The result of the command.
*/
static void prvPublishCommandCallback( CommandContext_t * pxCommandContext,
static void prvPublishCommandCallback( MQTTAgentCommandContext_t * pxCommandContext,
MQTTAgentReturnInfo_t * pxReturnInfo );
/**
@ -236,7 +236,7 @@ void vStartSimpleSubscribePublishTask( uint32_t ulNumberToCreate,
/*-----------------------------------------------------------*/
static void prvPublishCommandCallback( CommandContext_t * pxCommandContext,
static void prvPublishCommandCallback( MQTTAgentCommandContext_t * pxCommandContext,
MQTTAgentReturnInfo_t * pxReturnInfo )
{
/* Store the result in the application defined context so the task that
@ -260,7 +260,7 @@ static void prvSubscribeCommandCallback( void * pxCommandContext,
MQTTAgentReturnInfo_t * pxReturnInfo )
{
bool xSubscriptionAdded = false;
CommandContext_t * pxApplicationDefinedContext = ( CommandContext_t * ) pxCommandContext;
MQTTAgentCommandContext_t * pxApplicationDefinedContext = ( MQTTAgentCommandContext_t * ) pxCommandContext;
MQTTAgentSubscribeArgs_t * pxSubscribeArgs = ( MQTTAgentSubscribeArgs_t * ) pxApplicationDefinedContext->pArgs;
/* Store the result in the application defined context so the task that
@ -345,8 +345,8 @@ static bool prvSubscribeToTopic( MQTTQoS_t xQoS,
MQTTAgentSubscribeArgs_t xSubscribeArgs;
MQTTSubscribeInfo_t xSubscribeInfo;
static int32_t ulNextSubscribeMessageID = 0;
CommandContext_t xApplicationDefinedContext = { 0 };
CommandInfo_t xCommandParams = { 0 };
MQTTAgentCommandContext_t xApplicationDefinedContext = { 0 };
MQTTAgentCommandInfo_t xCommandParams = { 0 };
/* Create a unique number of the subscribe that is about to be sent. The number
* is used as the command context and is sent back to this task as a notification
@ -426,13 +426,13 @@ static void prvSimpleSubscribePublishTask( void * pvParameters )
MQTTPublishInfo_t xPublishInfo = { 0 };
char payloadBuf[ mqttexampleSTRING_BUFFER_LENGTH ];
char taskName[ mqttexampleSTRING_BUFFER_LENGTH ];
CommandContext_t xCommandContext;
MQTTAgentCommandContext_t xCommandContext;
uint32_t ulNotification = 0U, ulValueToNotify = 0UL;
MQTTStatus_t xCommandAdded;
uint32_t ulTaskNumber = ( uint32_t ) pvParameters;
MQTTQoS_t xQoS;
TickType_t xTicksToDelay;
CommandInfo_t xCommandParams = { 0 };
MQTTAgentCommandInfo_t xCommandParams = { 0 };
char * pcTopicBuffer = topicBuf[ ulTaskNumber ];
/* Have different tasks use different QoS. 0 and 1. 2 can also be used

View file

@ -157,8 +157,8 @@
<ClCompile Include="..\..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\FreeRTOS_UDP_IP.c" />
<ClCompile Include="..\..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\portable\BufferManagement\BufferAllocation_2.c" />
<ClCompile Include="..\..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\portable\NetworkInterface\WinPCap\NetworkInterface.c" />
<ClCompile Include="..\..\..\Source\Application-Protocols\coreMQTT-Agent\source\mqtt_agent.c" />
<ClCompile Include="..\..\..\Source\Application-Protocols\coreMQTT-Agent\source\mqtt_agent_command_functions.c" />
<ClCompile Include="..\..\..\Source\Application-Protocols\coreMQTT-Agent\source\core_mqtt_agent.c" />
<ClCompile Include="..\..\..\Source\Application-Protocols\coreMQTT-Agent\source\core_mqtt_agent_command_functions.c" />
<ClCompile Include="..\..\..\Source\Utilities\mbedtls_freertos\mbedtls_freertos_port.c" />
<ClCompile Include="..\..\..\Source\Utilities\mbedtls_freertos\mbedtls_error.c" />
<ClCompile Include="..\..\..\Source\Utilities\backoff_algorithm\source\backoff_algorithm.c" />
@ -520,8 +520,8 @@
<ClInclude Include="..\..\..\..\FreeRTOS-Plus\Source\Utilities\logging\logging_levels.h" />
<ClInclude Include="..\..\..\..\FreeRTOS-Plus\Source\Utilities\logging\logging_stack.h" />
<ClInclude Include="..\..\..\Source\Application-Protocols\coreMQTT-Agent\source\include\agent_message.h" />
<ClInclude Include="..\..\..\Source\Application-Protocols\coreMQTT-Agent\source\include\mqtt_agent.h" />
<ClInclude Include="..\..\..\Source\Application-Protocols\coreMQTT-Agent\source\include\mqtt_agent_command_functions.h" />
<ClInclude Include="..\..\..\Source\Application-Protocols\coreMQTT-Agent\source\include\core_mqtt_agent.h" />
<ClInclude Include="..\..\..\Source\Application-Protocols\coreMQTT-Agent\source\include\core_mqtt_agent_command_functions.h" />
<ClInclude Include="..\..\..\Source\Application-Protocols\coreMQTT\source\include\core_mqtt_config_defaults.h" />
<ClInclude Include="..\..\..\Source\FreeRTOS-Plus-TCP\include\FreeRTOS_errno_TCP.h" />
<ClInclude Include="..\..\..\Source\Utilities\mbedtls_freertos\mbedtls_error.h" />
@ -625,4 +625,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>

View file

@ -423,10 +423,10 @@
<ClCompile Include="DemoTasks\simple_sub_pub_demo.c">
<Filter>DemoTasks</Filter>
</ClCompile>
<ClCompile Include="..\..\..\Source\Application-Protocols\coreMQTT-Agent\source\mqtt_agent.c">
<ClCompile Include="..\..\..\Source\Application-Protocols\coreMQTT-Agent\source\core_mqtt_agent.c">
<Filter>FreeRTOS+\FreeRTOS IoT Libraries\standard\coreMQTT-Agent</Filter>
</ClCompile>
<ClCompile Include="..\..\..\Source\Application-Protocols\coreMQTT-Agent\source\mqtt_agent_command_functions.c">
<ClCompile Include="..\..\..\Source\Application-Protocols\coreMQTT-Agent\source\core_mqtt_agent_command_functions.c">
<Filter>FreeRTOS+\FreeRTOS IoT Libraries\standard\coreMQTT-Agent</Filter>
</ClCompile>
<ClCompile Include="..\..\Common\coreMQTT_Agent_Interface\freertos_agent_message.c">
@ -809,10 +809,10 @@
<ClInclude Include="..\..\..\Source\Application-Protocols\coreMQTT-Agent\source\include\agent_message.h">
<Filter>FreeRTOS+\FreeRTOS IoT Libraries\standard\coreMQTT-Agent\include</Filter>
</ClInclude>
<ClInclude Include="..\..\..\Source\Application-Protocols\coreMQTT-Agent\source\include\mqtt_agent.h">
<ClInclude Include="..\..\..\Source\Application-Protocols\coreMQTT-Agent\source\include\core_mqtt_agent.h">
<Filter>FreeRTOS+\FreeRTOS IoT Libraries\standard\coreMQTT-Agent\include</Filter>
</ClInclude>
<ClInclude Include="..\..\..\Source\Application-Protocols\coreMQTT-Agent\source\include\mqtt_agent_command_functions.h">
<ClInclude Include="..\..\..\Source\Application-Protocols\coreMQTT-Agent\source\include\core_mqtt_agent_command_functions.h">
<Filter>FreeRTOS+\FreeRTOS IoT Libraries\standard\coreMQTT-Agent\include</Filter>
</ClInclude>
<ClInclude Include="..\..\Common\coreMQTT_Agent_Interface\include\freertos_agent_message.h">
@ -825,4 +825,4 @@
<Filter>subscription-manager</Filter>
</ClInclude>
</ItemGroup>
</Project>
</Project>

@ -1 +1 @@
Subproject commit 134b478a4862aa084575e3c37ab9fc86c04d3509
Subproject commit c688e34c8fc7c7b514ea0083ff93016b08962638