static bool isFreeRTOSOtaJob()

in source/otaJobParser/ota_job_handler.c [20:59]


static bool isFreeRTOSOtaJob( const char * jobDoc,
                              const size_t jobDocLength );
static bool isJobFileIndexValid( const char * jobDoc,
                                 const size_t jobDocLength,
                                 const uint8_t fileIndex );

/**
 * @brief Signals if the job document provided is a FreeRTOS OTA update document
 *
 * @param jobDoc The job document contained in the AWS IoT Job
 * @param jobDocLength The length of the job document
 * @param fields A pointer to an job document fields structure populated by call
 * @return int8_t The next file index in the job. Returns 0 if no additional files are available. Returns -1 if error.
 */
int8_t otaParser_parseJobDocFile( const char * jobDoc,
                                  const size_t jobDocLength,
                                  const uint8_t fileIndex,
                                  AfrOtaJobDocumentFields_t * fields )
{
    bool fieldsPopulated = false;
    int8_t nextFileIndex = -1;

    if( ( jobDoc != NULL ) && ( jobDocLength > 0U ) )
    {
        if( isFreeRTOSOtaJob( jobDoc, jobDocLength ) && isJobFileIndexValid( jobDoc, jobDocLength, fileIndex ) )
        {
            fieldsPopulated = populateJobDocFields( jobDoc,
                                                    jobDocLength,
                                                    ( int32_t ) fileIndex,
                                                    fields );
        }

        if( fieldsPopulated )
        {
            nextFileIndex = ( isJobFileIndexValid( jobDoc, jobDocLength, fileIndex + 1U ) ) ? ( int8_t ) ( ( int8_t ) fileIndex + 1 ) : ( int8_t ) 0;
        }
    }

    return nextFileIndex;
}