AzureIoTResult_t AzureIoTJSONWriter_AppendPropertyWithInt32Value()

in source/azure_iot_json_writer.c [48:79]


AzureIoTResult_t AzureIoTJSONWriter_AppendPropertyWithInt32Value( AzureIoTJSONWriter_t * pxWriter,
                                                                  const uint8_t * pucPropertyName,
                                                                  uint32_t ulPropertyNameLength,
                                                                  int32_t lValue )
{
    AzureIoTResult_t xResult;
    az_result xCoreResult;
    az_span xPropertyNameSpan;

    if( ( pxWriter == NULL ) || ( pucPropertyName == NULL ) || ( ulPropertyNameLength == 0 ) )
    {
        AZLogError( ( "AzureIoTJSONWriter_AppendPropertyWithInt32Value failed: invalid argument" ) );
        xResult = eAzureIoTErrorInvalidArgument;
    }
    else
    {
        xPropertyNameSpan = az_span_create( ( uint8_t * ) pucPropertyName, ( int32_t ) ulPropertyNameLength );

        if( az_result_failed( xCoreResult = az_json_writer_append_property_name( &pxWriter->_internal.xCoreWriter, xPropertyNameSpan ) ) ||
            az_result_failed( xCoreResult = az_json_writer_append_int32( &pxWriter->_internal.xCoreWriter, lValue ) ) )
        {
            AZLogError( ( "Could not append property and int32: core error=0x%08x", ( uint16_t ) xCoreResult ) );
            xResult = AzureIoT_TranslateCoreError( xCoreResult );
        }
        else
        {
            xResult = eAzureIoTSuccess;
        }
    }

    return xResult;
}