in source/ota.c [2634:2699]
static IngestResult_t ingestDataBlockCleanup( OtaFileContext_t * pFileContext,
OtaPalStatus_t * pCloseResult )
{
IngestResult_t eIngestResult = IngestResultAccepted_Continue;
OtaPalMainStatus_t otaPalMainErr;
OtaPalSubStatus_t otaPalSubErr = 0;
( void ) otaPalSubErr; /* For suppressing compiler-warning: unused variable. */
if( pFileContext->blocksRemaining == 0U )
{
LogInfo( ( "Received final block of the update." ) );
/* Stop the request timer. */
( void ) otaAgent.pOtaInterface->os.timer.stop( OtaRequestTimer );
/* Free the bitmap now that we're done with the download. */
if( ( pFileContext->pRxBlockBitmap != NULL ) && ( pFileContext->blockBitmapMaxSize == 0u ) )
{
/* Free any previously allocated bitmap. */
otaAgent.pOtaInterface->os.mem.free( pFileContext->pRxBlockBitmap );
pFileContext->pRxBlockBitmap = NULL;
}
if( pFileContext->pFile != NULL )
{
*pCloseResult = otaAgent.pOtaInterface->pal.closeFile( pFileContext );
otaPalMainErr = OTA_PAL_MAIN_ERR( *pCloseResult );
otaPalSubErr = OTA_PAL_SUB_ERR( *pCloseResult );
if( otaPalMainErr == OtaPalSuccess )
{
LogInfo( ( "Received entire update and validated the signature." ) );
eIngestResult = IngestResultFileComplete;
}
else
{
LogError( ( "Failed to close the OTA file: Error=(%s:0x%06x)",
OTA_PalStatus_strerror( otaPalMainErr ), otaPalSubErr ) );
if( otaPalMainErr == OtaPalSignatureCheckFailed )
{
eIngestResult = IngestResultSigCheckFail;
}
else
{
eIngestResult = IngestResultFileCloseFail;
}
}
/* File is now closed so clear the file handle in the context. */
pFileContext->pFile = NULL;
}
else
{
LogError( ( "Parameter check failed: pFileContext->pFile is NULL." ) );
eIngestResult = IngestResultBadFileHandle;
}
}
else
{
LogInfo( ( "Number of blocks remaining: %u", pFileContext->blocksRemaining ) );
}
return eIngestResult;
}