AzureIoTResult_t AzureIoTHubClientProperties_BuilderBeginResponseStatus()

in source/azure_iot_hub_client_properties.c [78:122]


AzureIoTResult_t AzureIoTHubClientProperties_BuilderBeginResponseStatus( AzureIoTHubClient_t * pxAzureIoTHubClient,
                                                                         AzureIoTJSONWriter_t * pxJSONWriter,
                                                                         const uint8_t * pucPropertyName,
                                                                         uint16_t usPropertyNameLength,
                                                                         int32_t lAckCode,
                                                                         int32_t lAckVersion,
                                                                         const uint8_t * pucAckDescription,
                                                                         uint16_t usAckDescriptionLength )
{
    AzureIoTResult_t xResult;
    az_result xCoreResult;
    az_span xPropertyName;
    az_span xAckDescription;

    if( ( pxAzureIoTHubClient == NULL ) ||
        ( pxJSONWriter == NULL ) ||
        ( pucPropertyName == NULL ) ||
        ( usPropertyNameLength == 0 ) )
    {
        AZLogError( ( "AzureIoTHubClientProperties_BuilderBeginResponseStatus failed: invalid argument" ) );
        xResult = eAzureIoTErrorInvalidArgument;
    }
    else
    {
        xPropertyName = az_span_create( ( uint8_t * ) pucPropertyName, usPropertyNameLength );
        xAckDescription = az_span_create( ( uint8_t * ) pucAckDescription, usAckDescriptionLength );

        if( az_result_failed(
                xCoreResult = az_iot_hub_client_properties_writer_begin_response_status( &pxAzureIoTHubClient->_internal.xAzureIoTHubClientCore,
                                                                                         &pxJSONWriter->_internal.xCoreWriter,
                                                                                         xPropertyName,
                                                                                         lAckCode, lAckVersion,
                                                                                         xAckDescription ) ) )
        {
            AZLogError( ( "Could not begin response: core error=0x%08x", ( uint16_t ) xCoreResult ) );
            xResult = AzureIoT_TranslateCoreError( xCoreResult );
        }
        else
        {
            xResult = eAzureIoTSuccess;
        }
    }

    return xResult;
}