Refactor prvGetFileContextFromJob
@@ -2154,6 +2154,8 @@ static OTA_FileContext_t * prvParseJobDoc( const char * pcJSON,
static OTA_FileContext_t * prvGetFileContextFromJob( const char * pcRawMsg,
uint32_t ulMsgLen )
{
+ DEFINE_OTA_METHOD_NAME( "prvGetFileContextFromJob" );
+
uint32_t ulIndex;
uint32_t ulNumBlocks; /* How many data pages are in the expected update image. */
uint32_t ulBitmapLen; /* Length of the file block bitmap in bytes. */
@@ -2162,15 +2164,16 @@ static OTA_FileContext_t * prvGetFileContextFromJob( const char * pcRawMsg,
bool_t bUpdateJob = false;
- DEFINE_OTA_METHOD_NAME( "prvGetFileContextFromJob" );
-
/* Populate an OTA file context from the OTA job document. */
pstUpdateFile = prvParseJobDoc( pcRawMsg, ulMsgLen, &bUpdateJob );
- if( !bUpdateJob )
+ if( bUpdateJob )
{
- if( ( pstUpdateFile != NULL ) && ( prvInSelftest() == false ) )
+ OTA_LOG_L1( "[%s] We receive a job update.\r\n", OTA_METHOD_NAME );
+ }
+
+ if( !bUpdateJob && ( pstUpdateFile != NULL ) && ( prvInSelftest() == false ) )
{
if( pstUpdateFile->pucRxBlockBitmap != NULL )
{
@@ -2213,7 +2216,7 @@ static OTA_FileContext_t * prvGetFileContextFromJob( const char * pcRawMsg,
if( xErr != kOTA_Err_None )
{
- ( void ) prvSetImageStateWithReason( eOTA_ImageState_Aborted, xErr );
+ ( void ) prvSetImageStateWithReason( eOTA_ImageState_Aborted, ( int32_t ) xErr );
( void ) prvOTA_Close( pstUpdateFile ); /* Ignore false result since we're setting the pointer to null on the next line. */
pstUpdateFile = NULL;
}
@@ -2225,11 +2228,6 @@ static OTA_FileContext_t * prvGetFileContextFromJob( const char * pcRawMsg,
pstUpdateFile = NULL;
}
}
- }
- else
- {
- OTA_LOG_L1( "[%s] We receive a job update.\r\n", OTA_METHOD_NAME );
- }
return pstUpdateFile; /* Return the OTA file context. */
}
