Пример #1
0
/*******************************************************************************
**
** Function         rw_t4t_read_file
**
** Description      Send ReadBinary Command to peer
**
** Returns          TRUE if success
**
*******************************************************************************/
static BOOLEAN rw_t4t_read_file (UINT16 offset, UINT16 length, BOOLEAN is_continue)
{
    tRW_T4T_CB      *p_t4t = &rw_cb.tcb.t4t;
    BT_HDR          *p_c_apdu;
    UINT8           *p;

    RW_TRACE_DEBUG3 ("rw_t4t_read_file () offset:%d, length:%d, is_continue:%d, ",
                      offset, length, is_continue);

    p_c_apdu = (BT_HDR *) GKI_getpoolbuf (NFC_RW_POOL_ID);

    if (!p_c_apdu)
    {
        RW_TRACE_ERROR0 ("rw_t4t_read_file (): Cannot allocate buffer");
        return FALSE;
    }

    /* if this is the first reading */
    if (is_continue == FALSE)
    {
        /* initialise starting offset and total length */
        /* these will be updated when receiving response */
        p_t4t->rw_offset = offset;
        p_t4t->rw_length = length;
    }

    /* adjust reading length if payload is bigger than max size per single command */
    if (length > p_t4t->max_read_size)
    {
        length = (UINT8) (p_t4t->max_read_size);
    }

    p_c_apdu->offset = NCI_MSG_OFFSET_SIZE + NCI_DATA_HDR_SIZE;
    p = (UINT8 *) (p_c_apdu + 1) + p_c_apdu->offset;

    UINT8_TO_BE_STREAM (p, T4T_CMD_CLASS);
    UINT8_TO_BE_STREAM (p, T4T_CMD_INS_READ_BINARY);
    UINT16_TO_BE_STREAM (p, offset);
    UINT8_TO_BE_STREAM (p, length); /* Le */

    p_c_apdu->len = T4T_CMD_MIN_HDR_SIZE + 1; /* adding Le */

    if (!rw_t4t_send_to_lower (p_c_apdu))
    {
        return FALSE;
    }

    return TRUE;
}
Пример #2
0
/*******************************************************************************
**
** Function         RW_SetActivatedTagType
**
** Description      This function selects the tag type for Reader/Writer mode.
**
** Returns          tNFC_STATUS
**
*******************************************************************************/
tNFC_STATUS RW_SetActivatedTagType (tNFC_ACTIVATE_DEVT *p_activate_params, tRW_CBACK *p_cback)
{
    tNFC_STATUS status = NFC_STATUS_FAILED;

    /* check for null cback here / remove checks from rw_t?t */
    RW_TRACE_DEBUG3 ("RW_SetActivatedTagType protocol:%d, technology:%d, SAK:%d", p_activate_params->protocol, p_activate_params->rf_tech_param.mode, p_activate_params->rf_tech_param.param.pa.sel_rsp);

    if (p_cback == NULL)
    {
        RW_TRACE_ERROR0 ("RW_SetActivatedTagType called with NULL callback");
        return (NFC_STATUS_FAILED);
    }

    /* Reset tag-specific area of control block */
    memset (&rw_cb.tcb, 0, sizeof (tRW_TCB));

#if (defined (RW_STATS_INCLUDED) && (RW_STATS_INCLUDED == TRUE))
    /* Reset RW stats */
    rw_main_reset_stats ();
#endif  /* RW_STATS_INCLUDED */

    rw_cb.p_cback = p_cback;
    switch (p_activate_params->protocol)
    {
    /* not a tag NFC_PROTOCOL_NFCIP1:   NFCDEP/LLCP - NFC-A or NFC-F */
    case NFC_PROTOCOL_T1T:    /* Type1Tag    - NFC-A */
        if (p_activate_params->rf_tech_param.mode == NFC_DISCOVERY_TYPE_POLL_A)
        {
            status = rw_t1t_select (p_activate_params->rf_tech_param.param.pa.hr,
                                    p_activate_params->rf_tech_param.param.pa.nfcid1);
        }
        break;

    case NFC_PROTOCOL_T2T:   /* Type2Tag    - NFC-A */
        if (p_activate_params->rf_tech_param.mode == NFC_DISCOVERY_TYPE_POLL_A)
        {
            if (p_activate_params->rf_tech_param.param.pa.sel_rsp == NFC_SEL_RES_NFC_FORUM_T2T)
                status      = rw_t2t_select ();
        }
        break;

    case NFC_PROTOCOL_T3T:   /* Type3Tag    - NFC-F */
        if (p_activate_params->rf_tech_param.mode == NFC_DISCOVERY_TYPE_POLL_F)
        {
            status = rw_t3t_select (p_activate_params->rf_tech_param.param.pf.nfcid2,
                                    p_activate_params->rf_tech_param.param.pf.mrti_check,
                                    p_activate_params->rf_tech_param.param.pf.mrti_update);
        }
        break;

    case NFC_PROTOCOL_ISO_DEP:     /* ISODEP/4A,4B- NFC-A or NFC-B */
#if(NFC_NXP_NOT_OPEN_INCLUDED == TRUE)
    case NFC_PROTOCOL_T3BT:
#endif
        if (  (p_activate_params->rf_tech_param.mode == NFC_DISCOVERY_TYPE_POLL_B)
                ||(p_activate_params->rf_tech_param.mode == NFC_DISCOVERY_TYPE_POLL_A)  )
        {
            status          = rw_t4t_select ();
        }
        break;

    case NFC_PROTOCOL_15693:     /* ISO 15693 */
        if (p_activate_params->rf_tech_param.mode == NFC_DISCOVERY_TYPE_POLL_ISO15693)
        {
            status          = rw_i93_select (p_activate_params->rf_tech_param.param.pi93.uid);
        }
        break;
    /* TODO set up callback for proprietary protocol */

    default:
        RW_TRACE_ERROR0 ("RW_SetActivatedTagType Invalid protocol");
    }

    if (status != NFC_STATUS_OK)
        rw_cb.p_cback = NULL;
    return status;
}