AzureIoTResult_t AzureIoTADUClient_Init()

in source/azure_iot_adu_client.c [37:71]


AzureIoTResult_t AzureIoTADUClient_Init( AzureIoTADUClient_t * pxAzureIoTADUClient,
                                         AzureIoTADUClientOptions_t * pxADUClientOptions )
{
    az_result xCoreResult;
    az_iot_adu_client_options xADUOptions;

    if( pxAzureIoTADUClient == NULL )
    {
        AZLogError( ( "AzureIoTADUClient_Init failed: invalid argument" ) );
        return eAzureIoTErrorInvalidArgument;
    }

    memset( ( void * ) pxAzureIoTADUClient, 0, sizeof( AzureIoTADUClient_t ) );

    xADUOptions = az_iot_adu_client_options_default();

    if( pxADUClientOptions )
    {
        if( ( pxADUClientOptions->pucCompatibilityProperties != NULL ) &&
            ( pxADUClientOptions->ulCompatibilityPropertiesLength > 0 ) )
        {
            xADUOptions.device_compatibility_properties = az_span_create(
                ( uint8_t * ) pxADUClientOptions->pucCompatibilityProperties,
                ( int32_t ) pxADUClientOptions->ulCompatibilityPropertiesLength );
        }
    }

    if( az_result_failed( xCoreResult = az_iot_adu_client_init( &pxAzureIoTADUClient->_internal.xADUClient, &xADUOptions ) ) )
    {
        AZLogError( ( "Failed to initialize az_iot_adu_client_init: core error=0x%08x", ( uint16_t ) xCoreResult ) );
        return AzureIoT_TranslateCoreError( xCoreResult );
    }

    return eAzureIoTSuccess;
}