INT32 nativeNdef_readUrl(UINT8*ndefBuff, UINT32 ndefBuffLen, char * outUrl, UINT32 urlBufferLen)
{
    UINT32 prefixIdx;
    UINT32 prefixLen;
    UINT8 *payload;
    UINT32 payloadLength;
    UINT8 ndef_tnf;
    UINT8 *ndef_type;
    UINT8 ndef_typeLength;
    nfc_friendly_type_t friendly_type;

    ndef_type = NDEF_RecGetType((UINT8*)ndefBuff, &ndef_tnf, &ndef_typeLength);
    friendly_type = nativeNdef_getFriendlyType(ndef_tnf, ndef_type, ndef_typeLength);
    if (friendly_type != NDEF_FRIENDLY_TYPE_URL)
    {
        return -1;
    }
    payload = NDEF_RecGetPayload((UINT8*)ndefBuff, &payloadLength);
    if (payload == NULL)
    {
        return -1;
    }
    prefixIdx = payload[0];
    prefixLen = strlen(URI_PREFIX_MAP[prefixIdx]);
    if (urlBufferLen >= payloadLength + prefixLen)
    {
        memcpy(outUrl, URI_PREFIX_MAP[prefixIdx], prefixLen);
        memcpy(outUrl + prefixLen, payload + 1, payloadLength - 1);
    
        outUrl[prefixLen + payloadLength - 1] = '\0';
    }
    return 0;
}
INT32 nativeNdef_readText( UINT8*ndefBuff, UINT32 ndefBuffLen, char * outText, UINT32 textLen)
{
    int langCodeLen;
    UINT8 *payload;
    UINT32 payloadLength;
    UINT8 ndef_tnf;
    UINT8 *ndef_type;
    UINT8 ndef_typeLength;
    nfc_friendly_type_t friendly_type;

    ndef_type = NDEF_RecGetType((UINT8*)ndefBuff, &ndef_tnf, &ndef_typeLength);
    friendly_type = nativeNdef_getFriendlyType(ndef_tnf, ndef_type, ndef_typeLength);
    if (friendly_type != NDEF_FRIENDLY_TYPE_TEXT)
    {
        return -1;
    }
    payload = NDEF_RecGetPayload((UINT8*)ndefBuff, &payloadLength);
    if (payload == NULL)
    {
        return -1;
    }
    langCodeLen = payload[0];
    memcpy(outText, payload + langCodeLen + 1, payloadLength - langCodeLen - 1);
    outText[payloadLength - langCodeLen - 1] = '\0';
    return 0;
}
/*******************************************************************************
**
** Function         ndef_get_bt_oob_record
**
** Description      This function returns BT OOB record which has matched payload ID
**
** Returns          pointer of record if found, otherwise NULL
**
*******************************************************************************/
static UINT8 *ndef_get_bt_oob_record (UINT8 *p_msg, UINT32 max_size, UINT32 *p_cur_size,
                                      char *p_id_str)
{
    UINT8  *p_rec, *p_type;
    UINT8   id_len, tnf, type_len;

    /* find record by Payload ID */
    id_len = (UINT8)strlen (p_id_str);
    p_rec = NDEF_MsgGetFirstRecById (p_msg, (UINT8*)p_id_str, id_len);

    if (!p_rec)
        return (NULL);

    p_type = NDEF_RecGetType (p_rec, &tnf, &type_len);

    /* check type if this is BT OOB record */
    if ((!p_rec)
      ||(tnf != NDEF_TNF_MEDIA)
      ||(type_len != BT_OOB_REC_TYPE_LEN)
      ||(memcmp (p_type, p_bt_oob_rec_type, BT_OOB_REC_TYPE_LEN)))
    {
        return (NULL);
    }

    return (p_rec);
}