/******************************************************************************* ** ** Function NFA_EeDeregister ** ** Description This function de-registers the callback function ** ** Returns NFA_STATUS_OK if successfully initiated ** NFA_STATUS_FAILED otherwise ** NFA_STATUS_INVALID_PARAM If bad parameter ** *******************************************************************************/ tNFA_STATUS NFA_EeDeregister(tNFA_EE_CBACK *p_cback) { tNFA_EE_API_DEREGISTER *p_msg; tNFA_STATUS status = NFA_STATUS_INVALID_PARAM; int index = NFA_EE_MAX_CBACKS; int xx; for (xx = 0; xx < NFA_EE_MAX_CBACKS; xx++) { if (nfa_ee_cb.p_ee_cback[xx] == p_cback) { index = xx; status = NFA_STATUS_FAILED; break; } } NFA_TRACE_API2 ("NFA_EeDeregister() %d, status:%d", index, status); if ((status != NFA_STATUS_INVALID_PARAM) && (p_msg = (tNFA_EE_API_DEREGISTER *) GKI_getbuf (sizeof(tNFA_EE_API_DEREGISTER))) != NULL) { p_msg->hdr.event = NFA_EE_API_DEREGISTER_EVT; p_msg->index = index; nfa_sys_sendmsg (p_msg); status = NFA_STATUS_OK; } return status; }
/******************************************************************************* ** ** Function NFA_HciClosePipe ** ** Description This function is called to close a dynamic pipe. ** When the dynamic pipe is closed (or ** if an error occurs), the app will be notified with ** NFA_HCI_CLOSE_PIPE_EVT with the pipe id. ** ** Returns NFA_STATUS_OK if successfully initiated ** NFA_STATUS_FAILED otherwise ** *******************************************************************************/ tNFA_STATUS NFA_HciClosePipe (tNFA_HANDLE hci_handle, UINT8 pipe) { tNFA_HCI_API_CLOSE_PIPE_EVT *p_msg; NFA_TRACE_API2 ("NFA_HciClosePipe (): hci_handle:0x%04x, pipe:0x%02X", hci_handle, pipe); if ((NFA_HANDLE_GROUP_MASK & hci_handle) != NFA_HANDLE_GROUP_HCI) { NFA_TRACE_API1 ("NFA_HciClosePipe (): Invalid hci_handle:0x%04x", hci_handle); return (NFA_STATUS_FAILED); } if ((pipe < NFA_HCI_FIRST_DYNAMIC_PIPE) || (pipe > NFA_HCI_LAST_DYNAMIC_PIPE)) { NFA_TRACE_API1 ("NFA_HciClosePipe (): Invalid Pipe:0x%02x", pipe); return (NFA_STATUS_FAILED); } /* Request HCI to close a pipe if it is in opened state */ if ( (nfa_hci_cb.hci_state != NFA_HCI_STATE_DISABLED) &&(!nfa_hci_cb.b_low_power_mode) &&((p_msg = (tNFA_HCI_API_CLOSE_PIPE_EVT *) GKI_getbuf (sizeof (tNFA_HCI_API_CLOSE_PIPE_EVT))) != NULL) ) { p_msg->hdr.event = NFA_HCI_API_CLOSE_PIPE_EVT; p_msg->hci_handle = hci_handle; p_msg->pipe = pipe; nfa_sys_sendmsg (p_msg); return (NFA_STATUS_OK); } return (NFA_STATUS_FAILED); }
/******************************************************************************* ** ** Function NFA_RegisterNDefTypeHandler ** ** Description This function allows the applications to register for ** specific types of NDEF records. When NDEF records are ** received, NFA will parse the record-type field, and pass ** the record to the registered tNFA_NDEF_CBACK. ** ** For records types which were not registered, the record will ** be sent to the default handler. A default type-handler may ** be registered by calling this NFA_RegisterNDefTypeHandler ** with tnf=NFA_TNF_DEFAULT. In this case, all un-registered ** record types will be sent to the callback. Only one default ** handler may be registered at a time. ** ** An NFA_NDEF_REGISTER_EVT will be sent to the tNFA_NDEF_CBACK ** to indicate that registration was successful, and provide a ** handle for this record type. ** ** Returns NFA_STATUS_OK if successfully initiated ** NFA_STATUS_FAILED otherwise ** *******************************************************************************/ tNFA_STATUS NFA_RegisterNDefTypeHandler (BOOLEAN handle_whole_message, tNFA_TNF tnf, UINT8 *p_type_name, UINT8 type_name_len, tNFA_NDEF_CBACK *p_ndef_cback) { tNFA_DM_API_REG_NDEF_HDLR *p_msg; NFA_TRACE_API2 ("NFA_RegisterNDefTypeHandler (): handle whole ndef message: %i, tnf=0x%02x", handle_whole_message, tnf); /* Check for NULL callback */ if (!p_ndef_cback) { NFA_TRACE_ERROR0 ("NFA_RegisterNDefTypeHandler (): error - null callback"); return (NFA_STATUS_INVALID_PARAM); } if ((p_msg = (tNFA_DM_API_REG_NDEF_HDLR *) GKI_getbuf ((UINT16) (sizeof (tNFA_DM_API_REG_NDEF_HDLR) + type_name_len))) != NULL) { p_msg->hdr.event = NFA_DM_API_REG_NDEF_HDLR_EVT; p_msg->flags = (handle_whole_message ? NFA_NDEF_FLAGS_HANDLE_WHOLE_MESSAGE : 0); p_msg->tnf = tnf; p_msg->name_len = type_name_len; p_msg->p_ndef_cback = p_ndef_cback; memcpy (p_msg->name, p_type_name, type_name_len); nfa_sys_sendmsg (p_msg); return (NFA_STATUS_OK); } return (NFA_STATUS_FAILED); }
/******************************************************************************* ** ** Function NFA_HciGetRegistry ** ** Description This function requests a peer host to return the desired ** registry field value for the gate that the pipe is on. ** ** When the peer host responds,the app is notified with ** NFA_HCI_GET_REG_RSP_EVT or ** if an error occurs in sending the command the app will be ** notified by NFA_HCI_CMD_SENT_EVT ** ** Returns NFA_STATUS_OK if successfully initiated ** NFA_STATUS_FAILED otherwise ** *******************************************************************************/ tNFA_STATUS NFA_HciGetRegistry (tNFA_HANDLE hci_handle, UINT8 pipe, UINT8 reg_inx) { tNFA_HCI_API_GET_REGISTRY *p_msg; if ((NFA_HANDLE_GROUP_MASK & hci_handle) != NFA_HANDLE_GROUP_HCI) { NFA_TRACE_API1 ("NFA_HciGetRegistry (): Invalid hci_handle:0x%04x", hci_handle); return (NFA_STATUS_FAILED); } if (pipe < NFA_HCI_FIRST_DYNAMIC_PIPE) { NFA_TRACE_API1 ("NFA_HciGetRegistry (): Invalid Pipe:0x%02x", pipe); return (NFA_STATUS_FAILED); } NFA_TRACE_API2 ("NFA_HciGetRegistry (): hci_handle:0x%04x Pipe: 0x%02x", hci_handle, pipe); /* 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_GET_REGISTRY *) GKI_getbuf (sizeof (tNFA_HCI_API_GET_REGISTRY))) != NULL) ) { p_msg->hdr.event = NFA_HCI_API_GET_REGISTRY_EVT; p_msg->hci_handle = hci_handle; p_msg->pipe = pipe; p_msg->reg_inx = reg_inx; nfa_sys_sendmsg (p_msg); return (NFA_STATUS_OK); } return (NFA_STATUS_FAILED); }
/******************************************************************************* ** ** Function NFA_RwSetTagReadOnly ** ** Description: ** Sets tag as read only. ** ** When tag is set as read only, or if an error occurs, the app will be ** notified with NFA_SET_TAG_RO_EVT. ** ** Returns: ** NFA_STATUS_OK if successfully initiated ** NFA_STATUS_REJECTED if protocol is not T1/T2/ISO15693 ** (or) if hard lock is not requested for protocol ISO15693 ** NFA_STATUS_FAILED otherwise ** *******************************************************************************/ tNFA_STATUS NFA_RwSetTagReadOnly (BOOLEAN b_hard_lock) { tNFA_RW_OPERATION *p_msg; tNFC_PROTOCOL protocol = nfa_rw_cb.protocol; if ((protocol != NFC_PROTOCOL_T1T) && (protocol != NFC_PROTOCOL_T2T) && (protocol != NFC_PROTOCOL_15693) && (protocol != NFC_PROTOCOL_ISO_DEP) && (protocol != NFC_PROTOCOL_T3T)) { NFA_TRACE_API1 ("NFA_RwSetTagReadOnly (): Cannot Configure as read only for Protocol: %d", protocol); return (NFA_STATUS_REJECTED); } if ( (!b_hard_lock && (protocol == NFC_PROTOCOL_15693)) ||(b_hard_lock && (protocol == NFC_PROTOCOL_ISO_DEP)) ) { NFA_TRACE_API2 ("NFA_RwSetTagReadOnly (): Cannot %s for Protocol: %d", b_hard_lock ? "Hard lock" : "Soft lock", protocol); return (NFA_STATUS_REJECTED); } NFA_TRACE_API1 ("NFA_RwSetTagReadOnly (): %s", b_hard_lock ? "Hard lock" : "Soft lock"); if ((p_msg = (tNFA_RW_OPERATION *) GKI_getbuf ((UINT16) (sizeof (tNFA_RW_OPERATION)))) != NULL) { /* Fill in tNFA_RW_OPERATION struct */ p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT; p_msg->op = NFA_RW_OP_SET_TAG_RO; p_msg->params.set_readonly.b_hard_lock = b_hard_lock; nfa_sys_sendmsg (p_msg); return (NFA_STATUS_OK); } return (NFA_STATUS_FAILED); }
/******************************************************************************* ** ** Function NFA_RwI93GetMultiBlockSecurityStatus ** ** Description: ** Send Get Multiple block security status command to the activated ISO 15693 tag. ** ** Data is returned to the application using the NFA_DATA_EVT. When the read ** 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_RwI93GetMultiBlockSecurityStatus (UINT8 first_block_number, UINT16 number_blocks) { tNFA_RW_OPERATION *p_msg; NFA_TRACE_API2 ("NFA_RwI93GetMultiBlockSecurityStatus(): %d, %d", first_block_number, number_blocks); 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)))) != NULL) { /* Fill in tNFA_RW_OPERATION struct */ p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT; p_msg->op = NFA_RW_OP_I93_GET_MULTI_BLOCK_STATUS; p_msg->params.i93_cmd.first_block_number = first_block_number; p_msg->params.i93_cmd.number_blocks = number_blocks; nfa_sys_sendmsg (p_msg); return (NFA_STATUS_OK); } return (NFA_STATUS_FAILED); }
/******************************************************************************* ** ** Function NFA_HciDeletePipe ** ** Description This function is called to delete a particular dynamic pipe. ** When the dynamic pipe is deleted (or if an error occurs), ** the app will be notified with NFA_HCI_DELETE_PIPE_EVT with ** the pipe id. After successful deletion of pipe, registry ** entry will be deleted for the dynamic pipe and all ** information related to the pipe will be deleted from non ** volatile memory. ** ** Returns NFA_STATUS_OK if successfully initiated ** NFA_STATUS_FAILED otherwise ** *******************************************************************************/ tNFA_STATUS NFA_HciDeletePipe (tNFA_HANDLE hci_handle, UINT8 pipe) { tNFA_HCI_API_DELETE_PIPE_EVT *p_msg; if ((NFA_HANDLE_GROUP_MASK & hci_handle) != NFA_HANDLE_GROUP_HCI) { NFA_TRACE_API1 ("NFA_HciDeletePipe (): Invalid hci_handle:0x%04x", hci_handle); return (NFA_STATUS_FAILED); } if ((pipe < NFA_HCI_FIRST_DYNAMIC_PIPE) || (pipe > NFA_HCI_LAST_DYNAMIC_PIPE)) { NFA_TRACE_API1 ("NFA_HciDeletePipe (): Invalid Pipe:0x%02x", pipe); return (NFA_STATUS_FAILED); } NFA_TRACE_API2 ("NFA_HciDeletePipe (): hci_handle:0x%04x, pipe:0x%02X", hci_handle, pipe); /* Request HCI to delete a pipe created by the application identified by hci handle */ if ( (nfa_hci_cb.hci_state != NFA_HCI_STATE_DISABLED) &&(!nfa_hci_cb.b_low_power_mode) &&((p_msg = (tNFA_HCI_API_DELETE_PIPE_EVT *) GKI_getbuf (sizeof (tNFA_HCI_API_DELETE_PIPE_EVT))) != NULL) ) { p_msg->hdr.event = NFA_HCI_API_DELETE_PIPE_EVT; p_msg->hci_handle = hci_handle; p_msg->pipe = pipe; nfa_sys_sendmsg (p_msg); return (NFA_STATUS_OK); } return (NFA_STATUS_FAILED); }
/******************************************************************************* ** ** Function NFA_HciDeallocGate ** ** Description This function will release the specified gate that was ** previously allocated to the application. When the generic ** gate is released (or if an error occurs), the app will be ** notified with NFA_HCI_DEALLOCATE_GATE_EVT with the gate id. ** ** Returns NFA_STATUS_OK if successfully initiated ** NFA_STATUS_FAILED otherwise ** *******************************************************************************/ tNFA_STATUS NFA_HciDeallocGate (tNFA_HANDLE hci_handle, UINT8 gate) { tNFA_HCI_API_DEALLOC_GATE *p_msg; if ((NFA_HANDLE_GROUP_MASK & hci_handle) != NFA_HANDLE_GROUP_HCI) { NFA_TRACE_API1 ("NFA_HciDeallocGate (): Invalid hci_handle:0x%04x", hci_handle); return (NFA_STATUS_FAILED); } if ((gate < NFA_HCI_FIRST_HOST_SPECIFIC_GENERIC_GATE) || (gate > NFA_HCI_LAST_PROP_GATE) || (gate == NFA_HCI_CONNECTIVITY_GATE)) { NFA_TRACE_API1 ("NFA_HciDeallocGate (): Cannot deallocate the gate:0x%02x", gate); return (NFA_STATUS_FAILED); } NFA_TRACE_API2 ("NFA_HciDeallocGate (): hci_handle:0x%04x, gate:0x%02X", hci_handle, gate); /* Request HCI to deallocate the gate that was previously allocated to the application */ if ( (nfa_hci_cb.hci_state != NFA_HCI_STATE_DISABLED) &&((p_msg = (tNFA_HCI_API_DEALLOC_GATE *) GKI_getbuf (sizeof (tNFA_HCI_API_DEALLOC_GATE))) != NULL) ) { p_msg->hdr.event = NFA_HCI_API_DEALLOC_GATE_EVT; p_msg->hci_handle = hci_handle; p_msg->gate = gate; nfa_sys_sendmsg (p_msg); return (NFA_STATUS_OK); } return (NFA_STATUS_FAILED); }
/******************************************************************************* ** ** Function NFA_EeConnect ** ** Description Open connection to an NFCEE attached to the NFCC ** ** The status of this operation is ** reported with the NFA_EE_CONNECT_EVT. ** ** Returns NFA_STATUS_OK if successfully initiated ** NFA_STATUS_FAILED otherwise ** NFA_STATUS_INVALID_PARAM If bad parameter ** *******************************************************************************/ tNFA_STATUS NFA_EeConnect(tNFA_HANDLE ee_handle, UINT8 ee_interface, tNFA_EE_CBACK *p_cback) { tNFA_EE_API_CONNECT *p_msg; tNFA_STATUS status = NFA_STATUS_FAILED; UINT8 nfcee_id = (UINT8)(ee_handle & 0xFF); tNFA_EE_ECB *p_cb; NFA_TRACE_API2 ("NFA_EeConnect(): handle:<0x%x> ee_interface:0x%x", ee_handle, ee_interface); p_cb = nfa_ee_find_ecb (nfcee_id); if ((p_cb == NULL) || (p_cback == NULL)) { NFA_TRACE_ERROR0 ("Bad ee_handle or NULL callback function"); status = NFA_STATUS_INVALID_PARAM; } else if ((p_msg = (tNFA_EE_API_CONNECT *) GKI_getbuf (sizeof(tNFA_EE_API_CONNECT))) != NULL) { p_msg->hdr.event = NFA_EE_API_CONNECT_EVT; p_msg->nfcee_id = nfcee_id; p_msg->p_cb = p_cb; p_msg->ee_interface = ee_interface; p_msg->p_cback = p_cback; nfa_sys_sendmsg (p_msg); status = NFA_STATUS_OK; } return status; }
/******************************************************************************* ** ** Function NFA_HciAddStaticPipe ** ** Description This function is called to add a static pipe for sending ** 7816 APDUs. When the static pipe is added (or if an error occurs), ** the app will be notified with NFA_HCI_ADD_STATIC_PIPE_EVT with ** the status. ** Returns NFA_STATUS_OK if successfully initiated ** NFA_STATUS_FAILED otherwise ** *******************************************************************************/ tNFA_STATUS NFA_HciAddStaticPipe (tNFA_HANDLE hci_handle, UINT8 host, UINT8 gate, UINT8 pipe) { tNFA_HCI_API_ADD_STATIC_PIPE_EVT *p_msg; UINT8 xx; if ((NFA_HANDLE_GROUP_MASK & hci_handle) != NFA_HANDLE_GROUP_HCI) { NFA_TRACE_API1 ("NFA_HciAddStaticPipe (): Invalid hci_handle:0x%04x", hci_handle); return (NFA_STATUS_FAILED); } for (xx = 0; xx < NFA_HCI_MAX_HOST_IN_NETWORK; xx++) if (nfa_hci_cb.inactive_host[xx] == host) break; if (xx != NFA_HCI_MAX_HOST_IN_NETWORK) { NFA_TRACE_API1 ("NFA_HciAddStaticPipe (): Host not active:0x%02x", host); return (NFA_STATUS_FAILED); } if (gate <= NFA_HCI_LAST_HOST_SPECIFIC_GATE) { NFA_TRACE_API1 ("NFA_HciAddStaticPipe (): Invalid Gate:0x%02x", gate); return (NFA_STATUS_FAILED); } #if(NFC_NXP_NOT_OPEN_INCLUDED != TRUE) if (pipe <= NFA_HCI_LAST_DYNAMIC_PIPE) { NFA_TRACE_API1 ("NFA_HciAddStaticPipe (): Invalid Pipe:0x%02x", pipe); return (NFA_STATUS_FAILED); } #endif NFA_TRACE_API2 ("NFA_HciAddStaticPipe (): hci_handle:0x%04x, pipe:0x%02X", hci_handle, pipe); /* Request HCI to delete a pipe created by the application identified by hci handle */ if ( (nfa_hci_cb.hci_state != NFA_HCI_STATE_DISABLED) &&((p_msg = (tNFA_HCI_API_ADD_STATIC_PIPE_EVT *) GKI_getbuf (sizeof (tNFA_HCI_API_ADD_STATIC_PIPE_EVT))) != NULL) ) { p_msg->hdr.event = NFA_HCI_API_ADD_STATIC_PIPE_EVT; p_msg->hci_handle = hci_handle; p_msg->host = host; p_msg->gate = gate; p_msg->pipe = pipe; nfa_sys_sendmsg (p_msg); return (NFA_STATUS_OK); } /* Unable to add static pipe */ return (NFA_STATUS_FAILED); }
/******************************************************************************* ** ** Function NFA_RegisterNDefUriHandler ** ** Description This API is a special-case of NFA_RegisterNDefTypeHandler ** with TNF=NFA_TNF_WKT, and type_name='U' (URI record); and allows ** registering for specific URI types (e.g. 'tel:' or 'mailto:'). ** ** An NFA_NDEF_REGISTER_EVT will be sent to the tNFA_NDEF_CBACK ** to indicate that registration was successful, and provide a ** handle for this registration. ** ** If uri_id=NFA_NDEF_URI_ID_ABSOLUTE, then p_abs_uri contains the ** unabridged URI. For all other uri_id values, the p_abs_uri ** parameter is ignored (i.e the URI prefix is implied by uri_id). ** See [NFC RTD URI] for more information. ** ** Returns NFA_STATUS_OK if successfully initiated ** NFA_STATUS_FAILED otherwise ** *******************************************************************************/ NFC_API extern tNFA_STATUS NFA_RegisterNDefUriHandler (BOOLEAN handle_whole_message, tNFA_NDEF_URI_ID uri_id, UINT8 *p_abs_uri, UINT8 uri_id_len, tNFA_NDEF_CBACK *p_ndef_cback) { tNFA_DM_API_REG_NDEF_HDLR *p_msg; NFA_TRACE_API2 ("NFA_RegisterNDefUriHandler (): handle whole ndef message: %i, uri_id=0x%02x", handle_whole_message, uri_id); /* Check for NULL callback */ if (!p_ndef_cback) { NFA_TRACE_ERROR0 ("NFA_RegisterNDefUriHandler (): error - null callback"); return (NFA_STATUS_INVALID_PARAM); } if ((p_msg = (tNFA_DM_API_REG_NDEF_HDLR *) GKI_getbuf ((UINT16) (sizeof (tNFA_DM_API_REG_NDEF_HDLR) + uri_id_len))) != NULL) { p_msg->hdr.event = NFA_DM_API_REG_NDEF_HDLR_EVT; p_msg->flags = NFA_NDEF_FLAGS_WKT_URI; if (handle_whole_message) { p_msg->flags |= NFA_NDEF_FLAGS_HANDLE_WHOLE_MESSAGE; } /* abs_uri is only valid fir uri_id=NFA_NDEF_URI_ID_ABSOLUTE */ if (uri_id != NFA_NDEF_URI_ID_ABSOLUTE) { uri_id_len = 0; } p_msg->tnf = NFA_TNF_WKT; p_msg->uri_id = uri_id; p_msg->name_len = uri_id_len; p_msg->p_ndef_cback = p_ndef_cback; memcpy (p_msg->name, p_abs_uri, uri_id_len); nfa_sys_sendmsg (p_msg); return (NFA_STATUS_OK); } return (NFA_STATUS_FAILED); }
/******************************************************************************* ** ** Function NFA_HciSetRegistry ** ** Description This function requests a peer host to set the desired ** registry field value for the gate that the pipe is on. ** ** When the peer host responds,the app is notified with ** NFA_HCI_SET_REG_RSP_EVT or ** if an error occurs in sending the command the app will be ** notified by NFA_HCI_CMD_SENT_EVT ** ** Returns NFA_STATUS_OK if successfully initiated ** NFA_STATUS_FAILED otherwise ** *******************************************************************************/ NFC_API extern tNFA_STATUS NFA_HciSetRegistry (tNFA_HANDLE hci_handle, UINT8 pipe, UINT8 reg_inx, UINT8 data_size, UINT8 *p_data) { tNFA_HCI_API_SET_REGISTRY *p_msg; if ((NFA_HANDLE_GROUP_MASK & hci_handle) != NFA_HANDLE_GROUP_HCI) { NFA_TRACE_API1 ("NFA_HciSetRegistry (): Invalid hci_handle:0x%04x", hci_handle); return (NFA_STATUS_FAILED); } if (pipe < NFA_HCI_FIRST_DYNAMIC_PIPE) { NFA_TRACE_API1 ("NFA_HciSetRegistry (): Invalid Pipe:0x%02x", pipe); return (NFA_STATUS_FAILED); } if ((data_size == 0) || (p_data == NULL) || (data_size > NFA_MAX_HCI_CMD_LEN)) { NFA_TRACE_API1 ("NFA_HciSetRegistry (): Invalid data size:0x%02x", data_size); return (NFA_STATUS_FAILED); } NFA_TRACE_API2 ("NFA_HciSetRegistry (): hci_handle:0x%04x Pipe: 0x%02x", hci_handle, pipe); /* 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_SET_REGISTRY *) GKI_getbuf (sizeof (tNFA_HCI_API_SET_REGISTRY))) != NULL) ) { p_msg->hdr.event = NFA_HCI_API_SET_REGISTRY_EVT; p_msg->hci_handle = hci_handle; p_msg->pipe = pipe; p_msg->reg_inx = reg_inx; p_msg->size = data_size; memcpy (p_msg->data, p_data, data_size); nfa_sys_sendmsg (p_msg); return (NFA_STATUS_OK); } return (NFA_STATUS_FAILED); }
/******************************************************************************* ** ** Function NFA_RwI93WriteMultipleBlocks ** ** Description: ** Send Write Multiple Block command to the activated ISO 15693 tag. ** ** When the write 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_RwI93WriteMultipleBlocks (UINT8 first_block_number, UINT16 number_blocks, UINT8 *p_data) { tNFA_RW_OPERATION *p_msg; UINT16 data_length; NFA_TRACE_API2 ("NFA_RwI93WriteMultipleBlocks (): %d, %d", first_block_number, number_blocks); if ( nfa_rw_cb.protocol != NFC_PROTOCOL_15693) { return (NFA_STATUS_WRONG_PROTOCOL); } /* we don't know block size of tag */ if ((nfa_rw_cb.i93_block_size == 0) || (nfa_rw_cb.i93_num_block == 0)) { return (NFA_STATUS_FAILED); } data_length = nfa_rw_cb.i93_block_size * number_blocks; if ((p_msg = (tNFA_RW_OPERATION *) GKI_getbuf ((UINT16) (sizeof (tNFA_RW_OPERATION) + data_length))) != NULL) { /* Fill in tNFA_RW_OPERATION struct */ p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT; p_msg->op = NFA_RW_OP_I93_WRITE_MULTI_BLOCK; p_msg->params.i93_cmd.first_block_number = first_block_number; p_msg->params.i93_cmd.number_blocks = number_blocks; p_msg->params.i93_cmd.p_data = (UINT8*) (p_msg + 1); memcpy (p_msg->params.i93_cmd.p_data, p_data, data_length); nfa_sys_sendmsg (p_msg); return (NFA_STATUS_OK); } return (NFA_STATUS_FAILED); }
/******************************************************************************* ** ** Function NFA_EeModeSet ** ** Description This function is called to activate (mode = NFA_EE_MD_ACTIVATE) ** or deactivate (mode = NFA_EE_MD_DEACTIVATE) the NFCEE ** identified by the given ee_handle. The result of this ** operation is reported with the NFA_EE_MODE_SET_EVT. ** ** Returns NFA_STATUS_OK if successfully initiated ** NFA_STATUS_FAILED otherwise ** NFA_STATUS_INVALID_PARAM If bad parameter ** *******************************************************************************/ tNFA_STATUS NFA_EeModeSet(tNFA_HANDLE ee_handle, tNFA_EE_MD mode) { tNFA_EE_API_MODE_SET *p_msg; tNFA_STATUS status = NFA_STATUS_FAILED; tNFA_EE_ECB *p_cb, *p_found = NULL; UINT32 xx; UINT8 nfcee_id = (ee_handle & 0xFF); p_cb = nfa_ee_cb.ecb; for (xx = 0; xx < nfa_ee_cb.cur_ee; xx++, p_cb++) { if (nfcee_id == p_cb->nfcee_id) { p_found = p_cb; break; } } NFA_TRACE_API2 ("NFA_EeModeSet(): handle:<0x%x>, mode:0x%02X", ee_handle, mode); if (p_found == NULL) { NFA_TRACE_ERROR1 ("NFA_EeModeSet() invalid NFCEE:0x%04x", ee_handle); status = NFA_STATUS_INVALID_PARAM; } else if ((p_msg = (tNFA_EE_API_MODE_SET *) GKI_getbuf (sizeof(tNFA_EE_API_MODE_SET))) != NULL) { p_msg->hdr.event = NFA_EE_API_MODE_SET_EVT; p_msg->nfcee_id = nfcee_id; p_msg->mode = mode; p_msg->p_cb = p_found; nfa_sys_sendmsg (p_msg); status = NFA_STATUS_OK; } return status; }
/******************************************************************************* ** ** Function NFA_RwWriteNDef ** ** Description Write NDEF data to the activated tag. This function will ** internally perform NDEF detection if necessary, and write ** the NDEF tag data using the appropriate method for the ** currently activated tag. ** ** When the entire message has been written, or if an error ** occurs, the app will be notified with NFA_WRITE_CPLT_EVT. ** ** p_data needs to be persistent until NFA_WRITE_CPLT_EVT ** ** ** Returns: ** NFA_STATUS_OK if successfully initiated ** NFC_STATUS_REFUSED if tag does not support NDEF/locked ** NFA_STATUS_FAILED otherwise ** *******************************************************************************/ tNFA_STATUS NFA_RwWriteNDef (UINT8 *p_data, UINT32 len) { tNFA_RW_OPERATION *p_msg; NFA_TRACE_API2 ("NFA_RwWriteNDef (): ndef p_data=%08x, len: %i", p_data, len); /* Validate parameters */ if (p_data == NULL) return (NFA_STATUS_INVALID_PARAM); if ((p_msg = (tNFA_RW_OPERATION *) GKI_getbuf ((UINT16) (sizeof (tNFA_RW_OPERATION)))) != NULL) { p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT; p_msg->op = NFA_RW_OP_WRITE_NDEF; p_msg->params.write_ndef.len = len; p_msg->params.write_ndef.p_data = p_data; nfa_sys_sendmsg (p_msg); return (NFA_STATUS_OK); } return (NFA_STATUS_FAILED); }
/******************************************************************************* ** ** Function NFA_RwI93Inventory ** ** Description: ** Send Inventory command to the activated ISO 15693 tag with/without AFI ** If UID is provided then set UID[0]:MSB, ... 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_RwI93Inventory (BOOLEAN afi_present, UINT8 afi, UINT8 *p_uid) { tNFA_RW_OPERATION *p_msg; NFA_TRACE_API2 ("NFA_RwI93Inventory (): afi_present:%d, AFI: 0x%02X", afi_present, afi); 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)))) != NULL) { /* Fill in tNFA_RW_OPERATION struct */ p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT; p_msg->op = NFA_RW_OP_I93_INVENTORY; p_msg->params.i93_cmd.afi_present = afi_present; p_msg->params.i93_cmd.afi = afi; if (p_uid) { p_msg->params.i93_cmd.uid_present = TRUE; memcpy (p_msg->params.i93_cmd.uid, p_uid, I93_UID_BYTE_LEN); } else { p_msg->params.i93_cmd.uid_present = FALSE; } nfa_sys_sendmsg (p_msg); return (NFA_STATUS_OK); } return (NFA_STATUS_FAILED); }
/******************************************************************************* ** ** Function NFA_HciDebug ** ** Description Debug function. ** *******************************************************************************/ void NFA_HciDebug (UINT8 action, UINT8 size, UINT8 *p_data) { int xx; tNFA_HCI_DYN_GATE *pg = nfa_hci_cb.cfg.dyn_gates; tNFA_HCI_DYN_PIPE *pp = nfa_hci_cb.cfg.dyn_pipes; BT_HDR *p_msg; UINT8 *p; switch (action) { case NFA_HCI_DEBUG_DISPLAY_CB: NFA_TRACE_API0 ("NFA_HciDebug Host List:"); for (xx = 0; xx < NFA_HCI_MAX_APP_CB; xx++) { if (nfa_hci_cb.cfg.reg_app_names[xx][0] != 0) { NFA_TRACE_API2 (" Host Inx: %u Name: %s", xx, &nfa_hci_cb.cfg.reg_app_names[xx][0]); } } NFA_TRACE_API0 ("NFA_HciDebug Gate List:"); for (xx = 0; xx < NFA_HCI_MAX_GATE_CB; xx++, pg++) { if (pg->gate_id != 0) { NFA_TRACE_API4 (" Gate Inx: %x ID: 0x%02x Owner: 0x%04x PipeInxMask: 0x%08x", xx, pg->gate_id, pg->gate_owner, pg->pipe_inx_mask); } } NFA_TRACE_API0 ("NFA_HciDebug Pipe List:"); for (xx = 0; xx < NFA_HCI_MAX_PIPE_CB; xx++, pp++) { if (pp->pipe_id != 0) { NFA_TRACE_API6 (" Pipe Inx: %x ID: 0x%02x State: %u LocalGate: 0x%02x Dest Gate: 0x%02x Host: 0x%02x", xx, pp->pipe_id, pp->pipe_state, pp->local_gate, pp->dest_gate, pp->dest_host); } } break; case NFA_HCI_DEBUG_SIM_HCI_EVENT: if ((p_msg = (BT_HDR *) GKI_getpoolbuf (NFC_RW_POOL_ID)) != NULL) { p = (UINT8 *) (p_msg + 1); p_msg->event = NFA_HCI_CHECK_QUEUE_EVT; p_msg->len = size; p_msg->offset = 0; memcpy (p, p_data, size); nfa_sys_sendmsg (p_msg); } break; case NFA_HCI_DEBUG_ENABLE_LOOPBACK: NFA_TRACE_API0 ("NFA_HciDebug HCI_LOOPBACK_DEBUG = TRUE"); HCI_LOOPBACK_DEBUG = TRUE; break; case NFA_HCI_DEBUG_DISABLE_LOOPBACK: NFA_TRACE_API0 ("NFA_HciDebug HCI_LOOPBACK_DEBUG = FALSE"); HCI_LOOPBACK_DEBUG = FALSE; break; } }