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