/***************************************************************************** ** ** Function rw_t1t_handle_rid_rsp ** ** Description Handles response to RID: Collects HR, UID, notify up the ** stack ** ** Returns event to notify application ** *****************************************************************************/ static tRW_EVENT rw_t1t_handle_rid_rsp (BT_HDR *p_pkt) { tRW_T1T_CB *p_t1t = &rw_cb.tcb.t1t; tRW_DATA evt_data; UINT8 *p_rid_rsp; evt_data.status = NFC_STATUS_OK; evt_data.data.p_data = p_pkt; /* Assume the data is just the response byte sequence */ p_rid_rsp = (UINT8 *) (p_pkt + 1) + p_pkt->offset; /* Response indicates tag is present */ if (p_t1t->state == RW_T1T_STATE_CHECK_PRESENCE) { /* If checking for the presence of the tag then just notify */ return RW_T1T_PRESENCE_CHECK_EVT; } /* Extract HR and UID from response */ STREAM_TO_ARRAY (p_t1t->hr, p_rid_rsp, T1T_HR_LEN); #if (BT_TRACE_VERBOSE == TRUE) RW_TRACE_DEBUG2 ("hr0:0x%x, hr1:0x%x", p_t1t->hr[0], p_t1t->hr[1]); RW_TRACE_DEBUG4 ("rw_t1t_handle_rid_rsp (): UID0-3=%02x%02x%02x%02x", p_rid_rsp[0], p_rid_rsp[1], p_rid_rsp[2], p_rid_rsp[3]); #else RW_TRACE_DEBUG0 ("rw_t1t_handle_rid_rsp ()"); #endif /* Fetch UID0-3 from RID response message */ STREAM_TO_ARRAY (p_t1t->mem, p_rid_rsp, T1T_CMD_UID_LEN); /* Notify RID response Event */ return RW_T1T_RID_EVT; }
/******************************************************************************* ** ** Function rw_t4t_handle_error ** ** Description notify error to application and clean up ** ** Returns none ** *******************************************************************************/ static void rw_t4t_handle_error (tNFC_STATUS status, UINT8 sw1, UINT8 sw2) { tRW_T4T_CB *p_t4t = &rw_cb.tcb.t4t; tRW_DATA rw_data; tRW_EVENT event; RW_TRACE_DEBUG4 ("rw_t4t_handle_error (): status:0%02X, sw1:0x%02X, sw2:0x%02X, state:0x%X", status, sw1, sw2, p_t4t->state); nfc_stop_quick_timer (&p_t4t->timer); if (rw_cb.p_cback) { rw_data.status = status; rw_data.t4t_sw.sw1 = sw1; rw_data.t4t_sw.sw2 = sw2; switch (p_t4t->state) { case RW_T4T_STATE_DETECT_NDEF: rw_data.ndef.flags = RW_NDEF_FL_UNKNOWN; event = RW_T4T_NDEF_DETECT_EVT; break; case RW_T4T_STATE_READ_NDEF: event = RW_T4T_NDEF_READ_FAIL_EVT; break; case RW_T4T_STATE_UPDATE_NDEF: event = RW_T4T_NDEF_UPDATE_FAIL_EVT; break; case RW_T4T_STATE_PRESENCE_CHECK: event = RW_T4T_PRESENCE_CHECK_EVT; rw_data.status = NFC_STATUS_FAILED; break; default: event = RW_T4T_MAX_EVT; break; } p_t4t->state = RW_T4T_STATE_IDLE; if (event != RW_T4T_MAX_EVT) { (*(rw_cb.p_cback)) (event, &rw_data); } } else { p_t4t->state = RW_T4T_STATE_IDLE; } }