Skip to content

Commit 6760498

Browse files
Change void to MQTTAgentCommandContext_t (#50)
* Change void * to context pointer in completion callback
1 parent d04f450 commit 6760498

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

Diff for: source/include/core_mqtt_agent.h

+9-9
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ typedef struct MQTTAgentCommandContext MQTTAgentCommandContext_t;
124124
* application wants to enqueue command(s) with non-zero blocking time, the
125125
* callback can notify a different task to enqueue command(s) to the MQTT agent.
126126
*/
127-
typedef void (* MQTTAgentCommandCallback_t )( void * pCmdCallbackContext,
127+
typedef void (* MQTTAgentCommandCallback_t )( MQTTAgentCommandContext_t * pCmdCallbackContext,
128128
MQTTAgentReturnInfo_t * pReturnInfo );
129129

130130
/**
@@ -473,7 +473,7 @@ MQTTStatus_t MQTTAgent_CancelAll( MQTTAgentContext_t * pMqttAgentContext );
473473
* MQTTAgentSubscribeArgs_t subscribeArgs = { 0 };
474474
*
475475
* // Function for command complete callback.
476-
* void subscribeCmdCompleteCb( void * pCmdCallbackContext,
476+
* void subscribeCmdCompleteCb( MQTTAgentCommandContext_t * pCmdCallbackContext,
477477
* MQTTAgentReturnInfo_t * pReturnInfo );
478478
*
479479
* // Fill the command information.
@@ -534,7 +534,7 @@ MQTTStatus_t MQTTAgent_Subscribe( const MQTTAgentContext_t * pMqttAgentContext,
534534
* MQTTAgentSubscribeArgs_t unsubscribeArgs = { 0 };
535535
*
536536
* // Function for command complete callback.
537-
* void unsubscribeCmdCompleteCb( void * pCmdCallbackContext,
537+
* void unsubscribeCmdCompleteCb( MQTTAgentCommandContext_t * pCmdCallbackContext,
538538
* MQTTAgentReturnInfo_t * pReturnInfo );
539539
*
540540
* // Fill the command information.
@@ -593,7 +593,7 @@ MQTTStatus_t MQTTAgent_Unsubscribe( const MQTTAgentContext_t * pMqttAgentContext
593593
* MQTTPublishInfo_t publishInfo = { 0 };
594594
*
595595
* // Function for command complete callback.
596-
* void publishCmdCompleteCb( void * pCmdCallbackContext,
596+
* void publishCmdCompleteCb( MQTTAgentCommandContext_t * pCmdCallbackContext,
597597
* MQTTAgentReturnInfo_t * pReturnInfo );
598598
*
599599
* // Fill the command information.
@@ -650,7 +650,7 @@ MQTTStatus_t MQTTAgent_Publish( const MQTTAgentContext_t * pMqttAgentContext,
650650
* MQTTAgentCommandInfo_t commandInfo = { 0 };
651651
*
652652
* // Function for command complete callback.
653-
* void cmdCompleteCb( void * pCmdCallbackContext,
653+
* void cmdCompleteCb( MQTTAgentCommandContext_t * pCmdCallbackContext,
654654
* MQTTAgentReturnInfo_t * pReturnInfo );
655655
*
656656
* // Fill the command information.
@@ -707,7 +707,7 @@ MQTTStatus_t MQTTAgent_ProcessLoop( const MQTTAgentContext_t * pMqttAgentContext
707707
* MQTTAgentCommandInfo_t commandInfo = { 0 };
708708
*
709709
* // Function for command complete callback.
710-
* void pingRequestCompleteCb( void * pCmdCallbackContext,
710+
* void pingRequestCompleteCb( MQTTAgentCommandContext_t * pCmdCallbackContext,
711711
* MQTTAgentReturnInfo_t * pReturnInfo );
712712
*
713713
* // Fill the command information.
@@ -801,7 +801,7 @@ MQTTStatus_t MQTTAgent_Ping( const MQTTAgentContext_t * pMqttAgentContext,
801801
* connectArgs.timeoutMs = 500;
802802
*
803803
* // Function for command complete callback.
804-
* void connectCmdCallback( void * pCmdCallbackContext,
804+
* void connectCmdCallback( MQTTAgentCommandContext_t * pCmdCallbackContext,
805805
* MQTTAgentReturnInfo_t * pReturnInfo );
806806
*
807807
* // Fill the command information.
@@ -863,7 +863,7 @@ MQTTStatus_t MQTTAgent_Connect( const MQTTAgentContext_t * pMqttAgentContext,
863863
* MQTTAgentCommandInfo_t commandInfo = { 0 };
864864
*
865865
* // Function for command complete callback.
866-
* void disconnectCmdCallback( void * pCmdCallbackContext,
866+
* void disconnectCmdCallback( MQTTAgentCommandContext_t * pCmdCallbackContext,
867867
* MQTTAgentReturnInfo_t * pReturnInfo );
868868
*
869869
* // Fill the command information.
@@ -927,7 +927,7 @@ MQTTStatus_t MQTTAgent_Disconnect( const MQTTAgentContext_t * pMqttAgentContext,
927927
* MQTTAgentCommandInfo_t commandInfo = { 0 };
928928
*
929929
* // Function for command complete callback.
930-
* void terminateCallback( void * pCmdCallbackContext,
930+
* void terminateCallback( MQTTAgentCommandContext_t * pCmdCallbackContext,
931931
* MQTTAgentReturnInfo_t * pReturnInfo );
932932
*
933933
* // Fill the command information.

Diff for: test/unit-test/mqtt_agent_utest.c

+3-7
Original file line numberDiff line numberDiff line change
@@ -230,16 +230,12 @@ static void stubPublishCallback( MQTTAgentContext_t * pMqttAgentContext,
230230
publishCallbackCount++;
231231
}
232232

233-
static void stubCompletionCallback( void * pCommandCompletionContext,
233+
static void stubCompletionCallback( MQTTAgentCommandContext_t * pCommandCompletionContext,
234234
MQTTAgentReturnInfo_t * pReturnInfo )
235235
{
236-
MQTTAgentCommandContext_t * pCastContext;
237-
238-
pCastContext = ( MQTTAgentCommandContext_t * ) pCommandCompletionContext;
239-
240-
if( pCastContext != NULL )
236+
if( pCommandCompletionContext != NULL )
241237
{
242-
pCastContext->returnStatus = pReturnInfo->returnCode;
238+
pCommandCompletionContext->returnStatus = pReturnInfo->returnCode;
243239
}
244240

245241
commandCompleteCallbackCount++;

0 commit comments

Comments
 (0)