nfa_api.h revision 855ae32a422fe508c56a9d33f4f65cf6bf77cd9e
1/****************************************************************************** 2 * 3 * Copyright (C) 2010-2014 Broadcom Corporation 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at: 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 ******************************************************************************/ 18 19 20/****************************************************************************** 21 * 22 * This is the public interface file for NFA, Broadcom's NFC application 23 * layer for mobile phones. 24 * 25 ******************************************************************************/ 26#ifndef NFA_API_H 27#define NFA_API_H 28 29#include "nfc_target.h" 30#include "nci_defs.h" 31#include "tags_defs.h" 32#include "nfc_api.h" 33#include "rw_api.h" 34#include "nfc_hal_api.h" 35#include "gki.h" 36 37 38/***************************************************************************** 39** Constants and data types 40*****************************************************************************/ 41 42/* Max length of Appliction ID in 7816-4 */ 43#define NFA_MAX_AID_LEN NFC_MAX_AID_LEN 44#define NFA_MIN_AID_LEN 5 /* per NCI specification */ 45 46/* NFA API return status codes */ 47#define NFA_STATUS_OK NCI_STATUS_OK /* Command succeeded */ 48#define NFA_STATUS_REJECTED NCI_STATUS_REJECTED /* Command is rejected. */ 49#define NFA_STATUS_MSG_CORRUPTED NCI_STATUS_MESSAGE_CORRUPTED /* Message is corrupted */ 50#define NFA_STATUS_BUFFER_FULL NCI_STATUS_BUFFER_FULL /* buffer full */ 51#define NFA_STATUS_FAILED NCI_STATUS_FAILED /* failed */ 52#define NFA_STATUS_NOT_INITIALIZED NCI_STATUS_NOT_INITIALIZED /* not initialized */ 53#define NFA_STATUS_SYNTAX_ERROR NCI_STATUS_SYNTAX_ERROR /* Syntax error */ 54#define NFA_STATUS_SEMANTIC_ERROR NCI_STATUS_SEMANTIC_ERROR /* Semantic error */ 55#define NFA_STATUS_UNKNOWN_GID NCI_STATUS_UNKNOWN_GID /* Unknown NCI Group ID */ 56#define NFA_STATUS_UNKNOWN_OID NCI_STATUS_UNKNOWN_OID /* Unknown NCI Opcode */ 57#define NFA_STATUS_INVALID_PARAM NCI_STATUS_INVALID_PARAM /* Invalid Parameter */ 58#define NFA_STATUS_MSG_SIZE_TOO_BIG NCI_STATUS_MSG_SIZE_TOO_BIG /* Message size too big */ 59#define NFA_STATUS_ALREADY_STARTED NCI_STATUS_ALREADY_STARTED /* Already started */ 60#define NFA_STATUS_ACTIVATION_FAILED NCI_STATUS_ACTIVATION_FAILED /* Activation Failed */ 61#define NFA_STATUS_TEAR_DOWN NCI_STATUS_TEAR_DOWN /* Tear Down Error */ 62#define NFA_STATUS_RF_TRANSMISSION_ERR NCI_STATUS_RF_TRANSMISSION_ERR /* RF transmission error*/ 63#define NFA_STATUS_RF_PROTOCOL_ERR NCI_STATUS_RF_PROTOCOL_ERR /* RF protocol error */ 64#define NFA_STATUS_TIMEOUT NCI_STATUS_TIMEOUT /* RF Timeout */ 65#define NFA_STATUS_EE_INTF_ACTIVE_FAIL NCI_STATUS_EE_INTF_ACTIVE_FAIL /* EE Intf activate err */ 66#define NFA_STATUS_EE_TRANSMISSION_ERR NCI_STATUS_EE_TRANSMISSION_ERR /* EE transmission error*/ 67#define NFA_STATUS_EE_PROTOCOL_ERR NCI_STATUS_EE_PROTOCOL_ERR /* EE protocol error */ 68#define NFA_STATUS_EE_TIMEOUT NCI_STATUS_EE_TIMEOUT /* EE Timeout */ 69 70#define NFA_STATUS_CMD_STARTED NFC_STATUS_CMD_STARTED /* Command started successfully */ 71#define NFA_STATUS_HW_TIMEOUT NFC_STATUS_HW_TIMEOUT /* NFCC Timeout in responding to an NCI command */ 72#define NFA_STATUS_CONTINUE NFC_STATUS_CONTINUE /* More NFA_CE_GET_ROUTING_REVT to follow */ 73#define NFA_STATUS_REFUSED NFC_STATUS_REFUSED /* API is called to perform illegal function */ 74#define NFA_STATUS_BAD_RESP NFC_STATUS_BAD_RESP /* Wrong format of R-APDU, CC file or NDEF file */ 75#define NFA_STATUS_CMD_NOT_CMPLTD NFC_STATUS_CMD_NOT_CMPLTD /* 7816 Status Word is not command complete(0x9000) */ 76#define NFA_STATUS_NO_BUFFERS NFC_STATUS_NO_BUFFERS /* Out of GKI buffers */ 77#define NFA_STATUS_WRONG_PROTOCOL NFC_STATUS_WRONG_PROTOCOL /* Protocol mismatch between API and activated one */ 78#define NFA_STATUS_BUSY NFC_STATUS_BUSY /* Another Tag command is already in progress */ 79 80#define NFA_STATUS_BAD_LENGTH NFC_STATUS_BAD_LENGTH /* data len exceeds MIU */ 81#define NFA_STATUS_BAD_HANDLE NFC_STATUS_BAD_HANDLE /* invalid handle */ 82#define NFA_STATUS_CONGESTED NFC_STATUS_CONGESTED /* congested */ 83typedef UINT8 tNFA_STATUS; 84 85/* Handle for NFA registrations and connections */ 86typedef UINT16 tNFA_HANDLE; 87#define NFA_HANDLE_INVALID (0xFFFF) 88/* NFA Handle definitions */ 89 90/* The upper byte of NFA_HANDLE signifies the handle group */ 91#define NFA_HANDLE_GROUP_CONNECTION 0x0100 /* Connection handles */ 92#define NFA_HANDLE_GROUP_NDEF_HANDLER 0x0200 /* NDEF Type Handler handles */ 93#define NFA_HANDLE_GROUP_CE 0x0300 /* DH Card Emulation handles */ 94#define NFA_HANDLE_GROUP_EE 0x0400 /* Handles to identify NFCEE */ 95#define NFA_HANDLE_GROUP_P2P 0x0500 /* P2P handles */ 96#define NFA_HANDLE_GROUP_CHO 0x0600 /* Connection Handvoer handles */ 97#define NFA_HANDLE_GROUP_SNEP 0x0700 /* SNEP handles */ 98#define NFA_HANDLE_GROUP_HCI 0x0800 /* HCI handles */ 99#define NFA_HANDLE_GROUP_LOCAL_NDEF 0x0900 /* Local NDEF message handle */ 100#define NFA_HANDLE_GROUP_MASK 0xFF00 101#define NFA_HANDLE_MASK 0x00FF 102 103/* NCI Parameter IDs */ 104typedef UINT8 tNFA_PMID; 105 106/* Definitions for tNFA_TECHNOLOGY_MASK */ 107#define NFA_TECHNOLOGY_MASK_A 0x01 /* NFC Technology A */ 108#define NFA_TECHNOLOGY_MASK_B 0x02 /* NFC Technology B */ 109#define NFA_TECHNOLOGY_MASK_F 0x04 /* NFC Technology F */ 110#define NFA_TECHNOLOGY_MASK_ISO15693 0x08 /* Proprietary Technology */ 111#define NFA_TECHNOLOGY_MASK_B_PRIME 0x10 /* Proprietary Technology */ 112#define NFA_TECHNOLOGY_MASK_KOVIO 0x20 /* Proprietary Technology */ 113#define NFA_TECHNOLOGY_MASK_A_ACTIVE 0x40 /* NFC Technology A active mode */ 114#define NFA_TECHNOLOGY_MASK_F_ACTIVE 0x80 /* NFC Technology F active mode */ 115#define NFA_TECHNOLOGY_MASK_ALL 0xFF /* All supported technologies */ 116typedef UINT8 tNFA_TECHNOLOGY_MASK; 117 118/* Definitions for NFC protocol for RW, CE and P2P APIs */ 119#define NFA_PROTOCOL_T1T NFC_PROTOCOL_T1T /* Type1Tag - NFC-A */ 120#define NFA_PROTOCOL_T2T NFC_PROTOCOL_T2T /* MIFARE/Type2Tag - NFC-A */ 121#define NFA_PROTOCOL_T3T NFC_PROTOCOL_T3T /* Felica/Type3Tag - NFC-F */ 122#define NFA_PROTOCOL_ISO_DEP NFC_PROTOCOL_ISO_DEP /* Type 4A,4B - NFC-A or NFC-B */ 123#define NFA_PROTOCOL_NFC_DEP NFC_PROTOCOL_NFC_DEP /* NFCDEP/LLCP - NFC-A or NFC-F */ 124#define NFA_PROTOCOL_ISO15693 NFC_PROTOCOL_15693 125#define NFA_PROTOCOL_B_PRIME NFC_PROTOCOL_B_PRIME 126#define NFA_PROTOCOL_KOVIO NFC_PROTOCOL_KOVIO 127#define NFA_PROTOCOL_INVALID 0xFF 128#define NFA_MAX_NUM_PROTOCOLS 8 129typedef UINT8 tNFA_NFC_PROTOCOL; 130 131/* Definitions for tNFA_PROTOCOL_MASK */ 132#define NFA_PROTOCOL_MASK_T1T 0x01 /* Type 1 tag */ 133#define NFA_PROTOCOL_MASK_T2T 0x02 /* MIFARE / Type 2 tag */ 134#define NFA_PROTOCOL_MASK_T3T 0x04 /* FeliCa / Type 3 tag */ 135#define NFA_PROTOCOL_MASK_ISO_DEP 0x08 /* ISODEP/4A,4B */ 136#define NFA_PROTOCOL_MASK_NFC_DEP 0x10 /* NFCDEP/LLCP */ 137typedef UINT8 tNFA_PROTOCOL_MASK; 138 139 140/* NFA_DM callback events */ 141#define NFA_DM_ENABLE_EVT 0 /* Result of NFA_Enable */ 142#define NFA_DM_DISABLE_EVT 1 /* Result of NFA_Disable */ 143#define NFA_DM_SET_CONFIG_EVT 2 /* Result of NFA_SetConfig */ 144#define NFA_DM_GET_CONFIG_EVT 3 /* Result of NFA_GetConfig */ 145#define NFA_DM_PWR_MODE_CHANGE_EVT 4 /* Result of NFA_PowerOffSleepMode */ 146#define NFA_DM_RF_FIELD_EVT 5 /* Status of RF Field */ 147#define NFA_DM_NFCC_TIMEOUT_EVT 6 /* NFCC is not responding */ 148#define NFA_DM_NFCC_TRANSPORT_ERR_EVT 7 /* NCI Tranport error */ 149 150#define NFA_T1T_HR_LEN T1T_HR_LEN /* T1T HR length */ 151#define NFA_MAX_UID_LEN TAG_MAX_UID_LEN /* Max UID length of T1/T2 */ 152#define NFA_T1T_UID_LEN T1T_UID_LEN /* T1T UID length */ 153#define NFA_T1T_CMD_UID_LEN T1T_CMD_UID_LEN /* UID len for T1T cmds */ 154#define NFA_T2T_UID_LEN T2T_UID_LEN /* T2T UID length */ 155 156#define NFA_RW_NDEF_FL_READ_ONLY RW_NDEF_FL_READ_ONLY /* Tag is read only */ 157#define NFA_RW_NDEF_FL_FORMATED RW_NDEF_FL_FORMATED /* Tag formated for NDEF */ 158#define NFA_RW_NDEF_FL_SUPPORTED RW_NDEF_FL_SUPPORTED /* NDEF supported by the tag */ 159#define NFA_RW_NDEF_FL_UNKNOWN RW_NDEF_FL_UNKNOWN /* Unable to find if tag is ndef capable/formated/read only */ 160#define NFA_RW_NDEF_FL_FORMATABLE RW_NDEF_FL_FORMATABLE /* Tag supports format operation */ 161#define NFA_RW_NDEF_FL_SOFT_LOCKABLE RW_NDEF_FL_SOFT_LOCKABLE /* Tag can be soft locked */ 162#define NFA_RW_NDEF_FL_HARD_LOCKABLE RW_NDEF_FL_HARD_LOCKABLE /* Tag can be hard locked */ 163#define NFA_RW_NDEF_FL_OTP RW_NDEF_FL_OTP /* Tag is one time programmable */ 164 165typedef UINT8 tNFA_RW_NDEF_FLAG; 166 167/* Data for NFA_DM_SET_CONFIG_EVT */ 168typedef struct 169{ 170 tNFA_STATUS status; /* NFA_STATUS_OK if successful */ 171 UINT8 num_param_id; /* Number of rejected Param ID */ 172 tNFA_PMID param_ids[NFC_MAX_NUM_IDS]; /* Rejected Param ID */ 173} tNFA_SET_CONFIG; 174 175/* Data for NFA_DM_GET_CONFIG_EVT */ 176typedef struct 177{ 178 tNFA_STATUS status; /* NFA_STATUS_OK if successful */ 179 UINT16 tlv_size; /* The length of TLV */ 180 UINT8 param_tlvs[1]; /* TLV (Parameter ID-Len-Value byte stream) */ 181} tNFA_GET_CONFIG; 182 183#define NFA_DM_PWR_MODE_FULL 0x04 184#define NFA_DM_PWR_MODE_OFF_SLEEP 0x00 185 186typedef UINT8 tNFA_DM_PWR_MODE; 187 188/* Data for NFA_DM_PWR_MODE_CHANGE_EVT */ 189typedef struct 190{ 191 tNFA_STATUS status; /* NFA_STATUS_OK if successful */ 192 tNFA_DM_PWR_MODE power_mode; /* NFA_DM_PWR_MODE_FULL or NFA_DM_PWR_MODE_OFF_SLEEP */ 193} tNFA_DM_PWR_MODE_CHANGE; 194 195/* Data for NFA_DM_RF_FIELD_EVT */ 196#define NFA_DM_RF_FIELD_OFF 0x00 197#define NFA_DM_RF_FIELD_ON 0x01 198 199typedef struct 200{ 201 tNFA_STATUS status; /* NFA_STATUS_OK if successful */ 202 UINT8 rf_field_status;/* NFA_DM_RF_FIELD_ON if operating field generated by remote */ 203} tNFA_DM_RF_FIELD; 204 205/* Union of all DM callback structures */ 206typedef union 207{ 208 tNFA_STATUS status; /* NFA_DM_ENABLE_EVT */ 209 tNFA_SET_CONFIG set_config; /* NFA_DM_SET_CONFIG_EVT */ 210 tNFA_GET_CONFIG get_config; /* NFA_DM_GET_CONFIG_EVT */ 211 tNFA_DM_PWR_MODE_CHANGE power_mode; /* NFA_DM_PWR_MODE_CHANGE_EVT */ 212 tNFA_DM_RF_FIELD rf_field; /* NFA_DM_RF_FIELD_EVT */ 213 void *p_vs_evt_data; /* Vendor-specific evt data */ 214} tNFA_DM_CBACK_DATA; 215 216/* NFA_DM callback */ 217typedef void (tNFA_DM_CBACK) (UINT8 event, tNFA_DM_CBACK_DATA *p_data); 218 219 220/* NFA Connection Callback Events */ 221#define NFA_POLL_ENABLED_EVT 0 /* Polling enabled event */ 222#define NFA_POLL_DISABLED_EVT 1 /* Polling disabled event */ 223#define NFA_DISC_RESULT_EVT 2 /* NFC link/protocol discovery notificaiton */ 224#define NFA_SELECT_RESULT_EVT 3 /* NFC link/protocol discovery select response */ 225#define NFA_DEACTIVATE_FAIL_EVT 4 /* NFA_Deactivate failure */ 226#define NFA_ACTIVATED_EVT 5 /* NFC link/protocol activated */ 227#define NFA_DEACTIVATED_EVT 6 /* NFC link/protocol deactivated */ 228#define NFA_TLV_DETECT_EVT 7 /* TLV Detection complete */ 229#define NFA_NDEF_DETECT_EVT 8 /* NDEF Detection complete */ 230#define NFA_DATA_EVT 9 /* Data message received */ 231#define NFA_SELECT_CPLT_EVT 10 /* Select completed */ 232#define NFA_READ_CPLT_EVT 11 /* Read completed */ 233#define NFA_WRITE_CPLT_EVT 12 /* Write completed */ 234#define NFA_LLCP_ACTIVATED_EVT 13 /* LLCP link is activated */ 235#define NFA_LLCP_DEACTIVATED_EVT 14 /* LLCP link is deactivated */ 236#define NFA_PRESENCE_CHECK_EVT 15 /* Response to NFA_RwPresenceCheck */ 237#define NFA_FORMAT_CPLT_EVT 16 /* Tag Formating completed */ 238#define NFA_I93_CMD_CPLT_EVT 17 /* ISO 15693 command completed */ 239#define NFA_SET_TAG_RO_EVT 18 /* Tag set as Read only */ 240#define NFA_EXCLUSIVE_RF_CONTROL_STARTED_EVT 19 /* Result for NFA_RequestExclusiveRfControl */ 241#define NFA_EXCLUSIVE_RF_CONTROL_STOPPED_EVT 20 /* Result for NFA_ReleaseExclusiveRfControl */ 242#define NFA_CE_REGISTERED_EVT 21 /* DH Card emulation: AID or System code reg'd */ 243#define NFA_CE_DEREGISTERED_EVT 22 /* DH Card emulation: AID or System code dereg'd*/ 244#define NFA_CE_DATA_EVT 23 /* DH Card emulation: data received event */ 245#define NFA_CE_ACTIVATED_EVT 24 /* DH Card emulation: activation event */ 246#define NFA_CE_DEACTIVATED_EVT 25 /* DH Card emulation: deactivation event */ 247#define NFA_CE_LOCAL_TAG_CONFIGURED_EVT 26 /* DH Card emulation: local NDEF configured */ 248#define NFA_CE_NDEF_WRITE_START_EVT 27 /* DH Card emulation: NDEF write started */ 249#define NFA_CE_NDEF_WRITE_CPLT_EVT 28 /* DH Card emulation: NDEF write completed */ 250#define NFA_CE_UICC_LISTEN_CONFIGURED_EVT 29 /* UICC Listen configured */ 251#define NFA_RF_DISCOVERY_STARTED_EVT 30 /* RF Discovery started event */ 252#define NFA_RF_DISCOVERY_STOPPED_EVT 31 /* RF Discovery stopped event */ 253#define NFA_UPDATE_RF_PARAM_RESULT_EVT 32 /* status of updating RF communication paramters*/ 254#define NFA_SET_P2P_LISTEN_TECH_EVT 33 /* status of setting P2P listen technologies */ 255#define NFA_RW_INTF_ERROR_EVT 34 /* RF Interface error event */ 256#define NFA_LLCP_FIRST_PACKET_RECEIVED_EVT 35 /* First packet received over LLCP link */ 257#define NFA_LISTEN_ENABLED_EVT 36 /* Listening enabled event */ 258#define NFA_LISTEN_DISABLED_EVT 37 /* Listening disabled event */ 259#define NFA_P2P_PAUSED_EVT 38 /* P2P services paused event */ 260#define NFA_P2P_RESUMED_EVT 39 /* P2P services resumed event */ 261 262/* NFC deactivation type */ 263#define NFA_DEACTIVATE_TYPE_IDLE NFC_DEACTIVATE_TYPE_IDLE 264#define NFA_DEACTIVATE_TYPE_SLEEP NFC_DEACTIVATE_TYPE_SLEEP 265#define NFA_DEACTIVATE_TYPE_DISCOVERY NFC_DEACTIVATE_TYPE_DISCOVERY 266 267typedef UINT8 tNFA_DEACTIVATE_TYPE; 268 269/* Data for NFA_DISC_RESULT_EVT */ 270typedef struct 271{ 272 tNFA_STATUS status; /* NFA_STATUS_OK if successful */ 273 tNFC_RESULT_DEVT discovery_ntf; /* RF discovery notification details */ 274} tNFA_DISC_RESULT; 275 276/* Data for NFA_ACTIVATED_EVT */ 277typedef struct 278{ 279 UINT8 hr[NFA_T1T_HR_LEN]; /* HR of Type 1 tag */ 280 UINT8 uid[NFA_T1T_CMD_UID_LEN]; /* UID used in T1T Commands */ 281} tNFA_T1T_PARAMS; 282 283typedef struct 284{ 285 UINT8 uid[NFA_MAX_UID_LEN]; /* UID of T2T tag */ 286} tNFA_T2T_PARAMS; 287 288typedef struct 289{ 290 UINT8 num_system_codes; /* Number of system codes supporte by tag */ 291 UINT16 *p_system_codes; /* Pointer to list of system codes */ 292} tNFA_T3T_PARAMS; 293 294typedef struct 295{ 296 UINT8 uid[I93_UID_BYTE_LEN]; /* UID[0]:MSB, ... UID[7]:LSB */ 297 UINT8 info_flags; /* information flags */ 298 UINT8 dsfid; /* DSFID if I93_INFO_FLAG_DSFID */ 299 UINT8 afi; /* AFI if I93_INFO_FLAG_AFI */ 300 UINT16 num_block; /* number of blocks if I93_INFO_FLAG_MEM_SIZE */ 301 UINT8 block_size; /* block size in byte if I93_INFO_FLAG_MEM_SIZE */ 302 UINT8 IC_reference; /* IC Reference if I93_INFO_FLAG_IC_REF */ 303} tNFA_I93_PARAMS; 304 305typedef union 306{ 307 tNFA_T1T_PARAMS t1t; /* HR and UID of T1T */ 308 tNFA_T2T_PARAMS t2t; /* UID of T2T */ 309 tNFA_T3T_PARAMS t3t; /* System codes */ 310 tNFA_I93_PARAMS i93; /* System Information of ISO 15693 */ 311} tNFA_TAG_PARAMS; 312 313typedef struct 314{ 315 tNFC_ACTIVATE_DEVT activate_ntf; /* RF discovery activation details */ 316 tNFA_TAG_PARAMS params; /* additional informaiton of tag */ 317} tNFA_ACTIVATED; 318 319/* Data for NFA_DEACTIVATED_EVT */ 320typedef struct 321{ 322 tNFA_DEACTIVATE_TYPE type; /* NFA_DEACTIVATE_TYPE_IDLE or NFA_DEACTIVATE_TYPE_SLEEP */ 323} tNFA_DEACTIVATED; 324 325/* Structure for NFA_NDEF_DETECT_EVT event data */ 326typedef struct 327{ 328 tNFA_STATUS status; /* Status of the ndef detecton */ 329 tNFA_NFC_PROTOCOL protocol; /* protocol used to detect NDEF */ 330 UINT32 max_size; /* max number of bytes available for NDEF data */ 331 UINT32 cur_size; /* current size of stored NDEF data (in bytes) */ 332 tNFA_RW_NDEF_FLAG flags; /* Flags to indicate NDEF capability, is formated, soft/hard lockable, formatable, otp and read only */ 333} tNFA_NDEF_DETECT; 334 335 336/* Structure for NFA_TLV_DETECT_EVT event data */ 337typedef struct 338{ 339 tNFA_STATUS status; /* Status of the tlv detecton */ 340 tNFA_NFC_PROTOCOL protocol; /* protocol used to detect TLV */ 341 UINT8 num_tlvs; /* number of tlvs present in the tag */ 342 UINT8 num_bytes; /* number of lock/reserved bytes */ 343} tNFA_TLV_DETECT; 344 345/* Structure for NFA_DATA_EVT data */ 346typedef struct 347{ 348 tNFA_STATUS status; /* Status of Data received */ 349 UINT8 *p_data; /* Data buffer */ 350 UINT16 len; /* Length of data */ 351} tNFA_RX_DATA; 352 353/* Structure for NFA_CE_NDEF_WRITE_CPLT_EVT data */ 354typedef struct 355{ 356 tNFA_STATUS status; /* Status of the ndef write op */ 357 UINT32 len; /* Update length of NDEF data */ 358 UINT8 *p_data; /* data buffer */ 359} tNFA_CE_NDEF_WRITE_CPLT; 360 361/* Data for NFA_LLCP_ACTIVATED_EVT */ 362typedef struct 363{ 364 BOOLEAN is_initiator; /* TRUE if initiator */ 365 UINT16 remote_wks; /* Well-Known service mask of peer */ 366 UINT8 remote_lsc; /* Link Service Class of peer */ 367 UINT16 remote_link_miu;/* Link MIU of peer */ 368 UINT16 local_link_miu; /* Link MIU of local */ 369} tNFA_LLCP_ACTIVATED; 370 371/* Data for NFA_LLCP_DEACTIVATED_EVT */ 372typedef struct 373{ 374 UINT8 reason; /* reason of deactivation */ 375} tNFA_LLCP_DEACTIVATED; 376 377/* Data for NFA_I93_CMD_CPLT_EVT */ 378typedef struct 379{ 380 UINT8 dsfid; /* DSFID */ 381 UINT8 uid[I93_UID_BYTE_LEN]; /* UID[0]:MSB, ... UID[7]:LSB */ 382} tNFA_I93_INVENTORY; 383 384typedef struct /* RW_I93_SYS_INFO_EVT */ 385{ 386 UINT8 info_flags; /* information flags */ 387 UINT8 uid[I93_UID_BYTE_LEN]; /* UID */ 388 UINT8 dsfid; /* DSFID if I93_INFO_FLAG_DSFID */ 389 UINT8 afi; /* AFI if I93_INFO_FLAG_AFI */ 390 UINT16 num_block; /* number of blocks if I93_INFO_FLAG_MEM_SIZE */ 391 UINT8 block_size; /* block size in byte if I93_INFO_FLAG_MEM_SIZE */ 392 UINT8 IC_reference; /* IC Reference if I93_INFO_FLAG_IC_REF */ 393} tNFA_I93_SYS_INFO; 394 395typedef struct 396{ 397 tNFA_STATUS status; /* Status of sending command */ 398 UINT8 sent_command; /* sent command to tag */ 399 union 400 { 401 UINT8 error_code; /* error code defined in ISO 15693 */ 402 tNFA_I93_INVENTORY inventory; /* inventory response */ 403 tNFA_I93_SYS_INFO sys_info; /* system information */ 404 } params; 405} tNFA_I93_CMD_CPLT; 406 407/* Data for NFA_CE_REGISTERED_EVT */ 408typedef struct 409{ 410 tNFA_STATUS status; /* NFA_STATUS_OK if successful */ 411 tNFA_HANDLE handle; /* handle for NFA_CeRegisterFelicaSystemCodeOnDH () */ 412 /* NFA_CeRegisterT4tAidOnDH () */ 413} tNFA_CE_REGISTERED; 414 415/* Data for NFA_CE_DEREGISTERED_EVT */ 416typedef struct 417{ 418 tNFA_HANDLE handle; /* handle from NFA_CE_REGISTERED_EVT */ 419} tNFA_CE_DEREGISTERED; 420 421/* Data for NFA_CE_ACTIVATED_EVT */ 422typedef struct 423{ 424 tNFA_STATUS status; /* NFA_STATUS_OK if successful */ 425 tNFA_HANDLE handle; /* handle from NFA_CE_REGISTERED_EVT */ 426 tNFC_ACTIVATE_DEVT activate_ntf; /* RF discovery activation details */ 427} tNFA_CE_ACTIVATED; 428 429/* Data for NFA_CE_DEACTIVATED_EVT */ 430typedef struct 431{ 432 tNFA_HANDLE handle; /* handle from NFA_CE_REGISTERED_EVT */ 433 tNFA_DEACTIVATE_TYPE type; /* NFA_DEACTIVATE_TYPE_IDLE or NFA_DEACTIVATE_TYPE_SLEEP */ 434} tNFA_CE_DEACTIVATED; 435 436/* Structure for NFA_CE_DATA_EVT data */ 437typedef struct 438{ 439 tNFA_STATUS status; /* NFA_STATUS_OK if complete packet */ 440 tNFA_HANDLE handle; /* handle from NFA_CE_REGISTERED_EVT */ 441 UINT8 *p_data; /* Data buffer */ 442 UINT16 len; /* Length of data */ 443} tNFA_CE_DATA; 444 445 446/* Union of all connection callback structures */ 447typedef union 448{ 449 tNFA_STATUS status; /* NFA_POLL_ENABLED_EVT */ 450 /* NFA_POLL_DISABLED_EVT */ 451 /* NFA_CE_UICC_LISTEN_CONFIGURED_EVT */ 452 /* NFA_EXCLUSIVE_RF_CONTROL_STARTED_EVT */ 453 /* NFA_EXCLUSIVE_RF_CONTROL_STOPPED_EVT */ 454 /* NFA_SELECT_RESULT_EVT */ 455 /* NFA_DEACTIVATE_FAIL_EVT */ 456 /* NFA_CE_NDEF_WRITE_START_EVT */ 457 /* NFA_SELECT_CPLT_EVT */ 458 /* NFA_READ_CPLT_EVT */ 459 /* NFA_WRITE_CPLT_EVT */ 460 /* NFA_PRESENCE_CHECK_EVT */ 461 /* NFA_FORMAT_CPLT_EVT */ 462 /* NFA_SET_TAG_RO_EVT */ 463 /* NFA_UPDATE_RF_PARAM_RESULT_EVT */ 464 /* NFA_RW_INTF_ERROR_EVT */ 465 tNFA_DISC_RESULT disc_result; /* NFA_DISC_RESULT_EVT */ 466 tNFA_ACTIVATED activated; /* NFA_ACTIVATED_EVT */ 467 tNFA_DEACTIVATED deactivated; /* NFA_DEACTIVATED_EVT */ 468 tNFA_NDEF_DETECT ndef_detect; /* NFA_NDEF_DETECT_EVT */ 469 tNFA_TLV_DETECT tlv_detect; /* NFA_TLV_DETECT_EVT */ 470 tNFA_RX_DATA data; /* NFA_DATA_EVT */ 471 tNFA_CE_NDEF_WRITE_CPLT ndef_write_cplt; /* NFA_CE_NDEF_WRITE_CPLT_EVT */ 472 tNFA_LLCP_ACTIVATED llcp_activated; /* NFA_LLCP_ACTIVATED_EVT */ 473 tNFA_LLCP_DEACTIVATED llcp_deactivated; /* NFA_LLCP_DEACTIVATED_EVT */ 474 tNFA_I93_CMD_CPLT i93_cmd_cplt; /* NFA_I93_CMD_CPLT_EVT */ 475 tNFA_CE_REGISTERED ce_registered; /* NFA_CE_REGISTERED_EVT */ 476 tNFA_CE_DEREGISTERED ce_deregistered; /* NFA_CE_DEREGISTERED_EVT */ 477 tNFA_CE_ACTIVATED ce_activated; /* NFA_CE_ACTIVATED_EVT */ 478 tNFA_CE_DEACTIVATED ce_deactivated; /* NFA_CE_DEACTIVATED_EVT */ 479 tNFA_CE_DATA ce_data; /* NFA_CE_DATA_EVT */ 480 481} tNFA_CONN_EVT_DATA; 482 483/* NFA Connection Callback */ 484typedef void (tNFA_CONN_CBACK) (UINT8 event, tNFA_CONN_EVT_DATA *p_data); 485 486#ifndef NFA_DM_NUM_INTERFACE_MAP 487#define NFA_DM_NUM_INTERFACE_MAP 3 488#endif 489 490/* compile-time configuration structure for the RF Discovery Frequency for each technology */ 491typedef struct 492{ 493 UINT8 pa; /* Frequency for NFC Technology A */ 494 UINT8 pb; /* Frequency for NFC Technology B */ 495 UINT8 pf; /* Frequency for NFC Technology F */ 496 UINT8 pi93; /* Frequency for Proprietary Technology/15693 */ 497 UINT8 pbp; /* Frequency for Proprietary Technology/B-Prime */ 498 UINT8 pk; /* Frequency for Proprietary Technology/Kovio */ 499 UINT8 paa; /* Frequency for NFC Technology A active mode */ 500 UINT8 pfa; /* Frequency for NFC Technology F active mode */ 501} tNFA_DM_DISC_FREQ_CFG; 502 503/* definitions for tNFA_DM_CFG.presence_check_option */ 504#define NFA_DM_PCO_ISO_SLEEP_WAKE 0x01 /* if NDEF is not supported by the tag, use sleep/wake(last interface) */ 505#define NFA_DM_PCO_EMPTY_I_BLOCK 0x02 /* NFA_SendRawFrame() has been used, use empty I block for presence check 506 * if this bit is not set, use read-binary on channel 3 for presence check */ 507 508/* compile-time configuration structure */ 509typedef struct 510{ 511 BOOLEAN auto_detect_ndef; /* Automatic NDEF detection (when not in exclusive RF mode) */ 512 BOOLEAN auto_read_ndef; /* Automatic NDEF read (when not in exclusive RF mode) */ 513 BOOLEAN auto_presence_check; /* Automatic presence check */ 514 UINT8 presence_check_option; /* Use sleep/wake(last interface) for ISODEP presence check */ 515 UINT16 presence_check_timeout; /* Maximum time to wait for presence check response */ 516} tNFA_DM_CFG; 517 518/* compile-time configuration structure for HCI */ 519typedef struct 520{ 521 UINT16 hci_netwk_enable_timeout; /* Maximum idle(no HCP Pkt) time to wait for EE DISC REQ Ntf(s) */ 522 UINT16 hcp_response_timeout; /* Maximum time to wait for EE DISC REQ NTF(s) after HOT PLUG EVT(s) */ 523 UINT8 num_whitelist_host; /* Number of host in the whitelist of Terminal host */ 524 UINT8 *p_whitelist; /* Whitelist of Terminal Host */ 525} tNFA_HCI_CFG; 526 527/* 528** Exclusive RF mode listen configuration 529*/ 530 531#define NFA_LB_MAX_NFCID0_LEN 4 532#define NFA_LF_MAX_SC_NFCID2 1 533#define NFA_LA_MAX_HIST_BYTES 15 534#define NFA_LB_MAX_H_INFO_LEN 15 535 536typedef struct 537{ 538 /* 539 ** Discovery Configuration Parameters for Listen A 540 */ 541 BOOLEAN la_enable; /* TRUE if listening A */ 542 UINT8 la_bit_frame_sdd; /* Bit Frame SDD in Byte 1 of SENS_RES */ 543 UINT8 la_platform_config; /* Platform Config in Byte 2 of SENS_RES */ 544 UINT8 la_sel_info; /* Byte of SEL_RES */ 545 UINT8 la_nfcid1_len; /* NFCID1 (0, 4, 7 or 10 bytes) */ 546 UINT8 la_nfcid1[NCI_NFCID1_MAX_LEN]; /* if empty, NFCC will decide */ 547 548 /* 549 ** Discovery Configuration Parameters for Listen B 550 */ 551 BOOLEAN lb_enable; /* TRUE if listening B */ 552 UINT8 lb_sensb_info; /* Byte 2 of Protocol Info within SENSB_RES */ 553 UINT8 lb_nfcid0_len; /* NFCID0 (0, 1 or 4 bytes) */ 554 UINT8 lb_nfcid0[NFA_LB_MAX_NFCID0_LEN]; /* if empty, NFCC will decide */ 555 UINT8 lb_app_data[NCI_PARAM_LEN_LB_APPDATA];/* Bytes 6 - 9 in SENSB_RES */ 556 UINT8 lb_sfgi; /* Start-Up Frame Guard Time */ 557 UINT8 lb_adc_fo; /* Byte 12 in SENSB_RES */ 558 559 /* 560 ** Discovery Configuration Parameters for Listen F 561 */ 562 BOOLEAN lf_enable; /* TRUE if listening F */ 563 UINT8 lf_con_bitr_f; /* bit rate to listen */ 564 UINT8 lf_protocol_type; /* Supported Protocols */ 565 UINT16 lf_t3t_flags; /* bit field indicating which lf_t3t_identifier are enabled */ 566 UINT8 lf_t3t_identifier[NFA_LF_MAX_SC_NFCID2][NCI_SYSTEMCODE_LEN + NCI_NFCID2_LEN]; 567 /* System Code and NFCID2 */ 568 UINT8 lf_t3t_pmm[NCI_T3T_PMM_LEN]; /* Bytes 10 - 17 in SENSF_RES */ 569 570 /* 571 ** Discovery Configuration Parameters for Listen ISO-DEP 572 */ 573 BOOLEAN li_enable; /* TRUE if listening ISO-DEP */ 574 UINT8 li_fwi; /* Frame Waiting Time Integer */ 575 UINT8 la_hist_bytes_len; /* historical bytes for Listen-A */ 576 UINT8 la_hist_bytes[NFA_LA_MAX_HIST_BYTES]; 577 UINT8 lb_h_info_resp_len; /* higher layer response for Listen-B */ 578 UINT8 lb_h_info_resp[NFA_LB_MAX_H_INFO_LEN]; 579 580 /* 581 ** Discovery Configuration Parameters for Listen NFC-DEP 582 */ 583 BOOLEAN ln_enable; /* TRUE if listening NFC-DEP */ 584 UINT8 ln_wt; /* Waiting Time Integer */ 585 UINT8 ln_atr_res_gen_bytes_len; /* General bytes in ATR_RES */ 586 UINT8 ln_atr_res_gen_bytes[NCI_MAX_GEN_BYTES_LEN]; 587 UINT8 ln_atr_res_config; /* Optional parameters (PPt) in ATR_RES */ 588} tNFA_LISTEN_CFG; 589 590/* Data for NFA_UpdateRFCommParams () */ 591typedef tNFC_RF_COMM_PARAMS tNFA_RF_COMM_PARAMS; 592 593/* RF Interface type */ 594#define NFA_INTERFACE_FRAME NFC_INTERFACE_FRAME 595#define NFA_INTERFACE_ISO_DEP NFC_INTERFACE_ISO_DEP 596#define NFA_INTERFACE_NFC_DEP NFC_INTERFACE_NFC_DEP 597typedef tNFC_INTF_TYPE tNFA_INTF_TYPE; 598 599/******************************************************************************* 600** NDEF Definitions 601*******************************************************************************/ 602 603/* Definitions for tNFA_TNF (NDEF type name format ID) */ 604#define NFA_TNF_EMPTY NDEF_TNF_EMPTY /* Empty or no type specified */ 605#define NFA_TNF_WKT NDEF_TNF_WKT /* NFC Forum well-known type [NFC RTD] */ 606#define NFA_TNF_RFC2046_MEDIA NDEF_TNF_MEDIA /* Media-type as defined in RFC 2046 [RFC 2046] */ 607#define NFA_TNF_RFC3986_URI NDEF_TNF_URI /* Absolute URI as defined in RFC 3986 [RFC 3986] */ 608#define NFA_TNF_EXTERNAL NDEF_TNF_EXT /* NFC Forum external type [NFC RTD] */ 609#define NFA_TNF_UNKNOWN NDEF_TNF_UNKNOWN /* Unknown */ 610#define NFA_TNF_UNCHANGED NDEF_TNF_UNCHANGED /* Unchanged */ 611#define NFA_TNF_RESERVED NDEF_TNF_RESERVED /* Reserved */ 612#define NFA_TNF_DEFAULT 0xFF /* Used to register default NDEF type handler */ 613typedef UINT8 tNFA_TNF; 614 615/* Definitions for tNFA_NDEF_URI_ID (Frequently used prefixes. For additional values, see [NFC RTD URI] */ 616#define NFA_NDEF_URI_ID_ABSOLUTE 0x00 /* Unabridged URI. */ 617#define NFA_NDEF_URI_ID_HTTP 0x03 /* http:// */ 618#define NFA_NDEF_URI_ID_HTTPS 0x04 /* https:// */ 619#define NFA_NDEF_URI_ID_TEL 0x05 /* tel: */ 620#define NFA_NDEF_URI_ID_MAILTO 0x06 /* mailto: */ 621#define NFA_NDEF_URI_ID_FTP 0x0D /* ftp:// */ 622#define NFA_NDEF_URI_ID_FILE 0x1D /* file:// */ 623 624typedef UINT8 tNFA_NDEF_URI_ID; 625 626/* Events for tNFA_NDEF_CBACK */ 627#define NFA_NDEF_REGISTER_EVT 0 /* NDEF record type registered. (In response to NFA_RegisterNDefTypeHandler) */ 628#define NFA_NDEF_DATA_EVT 1 /* Received an NDEF message with the registered type. See [tNFA_NDEF_DATA] */ 629typedef UINT8 tNFA_NDEF_EVT; 630 631/* Structure for NFA_NDEF_REGISTER_EVT event data */ 632typedef struct 633{ 634 tNFA_STATUS status; /* Status of the registration */ 635 tNFA_HANDLE ndef_type_handle; /* Handle for this NDEF type registration. */ 636} tNFA_NDEF_REGISTER; 637 638/* Structure for NFA_NDEF_DATA_EVT event data */ 639typedef struct 640{ 641 tNFA_HANDLE ndef_type_handle; /* Handle for NDEF type registration. */ 642 UINT8 *p_data; /* Data buffer */ 643 UINT32 len; /* Length of data */ 644} tNFA_NDEF_DATA; 645 646/* Union of all NDEF callback structures */ 647typedef union 648{ 649 tNFA_NDEF_REGISTER ndef_reg; /* Structure for NFA_NDEF_REGISTER_EVT event data */ 650 tNFA_NDEF_DATA ndef_data; /* Structure for NFA_NDEF_DATA_EVT event data */ 651} tNFA_NDEF_EVT_DATA; 652 653/* NFA_NDEF callback */ 654typedef void (tNFA_NDEF_CBACK) (tNFA_NDEF_EVT event, tNFA_NDEF_EVT_DATA *p_data); 655 656/* NFA VSC Callback */ 657typedef void (tNFA_VSC_CBACK)(UINT8 event, UINT16 param_len, UINT8 *p_param); 658 659 660/***************************************************************************** 661** External Function Declarations 662*****************************************************************************/ 663#ifdef __cplusplus 664extern "C" 665{ 666#endif 667 668/******************************************************************************* 669** 670** Function NFA_Init 671** 672** Description This function initializes control blocks for NFA 673** 674** p_hal_entry_tbl points to a table of HAL entry points 675** 676** NOTE: the buffer that p_hal_entry_tbl points must be 677** persistent until NFA is disabled. 678** 679** 680** Returns none 681** 682*******************************************************************************/ 683NFC_API extern void NFA_Init (tHAL_NFC_ENTRY *p_hal_entry_tbl); 684 685/******************************************************************************* 686** 687** Function NFA_Enable 688** 689** Description This function enables NFC. Prior to calling NFA_Enable, 690** the NFCC must be powered up, and ready to receive commands. 691** This function enables the tasks needed by NFC, opens the NCI 692** transport, resets the NFC controller, downloads patches to 693** the NFCC (if necessary), and initializes the NFC subsystems. 694** 695** This function should only be called once - typically when NFC 696** is enabled during boot-up, or when NFC is enabled from a 697** settings UI. Subsequent calls to NFA_Enable while NFA is 698** enabling or enabled will be ignored. When the NFC startup 699** procedure is completed, an NFA_DM_ENABLE_EVT is returned to the 700** application using the tNFA_DM_CBACK. 701** 702** The tNFA_CONN_CBACK parameter is used to register a callback 703** for polling, p2p and card emulation events. 704** 705** 706** Returns NFA_STATUS_OK if successfully initiated 707** NFA_STATUS_FAILED otherwise 708** 709*******************************************************************************/ 710NFC_API extern tNFA_STATUS NFA_Enable (tNFA_DM_CBACK *p_dm_cback, 711 tNFA_CONN_CBACK *p_conn_cback); 712 713/******************************************************************************* 714** 715** Function NFA_Disable 716** 717** Description This function is called to shutdown NFC. The tasks for NFC 718** are terminated, and clean up routines are performed. This 719** function is typically called during platform shut-down, or 720** when NFC is disabled from a settings UI. When the NFC 721** shutdown procedure is completed, an NFA_DM_DISABLE_EVT is 722** returned to the application using the tNFA_DM_CBACK. 723** 724** The platform should wait until the NFC_DISABLE_REVT is 725** received before powering down the NFC chip and NCI transport. 726** This is required to so that NFA can gracefully shut down any 727** open connections. 728** 729** Returns NFA_STATUS_OK if successfully initiated 730** NFA_STATUS_FAILED otherwise 731** 732*******************************************************************************/ 733NFC_API extern tNFA_STATUS NFA_Disable (BOOLEAN graceful); 734 735/******************************************************************************* 736** 737** Function NFA_SetConfig 738** 739** Description Set the configuration parameters to NFCC. The result is 740** reported with an NFA_DM_SET_CONFIG_EVT in the tNFA_DM_CBACK 741** callback. 742** 743** Note: If RF discovery is started, NFA_StopRfDiscovery()/NFA_RF_DISCOVERY_STOPPED_EVT 744** should happen before calling this function. Most Configuration 745** parameters are related to RF discovery. 746** 747** Returns NFA_STATUS_OK if successfully initiated 748** NFA_STATUS_BUSY if previous setting is on-going 749** NFA_STATUS_FAILED otherwise 750** 751*******************************************************************************/ 752NFC_API extern tNFA_STATUS NFA_SetConfig (tNFA_PMID param_id, 753 UINT8 length, 754 UINT8 *p_data); 755 756/******************************************************************************* 757** 758** Function NFA_GetConfig 759** 760** Description Get the configuration parameters from NFCC. The result is 761** reported with an NFA_DM_GET_CONFIG_EVT in the tNFA_DM_CBACK 762** callback. 763** 764** Returns NFA_STATUS_OK if successfully initiated 765** NFA_STATUS_FAILED otherwise 766** 767*******************************************************************************/ 768NFC_API extern tNFA_STATUS NFA_GetConfig (UINT8 num_ids, tNFA_PMID *p_param_ids); 769 770/******************************************************************************* 771** 772** Function NFA_RequestExclusiveRfControl 773** 774** Description Request exclusive control of NFC. 775** - Previous behavior (polling/tag reading, DH card emulation) 776** will be suspended . 777** - Polling and listening will be done based on the specified 778** params 779** 780** The NFA_EXCLUSIVE_RF_CONTROL_STARTED_EVT event of 781** tNFA_CONN_CBACK indicates the status of the operation. 782** 783** NFA_ACTIVATED_EVT and NFA_DEACTIVATED_EVT indicates link 784** activation/deactivation. 785** 786** NFA_SendRawFrame is used to send data to the peer. NFA_DATA_EVT 787** indicates data from the peer. 788** 789** If a tag is activated, then the NFA_RW APIs may be used to 790** send commands to the tag. Incoming NDEF messages are sent to 791** the NDEF callback. 792** 793** Once exclusive RF control has started, NFA will not activate 794** LLCP internally. The application has exclusive control of 795** the link. 796** 797** Note: If RF discovery is started, NFA_StopRfDiscovery()/NFA_RF_DISCOVERY_STOPPED_EVT 798** should happen before calling this function 799** 800** Returns NFA_STATUS_OK if successfully initiated 801** NFA_STATUS_FAILED otherwise 802** 803*******************************************************************************/ 804NFC_API extern tNFA_STATUS NFA_RequestExclusiveRfControl (tNFA_TECHNOLOGY_MASK poll_mask, 805 tNFA_LISTEN_CFG *p_listen_cfg, 806 tNFA_CONN_CBACK *p_conn_cback, 807 tNFA_NDEF_CBACK *p_ndef_cback); 808 809/******************************************************************************* 810** 811** Function NFA_ReleaseExclusiveRfControl 812** 813** Description Release exclusive control of NFC. Once released, behavior 814** prior to obtaining exclusive RF control will resume. 815** 816Note?? 817** Returns NFA_STATUS_OK if successfully initiated 818** NFA_STATUS_FAILED otherwise 819** 820*******************************************************************************/ 821NFC_API extern tNFA_STATUS NFA_ReleaseExclusiveRfControl (void); 822 823/******************************************************************************* 824** 825** Function NFA_EnablePolling 826** 827** Description Enable polling for technologies specified by poll_mask. 828** 829** The following events (notified using the connection 830** callback registered with NFA_Enable) are generated during 831** polling: 832** 833** - NFA_POLL_ENABLED_EVT indicates whether or not polling 834** successfully enabled. 835** - NFA_DISC_RESULT_EVT indicates there are more than one devices, 836** so application must select one of tags by calling NFA_Select(). 837** - NFA_SELECT_RESULT_EVT indicates whether previous selection was 838** successful or not. If it was failed then application must select 839** again or deactivate by calling NFA_Deactivate(). 840** - NFA_ACTIVATED_EVT is generated when an NFC link is activated. 841** - NFA_NDEF_DETECT_EVT is generated if tag is activated 842** - NFA_LLCP_ACTIVATED_EVT/NFA_LLCP_DEACTIVATED_EVT is generated 843** if NFC-DEP is activated 844** - NFA_DEACTIVATED_EVT will be returned after deactivating NFC link. 845** 846** Note: If RF discovery is started, NFA_StopRfDiscovery()/NFA_RF_DISCOVERY_STOPPED_EVT 847** should happen before calling this function 848** 849** Returns NFA_STATUS_OK if successfully initiated 850** NFA_STATUS_FAILED otherwise 851** 852*******************************************************************************/ 853NFC_API extern tNFA_STATUS NFA_EnablePolling (tNFA_TECHNOLOGY_MASK poll_mask); 854 855/******************************************************************************* 856** 857** Function NFA_DisablePolling 858** 859** Description Disable polling 860** NFA_POLL_DISABLED_EVT will be returned after stopping polling. 861** 862** Note: If RF discovery is started, NFA_StopRfDiscovery()/NFA_RF_DISCOVERY_STOPPED_EVT 863** should happen before calling this function 864** 865** Returns NFA_STATUS_OK if successfully initiated 866** NFA_STATUS_FAILED otherwise 867** 868*******************************************************************************/ 869NFC_API extern tNFA_STATUS NFA_DisablePolling (void); 870 871/******************************************************************************* 872** 873** Function NFA_EnableListening 874** 875** Description Enable listening. 876** NFA_LISTEN_ENABLED_EVT will be returned after listening is allowed. 877** 878** The actual listening technologies are specified by other NFA 879** API functions. Such functions include (but not limited to) 880** NFA_CeConfigureUiccListenTech. 881** If NFA_DisableListening () is called to ignore the listening technologies, 882** NFA_EnableListening () is called to restore the listening technologies 883** set by these functions. 884** 885** Note: If RF discovery is started, NFA_StopRfDiscovery()/NFA_RF_DISCOVERY_STOPPED_EVT 886** should happen before calling this function 887** 888** Returns NFA_STATUS_OK if successfully initiated 889** NFA_STATUS_FAILED otherwise 890** 891*******************************************************************************/ 892NFC_API extern tNFA_STATUS NFA_EnableListening (void); 893 894/******************************************************************************* 895** 896** Function NFA_DisableListening 897** 898** Description Disable listening 899** NFA_LISTEN_DISABLED_EVT will be returned after stopping listening. 900** This function is called to exclude listen at RF discovery. 901** 902** Note: If RF discovery is started, NFA_StopRfDiscovery()/NFA_RF_DISCOVERY_STOPPED_EVT 903** should happen before calling this function 904** 905** Returns NFA_STATUS_OK if successfully initiated 906** NFA_STATUS_FAILED otherwise 907** 908*******************************************************************************/ 909NFC_API extern tNFA_STATUS NFA_DisableListening (void); 910 911/******************************************************************************* 912** 913** Function NFA_PauseP2p 914** 915** Description Pause P2P services. 916** NFA_P2P_PAUSED_EVT will be returned after P2P services are 917** disabled. 918** 919** The P2P services enabled by NFA_P2p* API functions are not 920** available. NFA_ResumeP2p() is called to resume the P2P 921** services. 922** 923** Note: If RF discovery is started, NFA_StopRfDiscovery()/NFA_RF_DISCOVERY_STOPPED_EVT 924** should happen before calling this function 925** 926** Returns NFA_STATUS_OK if successfully initiated 927** NFA_STATUS_FAILED otherwise 928** 929*******************************************************************************/ 930NFC_API extern tNFA_STATUS NFA_PauseP2p (void); 931 932/******************************************************************************* 933** 934** Function NFA_ResumeP2p 935** 936** Description Resume P2P services. 937** NFA_P2P_RESUMED_EVT will be returned after P2P services are. 938** enables again. 939** 940** Note: If RF discovery is started, NFA_StopRfDiscovery()/NFA_RF_DISCOVERY_STOPPED_EVT 941** should happen before calling this function 942** 943** Returns NFA_STATUS_OK if successfully initiated 944** NFA_STATUS_FAILED otherwise 945** 946*******************************************************************************/ 947NFC_API extern tNFA_STATUS NFA_ResumeP2p (void); 948 949/******************************************************************************* 950** 951** Function NFA_SetP2pListenTech 952** 953** Description This function is called to set listen technology for NFC-DEP. 954** This funtion may be called before or after starting any server 955** on NFA P2P/CHO/SNEP. 956** If there is no technology for NFC-DEP, P2P listening will be 957** stopped. 958** 959** NFA_SET_P2P_LISTEN_TECH_EVT without data will be returned. 960** 961** Note: If RF discovery is started, NFA_StopRfDiscovery()/NFA_RF_DISCOVERY_STOPPED_EVT 962** should happen before calling this function 963** 964** Returns NFA_STATUS_OK if successfully initiated 965** NFA_STATUS_FAILED otherwise 966** 967*******************************************************************************/ 968NFC_API extern tNFA_STATUS NFA_SetP2pListenTech (tNFA_TECHNOLOGY_MASK tech_mask); 969 970/******************************************************************************* 971** 972** Function NFA_StartRfDiscovery 973** 974** Description Start RF discovery 975** RF discovery parameters shall be set by other APIs. 976** 977** An NFA_RF_DISCOVERY_STARTED_EVT indicates whether starting was successful or not. 978** 979** Returns NFA_STATUS_OK if successfully initiated 980** NFA_STATUS_FAILED otherwise 981** 982*******************************************************************************/ 983NFC_API extern tNFA_STATUS NFA_StartRfDiscovery (void); 984 985/******************************************************************************* 986** 987** Function NFA_StopRfDiscovery 988** 989** Description Stop RF discovery 990** 991** An NFA_RF_DISCOVERY_STOPPED_EVT indicates whether stopping was successful or not. 992** 993** Returns NFA_STATUS_OK if successfully initiated 994** NFA_STATUS_FAILED otherwise 995** 996*******************************************************************************/ 997NFC_API extern tNFA_STATUS NFA_StopRfDiscovery (void); 998 999/******************************************************************************* 1000** 1001** Function NFA_SetRfDiscoveryDuration 1002** 1003** Description Set the duration of the single discovery period in [ms]. 1004** Allowable range: 0 ms to 0xFFFF ms. 1005** 1006** Note: If discovery is already started, the application should 1007** call NFA_StopRfDiscovery prior to calling 1008** NFA_SetRfDiscoveryDuration, and then call 1009** NFA_StartRfDiscovery afterwards to restart discovery using 1010** the new duration. 1011** 1012** Returns: 1013** NFA_STATUS_OK, if command accepted 1014** NFA_STATUS_FAILED: otherwise 1015** 1016*******************************************************************************/ 1017NFC_API extern tNFA_STATUS NFA_SetRfDiscoveryDuration (UINT16 discovery_period_ms); 1018 1019/******************************************************************************* 1020** 1021** Function NFA_Select 1022** 1023** Description Select one from detected devices by NFA_DISC_RESULT_EVT after the 1024** last discovery result is received. 1025** An NFA_SELECT_RESULT_EVT indicates whether selection was successful or not. 1026** If failed then application must select again or deactivate by NFA_Deactivate (). 1027** 1028** Returns NFA_STATUS_OK if successfully initiated 1029** NFA_STATUS_INVALID_PARAM if RF interface is not matched protocol 1030** NFA_STATUS_FAILED otherwise 1031** 1032*******************************************************************************/ 1033NFC_API extern tNFA_STATUS NFA_Select (UINT8 rf_disc_id, 1034 tNFA_NFC_PROTOCOL protocol, 1035 tNFA_INTF_TYPE rf_interface); 1036 1037/******************************************************************************* 1038** 1039** Function NFA_UpdateRFCommParams 1040** 1041** Description This function is called to update RF Communication parameters 1042** once the Frame RF Interface has been activated. 1043** 1044** An NFA_UPDATE_RF_PARAM_RESULT_EVT indicates whether updating 1045** was successful or not. 1046** 1047** Returns NFA_STATUS_OK if successfully initiated 1048** NFA_STATUS_FAILED otherwise 1049** 1050*******************************************************************************/ 1051NFC_API extern tNFA_STATUS NFA_UpdateRFCommParams (tNFA_RF_COMM_PARAMS *p_params); 1052 1053/******************************************************************************* 1054** 1055** Function NFA_Deactivate 1056** 1057** Description 1058** If sleep_mode=TRUE: 1059** Deselect the activated device by deactivating into sleep mode. 1060** 1061** An NFA_DEACTIVATE_FAIL_EVT indicates that selection was not successful. 1062** Application can select another discovered device or deactivate by NFA_Deactivate () 1063** after receiving NFA_DEACTIVATED_EVT. 1064** 1065** Deactivating to sleep mode is not allowed when NFCC is in wait-for-host-select 1066** mode, or in listen-sleep states; NFA will deactivate to idle or discovery state 1067** for these cases respectively. 1068** 1069** 1070** If sleep_mode=FALSE: 1071** Deactivate the connection (e.g. as a result of presence check failure) 1072** NFA_DEACTIVATED_EVT will indicate that link is deactivated. 1073** Polling/listening will resume (unless the nfcc is in wait_for-all-discoveries state) 1074** 1075** 1076** Returns NFA_STATUS_OK if successfully initiated 1077** NFA_STATUS_FAILED otherwise 1078** 1079*******************************************************************************/ 1080NFC_API extern tNFA_STATUS NFA_Deactivate (BOOLEAN sleep_mode); 1081 1082/******************************************************************************* 1083** 1084** Function NFA_SendRawFrame 1085** 1086** Description Send a raw frame over the activated interface with the NFCC. 1087** This function can only be called after NFC link is activated. 1088** 1089** If the activated interface is a tag and auto-presence check is 1090** enabled then presence_check_start_delay can be used to indicate 1091** the delay in msec after which the next auto presence check 1092** command can be sent. NFA_DM_DEFAULT_PRESENCE_CHECK_START_DELAY 1093** can be used as the default value for the delay. 1094** 1095** Returns NFA_STATUS_OK if successfully initiated 1096** NFA_STATUS_FAILED otherwise 1097** 1098*******************************************************************************/ 1099NFC_API extern tNFA_STATUS NFA_SendRawFrame (UINT8 *p_raw_data, 1100 UINT16 data_len, 1101 UINT16 presence_check_start_delay); 1102 1103/******************************************************************************* 1104** NDEF APIs 1105*******************************************************************************/ 1106 1107/******************************************************************************* 1108** 1109** Function NFA_RegisterNDefTypeHandler 1110** 1111** Description This function allows the applications to register for 1112** specific types of NDEF records. When NDEF records are 1113** received, NFA will parse the record-type field, and pass 1114** the record to the registered tNFA_NDEF_CBACK. 1115** 1116** For records types which were not registered, the record will 1117** be sent to the default handler. A default type-handler may 1118** be registered by calling this NFA_RegisterNDefTypeHandler 1119** with tnf=NFA_TNF_DEFAULT. In this case, all un-registered 1120** record types will be sent to the callback. Only one default 1121** handler may be registered at a time. 1122** 1123** An NFA_NDEF_REGISTER_EVT will be sent to the tNFA_NDEF_CBACK 1124** to indicate that registration was successful, and provide a 1125** handle for this record type. 1126** 1127** 1128** Returns NFA_STATUS_OK if successfully initiated 1129** NFA_STATUS_FAILED otherwise 1130** 1131*******************************************************************************/ 1132NFC_API extern tNFA_STATUS NFA_RegisterNDefTypeHandler (BOOLEAN handle_whole_message, 1133 tNFA_TNF tnf, 1134 UINT8 *p_type_name, 1135 UINT8 type_name_len, 1136 tNFA_NDEF_CBACK *p_ndef_cback); 1137 1138/******************************************************************************* 1139** 1140** Function NFA_RegisterNDefUriHandler 1141** 1142** Description This API is a special-case of NFA_RegisterNDefTypeHandler 1143** with TNF=NFA_TNF_WKT, and type_name='U' (URI record); and allows 1144** registering for specific URI types (e.g. 'tel:' or 'mailto:'). 1145** 1146** An NFA_NDEF_REGISTER_EVT will be sent to the tNFA_NDEF_CBACK 1147** to indicate that registration was successful, and provide a 1148** handle for this registration. 1149** 1150** If uri_id=NFA_NDEF_URI_ID_ABSOLUTE, then p_abs_uri contains the 1151** unabridged URI. For all other uri_id values, the p_abs_uri 1152** parameter is ignored (i.e the URI prefix is implied by uri_id). 1153** See [NFC RTD URI] for more information. 1154** 1155** Returns NFA_STATUS_OK if successfully initiated 1156** NFA_STATUS_FAILED otherwise 1157** 1158*******************************************************************************/ 1159NFC_API extern tNFA_STATUS NFA_RegisterNDefUriHandler (BOOLEAN handle_whole_message, 1160 tNFA_NDEF_URI_ID uri_id, 1161 UINT8 *p_abs_uri, 1162 UINT8 uri_id_len, 1163 tNFA_NDEF_CBACK *p_ndef_cback); 1164 1165 1166/******************************************************************************* 1167** 1168** Function NFA_DeregisterNDefTypeHandler 1169** 1170** Description Deregister NDEF record type handler. 1171** 1172** Returns NFA_STATUS_OK if successfully initiated 1173** NFA_STATUS_FAILED otherwise 1174** 1175*******************************************************************************/ 1176NFC_API extern tNFA_STATUS NFA_DeregisterNDefTypeHandler (tNFA_HANDLE ndef_type_handle); 1177 1178 1179/******************************************************************************* 1180** 1181** Function NFA_PowerOffSleepMode 1182** 1183** Description This function is called to enter or leave NFCC Power Off Sleep mode 1184** NFA_DM_PWR_MODE_CHANGE_EVT will be sent to indicate status. 1185** 1186** start_stop : TRUE if entering Power Off Sleep mode 1187** FALSE if leaving Power Off Sleep mode 1188** 1189Note?? 1190** Returns NFA_STATUS_OK if successfully initiated 1191** NFA_STATUS_FAILED otherwise 1192** 1193*******************************************************************************/ 1194NFC_API extern tNFA_STATUS NFA_PowerOffSleepMode (BOOLEAN start_stop); 1195 1196/******************************************************************************* 1197** 1198** Function NFA_RegVSCback 1199** 1200** Description This function is called to register or de-register a callback 1201** function to receive Proprietary NCI response and notification 1202** events. 1203** The maximum number of callback functions allowed is NFC_NUM_VS_CBACKS 1204** 1205** Returns tNFC_STATUS 1206** 1207*******************************************************************************/ 1208NFC_API extern tNFC_STATUS NFA_RegVSCback (BOOLEAN is_register, 1209 tNFA_VSC_CBACK *p_cback); 1210 1211/******************************************************************************* 1212** 1213** Function NFA_SendVsCommand 1214** 1215** Description This function is called to send an NCI Vendor Specific 1216** command to NFCC. 1217** 1218** oid - The opcode of the VS command. 1219** cmd_params_len - The command parameter len 1220** p_cmd_params - The command parameter 1221** p_cback - The callback function to receive the command 1222** status 1223** 1224** Returns NFA_STATUS_OK if successfully initiated 1225** NFA_STATUS_FAILED otherwise 1226** 1227*******************************************************************************/ 1228NFC_API extern tNFA_STATUS NFA_SendVsCommand (UINT8 oid, 1229 UINT8 cmd_params_len, 1230 UINT8 *p_cmd_params, 1231 tNFA_VSC_CBACK *p_cback); 1232 1233/******************************************************************************* 1234** 1235** Function NFA_SetTraceLevel 1236** 1237** Description This function sets the trace level for NFA. If called with 1238** a value of 0xFF, it simply returns the current trace level. 1239** 1240** Returns The new or current trace level 1241** 1242*******************************************************************************/ 1243NFC_API extern UINT8 NFA_SetTraceLevel (UINT8 new_level); 1244 1245 1246#ifdef __cplusplus 1247} 1248#endif 1249 1250#endif /* NFA_API_H */ 1251 1252