Skip to content

Commit

Permalink
Change void to MQTTAgentCommandContext_t (#50)
Browse files Browse the repository at this point in the history
* Change void * to context pointer in completion callback
  • Loading branch information
muneebahmed10 authored Apr 28, 2021
1 parent d04f450 commit 6760498
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
18 changes: 9 additions & 9 deletions source/include/core_mqtt_agent.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ typedef struct MQTTAgentCommandContext MQTTAgentCommandContext_t;
* application wants to enqueue command(s) with non-zero blocking time, the
* callback can notify a different task to enqueue command(s) to the MQTT agent.
*/
typedef void (* MQTTAgentCommandCallback_t )( void * pCmdCallbackContext,
typedef void (* MQTTAgentCommandCallback_t )( MQTTAgentCommandContext_t * pCmdCallbackContext,
MQTTAgentReturnInfo_t * pReturnInfo );

/**
Expand Down Expand Up @@ -473,7 +473,7 @@ MQTTStatus_t MQTTAgent_CancelAll( MQTTAgentContext_t * pMqttAgentContext );
* MQTTAgentSubscribeArgs_t subscribeArgs = { 0 };
*
* // Function for command complete callback.
* void subscribeCmdCompleteCb( void * pCmdCallbackContext,
* void subscribeCmdCompleteCb( MQTTAgentCommandContext_t * pCmdCallbackContext,
* MQTTAgentReturnInfo_t * pReturnInfo );
*
* // Fill the command information.
Expand Down Expand Up @@ -534,7 +534,7 @@ MQTTStatus_t MQTTAgent_Subscribe( const MQTTAgentContext_t * pMqttAgentContext,
* MQTTAgentSubscribeArgs_t unsubscribeArgs = { 0 };
*
* // Function for command complete callback.
* void unsubscribeCmdCompleteCb( void * pCmdCallbackContext,
* void unsubscribeCmdCompleteCb( MQTTAgentCommandContext_t * pCmdCallbackContext,
* MQTTAgentReturnInfo_t * pReturnInfo );
*
* // Fill the command information.
Expand Down Expand Up @@ -593,7 +593,7 @@ MQTTStatus_t MQTTAgent_Unsubscribe( const MQTTAgentContext_t * pMqttAgentContext
* MQTTPublishInfo_t publishInfo = { 0 };
*
* // Function for command complete callback.
* void publishCmdCompleteCb( void * pCmdCallbackContext,
* void publishCmdCompleteCb( MQTTAgentCommandContext_t * pCmdCallbackContext,
* MQTTAgentReturnInfo_t * pReturnInfo );
*
* // Fill the command information.
Expand Down Expand Up @@ -650,7 +650,7 @@ MQTTStatus_t MQTTAgent_Publish( const MQTTAgentContext_t * pMqttAgentContext,
* MQTTAgentCommandInfo_t commandInfo = { 0 };
*
* // Function for command complete callback.
* void cmdCompleteCb( void * pCmdCallbackContext,
* void cmdCompleteCb( MQTTAgentCommandContext_t * pCmdCallbackContext,
* MQTTAgentReturnInfo_t * pReturnInfo );
*
* // Fill the command information.
Expand Down Expand Up @@ -707,7 +707,7 @@ MQTTStatus_t MQTTAgent_ProcessLoop( const MQTTAgentContext_t * pMqttAgentContext
* MQTTAgentCommandInfo_t commandInfo = { 0 };
*
* // Function for command complete callback.
* void pingRequestCompleteCb( void * pCmdCallbackContext,
* void pingRequestCompleteCb( MQTTAgentCommandContext_t * pCmdCallbackContext,
* MQTTAgentReturnInfo_t * pReturnInfo );
*
* // Fill the command information.
Expand Down Expand Up @@ -801,7 +801,7 @@ MQTTStatus_t MQTTAgent_Ping( const MQTTAgentContext_t * pMqttAgentContext,
* connectArgs.timeoutMs = 500;
*
* // Function for command complete callback.
* void connectCmdCallback( void * pCmdCallbackContext,
* void connectCmdCallback( MQTTAgentCommandContext_t * pCmdCallbackContext,
* MQTTAgentReturnInfo_t * pReturnInfo );
*
* // Fill the command information.
Expand Down Expand Up @@ -863,7 +863,7 @@ MQTTStatus_t MQTTAgent_Connect( const MQTTAgentContext_t * pMqttAgentContext,
* MQTTAgentCommandInfo_t commandInfo = { 0 };
*
* // Function for command complete callback.
* void disconnectCmdCallback( void * pCmdCallbackContext,
* void disconnectCmdCallback( MQTTAgentCommandContext_t * pCmdCallbackContext,
* MQTTAgentReturnInfo_t * pReturnInfo );
*
* // Fill the command information.
Expand Down Expand Up @@ -927,7 +927,7 @@ MQTTStatus_t MQTTAgent_Disconnect( const MQTTAgentContext_t * pMqttAgentContext,
* MQTTAgentCommandInfo_t commandInfo = { 0 };
*
* // Function for command complete callback.
* void terminateCallback( void * pCmdCallbackContext,
* void terminateCallback( MQTTAgentCommandContext_t * pCmdCallbackContext,
* MQTTAgentReturnInfo_t * pReturnInfo );
*
* // Fill the command information.
Expand Down
10 changes: 3 additions & 7 deletions test/unit-test/mqtt_agent_utest.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,16 +230,12 @@ static void stubPublishCallback( MQTTAgentContext_t * pMqttAgentContext,
publishCallbackCount++;
}

static void stubCompletionCallback( void * pCommandCompletionContext,
static void stubCompletionCallback( MQTTAgentCommandContext_t * pCommandCompletionContext,
MQTTAgentReturnInfo_t * pReturnInfo )
{
MQTTAgentCommandContext_t * pCastContext;

pCastContext = ( MQTTAgentCommandContext_t * ) pCommandCompletionContext;

if( pCastContext != NULL )
if( pCommandCompletionContext != NULL )
{
pCastContext->returnStatus = pReturnInfo->returnCode;
pCommandCompletionContext->returnStatus = pReturnInfo->returnCode;
}

commandCompleteCallbackCount++;
Expand Down

0 comments on commit 6760498

Please sign in to comment.