nfc_tlv_block.c
tlv_status_t t2t_parse_next_tlv(uint8_t *buf, tlv_t *tlv, size_t *br)
{
    if((buf == NULL) || (tlv == NULL) || (br == NULL))
        return TLV_E_INVALID_ARGS;

    uint8_t *buf_start = buf;

    if((*buf == TLV_NULL) || (*buf == TLV_TERMINATOR))
    {
        tlv->type   = *buf++;
        tlv->length = 0;
        tlv->value  = 0;            
    }
    else if((*buf == TLV_LOCK_CONTROL) || (*buf == TLV_MEMORY_CONTROL))
    {
        /* Length field should equal 3 for LOCK CONTROL and MEMORY CONTROL blocks. */
        if(buf[1] != TLV_LOCK_MEMORY_CTRL_LEN)
            return TLV_E_NOT_FOUND;

        tlv->type   = *buf++;
        tlv->length = *buf++;
        tlv->value  = buf;
    }
    else if((*buf == TLV_NDEF_MESSAGE) || (*buf == TLV_PROPRIETARY))
    {
        tlv->type = *buf++;

        if (*buf == 0xFF)
        {
            /* Long record? */
            tlv->length = ((*(buf + 1) << 8) & 0xFF00) | *(buf + 2);
            buf += 3;
        }
        else
        {
            /* Short record */
            tlv->length = *buf++;
        }

        tlv->value = buf;
    }
    else
    {
        *br = 1;
        return TLV_E_NOT_FOUND;
    }
    
    buf += tlv->length;
    *br = buf_start - buf;
    
    return TLV_OK;
}
/*
 * @brief This API parses the next TLV block found in the byte-buffer.
 */
@brief This API parses the next TLV block found in the byte-buffer.
@brief This API parses the next TLV block found in the byte - buffer .
tlv_status_t t2t_parse_next_tlv(uint8_t *buf, tlv_t *tlv, size_t *br)
{
    if((buf == NULL) || (tlv == NULL) || (br == NULL))
        return TLV_E_INVALID_ARGS;
    uint8_t *buf_start = buf;
    if((*buf == TLV_NULL) || (*buf == TLV_TERMINATOR))
    {
        tlv->type   = *buf++;
        tlv->length = 0;
        tlv->value  = 0;            
    }
    else if((*buf == TLV_LOCK_CONTROL) || (*buf == TLV_MEMORY_CONTROL))
    {
        if(buf[1] != TLV_LOCK_MEMORY_CTRL_LEN)
            return TLV_E_NOT_FOUND;
        tlv->type   = *buf++;
        tlv->length = *buf++;
        tlv->value  = buf;
    }
    else if((*buf == TLV_NDEF_MESSAGE) || (*buf == TLV_PROPRIETARY))
    {
        tlv->type = *buf++;
        if (*buf == 0xFF)
        {
            tlv->length = ((*(buf + 1) << 8) & 0xFF00) | *(buf + 2);
            buf += 3;
        }
        else
        {
            tlv->length = *buf++;
        }
        tlv->value = buf;
    }
    else
    {
        *br = 1;
        return TLV_E_NOT_FOUND;
    }
    buf += tlv->length;
    *br = buf_start - buf;
    return TLV_OK;
}
tlv_status_t t2t_parse_next_tlv ( uint8_t * buf , tlv_t * tlv , size_t * br ) { if ( ( buf == NULL ) || ( tlv == NULL ) || ( br == NULL ) ) return TLV_E_INVALID_ARGS ; uint8_t * buf_start = buf ; if ( ( * buf == TLV_NULL ) || ( * buf == TLV_TERMINATOR ) ) { tlv -> type = * buf ++ ; tlv -> length = 0 ; tlv -> value = 0 ; } else if ( ( * buf == TLV_LOCK_CONTROL ) || ( * buf == TLV_MEMORY_CONTROL ) ) { if ( buf [ 1 ] != TLV_LOCK_MEMORY_CTRL_LEN ) return TLV_E_NOT_FOUND ; tlv -> type = * buf ++ ; tlv -> length = * buf ++ ; tlv -> value = buf ; } else if ( ( * buf == TLV_NDEF_MESSAGE ) || ( * buf == TLV_PROPRIETARY ) ) { tlv -> type = * buf ++ ; if ( * buf == 0xFF ) { tlv -> length = ( ( * ( buf + 1 ) << 8 ) & 0xFF00 ) | * ( buf + 2 ) ; buf += 3 ; } else { tlv -> length = * buf ++ ; } tlv -> value = buf ; } else { * br = 1 ; return TLV_E_NOT_FOUND ; } buf += tlv -> length ; * br = buf_start - buf ; return TLV_OK ; }
@brief This API parses the next TLV block found in the byte-buffer.
@brief This API parses the next TLV block found in the byte - buffer .
/* Length field should equal 3 for LOCK CONTROL and MEMORY CONTROL blocks. */ /* Long record? */ /* Short record */