OtaErr_t decodeFileBlock_Http()

in source/ota_http.c [122:157]


OtaErr_t decodeFileBlock_Http( const uint8_t * pMessageBuffer,
                               size_t messageSize,
                               int32_t * pFileId,
                               int32_t * pBlockId,
                               int32_t * pBlockSize,
                               uint8_t ** pPayload,
                               size_t * pPayloadSize )
{
    OtaErr_t err = OtaErrNone;

    assert( pMessageBuffer != NULL && pFileId != NULL && pBlockId != NULL &&
            pBlockSize != NULL && pPayload != NULL && pPayloadSize != NULL );

    if( messageSize > OTA_FILE_BLOCK_SIZE )
    {
        LogError( ( "Incoming file block size %d larger than block size %d.",
                    ( int ) messageSize, ( int ) OTA_FILE_BLOCK_SIZE ) );
        err = OtaErrInvalidArg;
    }
    else
    {
        *pFileId = 0;
        *pBlockId = ( int32_t ) currBlock;
        *pBlockSize = ( int32_t ) messageSize;

        /* The data received over HTTP does not require any decoding. */
        ( void ) memcpy( *pPayload, pMessageBuffer, messageSize );

        *pPayloadSize = messageSize;

        /* Current block is processed, set the file block to next. */
        currBlock++;
    }

    return err;
}