in source/azure_iot_hub_client.c [252:299]
static uint32_t prvAzureIoTHubClientCommandProcess( AzureIoTHubClientReceiveContext_t * pxContext,
AzureIoTHubClient_t * pxAzureIoTHubClient,
void * pvPublishInfo )
{
AzureIoTResult_t xResult;
AzureIoTHubClientCommandRequest_t xCommandRequest = { 0 };
AzureIoTMQTTPublishInfo_t * xMQTTPublishInfo = ( AzureIoTMQTTPublishInfo_t * ) pvPublishInfo;
az_result xCoreResult;
az_iot_hub_client_command_request xOutEmbeddedRequest;
az_span xTopicSpan = az_span_create( ( uint8_t * ) xMQTTPublishInfo->pcTopicName, xMQTTPublishInfo->usTopicNameLength );
/* Failed means no topic match. This means the message is not for command. */
xCoreResult = az_iot_hub_client_commands_parse_received_topic( &pxAzureIoTHubClient->_internal.xAzureIoTHubClientCore,
xTopicSpan, &xOutEmbeddedRequest );
if( az_result_failed( xCoreResult ) )
{
xResult = AzureIoT_TranslateCoreError( xCoreResult );
}
else
{
AZLogDebug( ( "Command topic: %.*s with command payload : %.*s",
xMQTTPublishInfo->usTopicNameLength,
xMQTTPublishInfo->pcTopicName,
xMQTTPublishInfo->xPayloadLength,
( const char * ) xMQTTPublishInfo->pvPayload ) );
if( pxContext->_internal.callbacks.xCommandCallback )
{
xCommandRequest.pvMessagePayload = xMQTTPublishInfo->pvPayload;
xCommandRequest.ulPayloadLength = ( uint32_t ) xMQTTPublishInfo->xPayloadLength;
xCommandRequest.pucCommandName = az_span_ptr( xOutEmbeddedRequest.command_name );
xCommandRequest.usCommandNameLength = ( uint16_t ) az_span_size( xOutEmbeddedRequest.command_name );
xCommandRequest.pucComponentName = az_span_ptr( xOutEmbeddedRequest.component_name );
xCommandRequest.usComponentNameLength = ( uint16_t ) az_span_size( xOutEmbeddedRequest.component_name );
xCommandRequest.pucRequestID = az_span_ptr( xOutEmbeddedRequest.request_id );
xCommandRequest.usRequestIDLength = ( uint16_t ) az_span_size( xOutEmbeddedRequest.request_id );
AZLogDebug( ( "Invoking command callback" ) );
pxContext->_internal.callbacks.xCommandCallback( &xCommandRequest, pxContext->_internal.pvCallbackContext );
AZLogDebug( ( "Returned from command callback" ) );
}
xResult = eAzureIoTSuccess;
}
return ( uint32_t ) xResult;
}