nfc_api.h revision 63f80ce896f0f8c203191b4e44e038fecb6be02a
1/******************************************************************************
2**
3** File:         nfc_api.h
4**
5** Description:   This file contains the Near Field Communication (NFC)
6**                API function external definitions.
7**
8**                The NFC consists of several management entities:
9**                     1. Device Control - controls the local device
10**                     2. Device Discovery - manages discover database
11**                     3. Data Channels - manages connections
12**
13** Copyright (c) 2009-2012  Broadcom Corp.  All Rights Reserved.
14** Broadcom Bluetooth Core. Proprietary and confidential.
15**
16******************************************************************************/
17
18#ifndef NFC_API_H
19#define NFC_API_H
20
21#include "nci_defs.h"
22#include "gki.h"
23
24/* NFC application return status codes */
25#define NFC_STATUS_OK                   NCI_STATUS_OK                   /* Command succeeded    */
26#define NFC_STATUS_REJECTED             NCI_STATUS_REJECTED             /* Command is rejected. */
27#define NFC_STATUS_MSG_CORRUPTED        NCI_STATUS_MESSAGE_CORRUPTED    /* Message is corrupted */
28#define NFC_STATUS_BUFFER_FULL          NCI_STATUS_BUFFER_FULL          /* buffer full          */
29#define NFC_STATUS_FAILED               NCI_STATUS_FAILED               /* failed               */
30#define NFC_STATUS_NOT_INITIALIZED      NCI_STATUS_NOT_INITIALIZED      /* not initialized      */
31#define NFC_STATUS_SYNTAX_ERROR         NCI_STATUS_SYNTAX_ERROR         /* Syntax error         */
32#define NFC_STATUS_SEMANTIC_ERROR       NCI_STATUS_SEMANTIC_ERROR       /* Semantic error       */
33#define NFC_STATUS_UNKNOWN_GID          NCI_STATUS_UNKNOWN_GID          /* Unknown NCI Group ID */
34#define NFC_STATUS_UNKNOWN_OID          NCI_STATUS_UNKNOWN_OID          /* Unknown NCI Opcode   */
35#define NFC_STATUS_INVALID_PARAM        NCI_STATUS_INVALID_PARAM        /* Invalid Parameter    */
36#define NFC_STATUS_MSG_SIZE_TOO_BIG     NCI_STATUS_MSG_SIZE_TOO_BIG     /* Message size too big */
37#define NFC_STATUS_ALREADY_STARTED      NCI_STATUS_ALREADY_STARTED      /* Already started      */
38#define NFC_STATUS_ACTIVATION_FAILED    NCI_STATUS_ACTIVATION_FAILED    /* Activation Failed    */
39#define NFC_STATUS_TEAR_DOWN            NCI_STATUS_TEAR_DOWN            /* Tear Down Error      */
40#define NFC_STATUS_RF_TRANSMISSION_ERR  NCI_STATUS_RF_TRANSMISSION_ERR  /* RF transmission error*/
41#define NFC_STATUS_RF_PROTOCOL_ERR      NCI_STATUS_RF_PROTOCOL_ERR      /* RF protocol error    */
42#define NFC_STATUS_TIMEOUT              NCI_STATUS_TIMEOUT              /* RF Timeout           */
43#define NFC_STATUS_EE_INTF_ACTIVE_FAIL  NCI_STATUS_EE_INTF_ACTIVE_FAIL  /* EE Intf activate err */
44#define NFC_STATUS_EE_TRANSMISSION_ERR  NCI_STATUS_EE_TRANSMISSION_ERR  /* EE transmission error*/
45#define NFC_STATUS_EE_PROTOCOL_ERR      NCI_STATUS_EE_PROTOCOL_ERR      /* EE protocol error    */
46#define NFC_STATUS_EE_TIMEOUT           NCI_STATUS_EE_TIMEOUT           /* EE Timeout           */
47
48/* 0xE0 ~0xFF are proprietary status codes */
49#define NFC_STATUS_CMD_STARTED          0xE3/* Command started successfully                     */
50#define NFC_STATUS_HW_TIMEOUT           0xE4/* NFCC Timeout in responding to an NCI command     */
51#define NFC_STATUS_CONTINUE             0xE5/* More (same) event to follow                      */
52#define NFC_STATUS_REFUSED              0xE6/* API is called to perform illegal function        */
53#define NFC_STATUS_BAD_RESP             0xE7/* Wrong format of R-APDU, CC file or NDEF file     */
54#define NFC_STATUS_CMD_NOT_CMPLTD       0xE8/* 7816 Status Word is not command complete(0x9000) */
55#define NFC_STATUS_NO_BUFFERS           0xE9/* Out of GKI buffers                               */
56#define NFC_STATUS_WRONG_PROTOCOL       0xEA/* Protocol mismatch between API and activated one  */
57#define NFC_STATUS_BUSY                 0xEB/* Another Tag command is already in progress       */
58
59#define NFC_STATUS_LINK_LOSS            0xFC                      /* Link Loss                  */
60#define NFC_STATUS_BAD_LENGTH           0xFD                      /* data len exceeds MIU       */
61#define NFC_STATUS_BAD_HANDLE           0xFE                      /* invalid handle             */
62#define NFC_STATUS_CONGESTED            0xFF                      /* congested                  */
63typedef UINT8 tNFC_STATUS;
64
65
66
67/**********************************************
68 * NFC Config Parameter IDs defined by NCI
69 **********************************************/
70#define NFC_PMID_TOTAL_DURATION     NCI_PARAM_ID_TOTAL_DURATION
71#define NFC_PMID_CON_DEVICES_LIMIT  NCI_PARAM_ID_CON_DEVICES_LIMIT
72#define NFC_PMID_PA_BAILOUT         NCI_PARAM_ID_PA_BAILOUT
73#define NFC_PMID_PB_AFI             NCI_PARAM_ID_PB_AFI
74#define NFC_PMID_PB_BAILOUT         NCI_PARAM_ID_PB_BAILOUT
75#define NFC_PMID_PB_ATTRIB_PARAM1   NCI_PARAM_ID_PB_ATTRIB_PARAM1
76#define NFC_PMID_PF_BIT_RATE        NCI_PARAM_ID_PF_BIT_RATE
77#define NFC_PMID_PB_H_INFO          NCI_PARAM_ID_PB_H_INFO
78#define NFC_PMID_BITR_NFC_DEP       NCI_PARAM_ID_BITR_NFC_DEP
79#define NFC_PMID_ATR_REQ_GEN_BYTES  NCI_PARAM_ID_ATR_REQ_GEN_BYTES
80#define NFC_PMID_ATR_REQ_CONFIG     NCI_PARAM_ID_ATR_REQ_CONFIG
81#define NFC_PMID_LA_HIST_BY         NCI_PARAM_ID_LA_HIST_BY
82#define NFC_PMID_LA_NFCID1          NCI_PARAM_ID_LA_NFCID1
83#define NFC_PMID_PI_BIT_RATE        NCI_PARAM_ID_PI_BIT_RATE
84#define NFC_PMID_LA_BIT_FRAME_SDD   NCI_PARAM_ID_LA_BIT_FRAME_SDD
85#define NFC_PMID_LA_PLATFORM_CONFIG NCI_PARAM_ID_LA_PLATFORM_CONFIG
86#define NFC_PMID_LA_SEL_INFO        NCI_PARAM_ID_LA_SEL_INFO
87#define NFC_PMID_LI_BIT_RATE        NCI_PARAM_ID_LI_BIT_RATE
88#define NFC_PMID_LB_SENSB_INFO      NCI_PARAM_ID_LB_SENSB_INFO
89#define NFC_PMID_LB_PROTOCOL        NCI_PARAM_ID_LB_PROTOCOL
90#define NFC_PMID_LB_H_INFO          NCI_PARAM_ID_LB_H_INFO_RSP
91#define NFC_PMID_LB_NFCID0          NCI_PARAM_ID_LB_NFCID0
92#define NFC_PMID_LB_APPDATA         NCI_PARAM_ID_LB_APPDATA
93#define NFC_PMID_LB_SFGI            NCI_PARAM_ID_LB_SFGI
94#define NFC_PMID_LB_ADC_FO          NCI_PARAM_ID_LB_ADC_FO
95#define NFC_PMID_LF_T3T_ID1         NCI_PARAM_ID_LF_T3T_ID1
96#define NFC_PMID_LF_T3T_ID2         NCI_PARAM_ID_LF_T3T_ID2
97#define NFC_PMID_LF_T3T_ID3         NCI_PARAM_ID_LF_T3T_ID3
98#define NFC_PMID_LF_T3T_ID4         NCI_PARAM_ID_LF_T3T_ID4
99#define NFC_PMID_LF_T3T_ID5         NCI_PARAM_ID_LF_T3T_ID5
100#define NFC_PMID_LF_T3T_ID6         NCI_PARAM_ID_LF_T3T_ID6
101#define NFC_PMID_LF_T3T_ID7         NCI_PARAM_ID_LF_T3T_ID7
102#define NFC_PMID_LF_T3T_ID8         NCI_PARAM_ID_LF_T3T_ID8
103#define NFC_PMID_LF_T3T_ID9         NCI_PARAM_ID_LF_T3T_ID9
104#define NFC_PMID_LF_T3T_ID10        NCI_PARAM_ID_LF_T3T_ID10
105#define NFC_PMID_LF_T3T_ID11        NCI_PARAM_ID_LF_T3T_ID11
106#define NFC_PMID_LF_T3T_ID12        NCI_PARAM_ID_LF_T3T_ID12
107#define NFC_PMID_LF_T3T_ID13        NCI_PARAM_ID_LF_T3T_ID13
108#define NFC_PMID_LF_T3T_ID14        NCI_PARAM_ID_LF_T3T_ID14
109#define NFC_PMID_LF_T3T_ID15        NCI_PARAM_ID_LF_T3T_ID15
110#define NFC_PMID_LF_T3T_ID16        NCI_PARAM_ID_LF_T3T_ID16
111#define NFC_PMID_LF_PROTOCOL        NCI_PARAM_ID_LF_PROTOCOL
112#define NFC_PMID_LF_T3T_PMM         NCI_PARAM_ID_LF_T3T_PMM
113#define NFC_PMID_LF_T3T_MAX         NCI_PARAM_ID_LF_T3T_MAX
114#define NFC_PMID_LF_T3T_FLAGS2      NCI_PARAM_ID_LF_T3T_FLAGS2
115#define NFC_PMID_FWI                NCI_PARAM_ID_FWI
116#define NFC_PMID_LF_CON_BITR_F      NCI_PARAM_ID_LF_CON_BITR_F
117#define NFC_PMID_WT                 NCI_PARAM_ID_WT
118#define NFC_PMID_ATR_RES_GEN_BYTES  NCI_PARAM_ID_ATR_RES_GEN_BYTES
119#define NFC_PMID_ATR_RSP_CONFIG     NCI_PARAM_ID_ATR_RSP_CONFIG
120#define NFC_PMID_RF_FIELD_INFO      NCI_PARAM_ID_RF_FIELD_INFO
121#define NFC_PMID_NFC_DEP_OP         NCI_PARAM_ID_NFC_DEP_OP
122#define NFC_PARAM_ID_RF_EE_ACTION   NCI_PARAM_ID_RF_EE_ACTION
123#define NFC_PARAM_ID_ISO_DEP_OP     NCI_PARAM_ID_ISO_DEP_OP
124
125#define NFC_ROUTE_TAG_TECH           NCI_ROUTE_TAG_TECH      /* Technology based routing  */
126#define NFC_ROUTE_TAG_PROTO          NCI_ROUTE_TAG_PROTO     /* Protocol based routing  */
127#define NFC_ROUTE_TAG_AID            NCI_ROUTE_TAG_AID       /* AID routing */
128#define NFC_ROUTE_TLV_ENTRY_SIZE     4 /* tag, len, 2 byte value for technology/protocol based routing */
129
130/* For routing */
131#define NFC_DH_ID                NCI_DH_ID   /* for DH */
132/* To identify the loopback test */
133#define NFC_TEST_ID              NCI_TEST_ID            /* use a proprietary range */
134
135typedef UINT8 tNFC_PMID;
136#define NFC_TL_SIZE                     2
137#define NFC_SAVED_CMD_SIZE              2
138
139typedef tNCI_DISCOVER_MAPS   tNFC_DISCOVER_MAPS;
140typedef tNCI_DISCOVER_PARAMS tNFC_DISCOVER_PARAMS;
141
142/* all NFC Manager Callback functions have prototype like void (cback) (UINT8 event, void *p_data)
143 * tNFC_DATA_CBACK uses connection id as the first parameter; range 0x00-0x0F.
144 * tNFC_DISCOVER_CBACK uses tNFC_DISCOVER_EVT; range  0x4000 ~
145 * tNFC_RESPONSE_CBACK uses tNFC_RESPONSE_EVT; range  0x5000 ~
146 */
147
148#define NFC_FIRST_DEVT      0x4000
149#define NFC_FIRST_REVT      0x5000
150#define NFC_FIRST_CEVT      0x6000
151#define NFC_FIRST_TEVT      0x8000
152
153/* the events reported on tNFC_RESPONSE_CBACK */
154enum
155{
156    NFC_ENABLE_REVT = NFC_FIRST_REVT,       /* 0  Enable event                  */
157    NFC_DISABLE_REVT,                       /* 1  Disable event                 */
158    NFC_SET_CONFIG_REVT,                    /* 2  Set Config Response           */
159    NFC_GET_CONFIG_REVT,                    /* 3  Get Config Response           */
160    NFC_NFCEE_DISCOVER_REVT,                /* 4  Discover NFCEE response       */
161    NFC_NFCEE_INFO_REVT,                    /* 5  Discover NFCEE Notification   */
162    NFC_NFCEE_MODE_SET_REVT,                /* 6  NFCEE Mode Set response       */
163    NFC_CONN_REQUEST_REVT,                  /* 7  NFCC Requests Conn Create     */
164    NFC_RF_FIELD_REVT,                      /* 8  RF Field information          */
165    NFC_EE_ACTION_REVT,                     /* 9  EE Action notification        */
166    NFC_EE_DISCOVER_REQ_REVT,               /* 10 EE Discover Req notification  */
167    NFC_SET_ROUTING_REVT,                   /* 11 Configure Routing response    */
168    NFC_GET_ROUTING_REVT,                   /* 12 Retrieve Routing response     */
169    NFC_RF_COMM_PARAMS_UPDATE_REVT,         /* 13 RF Communication Param Update */
170    NFC_GEN_ERROR_REVT,                     /* 14 generic error notification    */
171    NFC_NFCC_RESTART_REVT,                  /* 15 NFCC has been re-initialized  */
172    NFC_NFCC_TIMEOUT_REVT,                  /* 16 NFCC is not responding        */
173    NFC_NFCC_TRANSPORT_ERR_REVT,            /* 17 NCI Tranport error            */
174    NFC_NFCC_POWER_OFF_REVT,                /* 18 NFCC turned off               */
175
176    NFC_FIRST_VS_REVT                       /* First vendor-specific rsp event  */
177};
178typedef UINT16 tNFC_RESPONSE_EVT;
179
180enum
181{
182    NFC_CONN_CREATE_CEVT = NFC_FIRST_CEVT,  /* 0  Conn Create Response          */
183    NFC_CONN_CLOSE_CEVT,                    /* 1  Conn Close Response           */
184    NFC_DEACTIVATE_CEVT,                    /* 2  Deactivate response/notificatn*/
185    NFC_DATA_CEVT,                          /* 3  Data                          */
186    NFC_ERROR_CEVT                          /* 4  generic or interface error    */
187};
188typedef UINT16 tNFC_CONN_EVT;
189
190#define NFC_NFCC_INFO_LEN       4
191#ifndef NFC_NFCC_MAX_NUM_VS_INTERFACE
192#define NFC_NFCC_MAX_NUM_VS_INTERFACE   4
193#endif
194typedef struct
195{
196    tNFC_STATUS             status;         /* The event status.                */
197    UINT8                   nci_version;    /* the NCI version of NFCC          */
198    UINT8                   max_conn;       /* max number of connections by NFCC*/
199    UINT32                  nci_features;   /* the NCI features of NFCC         */
200    UINT16                  nci_interfaces; /* the NCI interfaces of NFCC       */
201    UINT16                  max_ce_table;   /* the max routing table size       */
202    UINT16                  max_param_size; /* Max Size for Large Parameters    */
203    UINT8                   manufacture_id; /* the Manufacture ID for NFCC      */
204    UINT8                   nfcc_info[NFC_NFCC_INFO_LEN];/* the Manufacture Info for NFCC      */
205    UINT8                   vs_interface[NFC_NFCC_MAX_NUM_VS_INTERFACE];  /* the NCI VS interfaces of NFCC    */
206} tNFC_ENABLE_REVT;
207
208#define NFC_MAX_NUM_IDS     125
209/* the data type associated with NFC_SET_CONFIG_REVT */
210typedef struct
211{
212    tNFC_STATUS             status;         /* The event status.                */
213    UINT8                   num_param_id;   /* Number of rejected NCI Param ID  */
214    UINT8                   param_ids[NFC_MAX_NUM_IDS];/* NCI Param ID          */
215} tNFC_SET_CONFIG_REVT;
216
217/* the data type associated with NFC_GET_CONFIG_REVT */
218typedef struct
219{
220    tNFC_STATUS             status;         /* The event status.    */
221    UINT16                  tlv_size;       /* The length of TLV    */
222    UINT8                   *p_param_tlvs;  /* TLV                  */
223} tNFC_GET_CONFIG_REVT;
224
225/* the data type associated with NFC_NFCEE_DISCOVER_REVT */
226typedef struct
227{
228    tNFC_STATUS             status;         /* The event status.    */
229    UINT8                   num_nfcee;      /* The number of NFCEE  */
230} tNFC_NFCEE_DISCOVER_REVT;
231
232#define NFC_NFCEE_INTERFACE_APDU         NCI_NFCEE_INTERFACE_APDU
233#define NFC_NFCEE_INTERFACE_HCI_ACCESS   NCI_NFCEE_INTERFACE_HCI_ACCESS
234#define NFC_NFCEE_INTERFACE_T3T          NCI_NFCEE_INTERFACE_T3T
235#define NFC_NFCEE_INTERFACE_TRANSPARENT  NCI_NFCEE_INTERFACE_TRANSPARENT
236#define NFC_NFCEE_INTERFACE_PROPRIETARY  NCI_NFCEE_INTERFACE_PROPRIETARY
237typedef UINT8 tNFC_NFCEE_INTERFACE;
238
239#define NFC_NFCEE_TAG_HW_ID             NCI_NFCEE_TAG_HW_ID
240#define NFC_NFCEE_TAG_ATR_BYTES         NCI_NFCEE_TAG_ATR_BYTES
241#define NFC_NFCEE_TAG_T3T_INFO          NCI_NFCEE_TAG_T3T_INFO
242#define NFC_NFCEE_TAG_HCI_HOST_ID       NCI_NFCEE_TAG_HCI_HOST_ID
243typedef UINT8 tNFC_NFCEE_TAG;
244/* additional NFCEE Info */
245typedef struct
246{
247    tNFC_NFCEE_TAG          tag;
248    UINT8                   len;
249    UINT8                   info[NFC_MAX_EE_INFO];
250} tNFC_NFCEE_TLV;
251
252#define NFC_NFCEE_STATUS_INACTIVE       NCI_NFCEE_STS_CONN_INACTIVE/* NFCEE connected and inactive */
253#define NFC_NFCEE_STATUS_ACTIVE         NCI_NFCEE_STS_CONN_ACTIVE  /* NFCEE connected and active   */
254#define NFC_NFCEE_STATUS_REMOVED        NCI_NFCEE_STS_REMOVED      /* NFCEE removed                */
255/* the data type associated with NFC_NFCEE_INFO_REVT */
256typedef struct
257{
258    tNFC_STATUS             status;                 /* The event status - place holder  */
259    UINT8                   nfcee_id;               /* NFCEE ID                         */
260    UINT8                   ee_status;              /* The NFCEE status.                */
261    UINT8                   num_interface;          /* number of NFCEE interfaces       */
262    UINT8                   ee_interface[NFC_MAX_EE_INTERFACE];/* NFCEE interface       */
263    UINT8                   num_tlvs;               /* number of TLVs                   */
264    tNFC_NFCEE_TLV          ee_tlv[NFC_MAX_EE_TLVS];/* The TLVs associated with NFCEE   */
265} tNFC_NFCEE_INFO_REVT;
266
267#define NFC_MODE_ACTIVATE          NCI_NFCEE_MD_ACTIVATE
268#define NFC_MODE_DEACTIVATE        NCI_NFCEE_MD_DEACTIVATE
269typedef UINT8 tNFC_NFCEE_MODE;
270/* the data type associated with NFC_NFCEE_MODE_SET_REVT */
271typedef struct
272{
273    tNFC_STATUS             status;                 /* The event status.*/
274    UINT8                   nfcee_id;               /* NFCEE ID         */
275    tNFC_NFCEE_MODE         mode;                   /* NFCEE mode       */
276} tNFC_NFCEE_MODE_SET_REVT;
277
278#define NFC_MAX_AID_LEN     NCI_MAX_AID_LEN     /* 16 */
279
280/* the data type associated with NFC_CE_GET_ROUTING_REVT */
281typedef struct
282{
283    tNFC_STATUS             status;         /* The event status                 */
284    UINT8                   nfcee_id;       /* NFCEE ID                         */
285    UINT8                   num_tlvs;       /* number of TLVs                   */
286    UINT8                   tlv_size;       /* the total len of all TLVs        */
287    UINT8                   param_tlvs[NFC_MAX_EE_TLV_SIZE];/* the TLVs         */
288} tNFC_GET_ROUTING_REVT;
289
290
291/* the data type associated with NFC_CONN_CREATE_CEVT */
292typedef struct
293{
294    tNFC_STATUS             status;         /* The event status                 */
295    UINT8                   dest_type;      /* the destination type             */
296    UINT8                   id;             /* NFCEE ID  or RF Discovery ID     */
297    UINT8                   buff_size;      /* The max buffer size              */
298    UINT8                   num_buffs;      /* The number of buffers            */
299} tNFC_CONN_CREATE_CEVT;
300
301/* the data type associated with NFC_CONN_CLOSE_CEVT */
302typedef struct
303{
304    tNFC_STATUS             status;         /* The event status                 */
305} tNFC_CONN_CLOSE_CEVT;
306
307/* the data type associated with NFC_DATA_CEVT */
308typedef struct
309{
310    tNFC_STATUS             status;         /* The event status                 */
311    BT_HDR                  *p_data;        /* The received Data                */
312} tNFC_DATA_CEVT;
313
314/* RF Field Status */
315#define NFC_RF_STS_NO_REMOTE    NCI_RF_STS_NO_REMOTE    /* No field generated by remote device  */
316#define NFC_RF_STS_REMOTE       NCI_RF_STS_REMOTE       /* field generated by remote device     */
317typedef UINT8 tNFC_RF_STS;
318
319/* RF Field Technologies */
320#define NFC_RF_TECHNOLOGY_A     NCI_RF_TECHNOLOGY_A
321#define NFC_RF_TECHNOLOGY_B     NCI_RF_TECHNOLOGY_B
322#define NFC_RF_TECHNOLOGY_F     NCI_RF_TECHNOLOGY_F
323#define NFC_RF_TECHNOLOGY_15693 NCI_RF_TECHNOLOGY_15693
324typedef UINT8 tNFC_RF_TECH;
325
326
327/* Supported Protocols */
328#define NFC_PROTOCOL_UNKNOWN    NCI_PROTOCOL_UNKNOWN  /* Unknown */
329#define NFC_PROTOCOL_T1T        NCI_PROTOCOL_T1T      /* Type1Tag    - NFC-A            */
330#define NFC_PROTOCOL_T2T        NCI_PROTOCOL_T2T      /* Type2Tag    - NFC-A            */
331#define NFC_PROTOCOL_T3T        NCI_PROTOCOL_T3T      /* Type3Tag    - NFC-F            */
332#define NFC_PROTOCOL_ISO_DEP    NCI_PROTOCOL_ISO_DEP  /* Type 4A,4B  - NFC-A or NFC-B   */
333#define NFC_PROTOCOL_NFC_DEP    NCI_PROTOCOL_NFC_DEP  /* NFCDEP/LLCP - NFC-A or NFC-F       */
334#define NFC_PROTOCOL_B_PRIME    NCI_PROTOCOL_B_PRIME
335#define NFC_PROTOCOL_15693      NCI_PROTOCOL_15693
336#define NFC_PROTOCOL_KOVIO      NCI_PROTOCOL_KOVIO
337typedef UINT8 tNFC_PROTOCOL;
338
339/* Discovery Types/Detected Technology and Mode */
340#define NFC_DISCOVERY_TYPE_POLL_A           NCI_DISCOVERY_TYPE_POLL_A
341#define NFC_DISCOVERY_TYPE_POLL_B           NCI_DISCOVERY_TYPE_POLL_B
342#define NFC_DISCOVERY_TYPE_POLL_F           NCI_DISCOVERY_TYPE_POLL_F
343#define NFC_DISCOVERY_TYPE_POLL_A_ACTIVE    NCI_DISCOVERY_TYPE_POLL_A_ACTIVE
344#define NFC_DISCOVERY_TYPE_POLL_F_ACTIVE    NCI_DISCOVERY_TYPE_POLL_F_ACTIVE
345#define NFC_DISCOVERY_TYPE_POLL_ISO15693    NCI_DISCOVERY_TYPE_POLL_ISO15693
346#define NFC_DISCOVERY_TYPE_POLL_B_PRIME     NCI_DISCOVERY_TYPE_POLL_B_PRIME
347#define NFC_DISCOVERY_TYPE_POLL_KOVIO       NCI_DISCOVERY_TYPE_POLL_KOVIO
348#define NFC_DISCOVERY_TYPE_LISTEN_A         NCI_DISCOVERY_TYPE_LISTEN_A
349#define NFC_DISCOVERY_TYPE_LISTEN_B         NCI_DISCOVERY_TYPE_LISTEN_B
350#define NFC_DISCOVERY_TYPE_LISTEN_F         NCI_DISCOVERY_TYPE_LISTEN_F
351#define NFC_DISCOVERY_TYPE_LISTEN_A_ACTIVE  NCI_DISCOVERY_TYPE_LISTEN_A_ACTIVE
352#define NFC_DISCOVERY_TYPE_LISTEN_F_ACTIVE  NCI_DISCOVERY_TYPE_LISTEN_F_ACTIVE
353#define NFC_DISCOVERY_TYPE_LISTEN_ISO15693  NCI_DISCOVERY_TYPE_LISTEN_ISO15693
354#define NFC_DISCOVERY_TYPE_LISTEN_B_PRIME   NCI_DISCOVERY_TYPE_LISTEN_B_PRIME
355typedef UINT8 tNFC_DISCOVERY_TYPE;
356typedef UINT8 tNFC_RF_TECH_N_MODE;
357
358/* Select Response codes */
359#define NFC_SEL_RES_NFC_FORUM_T2T           0x00
360#define NFC_SEL_RES_MF_CLASSIC              0x08
361
362/* Bit Rates */
363#define NFC_BIT_RATE_106        NCI_BIT_RATE_106    /* 106 kbit/s */
364#define NFC_BIT_RATE_212        NCI_BIT_RATE_212    /* 212 kbit/s */
365#define NFC_BIT_RATE_424        NCI_BIT_RATE_424    /* 424 kbit/s */
366#define NFC_BIT_RATE_848        NCI_BIT_RATE_848    /* 848 Kbit/s */
367#define NFC_BIT_RATE_1696       NCI_BIT_RATE_1696   /* 1696 Kbit/s*/
368#define NFC_BIT_RATE_3392       NCI_BIT_RATE_3392   /* 3392 Kbit/s*/
369#define NFC_BIT_RATE_6784       NCI_BIT_RATE_6784   /* 6784 Kbit/s*/
370typedef UINT8 tNFC_BIT_RATE;
371
372/**********************************************
373 * Interface Types
374 **********************************************/
375#define NFC_INTERFACE_EE_DIRECT_RF  NCI_INTERFACE_EE_DIRECT_RF
376#define NFC_INTERFACE_FRAME         NCI_INTERFACE_FRAME
377#define NFC_INTERFACE_ISO_DEP       NCI_INTERFACE_ISO_DEP
378#define NFC_INTERFACE_NDEF          NCI_INTERFACE_NDEF
379#define NFC_INTERFACE_NFC_DEP       NCI_INTERFACE_NFC_DEP
380#define NFC_INTERFACE_LLCP_LOW      NCI_INTERFACE_LLCP_LOW
381#define NFC_INTERFACE_LLCP_HIGH     NCI_INTERFACE_LLCP_HIGH
382#define NFC_INTERFACE_VS_T2T_CE     NCI_INTERFACE_VS_T2T_CE
383typedef tNCI_INTF_TYPE tNFC_INTF_TYPE;
384
385/**********************************************
386 *  Deactivation Type
387 **********************************************/
388#define NFC_DEACTIVATE_TYPE_IDLE        NCI_DEACTIVATE_TYPE_IDLE
389#define NFC_DEACTIVATE_TYPE_SLEEP       NCI_DEACTIVATE_TYPE_SLEEP
390#define NFC_DEACTIVATE_TYPE_SLEEP_AF    NCI_DEACTIVATE_TYPE_SLEEP_AF
391#define NFC_DEACTIVATE_TYPE_DISCOVERY   NCI_DEACTIVATE_TYPE_DISCOVERY
392typedef UINT8 tNFC_DEACT_TYPE;
393
394/**********************************************
395 *  Deactivation Reasons
396 **********************************************/
397#define NFC_DEACTIVATE_REASON_DH_REQ        NCI_DEACTIVATE_REASON_DH_REQ
398#define NFC_DEACTIVATE_REASON_ENDPOINT_REQ  NCI_DEACTIVATE_REASON_ENDPOINT_REQ
399#define NFC_DEACTIVATE_REASON_RF_LINK_LOSS  NCI_DEACTIVATE_REASON_RF_LINK_LOSS
400#define NFC_DEACTIVATE_REASON_NFCB_BAD_AFI  NCI_DEACTIVATE_REASON_NFCB_BAD_AFI
401typedef UINT8 tNFC_DEACT_REASON;
402
403/* the data type associated with NFC_RF_FIELD_REVT */
404typedef struct
405{
406    tNFC_STATUS             status;     /* The event status - place holder. */
407    tNFC_RF_STS             rf_field;   /* RF Field Status                  */
408} tNFC_RF_FIELD_REVT;
409
410#define NFC_MAX_APP_DATA_LEN    40
411typedef struct
412{
413    UINT8                   len_aid;                /* length of application id */
414    UINT8                   aid[NFC_MAX_AID_LEN];   /* application id           */
415} tNFC_AID;
416typedef struct
417{
418    UINT8                   len_aid;                /* length of application id */
419    UINT8                   aid[NFC_MAX_AID_LEN];   /* application id           */
420    UINT8                   len_data;               /* len of application data  */
421    UINT8                   data[NFC_MAX_APP_DATA_LEN];  /* application data    */
422} tNFC_APP_INIT;
423
424#define NFC_EE_TRIG_SELECT              NCI_EE_TRIG_7816_SELECT  /* ISO 7816-4 SELECT command */
425#define NFC_EE_TRIG_RF_PROTOCOL         NCI_EE_TRIG_RF_PROTOCOL  /* RF Protocol changed       */
426#define NFC_EE_TRIG_RF_TECHNOLOGY       NCI_EE_TRIG_RF_TECHNOLOGY/* RF Technology changed     */
427#define NFC_EE_TRIG_APP_INIT            NCI_EE_TRIG_APP_INIT     /* Application initiation    */
428typedef UINT8 tNFC_EE_TRIGGER;
429typedef struct
430{
431    tNFC_EE_TRIGGER         trigger;        /* the trigger of this event        */
432    union
433    {
434        tNFC_PROTOCOL       protocol;
435        tNFC_RF_TECH        technology;
436        tNFC_AID            aid;
437        tNFC_APP_INIT       app_init;
438    } param; /* Discovery Type specific parameters */
439} tNFC_ACTION_DATA;
440
441/* the data type associated with NFC_EE_ACTION_REVT */
442typedef struct
443{
444    tNFC_STATUS             status;         /* The event status - place holder  */
445    UINT8                   nfcee_id;       /* NFCEE ID                         */
446    tNFC_ACTION_DATA        act_data;       /* data associated /w the action    */
447} tNFC_EE_ACTION_REVT;
448
449#define NFC_EE_DISC_OP_ADD      0
450#define NFC_EE_DISC_OP_REMOVE   1
451typedef UINT8 tNFC_EE_DISC_OP;
452typedef struct
453{
454    tNFC_EE_DISC_OP         op;             /* add or remove this entry         */
455    UINT8                   nfcee_id;       /* NFCEE ID                         */
456    tNFC_RF_TECH_N_MODE     tech_n_mode;    /* Discovery Technology and Mode    */
457    tNFC_PROTOCOL           protocol;       /* NFC protocol                     */
458} tNFC_EE_DISCOVER_INFO;
459
460#ifndef NFC_MAX_EE_DISC_ENTRIES
461#define NFC_MAX_EE_DISC_ENTRIES     6
462#endif
463#define NFC_EE_DISCOVER_ENTRY_LEN   5 /* T, L, V(NFCEE ID, TechnMode, Protocol) */
464#define NFC_EE_DISCOVER_INFO_LEN    3 /* NFCEE ID, TechnMode, Protocol */
465/* the data type associated with NFC_EE_DISCOVER_REQ_REVT */
466typedef struct
467{
468    tNFC_STATUS             status;         /* The event status - place holder  */
469    UINT8                   num_info;       /* number of entries in info[]      */
470    tNFC_EE_DISCOVER_INFO   info[NFC_MAX_EE_DISC_ENTRIES];  /* discovery request from NFCEE */
471} tNFC_EE_DISCOVER_REQ_REVT;
472
473typedef union
474{
475    tNFC_STATUS                 status;     /* The event status. */
476    tNFC_ENABLE_REVT            enable;
477    tNFC_SET_CONFIG_REVT        set_config;
478    tNFC_GET_CONFIG_REVT        get_config;
479    tNFC_NFCEE_DISCOVER_REVT    nfcee_discover;
480    tNFC_NFCEE_INFO_REVT        nfcee_info;
481    tNFC_NFCEE_MODE_SET_REVT    mode_set;
482    tNFC_RF_FIELD_REVT          rf_field;
483    tNFC_STATUS                 cfg_routing;
484    tNFC_GET_ROUTING_REVT       get_routing;
485    tNFC_EE_ACTION_REVT         ee_action;
486    tNFC_EE_DISCOVER_REQ_REVT   ee_discover_req;
487    void                        *p_vs_evt_data;
488} tNFC_RESPONSE;
489
490/*************************************
491**  RESPONSE Callback Functions
492**************************************/
493typedef void (tNFC_RESPONSE_CBACK) (tNFC_RESPONSE_EVT event, tNFC_RESPONSE *p_data);
494
495/* The events reported on tNFC_VS_CBACK */
496/* The event is (NCI_RSP_BIT|oid) for response and (NCI_NTF_BIT|oid) for notification*/
497
498typedef UINT8 tNFC_VS_EVT;
499
500/*************************************
501**  Proprietary (Vendor Specific) Callback Functions
502**************************************/
503typedef void (tNFC_VS_CBACK) (tNFC_VS_EVT event, UINT16 data_len, UINT8 *p_data);
504
505/* the events reported on tNFC_DISCOVER_CBACK */
506enum
507{
508    NFC_START_DEVT = NFC_FIRST_DEVT,    /* Status of NFC_DiscoveryStart     */
509    NFC_MAP_DEVT,                       /* Status of NFC_DiscoveryMap       */
510    NFC_RESULT_DEVT,                    /* The responses from remote device */
511    NFC_SELECT_DEVT,                    /* Status of NFC_DiscoverySelect    */
512    NFC_ACTIVATE_DEVT,                  /* RF interface is activated        */
513    NFC_DEACTIVATE_DEVT                 /* Status of RF deactivation        */
514};
515typedef UINT16 tNFC_DISCOVER_EVT;
516
517/* the data type associated with NFC_START_DEVT */
518typedef tNFC_STATUS tNFC_START_DEVT;
519
520typedef tNCI_RF_PA_PARAMS tNFC_RF_PA_PARAMS;
521#define NFC_MAX_SENSB_RES_LEN         NCI_MAX_SENSB_RES_LEN
522#define NFC_NFCID0_MAX_LEN          4
523typedef struct
524{
525    UINT8       sensb_res_len;/* Length of SENSB_RES Response (Byte 2 - Byte 12 or 13) Available after Technology Detection */
526    UINT8       sensb_res[NFC_MAX_SENSB_RES_LEN]; /* SENSB_RES Response (ATQ) */
527    UINT8       nfcid0[NFC_NFCID0_MAX_LEN];
528} tNFC_RF_PB_PARAMS;
529
530#define NFC_MAX_SENSF_RES_LEN       NCI_MAX_SENSF_RES_LEN
531#define NFC_NFCID2_LEN              NCI_NFCID2_LEN
532typedef struct
533{
534    UINT8       bit_rate;/* NFC_BIT_RATE_212 or NFC_BIT_RATE_424 */
535    UINT8       sensf_res_len;/* Length of SENSF_RES Response (Byte 2 - Byte 17 or 19) Available after Technology Detection */
536    UINT8       sensf_res[NFC_MAX_SENSF_RES_LEN]; /* SENSB_RES Response */
537    UINT8       nfcid2[NFC_NFCID2_LEN];  /* NFCID2 generated by the Local NFCC for NFC-DEP Protocol.Available for Frame Interface  */
538    UINT8       mrti_check;
539    UINT8       mrti_update;
540} tNFC_RF_PF_PARAMS;
541
542typedef tNCI_RF_LF_PARAMS tNFC_RF_LF_PARAMS;
543
544#define NFC_ISO15693_UID_LEN        8
545typedef struct
546{
547    UINT8       flag;
548    UINT8       dsfid;
549    UINT8       uid[NFC_ISO15693_UID_LEN];
550} tNFC_RF_PISO15693_PARAMS;
551
552#define NFC_KOVIO_MAX_LEN       16
553typedef struct
554{
555    UINT8       uid_len;
556    UINT8       uid[NFC_KOVIO_MAX_LEN];
557} tNFC_RF_PKOVIO_PARAMS;
558
559typedef struct
560{
561    tNFC_DISCOVERY_TYPE     mode;
562    union
563    {
564        tNFC_RF_PA_PARAMS   pa;
565        tNFC_RF_PB_PARAMS   pb;
566        tNFC_RF_PF_PARAMS   pf;
567        tNFC_RF_LF_PARAMS   lf;
568        tNFC_RF_PISO15693_PARAMS pi93;
569        tNFC_RF_PKOVIO_PARAMS pk;
570    } param; /* Discovery Type specific parameters */
571} tNFC_RF_TECH_PARAMS;
572
573/* the data type associated with NFC_RESULT_DEVT */
574typedef struct
575{
576    tNFC_STATUS             status;         /* The event status - place holder. */
577    UINT8                   rf_disc_id;     /* RF Discovery ID                  */
578    UINT8                   protocol;       /* supported protocol               */
579    tNFC_RF_TECH_PARAMS     rf_tech_param;  /* RF technology parameters         */
580    BOOLEAN                 more;           /* 0: last notification             */
581} tNFC_RESULT_DEVT;
582
583/* the data type associated with NFC_SELECT_DEVT */
584typedef tNFC_STATUS tNFC_SELECT_DEVT;
585
586/* the data type associated with NFC_STOP_DEVT */
587typedef tNFC_STATUS tNFC_STOP_DEVT;
588
589#define NFC_MAX_ATS_LEN             NCI_MAX_ATS_LEN
590#define NFC_MAX_HIS_BYTES_LEN       NCI_MAX_HIS_BYTES_LEN
591#define NFC_MAX_GEN_BYTES_LEN       NCI_MAX_GEN_BYTES_LEN
592
593
594typedef struct
595{
596    UINT8       ats_res_len;                /* Length of ATS RES                */
597    UINT8       ats_res[NFC_MAX_ATS_LEN];   /* ATS RES                          */
598    BOOLEAN     nad_used;                   /* NAD is used or not               */
599    UINT8       fwi;                        /* Frame Waiting time Integer       */
600    UINT8       sfgi;                       /* Start-up Frame Guard time Integer*/
601    UINT8       his_byte_len;               /* len of historical bytes          */
602    UINT8       his_byte[NFC_MAX_HIS_BYTES_LEN];/* historical bytes             */
603} tNFC_INTF_PA_ISO_DEP;
604
605typedef struct
606{
607    UINT8       rats;  /* RATS */
608} tNFC_INTF_LA_ISO_DEP;
609
610
611typedef struct
612{
613    UINT8       atr_res_len;                /* Length of ATR_RES            */
614    UINT8       atr_res[NFC_MAX_ATS_LEN];   /* ATR_RES (Byte 3 - Byte 17+n) */
615    UINT8       max_payload_size;           /* 64, 128, 192 or 254          */
616    UINT8       gen_bytes_len;              /* len of general bytes         */
617    UINT8       gen_bytes[NFC_MAX_GEN_BYTES_LEN];/* general bytes           */
618    UINT8       waiting_time;               /* WT -> Response Waiting Time RWT = (256 x 16/fC) x 2WT */
619} tNFC_INTF_PA_NFC_DEP;
620
621/* Note: keep tNFC_INTF_PA_NFC_DEP data member in the same order as tNFC_INTF_LA_NFC_DEP */
622typedef struct
623{
624    UINT8       atr_req_len;                /* Length of ATR_REQ            */
625    UINT8       atr_req[NFC_MAX_ATS_LEN];   /* ATR_REQ (Byte 3 - Byte 18+n) */
626    UINT8       max_payload_size;           /* 64, 128, 192 or 254          */
627    UINT8       gen_bytes_len;              /* len of general bytes         */
628    UINT8       gen_bytes[NFC_MAX_GEN_BYTES_LEN];/* general bytes           */
629} tNFC_INTF_LA_NFC_DEP;
630typedef tNFC_INTF_LA_NFC_DEP tNFC_INTF_LF_NFC_DEP;
631typedef tNFC_INTF_PA_NFC_DEP tNFC_INTF_PF_NFC_DEP;
632
633#define NFC_MAX_ATTRIB_LEN      NCI_MAX_ATTRIB_LEN
634
635typedef struct
636{
637    UINT8       attrib_res_len;                /* Length of ATTRIB RES      */
638    UINT8       attrib_res[NFC_MAX_ATTRIB_LEN];/* ATTRIB RES                */
639    UINT8       hi_info_len;                   /* len of Higher layer Info  */
640    UINT8       hi_info[NFC_MAX_GEN_BYTES_LEN];/* Higher layer Info         */
641    UINT8       mbli;                          /* Maximum buffer length.    */
642} tNFC_INTF_PB_ISO_DEP;
643
644typedef struct
645{
646    UINT8       attrib_req_len;                /* Length of ATTRIB REQ      */
647    UINT8       attrib_req[NFC_MAX_ATTRIB_LEN];/* ATTRIB REQ (Byte 2 - 10+k)*/
648    UINT8       hi_info_len;                   /* len of Higher layer Info  */
649    UINT8       hi_info[NFC_MAX_GEN_BYTES_LEN];/* Higher layer Info         */
650    UINT8       nfcid0[NFC_NFCID0_MAX_LEN];    /* NFCID0                    */
651} tNFC_INTF_LB_ISO_DEP;
652
653
654#ifndef NFC_MAX_RAW_PARAMS
655#define NFC_MAX_RAW_PARAMS      16
656#endif
657#define NFC_MAX_RAW_PARAMS       16
658typedef struct
659{
660    UINT8       param_len;
661    UINT8       param[NFC_MAX_RAW_PARAMS];
662} tNFC_INTF_FRAME;
663
664typedef struct
665{
666    tNFC_INTF_TYPE      type;  /* Interface Type  1 Byte  See Table 67 */
667    union
668    {
669        tNFC_INTF_LA_ISO_DEP    la_iso;
670        tNFC_INTF_PA_ISO_DEP    pa_iso;
671        tNFC_INTF_LB_ISO_DEP    lb_iso;
672        tNFC_INTF_PB_ISO_DEP    pb_iso;
673        tNFC_INTF_LA_NFC_DEP    la_nfc;
674        tNFC_INTF_PA_NFC_DEP    pa_nfc;
675        tNFC_INTF_LF_NFC_DEP    lf_nfc;
676        tNFC_INTF_PF_NFC_DEP    pf_nfc;
677        tNFC_INTF_FRAME         frame;
678    } intf_param;       /* Activation Parameters   0 - n Bytes */
679} tNFC_INTF_PARAMS;
680
681/* the data type associated with NFC_ACTIVATE_DEVT */
682typedef struct
683{
684    UINT8                   rf_disc_id;     /* RF Discovery ID          */
685    tNFC_PROTOCOL           protocol;       /* supported protocol       */
686    tNFC_RF_TECH_PARAMS     rf_tech_param;  /* RF technology parameters */
687    tNFC_BIT_RATE           tx_bitrate;     /* Data Exchange Tx Bitrate */
688    tNFC_BIT_RATE           rx_bitrate;     /* Data Exchange Rx Bitrate */
689    tNFC_INTF_PARAMS        intf_param;     /* interface type and params*/
690} tNFC_ACTIVATE_DEVT;
691
692/* the data type associated with NFC_DEACTIVATE_DEVT and NFC_DEACTIVATE_CEVT */
693typedef struct
694{
695    tNFC_STATUS             status;         /* The event status.        */
696    tNFC_DEACT_TYPE         type;           /* De-activate type         */
697    BOOLEAN                 is_ntf;         /* TRUE, if deactivate notif*/
698} tNFC_DEACTIVATE_DEVT;
699
700typedef union
701{
702    tNFC_STATUS             status;         /* The event status.        */
703    tNFC_START_DEVT         start;
704    tNFC_RESULT_DEVT        result;
705    tNFC_SELECT_DEVT        select;
706    tNFC_STOP_DEVT          stop;
707    tNFC_ACTIVATE_DEVT      activate;
708    tNFC_DEACTIVATE_DEVT    deactivate;
709} tNFC_DISCOVER;
710
711/* Min TR0 indicates to tag the min delay before responding after the end of command */
712#define NFC_RF_PARAM_MIN_TR0_DEFAULT    0x00
713#define NFC_RF_PARAM_MIN_TR0_48X        0x01    /* 48 x 16/fc */
714#define NFC_RF_PARAM_MIN_TR0_16X        0x02    /* 16 x 16/fc */
715
716/* Min TR1 indicates to tag the min delay between subcarrier modulation and data transmission */
717#define NFC_RF_PARAM_MIN_TR1_DEFAULT    0x00
718#define NFC_RF_PARAM_MIN_TR1_64X        0x01    /* 64 x 16/fc */
719#define NFC_RF_PARAM_MIN_TR1_16X        0x02    /* 16 x 16/fc */
720
721/* Min TR2 indicates to RW the min delay between EoS of tag and SoS of RW */
722#define NFC_RF_PARAM_MIN_TR2_1792       0x00    /* 1792/fc (10etu + 32/fc) */
723#define NFC_RF_PARAM_MIN_TR2_3328       0x01    /* 3328/fc (10etu + 128/fc) */
724#define NFC_RF_PARAM_MIN_TR2_5376       0x02    /* 5376/fc (10etu + 256/fc) */
725#define NFC_RF_PARAM_MIN_TR2_9472       0x03    /* 9472/fc (10etu + 512/fc) */
726
727#define NFC_RF_PARAM_EOS_REQUIRED       0x00    /* EoS required */
728#define NFC_RF_PARAM_EOS_NOT_REQUIRED   0x01    /* EoS not required */
729
730#define NFC_RF_PARAM_SOS_REQUIRED       0x00    /* SoS required */
731#define NFC_RF_PARAM_SOS_NOT_REQUIRED   0x01    /* SoS not required */
732
733typedef struct
734{
735    BOOLEAN                 include_rf_tech_mode;   /* TRUE if including RF Tech and Mode update    */
736    tNFC_RF_TECH_N_MODE     rf_tech_n_mode;         /* RF tech and mode                             */
737    BOOLEAN                 include_tx_bit_rate;    /* TRUE if including Tx bit rate update         */
738    tNFC_BIT_RATE           tx_bit_rate;            /* Transmit Bit Rate                            */
739    BOOLEAN                 include_rx_bit_rate;    /* TRUE if including Rx bit rate update         */
740    tNFC_BIT_RATE           rx_bit_rate;            /* Receive Bit Rate                             */
741    BOOLEAN                 include_nfc_b_config;   /* TRUE if including NFC-B data exchange config */
742    UINT8                   min_tr0;                /* Minimun TR0                                  */
743    UINT8                   min_tr1;                /* Minimun TR1                                  */
744    UINT8                   suppression_eos;        /* Suppression of EoS                           */
745    UINT8                   suppression_sos;        /* Suppression of SoS                           */
746    UINT8                   min_tr2;                /* Minimun TR1                                  */
747} tNFC_RF_COMM_PARAMS;
748
749/*************************************
750**  DISCOVER Callback Functions
751**************************************/
752typedef void (tNFC_DISCOVER_CBACK) (tNFC_DISCOVER_EVT event, tNFC_DISCOVER *p_data);
753
754/* the events reported on tNFC_TEST_CBACK */
755enum
756{
757    NFC_LOOPBACK_TEVT = NFC_FIRST_TEVT, /* 0  Loopback test             */
758    NFC_RF_CONTROL_TEVT,                /* 1  RF control Test response  */
759    NFC_RF_FIELD_DONE_TEVT              /* 1  RF control Test notificatn*/
760};
761typedef UINT16 tNFC_TEST_EVT;
762
763/* the data type associated with NFC_LOOPBACK_TEVT */
764typedef struct
765{
766    tNFC_STATUS             status;     /* The event status.            */
767    BT_HDR                  *p_data;    /* The loop back data from NFCC */
768} tNFC_LOOPBACK_TEVT;
769
770/* the data type associated with NFC_RF_CONTROL_TEVT */
771typedef tNFC_STATUS tNFC_RF_CONTROL_TEVT;
772
773typedef union
774{
775    tNFC_STATUS             status;     /* The event status.            */
776    tNFC_LOOPBACK_TEVT      loop_back;
777    tNFC_RF_CONTROL_TEVT    rf_control;
778} tNFC_TEST;
779
780/*************************************
781**  TEST Callback Functions
782**************************************/
783typedef void (tNFC_TEST_CBACK) (tNFC_TEST_EVT event, tNFC_TEST *p_data);
784
785
786typedef tNFC_DEACTIVATE_DEVT tNFC_DEACTIVATE_CEVT;
787typedef union
788{
789    tNFC_STATUS             status;     /* The event status. */
790    tNFC_CONN_CREATE_CEVT   conn_create;
791    tNFC_CONN_CLOSE_CEVT    conn_close;
792    tNFC_DEACTIVATE_CEVT    deactivate;
793    tNFC_DATA_CEVT          data;
794} tNFC_CONN;
795
796/*************************************
797**  Data Callback Functions
798**************************************/
799typedef void (tNFC_CONN_CBACK) (UINT8 conn_id, tNFC_CONN_EVT event, tNFC_CONN *p_data);
800#define NFC_MAX_CONN_ID                15
801#define NFC_ILLEGAL_CONN_ID            0xFF
802#define NFC_RF_CONN_ID                 0    /* the static connection ID for RF traffic */
803
804
805
806/*************************************
807**  Status callback function
808**************************************/
809typedef void (tNFC_STATUS_CBACK) (tNFC_STATUS status);
810
811/*****************************************************************************
812**  EXTERNAL FUNCTION DECLARATIONS
813*****************************************************************************/
814#ifdef __cplusplus
815extern "C" {
816#endif
817
818/*******************************************************************************
819**
820** Function         NFC_Enable
821**
822** Description      This function enables NFC. Prior to calling NFC_Enable:
823**                  - the NFCC must be powered up, and ready to receive commands.
824**                  - GKI must be enabled
825**                  - NFC_TASK must be started
826**                  - NCI_TASK must be started (if using dedicated NCI transport)
827**
828**                  This function opens the NCI transport (if applicable),
829**                  resets the NFC controller, and initializes the NFC subsystems.
830**
831**                  When the NFC startup procedure is completed, an
832**                  NFC_ENABLE_REVT is returned to the application using the
833**                  tNFC_RESPONSE_CBACK.
834**
835** Returns          tNFC_STATUS
836**
837*******************************************************************************/
838NFC_API extern tNFC_STATUS NFC_Enable (tNFC_RESPONSE_CBACK *p_cback);
839
840/*******************************************************************************
841**
842** Function         NFC_Disable
843**
844** Description      This function performs clean up routines for shutting down
845**                  NFC and closes the NCI transport (if using dedicated NCI
846**                  transport).
847**
848**                  When the NFC shutdown procedure is completed, an
849**                  NFC_DISABLED_REVT is returned to the application using the
850**                  tNFC_RESPONSE_CBACK.
851**
852** Returns          nothing
853**
854*******************************************************************************/
855NFC_API extern void NFC_Disable (void);
856
857/*******************************************************************************
858**
859** Function         NFC_Init
860**
861** Description      This function initializes control blocks for NFC
862**
863** Returns          nothing
864**
865*******************************************************************************/
866NFC_API extern void NFC_Init(void);
867
868/*******************************************************************************
869**
870** Function         NFC_GetLmrtSize
871**
872** Description      Called by application wto query the Listen Mode Routing
873**                  Table size supported by NFCC
874**
875** Returns          Listen Mode Routing Table size
876**
877*******************************************************************************/
878NFC_API extern UINT16 NFC_GetLmrtSize(void);
879
880/*******************************************************************************
881**
882** Function         NFC_SetConfig
883**
884** Description      This function is called to send the configuration parameter
885**                  TLV to NFCC. The response from NFCC is reported by
886**                  tNFC_RESPONSE_CBACK as NFC_SET_CONFIG_REVT.
887**
888** Parameters       tlv_size - the length of p_param_tlvs.
889**                  p_param_tlvs - the parameter ID/Len/Value list
890**
891** Returns          tNFC_STATUS
892**
893*******************************************************************************/
894NFC_API extern tNFC_STATUS NFC_SetConfig (UINT8     tlv_size,
895                                          UINT8    *p_param_tlvs);
896
897/*******************************************************************************
898**
899** Function         NFC_GetConfig
900**
901** Description      This function is called to retrieve the parameter TLV from NFCC.
902**                  The response from NFCC is reported by tNFC_RESPONSE_CBACK
903**                  as NFC_GET_CONFIG_REVT.
904**
905** Parameters       num_ids - the number of parameter IDs
906**                  p_param_ids - the parameter ID list.
907**
908** Returns          tNFC_STATUS
909**
910*******************************************************************************/
911NFC_API extern tNFC_STATUS NFC_GetConfig (UINT8     num_ids,
912                                          UINT8    *p_param_ids);
913
914/*******************************************************************************
915**
916** Function         NFC_NfceeDiscover
917**
918** Description      This function is called to enable or disable NFCEE Discovery.
919**                  The response from NFCC is reported by tNFC_RESPONSE_CBACK
920**                  as NFC_NFCEE_DISCOVER_REVT.
921**                  The notification from NFCC is reported by tNFC_RESPONSE_CBACK
922**                  as NFC_NFCEE_INFO_REVT.
923**
924** Parameters       discover - 1 to enable discover, 0 to disable.
925**
926** Returns          tNFC_STATUS
927**
928*******************************************************************************/
929NFC_API extern tNFC_STATUS NFC_NfceeDiscover (BOOLEAN discover);
930
931/*******************************************************************************
932**
933** Function         NFC_NfceeModeSet
934**
935** Description      This function is called to activate or de-activate an NFCEE
936**                  connected to the NFCC.
937**                  The response from NFCC is reported by tNFC_RESPONSE_CBACK
938**                  as NFC_NFCEE_MODE_SET_REVT.
939**
940** Parameters       nfcee_id - the NFCEE to activate or de-activate.
941**                  mode - 0 to activate NFCEE, 1 to de-activate.
942**
943** Returns          tNFC_STATUS
944**
945*******************************************************************************/
946NFC_API extern tNFC_STATUS NFC_NfceeModeSet (UINT8              nfcee_id,
947                                             tNFC_NFCEE_MODE    mode);
948/*******************************************************************************
949**
950** Function         NFC_DiscoveryMap
951**
952** Description      This function is called to set the discovery interface mapping.
953**                  The response from NFCC is reported by tNFC_DISCOVER_CBACK as.
954**                  NFC_MAP_DEVT.
955**
956** Parameters       num - the number of items in p_params.
957**                  p_maps - the discovery interface mappings
958**                  p_cback - the discovery callback function
959**
960** Returns          tNFC_STATUS
961**
962*******************************************************************************/
963NFC_API extern tNFC_STATUS NFC_DiscoveryMap(UINT8 num, tNFC_DISCOVER_MAPS *p_maps,
964                                        tNFC_DISCOVER_CBACK *p_cback);
965
966/*******************************************************************************
967**
968** Function         NFC_DiscoveryStart
969**
970** Description      This function is called to start Polling and/or Listening.
971**                  The response from NFCC is reported by tNFC_DISCOVER_CBACK as.
972**                  NFC_START_DEVT. The notification from NFCC is reported by
973**                  tNFC_DISCOVER_CBACK as NFC_RESULT_DEVT.
974**
975** Parameters       num_params - the number of items in p_params.
976**                  p_params - the discovery parameters
977**                  p_cback - the discovery callback function
978**
979** Returns          tNFC_STATUS
980**
981*******************************************************************************/
982NFC_API extern tNFC_STATUS NFC_DiscoveryStart(UINT8                 num_params,
983                                              tNFC_DISCOVER_PARAMS *p_params,
984                                              tNFC_DISCOVER_CBACK  *p_cback);
985
986/*******************************************************************************
987**
988** Function         NFC_DiscoverySelect
989**
990** Description      If tNFC_DISCOVER_CBACK reports status=NFC_MULTIPLE_PROT,
991**                  the application needs to use this function to select the
992**                  the logical endpoint to continue. The response from NFCC is
993**                  reported by tNFC_DISCOVER_CBACK as NFC_SELECT_DEVT.
994**
995** Parameters       rf_disc_id - The ID identifies the remote device.
996**                  protocol - the logical endpoint on the remote devide
997**                  rf_interface - the RF interface to communicate with NFCC
998**
999** Returns          tNFC_STATUS
1000**
1001*******************************************************************************/
1002NFC_API extern tNFC_STATUS NFC_DiscoverySelect (UINT8    rf_disc_id,
1003                                                UINT8    protocol,
1004                                                UINT8    rf_interface);
1005
1006/*******************************************************************************
1007**
1008** Function         NFC_ConnCreate
1009**
1010** Description      This function is called to create a logical connection with
1011**                  NFCC for data exchange.
1012**                  The response from NFCC is reported in tNFC_CONN_CBACK
1013**                  as NFC_CONN_CREATE_CEVT.
1014**
1015** Parameters       dest_type - the destination type
1016**                  id   - the NFCEE ID or RF Discovery ID .
1017**                  protocol - the protocol
1018**                  p_cback - the data callback function to receive data fron NFCC
1019**
1020** Returns          tNFC_STATUS
1021**
1022*******************************************************************************/
1023NFC_API extern tNFC_STATUS NFC_ConnCreate(UINT8             dest_type,
1024                                          UINT8             id,
1025                                          UINT8             protocol,
1026                                          tNFC_CONN_CBACK  *p_cback);
1027
1028/*******************************************************************************
1029**
1030** Function         NFC_ConnClose
1031**
1032** Description      This function is called to close a logical connection with
1033**                  NFCC.
1034**                  The response from NFCC is reported in tNFC_CONN_CBACK
1035**                  as NFC_CONN_CLOSE_CEVT.
1036**
1037** Parameters       conn_id - the connection id.
1038**
1039** Returns          tNFC_STATUS
1040**
1041*******************************************************************************/
1042NFC_API extern tNFC_STATUS NFC_ConnClose(UINT8 conn_id);
1043
1044/*******************************************************************************
1045**
1046** Function         NFC_SetStaticRfCback
1047**
1048** Description      This function is called to update the data callback function
1049**                  to receive the data for the given connection id.
1050**
1051** Parameters       p_cback - the connection callback function
1052**
1053** Returns          Nothing
1054**
1055*******************************************************************************/
1056NFC_API extern void NFC_SetStaticRfCback(tNFC_CONN_CBACK    *p_cback);
1057
1058/*******************************************************************************
1059**
1060** Function         NFC_SendData
1061**
1062** Description      This function is called to send the given data packet
1063**                  to the connection identified by the given connection id.
1064**
1065** Parameters       conn_id - the connection id.
1066**                  p_data - the data packet
1067**
1068** Returns          tNFC_STATUS
1069**
1070*******************************************************************************/
1071NFC_API extern tNFC_STATUS NFC_SendData(UINT8       conn_id,
1072                                        BT_HDR     *p_data);
1073
1074/*******************************************************************************
1075**
1076** Function         NFC_Deactivate
1077**
1078** Description      This function is called to stop the discovery process or
1079**                  put the listen device in sleep mode or terminate the NFC link.
1080**
1081**                  The response from NFCC is reported by tNFC_DISCOVER_CBACK
1082**                  as NFC_DEACTIVATE_DEVT.
1083**
1084** Parameters       deactivate_type - NFC_DEACTIVATE_TYPE_IDLE, to IDLE mode.
1085**                                    NFC_DEACTIVATE_TYPE_SLEEP to SLEEP mode.
1086**                                    NFC_DEACTIVATE_TYPE_SLEEP_AF to SLEEP_AF mode.
1087**
1088** Returns          tNFC_STATUS
1089**
1090*******************************************************************************/
1091NFC_API extern tNFC_STATUS NFC_Deactivate(tNFC_DEACT_TYPE deactivate_type);
1092
1093/*******************************************************************************
1094**
1095** Function         NFC_UpdateRFCommParams
1096**
1097** Description      This function is called to update RF Communication parameters
1098**                  once the Frame RF Interface has been activated.
1099**
1100**                  The response from NFCC is reported by tNFC_RESPONSE_CBACK
1101**                  as NFC_RF_COMM_PARAMS_UPDATE_REVT.
1102**
1103** Returns          tNFC_STATUS
1104**
1105*******************************************************************************/
1106NFC_API extern tNFC_STATUS NFC_UpdateRFCommParams (tNFC_RF_COMM_PARAMS *p_params);
1107
1108/*******************************************************************************
1109**
1110** Function         NFC_SetPowerOffSleep
1111**
1112** Description      This function closes/opens transport and turns off/on NFCC.
1113**
1114** Returns          tNFC_STATUS
1115**
1116*******************************************************************************/
1117NFC_API extern tNFC_STATUS NFC_SetPowerOffSleep (BOOLEAN enable);
1118
1119/*******************************************************************************
1120**
1121** Function         NFC_PowerCycleNFCC
1122**
1123** Description      This function turns off and then on NFCC.
1124**
1125** Returns          tNFC_STATUS
1126**
1127*******************************************************************************/
1128NFC_API extern tNFC_STATUS NFC_PowerCycleNFCC (void);
1129
1130/*******************************************************************************
1131**
1132** Function         NFC_SetRouting
1133**
1134** Description      This function is called to configure the CE routing table.
1135**                  The response from NFCC is reported by tNFC_RESPONSE_CBACK
1136**                  as NFC_SET_ROUTING_REVT.
1137**
1138** Parameters
1139**
1140** Returns          tNFC_STATUS
1141**
1142*******************************************************************************/
1143NFC_API extern tNFC_STATUS NFC_SetRouting(BOOLEAN     more,
1144                                            UINT8       nfcee_id,
1145                                            UINT8       num_tlv,
1146                                            UINT8       tlv_size,
1147                                            UINT8      *p_param_tlvs);
1148
1149/*******************************************************************************
1150**
1151** Function         NFC_GetRouting
1152**
1153** Description      This function is called to retrieve the CE routing table from
1154**                  NFCC. The response from NFCC is reported by tNFC_RESPONSE_CBACK
1155**                  as NFC_GET_ROUTING_REVT.
1156**
1157** Returns          tNFC_STATUS
1158**
1159*******************************************************************************/
1160NFC_API extern tNFC_STATUS NFC_GetRouting(void);
1161
1162/*******************************************************************************
1163**
1164** Function         NFC_RegVSCback
1165**
1166** Description      This function is called to register or de-register a callback
1167**                  function to receive Proprietary NCI response and notification
1168**                  events.
1169**                  The maximum number of callback functions allowed is NFC_NUM_VS_CBACKS
1170**
1171** Returns          tNFC_STATUS
1172**
1173*******************************************************************************/
1174NFC_API extern tNFC_STATUS NFC_RegVSCback (BOOLEAN          is_register,
1175                                           tNFC_VS_CBACK   *p_cback);
1176
1177/*******************************************************************************
1178**
1179** Function         NFC_SendVsCommand
1180**
1181** Description      This function is called to send the given vendor specific
1182**                  command to NFCC. The response from NFCC is reported to the
1183**                  given tNFC_VS_CBACK as (oid).
1184**
1185** Parameters       oid - The opcode of the VS command.
1186**                  p_data - The parameters for the VS command
1187**
1188** Returns          tNFC_STATUS
1189**
1190*******************************************************************************/
1191NFC_API extern tNFC_STATUS NFC_SendVsCommand(UINT8          oid,
1192                                             BT_HDR        *p_data,
1193                                             tNFC_VS_CBACK *p_cback);
1194
1195/*******************************************************************************
1196**
1197** Function         NFC_TestLoopback
1198**
1199** Description      This function is called to send the given data packet
1200**                  to NFCC for loopback test.
1201**                  When loopback data is received from NFCC, tNFC_TEST_CBACK .
1202**                  reports a NFC_LOOPBACK_TEVT.
1203**
1204** Parameters       p_data - the data packet
1205**
1206** Returns          tNFC_STATUS
1207**
1208*******************************************************************************/
1209NFC_API extern tNFC_STATUS NFC_TestLoopback(BT_HDR *p_data);
1210
1211/*******************************************************************************
1212**
1213** Function         NFC_SetTraceLevel
1214**
1215** Description      This function sets the trace level for NFC.  If called with
1216**                  a value of 0xFF, it simply returns the current trace level.
1217**
1218** Returns          The new or current trace level
1219**
1220*******************************************************************************/
1221NFC_API extern UINT8 NFC_SetTraceLevel (UINT8 new_level);
1222
1223/*******************************************************************************
1224**
1225** Function         NCI_SetTraceLevel
1226**
1227** Description      This function sets the trace level for NCI.  If called with
1228**                  a value of 0xFF, it simply returns the current trace level.
1229**
1230** Returns          The new or current trace level
1231**
1232*******************************************************************************/
1233NFC_API extern UINT8 NCI_SetTraceLevel (UINT8 new_level);
1234
1235#ifdef __cplusplus
1236}
1237#endif
1238
1239#endif /* NFC_API_H */
1240