/******************************************************************************* ** ** Function NFA_HciGetGateAndPipeList ** ** Description This function will get the list of gates allocated to the ** application and list of dynamic pipes created by the ** application. The app will be notified with ** NFA_HCI_GET_GATE_PIPE_LIST_EVT. List of allocated dynamic ** gates to the application and list of pipes created by the ** application will be returned as part of ** tNFA_HCI_GET_GATE_PIPE_LIST data. ** ** Returns NFA_STATUS_OK if successfully initiated ** NFA_STATUS_FAILED otherwise ** *******************************************************************************/ tNFA_STATUS NFA_HciGetGateAndPipeList (tNFA_HANDLE hci_handle) { tNFA_HCI_API_GET_APP_GATE_PIPE *p_msg; if ((NFA_HANDLE_GROUP_MASK & hci_handle) != NFA_HANDLE_GROUP_HCI) { NFA_TRACE_API1 ("NFA_HciGetGateAndPipeList (): Invalid hci_handle:0x%04x", hci_handle); return (NFA_STATUS_FAILED); } NFA_TRACE_API1 ("NFA_HciGetGateAndPipeList (): hci_handle:0x%04x", hci_handle); /* Register the application with HCI */ if ( (nfa_hci_cb.hci_state != NFA_HCI_STATE_DISABLED) &&((p_msg = (tNFA_HCI_API_GET_APP_GATE_PIPE *) GKI_getbuf (sizeof (tNFA_HCI_API_GET_APP_GATE_PIPE))) != NULL)) { p_msg->hdr.event = NFA_HCI_API_GET_APP_GATE_PIPE_EVT; p_msg->hci_handle = hci_handle; nfa_sys_sendmsg (p_msg); return (NFA_STATUS_OK); } return (NFA_STATUS_FAILED); }
/******************************************************************************* ** ** Function NFA_CeRegisterFelicaSystemCodeOnDH ** ** Description Register listening callback for Felica system code ** ** The NFA_CE_REGISTERED_EVT reports the status of the ** operation. ** ** Note: If RF discovery is started, NFA_StopRfDiscovery()/NFA_RF_DISCOVERY_STOPPED_EVT ** should happen before calling this function ** ** Returns: ** NFA_STATUS_OK, if command accepted ** NFA_STATUS_FAILED: otherwise ** *******************************************************************************/ tNFA_STATUS NFA_CeRegisterFelicaSystemCodeOnDH (UINT16 system_code, UINT8 nfcid2[NCI_RF_F_UID_LEN], tNFA_CONN_CBACK *p_conn_cback) { tNFA_CE_MSG *p_msg; NFA_TRACE_API0 ("NFA_CeRegisterFelicaSystemCodeOnDH ()"); /* Validate parameters */ if (p_conn_cback==NULL) return (NFA_STATUS_INVALID_PARAM); if ((p_msg = (tNFA_CE_MSG *) GKI_getbuf ((UINT16) sizeof(tNFA_CE_MSG))) != NULL) { p_msg->reg_listen.hdr.event = NFA_CE_API_REG_LISTEN_EVT; p_msg->reg_listen.p_conn_cback = p_conn_cback; p_msg->reg_listen.listen_type = NFA_CE_REG_TYPE_FELICA; /* Listen info */ memcpy (p_msg->reg_listen.nfcid2, nfcid2, NCI_RF_F_UID_LEN); p_msg->reg_listen.system_code = system_code; nfa_sys_sendmsg (p_msg); return (NFA_STATUS_OK); } return (NFA_STATUS_FAILED); }
/******************************************************************************* ** ** Function NFA_CeSetIsoDepListenTech ** ** Description Set the technologies (NFC-A and/or NFC-B) to listen for when ** NFA_CeConfigureLocalTag or NFA_CeDeregisterAidOnDH are called. ** ** By default (if this API is not called), NFA will listen ** for both NFC-A and NFC-B for ISODEP. ** ** Note: If listening for ISODEP on UICC, the DH listen callbacks ** may still get activate notifications for ISODEP if the reader/ ** writer selects an AID that is not routed to the UICC (regardless ** of whether A or B was disabled using NFA_CeSetIsoDepListenTech) ** ** Note: If RF discovery is started, NFA_StopRfDiscovery()/NFA_RF_DISCOVERY_STOPPED_EVT ** should happen before calling this function ** ** Returns: ** NFA_STATUS_OK, if command accepted ** NFA_STATUS_FAILED: otherwise ** *******************************************************************************/ tNFA_STATUS NFA_CeSetIsoDepListenTech (tNFA_TECHNOLOGY_MASK tech_mask) { tNFA_CE_MSG *p_msg; tNFA_TECHNOLOGY_MASK use_mask = (NFA_TECHNOLOGY_MASK_A | NFA_TECHNOLOGY_MASK_B); NFA_TRACE_API1 ("NFA_CeSetIsoDepListenTech (): 0x%x", tech_mask); if (((tech_mask & use_mask) == 0) || ((tech_mask & ~use_mask) != 0) ) { NFA_TRACE_ERROR0 ("NFA_CeSetIsoDepListenTech: Invalid technology mask"); return (NFA_STATUS_INVALID_PARAM); } if ((p_msg = (tNFA_CE_MSG *) GKI_getbuf ((UINT16) sizeof(tNFA_CE_MSG))) != NULL) { p_msg->hdr.event = NFA_CE_API_CFG_ISODEP_TECH_EVT; p_msg->hdr.layer_specific = tech_mask & use_mask; nfa_sys_sendmsg (p_msg); return (NFA_STATUS_OK); } return (NFA_STATUS_FAILED); }
/******************************************************************************* ** ** Function NFA_RwLocateTlv ** ** Description: ** Search for the Lock/Memory contril TLV on the activated Type1/Type2 tag ** ** Data is returned to the application using the NFA_TLV_DETECT_EVT. When ** search operation has completed, or if an error occurs, the app will be ** notified with NFA_TLV_DETECT_EVT. ** ** Description Perform the TLV detection procedure using the appropriate ** method for the currently activated tag. ** ** Upon successful completion of TLV detection in T1/T2 tag, a ** NFA_TLV_DETECT_EVT will be sent, to notify the application ** of the TLV attributes (total lock/reserved bytes etc.). ** However if the TLV type specified is NDEF then it is same as ** calling NFA_RwDetectNDef and should expect to receive ** NFA_NDEF_DETECT_EVT instead of NFA_TLV_DETECT_EVT ** ** It is not mandatory to call this function - NFA_RwDetectNDef, ** NFA_RwReadNDef and NFA_RwWriteNDef will perform TLV detection ** internally if not performed already. An application may call ** this API to check the a tag/card-emulator's total Reserved/ ** Lock bytes before issuing a write-request. ** ** Returns: ** NFA_STATUS_OK if successfully initiated ** NFC_STATUS_REFUSED if tlv_type is NDEF & tag won't support NDEF ** NFA_STATUS_FAILED otherwise ** *******************************************************************************/ tNFA_STATUS NFA_RwLocateTlv (UINT8 tlv_type) { tNFA_RW_OPERATION *p_msg; NFA_TRACE_API0 ("NFA_RwLocateTlv"); if ((p_msg = (tNFA_RW_OPERATION *) GKI_getbuf ((UINT16) (sizeof (tNFA_RW_OPERATION)))) != NULL) { p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT; if (tlv_type == TAG_LOCK_CTRL_TLV) { p_msg->op = NFA_RW_OP_DETECT_LOCK_TLV; } else if (tlv_type == TAG_MEM_CTRL_TLV) { p_msg->op = NFA_RW_OP_DETECT_MEM_TLV; } else if (tlv_type == TAG_NDEF_TLV) { p_msg->op = NFA_RW_OP_DETECT_NDEF; } else return (NFA_STATUS_FAILED); nfa_sys_sendmsg (p_msg); return (NFA_STATUS_OK); } return (NFA_STATUS_FAILED); }
/******************************************************************************* ** ** Function NFA_RwI93ReadSingleBlock ** ** Description: ** Send Read Single Block 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_RwI93ReadSingleBlock (UINT8 block_number) { tNFA_RW_OPERATION *p_msg; NFA_TRACE_API1 ("NFA_RwI93ReadSingleBlock (): block_number: 0x%02X", block_number); 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_READ_SINGLE_BLOCK; p_msg->params.i93_cmd.first_block_number = block_number; nfa_sys_sendmsg (p_msg); return (NFA_STATUS_OK); } return (NFA_STATUS_FAILED); }
/******************************************************************************* ** ** Function NFA_RwI93WriteDSFID ** ** Description: ** Send Write DSFID command to the activated ISO 15693 tag. ** ** 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_RwI93WriteDSFID (UINT8 dsfid) { tNFA_RW_OPERATION *p_msg; NFA_TRACE_API1 ("NFA_RwI93WriteDSFID (): DSFID: 0x%02X", dsfid); 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_WRITE_DSFID; p_msg->params.i93_cmd.dsfid = dsfid; 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_P2pRegisterClient ** ** Description This function is called to register a client service on LLCP. ** ** NFA_P2P_REG_CLIENT_EVT will be returned with status and handle. ** ** link_type : NFA_P2P_LLINK_TYPE and/or NFA_P2P_DLINK_TYPE ** ** Returns NFA_STATUS_OK if successfully initiated ** NFA_STATUS_FAILED otherwise ** *******************************************************************************/ tNFA_STATUS NFA_P2pRegisterClient (tNFA_P2P_LINK_TYPE link_type, tNFA_P2P_CBACK *p_cback) { tNFA_P2P_API_REG_CLIENT *p_msg; P2P_TRACE_API1 ("NFA_P2pRegisterClient (): link_type:0x%x", link_type); if ( ((link_type & NFA_P2P_LLINK_TYPE) == 0x00) &&((link_type & NFA_P2P_DLINK_TYPE) == 0x00) ) { P2P_TRACE_ERROR1 ("NFA_P2pRegisterClient (): link type (0x%x) must be specified", link_type); return (NFA_STATUS_FAILED); } if ((p_msg = (tNFA_P2P_API_REG_CLIENT *) GKI_getbuf (sizeof (tNFA_P2P_API_REG_CLIENT))) != NULL) { p_msg->hdr.event = NFA_P2P_API_REG_CLIENT_EVT; p_msg->p_cback = p_cback; p_msg->link_type = link_type; nfa_sys_sendmsg (p_msg); return (NFA_STATUS_OK); } return (NFA_STATUS_FAILED); }
/******************************************************************************* ** ** Function NFA_P2pDeregister ** ** Description This function is called to stop listening to a SAP as server ** or stop client service on LLCP. ** ** Note: If this function is called to de-register a server and RF discovery ** is started, NFA_StopRfDiscovery()/NFA_RF_DISCOVERY_STOPPED_EVT ** should happen before calling this function ** ** Returns NFA_STATUS_OK if successfully initiated ** NFA_STATUS_BAD_HANDLE if handle is not valid ** NFA_STATUS_FAILED otherwise ** *******************************************************************************/ tNFA_STATUS NFA_P2pDeregister (tNFA_HANDLE handle) { tNFA_P2P_API_DEREG *p_msg; tNFA_HANDLE xx; P2P_TRACE_API1 ("NFA_P2pDeregister (): handle:0x%02X", handle); xx = handle & NFA_HANDLE_MASK; if ( (xx >= NFA_P2P_NUM_SAP) ||(nfa_p2p_cb.sap_cb[xx].p_cback == NULL) ) { P2P_TRACE_ERROR0 ("NFA_P2pDeregister (): Handle is invalid or not registered"); return (NFA_STATUS_BAD_HANDLE); } if ((p_msg = (tNFA_P2P_API_DEREG *) GKI_getbuf (sizeof (tNFA_P2P_API_DEREG))) != NULL) { p_msg->hdr.event = NFA_P2P_API_DEREG_EVT; p_msg->handle = handle; nfa_sys_sendmsg (p_msg); return (NFA_STATUS_OK); } return (NFA_STATUS_FAILED); }
/******************************************************************************* ** ** 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_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_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_HciGetHostList ** ** Description This function will request the host controller to return the ** list of hosts that are present in the host network. When ** host controller responds with the host list (or if an error ** occurs), the app will be notified with NFA_HCI_HOST_LIST_EVT ** ** Returns NFA_STATUS_OK if successfully initiated ** NFA_STATUS_FAILED otherwise ** *******************************************************************************/ tNFA_STATUS NFA_HciGetHostList (tNFA_HANDLE hci_handle) { tNFA_HCI_API_GET_HOST_LIST *p_msg; if ((NFA_HANDLE_GROUP_MASK & hci_handle) != NFA_HANDLE_GROUP_HCI) { NFA_TRACE_API1 ("NFA_HciGetHostList (): Invalid hci_handle:0x%04x", hci_handle); return (NFA_STATUS_FAILED); } NFA_TRACE_API1 ("NFA_HciGetHostList (): hci_handle:0x%04x",hci_handle); /* Request HCI to get list of host in the hci network */ if ( (nfa_hci_cb.hci_state != NFA_HCI_STATE_DISABLED) &&((p_msg = (tNFA_HCI_API_GET_HOST_LIST *) GKI_getbuf (sizeof (tNFA_HCI_API_GET_HOST_LIST))) != NULL) ) { p_msg->hdr.event = NFA_HCI_API_GET_HOST_LIST_EVT; p_msg->hci_handle = hci_handle; 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_p2p_update_active_listen ** ** Description Remove active listen mode temporarily or restore it ** ** ** Returns None ** *******************************************************************************/ static void nfa_p2p_update_active_listen (void) { tNFA_DM_DISC_TECH_PROTO_MASK p2p_listen_mask = 0; BT_HDR *p_msg; P2P_TRACE_DEBUG1 ("nfa_p2p_update_active_listen (): listen_tech_mask_to_restore:0x%x", nfa_p2p_cb.listen_tech_mask_to_restore); /* if active listen mode was removed temporarily */ if (nfa_p2p_cb.listen_tech_mask_to_restore) { /* restore listen technologies */ nfa_p2p_cb.listen_tech_mask = nfa_p2p_cb.listen_tech_mask_to_restore; nfa_p2p_cb.listen_tech_mask_to_restore = 0; nfa_sys_stop_timer (&nfa_p2p_cb.active_listen_restore_timer); } else { /* start timer in case of no passive activation */ nfa_p2p_cb.active_listen_restore_timer.p_cback = (TIMER_CBACK *)nfa_p2p_update_active_listen_timeout_cback; nfa_sys_start_timer (&nfa_p2p_cb.active_listen_restore_timer, 0, NFA_P2P_RESTORE_ACTIVE_LISTEN_TIMEOUT); /* save listen techonologies */ nfa_p2p_cb.listen_tech_mask_to_restore = nfa_p2p_cb.listen_tech_mask; /* remove active listen mode */ nfa_p2p_cb.listen_tech_mask &= ~( NFA_TECHNOLOGY_MASK_A_ACTIVE|NFA_TECHNOLOGY_MASK_F_ACTIVE); } if (nfa_p2p_cb.dm_disc_handle != NFA_HANDLE_INVALID) { nfa_dm_delete_rf_discover (nfa_p2p_cb.dm_disc_handle); nfa_p2p_cb.dm_disc_handle = NFA_HANDLE_INVALID; } /* collect listen technologies with NFC-DEP protocol */ if (nfa_p2p_cb.listen_tech_mask & NFA_TECHNOLOGY_MASK_A) p2p_listen_mask |= NFA_DM_DISC_MASK_LA_NFC_DEP; if (nfa_p2p_cb.listen_tech_mask & NFA_TECHNOLOGY_MASK_F) p2p_listen_mask |= NFA_DM_DISC_MASK_LF_NFC_DEP; if (nfa_p2p_cb.listen_tech_mask & NFA_TECHNOLOGY_MASK_A_ACTIVE) p2p_listen_mask |= NFA_DM_DISC_MASK_LAA_NFC_DEP; if (nfa_p2p_cb.listen_tech_mask & NFA_TECHNOLOGY_MASK_F_ACTIVE) p2p_listen_mask |= NFA_DM_DISC_MASK_LFA_NFC_DEP; /* Configure listen technologies and protocols and register callback to NFA DM discovery */ nfa_p2p_cb.dm_disc_handle = nfa_dm_add_rf_discover (p2p_listen_mask, NFA_DM_DISC_HOST_ID_DH, nfa_p2p_discovery_cback); /* restart RF discovery to update RF technologies */ if ((p_msg = (BT_HDR *) GKI_getbuf (sizeof(BT_HDR))) != NULL) { p_msg->event = NFA_P2P_INT_RESTART_RF_DISC_EVT; nfa_sys_sendmsg (p_msg); } }
/******************************************************************************* ** ** Function NFA_P2pGetLinkInfo ** ** Description This function is called to get local/remote link MIU and ** Well-Known Service list encoded as a 16-bit field of connected LLCP. ** NFA_P2P_LINK_INFO_EVT will be returned. ** ** Returns NFA_STATUS_OK if successfully initiated ** NFA_STATUS_BAD_HANDLE if server or client is not registered ** NFA_STATUS_FAILED otherwise ** *******************************************************************************/ tNFA_STATUS NFA_P2pGetLinkInfo (tNFA_HANDLE handle) { tNFA_P2P_API_GET_LINK_INFO *p_msg; tNFA_HANDLE xx; P2P_TRACE_API1 ("NFA_P2pGetLinkInfo (): handle:0x%x", handle); if (nfa_p2p_cb.llcp_state != NFA_P2P_LLCP_STATE_ACTIVATED) { P2P_TRACE_ERROR0 ("NFA_P2pGetLinkInfo (): LLCP link is not activated"); return (NFA_STATUS_FAILED); } xx = handle & NFA_HANDLE_MASK; if ( (xx >= NFA_P2P_NUM_SAP) ||(nfa_p2p_cb.sap_cb[xx].p_cback == NULL) ) { P2P_TRACE_ERROR0 ("NFA_P2pGetLinkInfo (): Handle is invalid or not registered"); return (NFA_STATUS_BAD_HANDLE); } if ((p_msg = (tNFA_P2P_API_GET_LINK_INFO *) GKI_getbuf (sizeof (tNFA_P2P_API_GET_LINK_INFO))) != NULL) { p_msg->hdr.event = NFA_P2P_API_GET_LINK_INFO_EVT; p_msg->handle = handle; nfa_sys_sendmsg (p_msg); return (NFA_STATUS_OK); } return (NFA_STATUS_FAILED); }
/******************************************************************************* ** ** 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_SnepRegisterServer ** ** Description This function is called to listen to a SAP as SNEP server. ** ** If server_sap is set to NFA_SNEP_ANY_SAP, then NFA will allocate ** a SAP between LLCP_LOWER_BOUND_SDP_SAP and LLCP_UPPER_BOUND_SDP_SAP ** ** NFC Forum default SNEP server ("urn:nfc:sn:snep") may be launched ** by NFA_SnepStartDefaultServer(). ** ** NFA_SNEP_REG_EVT will be returned with status, handle and service name. ** ** Note: If RF discovery is started, NFA_StopRfDiscovery()/NFA_RF_DISCOVERY_STOPPED_EVT ** should happen before calling this function ** ** Returns NFA_STATUS_OK if successfully initiated ** NFA_STATUS_INVALID_PARAM if p_service_name or p_cback is NULL ** NFA_STATUS_FAILED otherwise ** *******************************************************************************/ tNFA_STATUS NFA_SnepRegisterServer (UINT8 server_sap, char *p_service_name, tNFA_SNEP_CBACK *p_cback) { tNFA_SNEP_API_REG_SERVER *p_msg; SNEP_TRACE_API2 ("NFA_SnepRegisterServer (): SAP:0x%X, SN:<%s>", server_sap, p_service_name); if ((p_service_name == NULL) || (p_cback == NULL)) { SNEP_TRACE_ERROR0 ("NFA_SnepRegisterServer (): p_service_name or p_cback is NULL"); return (NFA_STATUS_INVALID_PARAM); } if ((p_msg = (tNFA_SNEP_API_REG_SERVER *) GKI_getbuf (sizeof (tNFA_SNEP_API_REG_SERVER))) != NULL) { p_msg->hdr.event = NFA_SNEP_API_REG_SERVER_EVT; p_msg->server_sap = server_sap; BCM_STRNCPY_S (p_msg->service_name, sizeof (p_msg->service_name), p_service_name, LLCP_MAX_SN_LEN); p_msg->service_name[LLCP_MAX_SN_LEN] = 0; p_msg->p_cback = p_cback; nfa_sys_sendmsg (p_msg); return (NFA_STATUS_OK); } return (NFA_STATUS_FAILED); }
/******************************************************************************* ** ** Function NFA_RwI93GetSysInfo ** ** Description: ** Send Get system information command to the activated ISO 15693 tag. ** 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_RwI93GetSysInfo (UINT8 *p_uid) { tNFA_RW_OPERATION *p_msg; NFA_TRACE_API0 ("NFA_RwI93GetSysInfo ()"); 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_SYS_INFO; 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_SnepRegisterClient ** ** Description This function is called to register SNEP client. ** NFA_SNEP_REG_EVT will be returned with status, handle ** and zero-length service name. ** ** Returns NFA_STATUS_OK if successfully initiated ** NFA_STATUS_INVALID_PARAM if p_cback is NULL ** NFA_STATUS_FAILED otherwise ** *******************************************************************************/ tNFA_STATUS NFA_SnepRegisterClient (tNFA_SNEP_CBACK *p_cback) { tNFA_SNEP_API_REG_CLIENT *p_msg; SNEP_TRACE_API0 ("NFA_SnepRegisterClient ()"); if (p_cback == NULL) { SNEP_TRACE_ERROR0 ("NFA_SnepRegisterClient (): p_cback is NULL"); return (NFA_STATUS_INVALID_PARAM); } if ((p_msg = (tNFA_SNEP_API_REG_CLIENT *) GKI_getbuf (sizeof (tNFA_SNEP_API_REG_CLIENT))) != NULL) { p_msg->hdr.event = NFA_SNEP_API_REG_CLIENT_EVT; p_msg->p_cback = p_cback; 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_SnepDeregister ** ** Description This function is called to stop listening as SNEP server ** or SNEP client. Application shall use reg_handle returned in ** NFA_SNEP_REG_EVT. ** ** Note: If this function is called to de-register a SNEP server and RF ** discovery is started, NFA_StopRfDiscovery()/NFA_RF_DISCOVERY_STOPPED_EVT ** should happen before calling this function ** ** Returns NFA_STATUS_OK if successfully initiated ** NFA_STATUS_BAD_HANDLE if handle is not valid ** NFA_STATUS_FAILED otherwise ** *******************************************************************************/ tNFA_STATUS NFA_SnepDeregister (tNFA_HANDLE reg_handle) { tNFA_SNEP_API_DEREG *p_msg; tNFA_HANDLE xx; SNEP_TRACE_API1 ("NFA_SnepDeregister (): reg_handle:0x%X", reg_handle); xx = reg_handle & NFA_HANDLE_MASK; if ( (xx >= NFA_SNEP_MAX_CONN) ||(nfa_snep_cb.conn[xx].p_cback == NULL) ) { SNEP_TRACE_ERROR0 ("NFA_SnepDeregister (): Handle is invalid or not registered"); return (NFA_STATUS_BAD_HANDLE); } if ((p_msg = (tNFA_SNEP_API_DEREG *) GKI_getbuf (sizeof (tNFA_SNEP_API_DEREG))) != NULL) { p_msg->hdr.event = NFA_SNEP_API_DEREG_EVT; p_msg->reg_handle = reg_handle; nfa_sys_sendmsg (p_msg); return (NFA_STATUS_OK); } return (NFA_STATUS_FAILED); }
/******************************************************************************* ** ** Function NFA_RwT3tRead ** ** Description: ** Send a CHECK (read) command to the activated Type 3 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_READ_CPLT_EVT. ** ** Returns: ** NFA_STATUS_OK if successfully initiated ** NFA_STATUS_FAILED otherwise ** *******************************************************************************/ tNFA_STATUS NFA_RwT3tRead (UINT8 num_blocks, tNFA_T3T_BLOCK_DESC *t3t_blocks) { tNFA_RW_OPERATION *p_msg; UINT8 *p_block_desc; NFA_TRACE_API1 ("NFA_RwT3tRead (): num_blocks to read: %i", num_blocks); /* Validate parameters */ if ((num_blocks == 0) || (t3t_blocks == NULL)) return (NFA_STATUS_INVALID_PARAM); if ((p_msg = (tNFA_RW_OPERATION *) GKI_getbuf ((UINT16) (sizeof (tNFA_RW_OPERATION) + (num_blocks * sizeof (tNFA_T3T_BLOCK_DESC))))) != NULL) { /* point to area after tNFA_RW_OPERATION */ p_block_desc = (UINT8 *) (p_msg+1); /* Fill in tNFA_RW_OPERATION struct */ p_msg->hdr.event = NFA_RW_OP_REQUEST_EVT; p_msg->op = NFA_RW_OP_T3T_READ; p_msg->params.t3t_read.num_blocks = num_blocks; p_msg->params.t3t_read.p_block_desc = (tNFA_T3T_BLOCK_DESC *) p_block_desc; /* Copy block descriptor list */ memcpy (p_block_desc, t3t_blocks, (num_blocks * sizeof (tNFA_T3T_BLOCK_DESC))); nfa_sys_sendmsg (p_msg); return (NFA_STATUS_OK); } return (NFA_STATUS_FAILED); }
/******************************************************************************* ** ** Function NFA_SnepPut ** ** Description This function is called by client to send PUT request. ** ** Application shall allocate a buffer and put desired NDEF message ** to send to server. ** ** NFA_SNEP_PUT_RESP_EVT or NFA_SNEP_DISC_EVT will be returned ** through registered p_cback. Application may free the buffer after ** receiving these events. ** ** Returns NFA_STATUS_OK if successfully initiated ** NFA_STATUS_BAD_HANDLE if handle is not valid ** NFA_STATUS_FAILED otherwise ** *******************************************************************************/ tNFA_STATUS NFA_SnepPut (tNFA_HANDLE conn_handle, UINT32 ndef_length, UINT8 *p_ndef_buff) { tNFA_SNEP_API_PUT_REQ *p_msg; tNFA_HANDLE xx; SNEP_TRACE_API1 ("NFA_SnepPut (): conn_handle:0x%X", conn_handle); xx = conn_handle & NFA_HANDLE_MASK; if ( (xx >= NFA_SNEP_MAX_CONN) ||(nfa_snep_cb.conn[xx].p_cback == NULL) ||(!(nfa_snep_cb.conn[xx].flags & NFA_SNEP_FLAG_CLIENT)) ) { SNEP_TRACE_ERROR0 ("NFA_SnepPut (): Connection handle is invalid"); return (NFA_STATUS_BAD_HANDLE); } if ((p_msg = (tNFA_SNEP_API_PUT_REQ *) GKI_getbuf (sizeof (tNFA_SNEP_API_PUT_REQ))) != NULL) { p_msg->hdr.event = NFA_SNEP_API_PUT_REQ_EVT; p_msg->conn_handle = conn_handle; p_msg->ndef_length = ndef_length; p_msg->p_ndef_buff = p_ndef_buff; nfa_sys_sendmsg (p_msg); return (NFA_STATUS_OK); } return (NFA_STATUS_FAILED); }
/******************************************************************************* ** ** Function NFA_CeConfigureEseListenTech ** ** Description Configure listening for the Ese, using the specified ** technologies. ** ** Events will be notifed using the tNFA_CONN_CBACK ** (registered during NFA_Enable) ** ** The NFA_CE_ESE_LISTEN_CONFIGURED_EVT reports the status of the ** operation. ** ** Activation and deactivation are reported using the ** NFA_ACTIVATED_EVT and NFA_DEACTIVATED_EVT events ** ** Note: If RF discovery is started, NFA_StopRfDiscovery()/NFA_RF_DISCOVERY_STOPPED_EVT ** should happen before calling this function ** ** Returns: ** NFA_STATUS_OK, if command accepted ** NFA_STATUS_FAILED: otherwise ** *******************************************************************************/ tNFA_STATUS NFA_CeConfigureEseListenTech (tNFA_HANDLE ee_handle, tNFA_TECHNOLOGY_MASK tech_mask) { #if (NFC_NFCEE_INCLUDED == TRUE) tNFA_CE_MSG *p_msg; NFA_TRACE_API1 ("NFA_CeConfigureEseListenTech () ee_handle = 0x%x", ee_handle); /* If tech_mask is zero, then app is disabling listening for specified uicc */ if (tech_mask == 0) { return (nfa_ce_api_deregister_listen (ee_handle, NFA_CE_LISTEN_INFO_ESE)); } /* Otherwise then app is configuring ese listen for the specificed technologies */ if ((p_msg = (tNFA_CE_MSG *) GKI_getbuf ((UINT16) sizeof(tNFA_CE_MSG))) != NULL) { p_msg->reg_listen.hdr.event = NFA_CE_API_REG_LISTEN_EVT; p_msg->reg_listen.listen_type = NFA_CE_REG_TYPE_ESE; p_msg->reg_listen.ee_handle = ee_handle; p_msg->reg_listen.tech_mask = tech_mask; nfa_sys_sendmsg (p_msg); return (NFA_STATUS_OK); } #else NFA_TRACE_ERROR0 ("NFA_CeConfigureEseListenTech () NFCEE related functions are not enabled!"); #endif return (NFA_STATUS_FAILED); }
/******************************************************************************* ** ** Function NFA_SnepPutResponse ** ** Description This function is called by server to send response of PUT request. ** ** When server application receives NFA_SNEP_ALLOC_BUFF_EVT, ** it shall allocate a buffer for incoming NDEF message and ** pass the pointer within callback context. This buffer will be ** returned with NFA_SNEP_PUT_REQ_EVT after receiving complete ** NDEF message. If buffer is not allocated, NFA_SNEP_RESP_CODE_REJECT ** will be sent to client or NFA will discard request and send ** NFA_SNEP_RESP_CODE_SUCCESS (Note:There is no proper response code for ** this case). ** ** Server application shall provide conn_handle which is received in ** NFA_SNEP_PUT_REQ_EVT. ** ** NFA_SNEP_DISC_EVT will be returned through registered callback ** function when client disconnects data link connection. ** ** Returns NFA_STATUS_OK if successfully initiated ** NFA_STATUS_BAD_HANDLE if handle is not valid ** NFA_STATUS_FAILED otherwise ** *******************************************************************************/ tNFA_STATUS NFA_SnepPutResponse (tNFA_HANDLE conn_handle, tNFA_SNEP_RESP_CODE resp_code) { tNFA_SNEP_API_PUT_RESP *p_msg; tNFA_HANDLE xx; SNEP_TRACE_API1 ("NFA_SnepPutResponse (): conn_handle:0x%X", conn_handle); xx = conn_handle & NFA_HANDLE_MASK; if ( (xx >= NFA_SNEP_MAX_CONN) ||(nfa_snep_cb.conn[xx].p_cback == NULL) ||(!(nfa_snep_cb.conn[xx].flags & NFA_SNEP_FLAG_SERVER)) ) { SNEP_TRACE_ERROR0 ("NFA_SnepPutResponse (): Handle is invalid"); return (NFA_STATUS_BAD_HANDLE); } if ((p_msg = (tNFA_SNEP_API_PUT_RESP *) GKI_getbuf (sizeof (tNFA_SNEP_API_PUT_RESP))) != NULL) { p_msg->hdr.event = NFA_SNEP_API_PUT_RESP_EVT; p_msg->conn_handle = conn_handle; p_msg->resp_code = resp_code; nfa_sys_sendmsg (p_msg); return (NFA_STATUS_OK); } return (NFA_STATUS_FAILED); }
/******************************************************************************* ** ** Function NFA_CeRegisterAidOnDH ** ** Description Register listening callback for the specified ISODEP AID ** ** The NFA_CE_REGISTERED_EVT reports the status of the ** operation. ** ** If no AID is specified (aid_len=0), then p_conn_cback will ** will get notifications for any AIDs routed to the DH. This ** over-rides callbacks registered for specific AIDs. ** ** Note: If RF discovery is started, NFA_StopRfDiscovery()/NFA_RF_DISCOVERY_STOPPED_EVT ** should happen before calling this function ** ** Returns: ** NFA_STATUS_OK, if command accepted ** NFA_STATUS_FAILED: otherwise ** *******************************************************************************/ tNFA_STATUS NFA_CeRegisterAidOnDH (UINT8 aid[NFC_MAX_AID_LEN], UINT8 aid_len, tNFA_CONN_CBACK *p_conn_cback) { tNFA_CE_MSG *p_msg; NFA_TRACE_API0 ("NFA_CeRegisterAidOnDH ()"); /* Validate parameters */ if (p_conn_cback==NULL) return (NFA_STATUS_INVALID_PARAM); if ((p_msg = (tNFA_CE_MSG *) GKI_getbuf ((UINT16) sizeof(tNFA_CE_MSG))) != NULL) { p_msg->reg_listen.hdr.event = NFA_CE_API_REG_LISTEN_EVT; p_msg->reg_listen.p_conn_cback = p_conn_cback; p_msg->reg_listen.listen_type = NFA_CE_REG_TYPE_ISO_DEP; /* Listen info */ memcpy (p_msg->reg_listen.aid, aid, aid_len); p_msg->reg_listen.aid_len = aid_len; nfa_sys_sendmsg (p_msg); return (NFA_STATUS_OK); } return (NFA_STATUS_FAILED); }
/******************************************************************************* ** ** Function NFA_SnepDisconnect ** ** Description This function is called to disconnect data link connection. ** discard any pending data if flush is set to TRUE ** ** Client application shall provide conn_handle in NFA_SNEP_GET_RESP_EVT ** or NFA_SNEP_PUT_RESP_EVT. ** ** Server application shall provide conn_handle in NFA_SNEP_GET_REQ_EVT ** or NFA_SNEP_PUT_REQ_EVT. ** ** NFA_SNEP_DISC_EVT will be returned ** ** Returns NFA_STATUS_OK if successfully initiated ** NFA_STATUS_BAD_HANDLE if handle is not valid ** NFA_STATUS_FAILED otherwise ** *******************************************************************************/ tNFA_STATUS NFA_SnepDisconnect (tNFA_HANDLE conn_handle, BOOLEAN flush) { tNFA_SNEP_API_DISCONNECT *p_msg; tNFA_HANDLE xx; SNEP_TRACE_API2 ("NFA_SnepDisconnect (): conn_handle:0x%X, flush=%d", conn_handle, flush); xx = conn_handle & NFA_HANDLE_MASK; if ( (xx >= NFA_SNEP_MAX_CONN) ||(nfa_snep_cb.conn[xx].p_cback == NULL)) { SNEP_TRACE_ERROR0 ("NFA_SnepDisconnect (): Handle is invalid"); return (NFA_STATUS_BAD_HANDLE); } if ((p_msg = (tNFA_SNEP_API_DISCONNECT *) GKI_getbuf (sizeof (tNFA_SNEP_API_DISCONNECT))) != NULL) { p_msg->hdr.event = NFA_SNEP_API_DISCONNECT_EVT; p_msg->conn_handle = conn_handle; p_msg->flush = flush; nfa_sys_sendmsg (p_msg); return (NFA_STATUS_OK); } return (NFA_STATUS_FAILED); }
/******************************************************************************* ** ** Function nfa_ce_api_deregister_listen ** ** Description Internal function called by listening for Felica system ** code, ISO-DEP AID, or UICC technology ** ** Returns: ** NFA_STATUS_OK, if command accepted ** NFA_STATUS_BAD_HANDLE invalid handle ** NFA_STATUS_FAILED: otherwise ** *******************************************************************************/ tNFA_STATUS nfa_ce_api_deregister_listen (tNFA_HANDLE handle, UINT32 listen_info) { tNFA_CE_MSG *p_ce_msg; /* Validate handle */ if ( (listen_info != NFA_CE_LISTEN_INFO_UICC #if(NFC_NXP_NOT_OPEN_INCLUDED == TRUE) && listen_info != NFA_CE_LISTEN_INFO_ESE #endif ) &&((handle & NFA_HANDLE_GROUP_MASK) != NFA_HANDLE_GROUP_CE) ) { NFA_TRACE_ERROR0 ("nfa_ce_api_reregister_listen: Invalid handle"); return (NFA_STATUS_BAD_HANDLE); } if ((p_ce_msg = (tNFA_CE_MSG *) GKI_getbuf ((UINT16) (sizeof (tNFA_CE_MSG)))) != NULL) { p_ce_msg->hdr.event = NFA_CE_API_DEREG_LISTEN_EVT; p_ce_msg->dereg_listen.handle = handle; p_ce_msg->dereg_listen.listen_info = listen_info; nfa_sys_sendmsg (p_ce_msg); return (NFA_STATUS_OK); } else { NFA_TRACE_ERROR0 ("nfa_ce_api_reregister_listen: Out of buffers"); return (NFA_STATUS_FAILED); } }
/******************************************************************************* ** ** Function NFA_EeDisconnect ** ** Description Disconnect (if a connection is currently open) from an ** NFCEE interface. The result of this operation is reported ** with the NFA_EE_DISCONNECT_EVT. ** ** Returns NFA_STATUS_OK if successfully initiated ** NFA_STATUS_FAILED otherwise ** NFA_STATUS_INVALID_PARAM If bad parameter ** *******************************************************************************/ tNFA_STATUS NFA_EeDisconnect(tNFA_HANDLE ee_handle) { tNFA_EE_API_DISCONNECT *p_msg; tNFA_STATUS status = NFA_STATUS_FAILED; UINT8 nfcee_id = (UINT8)(ee_handle & 0xFF); tNFA_EE_ECB *p_cb; NFA_TRACE_API1 ("NFA_EeDisconnect(): handle:<0x%x>", ee_handle); p_cb = nfa_ee_find_ecb (nfcee_id); if ((p_cb == NULL) || (p_cb->conn_st != NFA_EE_CONN_ST_CONN)) { NFA_TRACE_ERROR0 ("NFA_EeDisconnect() Bad ee_handle"); status = NFA_STATUS_INVALID_PARAM; } else if ((p_msg = (tNFA_EE_API_DISCONNECT *) GKI_getbuf (sizeof(tNFA_EE_API_DISCONNECT))) != NULL) { p_msg->hdr.event = NFA_EE_API_DISCONNECT_EVT; p_msg->nfcee_id = nfcee_id; p_msg->p_cb = p_cb; nfa_sys_sendmsg (p_msg); status = NFA_STATUS_OK; } return status; }