mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-12-10 13:45:07 -05:00
Rename MQTT Agent structs and files (#576)
This commit is contained in:
parent
1fe418dc9f
commit
43bd42db27
9 changed files with 62 additions and 62 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue