/******************************************************************************* ** ** Function NFA_RwI93Select ** ** Description: ** Send Select command to the activated ISO 15693 tag. ** ** UID[0]: 0xE0, MSB ** UID[1]: IC Mfg Code ** ... ** UID[7]: LSB ** ** When the operation has completed (or if an error occurs), the ** app will be notified with NFA_I93_CMD_CPLT_EVT. ** ** Returns: ** NFA_STATUS_OK if successfully initiated ** NFA_STATUS_WRONG_PROTOCOL: ISO 15693 tag not activated ** NFA_STATUS_FAILED otherwise ** *******************************************************************************/ tNFA_STATUS NFA_RwI93Select (UINT8 *p_uid) { tNFA_RW_OPERATION *p_msg; NFA_TRACE_API3 ("NFA_RwI93Select (): UID: [%02X%02X%02X...]", *(p_uid), *(p_uid+1), *(p_uid+2)); if (nfa_rw_cb.protocol != NFC_PROTOCOL_15693) { return (NFA_STATUS_WRONG_PROTOCOL); } if ((p_msg = (tNFA_RW_OPERATION *) GKI_getbuf ((UINT16) (sizeof (tNFA_RW_OPERATION) + I93_UID_BYTE_LEN))) != NULL) { /* Fill in tNFA_RW_OPERATION struct */ p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT; p_msg->op = NFA_RW_OP_I93_SELECT; p_msg->params.i93_cmd.p_data = (UINT8 *) (p_msg + 1); memcpy (p_msg->params.i93_cmd.p_data, p_uid, I93_UID_BYTE_LEN); nfa_sys_sendmsg (p_msg); return (NFA_STATUS_OK); } return (NFA_STATUS_FAILED); }
/******************************************************************************* ** ** Function NFA_Select ** ** Description Select one from detected devices during discovery ** (from NFA_DISC_RESULT_EVTs). The application should wait for ** the final NFA_DISC_RESULT_EVT before selecting. ** ** An NFA_SELECT_RESULT_EVT indicates whether selection was successful or not. ** If failed then application must select again or deactivate by NFA_Deactivate(). ** ** Returns NFA_STATUS_OK if successfully initiated ** NFA_STATUS_INVALID_PARAM if RF interface is not matched protocol ** NFA_STATUS_FAILED otherwise ** *******************************************************************************/ tNFA_STATUS NFA_Select (UINT8 rf_disc_id, tNFA_NFC_PROTOCOL protocol, tNFA_INTF_TYPE rf_interface) { tNFA_DM_API_SELECT *p_msg; NFA_TRACE_API3 ("NFA_Select (): rf_disc_id:0x%X, protocol:0x%X, rf_interface:0x%X", rf_disc_id, protocol, rf_interface); if ( ((rf_interface == NFA_INTERFACE_ISO_DEP) && (protocol != NFA_PROTOCOL_ISO_DEP)) ||((rf_interface == NFA_INTERFACE_NFC_DEP) && (protocol != NFA_PROTOCOL_NFC_DEP)) ) { NFA_TRACE_ERROR0 ("NFA_Select (): RF interface is not matched protocol"); return (NFA_STATUS_INVALID_PARAM); } if ((p_msg = (tNFA_DM_API_SELECT *) GKI_getbuf ((UINT16) (sizeof (tNFA_DM_API_SELECT)))) != NULL) { p_msg->hdr.event = NFA_DM_API_SELECT_EVT; p_msg->rf_disc_id = rf_disc_id; p_msg->protocol = protocol; p_msg->rf_interface = rf_interface; nfa_sys_sendmsg (p_msg); return (NFA_STATUS_OK); } return (NFA_STATUS_FAILED); }
/******************************************************************************* ** ** Function NFA_HciSendEvent ** ** Description This function is called to send any event on a pipe created ** by the application. ** The app will be notified by NFA_HCI_EVENT_SENT_EVT ** after successfully sending the event on the specified pipe ** or if an error occurs. The application should wait for this ** event before releasing event buffer passed as argument. ** If the app is expecting a response to the event then it can ** provide response buffer for collecting the response. If it ** provides a response buffer it can also provide response ** timeout indicating maximum timeout for the response. ** Maximum of NFA_MAX_HCI_EVENT_LEN bytes APDU can be received ** using internal buffer if no response buffer is provided by ** the application. The app will be notified by ** NFA_HCI_EVENT_RCVD_EVT after receiving the response event ** or on timeout if app provided response buffer and response ** timeout. If response buffer and response timeout is provided ** by the application, it should wait for this event before ** releasing the response buffer. If the application did not ** provide response timeout then it should not release the ** response buffer until it receives NFA_HCI_EVENT_RCVD_EVT or ** after timeout it sends next event on the same pipe ** and receives NFA_HCI_EVENT_SENT_EVT for that event. ** ** Returns NFA_STATUS_OK if successfully initiated ** NFA_STATUS_FAILED otherwise ** *******************************************************************************/ tNFA_STATUS NFA_HciSendEvent (tNFA_HANDLE hci_handle, UINT8 pipe, UINT8 evt_code, UINT16 evt_size, UINT8 *p_data, UINT16 rsp_size, UINT8 *p_rsp_buf, UINT16 rsp_timeout) { tNFA_HCI_API_SEND_EVENT_EVT *p_msg; NFA_TRACE_API3 ("NFA_HciSendEvent(): hci_handle:0x%04x, pipe:0x%02x Code: 0x%02x", hci_handle, pipe, evt_code); if ((NFA_HANDLE_GROUP_MASK & hci_handle) != NFA_HANDLE_GROUP_HCI) { NFA_TRACE_API1 ("NFA_HciSendEvent (): Invalid hci_handle:0x%04x", hci_handle); return (NFA_STATUS_FAILED); } if (pipe < NFA_HCI_FIRST_DYNAMIC_PIPE) { NFA_TRACE_API1 ("NFA_HciSendEvent (): Invalid Pipe:0x%02x", pipe); return (NFA_STATUS_FAILED); } if (evt_size && (p_data == NULL)) { NFA_TRACE_API1 ("NFA_HciSendEvent (): Invalid Event size:0x%02x", evt_size); return (NFA_STATUS_FAILED); } if (rsp_size && (p_rsp_buf == NULL)) { NFA_TRACE_API1 ("NFA_HciSendEvent (): No Event buffer, but invalid event buffer size :%u", rsp_size); return (NFA_STATUS_FAILED); } /* Request HCI to post event data on a particular pipe */ if ( (nfa_hci_cb.hci_state != NFA_HCI_STATE_DISABLED) &&((p_msg = (tNFA_HCI_API_SEND_EVENT_EVT *) GKI_getbuf (sizeof (tNFA_HCI_API_SEND_EVENT_EVT))) != NULL) ) { p_msg->hdr.event = NFA_HCI_API_SEND_EVENT_EVT; p_msg->hci_handle = hci_handle; p_msg->pipe = pipe; p_msg->evt_code = evt_code; p_msg->evt_len = evt_size; p_msg->p_evt_buf = p_data; p_msg->rsp_len = rsp_size; p_msg->p_rsp_buf = p_rsp_buf; p_msg->rsp_timeout = rsp_timeout; nfa_sys_sendmsg (p_msg); return (NFA_STATUS_OK); } return (NFA_STATUS_FAILED); }
/******************************************************************************* ** ** Function NFA_HciSendCommand ** ** Description This function is called to send a command on a pipe created ** by the application. ** The app will be notified by NFA_HCI_CMD_SENT_EVT if an error ** occurs. ** When the peer host responds,the app is notified with ** NFA_HCI_RSP_RCVD_EVT ** ** Returns NFA_STATUS_OK if successfully initiated ** NFA_STATUS_FAILED otherwise ** *******************************************************************************/ tNFA_STATUS NFA_HciSendCommand (tNFA_HANDLE hci_handle, UINT8 pipe, UINT8 cmd_code, UINT16 cmd_size, UINT8 *p_data) { tNFA_HCI_API_SEND_CMD_EVT *p_msg; if ((NFA_HANDLE_GROUP_MASK & hci_handle) != NFA_HANDLE_GROUP_HCI) { NFA_TRACE_API1 ("NFA_HciSendCommand (): Invalid hci_handle:0x%04x", hci_handle); return (NFA_STATUS_FAILED); } if (pipe < NFA_HCI_FIRST_DYNAMIC_PIPE) { NFA_TRACE_API1 ("NFA_HciSendCommand (): Invalid Pipe:0x%02x", pipe); return (NFA_STATUS_FAILED); } if ((cmd_size && (p_data == NULL)) || (cmd_size > NFA_MAX_HCI_CMD_LEN)) { NFA_TRACE_API1 ("NFA_HciSendCommand (): Invalid cmd size:0x%02x", cmd_size); return (NFA_STATUS_FAILED); } NFA_TRACE_API3 ("NFA_HciSendCommand (): hci_handle:0x%04x, pipe:0x%02x Code: 0x%02x", hci_handle, pipe, cmd_code); /* Request HCI to post event data on a particular pipe */ if ( (nfa_hci_cb.hci_state != NFA_HCI_STATE_DISABLED) &&((p_msg = (tNFA_HCI_API_SEND_CMD_EVT *) GKI_getbuf (sizeof (tNFA_HCI_API_SEND_CMD_EVT))) != NULL) ) { p_msg->hdr.event = NFA_HCI_API_SEND_CMD_EVT; p_msg->hci_handle = hci_handle; p_msg->pipe = pipe; p_msg->cmd_code = cmd_code; p_msg->cmd_len = cmd_size; if (cmd_size) memcpy (p_msg->data, p_data, cmd_size); nfa_sys_sendmsg (p_msg); return (NFA_STATUS_OK); } return (NFA_STATUS_FAILED); }
/******************************************************************************* ** ** Function NFA_HciSendResponse ** ** Description This function is called to send a response on a pipe created ** by the application. ** The app will be notified by NFA_HCI_RSP_SENT_EVT if an error ** occurs. ** ** Returns NFA_STATUS_OK if successfully initiated ** NFA_STATUS_FAILED otherwise ** *******************************************************************************/ NFC_API extern tNFA_STATUS NFA_HciSendResponse (tNFA_HANDLE hci_handle, UINT8 pipe, UINT8 response, UINT8 data_size, UINT8 *p_data) { tNFA_HCI_API_SEND_RSP_EVT *p_msg; if ((NFA_HANDLE_GROUP_MASK & hci_handle) != NFA_HANDLE_GROUP_HCI) { NFA_TRACE_API1 ("NFA_HciSendResponse (): Invalid hci_handle:0x%04x", hci_handle); return (NFA_STATUS_FAILED); } if (pipe < NFA_HCI_FIRST_DYNAMIC_PIPE) { NFA_TRACE_API1 ("NFA_HciSendResponse (): Invalid Pipe:0x%02x", pipe); return (NFA_STATUS_FAILED); } if ((data_size && (p_data == NULL)) || (data_size > NFA_MAX_HCI_RSP_LEN)) { NFA_TRACE_API1 ("NFA_HciSendResponse (): Invalid data size:0x%02x", data_size); return (NFA_STATUS_FAILED); } NFA_TRACE_API3 ("NFA_HciSendResponse (): hci_handle:0x%04x Pipe: 0x%02x Response: 0x%02x", hci_handle, pipe, response); /* Request HCI to get list of gates supported by the specified host */ if ( (nfa_hci_cb.hci_state != NFA_HCI_STATE_DISABLED) &&((p_msg = (tNFA_HCI_API_SEND_RSP_EVT *) GKI_getbuf (sizeof (tNFA_HCI_API_SEND_RSP_EVT))) != NULL) ) { p_msg->hdr.event = NFA_HCI_API_SEND_RSP_EVT; p_msg->hci_handle = hci_handle; p_msg->response = response; p_msg->size = data_size; if (data_size) memcpy (p_msg->data, p_data, data_size); nfa_sys_sendmsg (p_msg); return (NFA_STATUS_OK); } return (NFA_STATUS_FAILED); }