blob: f23f026ca6b32da337edcb00f0287b943bf54d33 [file] [log] [blame]
nxpandroidc7611652015-09-23 16:42:05 +05301/******************************************************************************
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 *
nxf24591c1cbeab2018-02-21 17:32:26 +053020 * The original Work has been changed by NXP.
nxpandroidc7611652015-09-23 16:42:05 +053021 *
22 * Licensed under the Apache License, Version 2.0 (the "License");
23 * you may not use this file except in compliance with the License.
24 * You may obtain a copy of the License at
25 *
26 * http://www.apache.org/licenses/LICENSE-2.0
27 *
28 * Unless required by applicable law or agreed to in writing, software
29 * distributed under the License is distributed on an "AS IS" BASIS,
30 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 * See the License for the specific language governing permissions and
32 * limitations under the License.
33 *
nxf24591c1cbeab2018-02-21 17:32:26 +053034 * Copyright 2018 NXP
35 *
nxpandroidc7611652015-09-23 16:42:05 +053036 ******************************************************************************/
37
38/******************************************************************************
39 *
40 * This is the public interface file for NFA HCI, Broadcom's NFC
41 * application layer for mobile phones.
42 *
43 ******************************************************************************/
44#ifndef NFA_HCI_API_H
45#define NFA_HCI_API_H
46
47#include "nfa_api.h"
nxf24591c1cbeab2018-02-21 17:32:26 +053048
nxpandroidc7611652015-09-23 16:42:05 +053049/*****************************************************************************
50** Constants and data types
51*****************************************************************************/
52
53/* NFA HCI Debug constants */
nxpandroid8f6d0532017-07-12 18:25:30 +053054#define NFA_HCI_DEBUG_DISPLAY_CB 0
55#define NFA_HCI_DEBUG_SIM_HCI_EVENT 1
56#define NFA_HCI_DEBUG_ENABLE_LOOPBACK 101
57#define NFA_HCI_DEBUG_DISABLE_LOOPBACK 102
nxpandroidc7611652015-09-23 16:42:05 +053058
59/* NFA HCI callback events */
nxpandroid8f6d0532017-07-12 18:25:30 +053060#define NFA_HCI_REGISTER_EVT \
61 0x00 /* Application registered */
62/* Application deregistered */
63#define NFA_HCI_DEREGISTER_EVT 0x01
64/* Retrieved gates,pipes assoc. to application */
65#define NFA_HCI_GET_GATE_PIPE_LIST_EVT 0x02
nxf24591c1cbeab2018-02-21 17:32:26 +053066#define NFA_HCI_ALLOCATE_GATE_EVT \
67 0x03 /* A generic gate allocated to the application */
nxpandroid8f6d0532017-07-12 18:25:30 +053068#define NFA_HCI_DEALLOCATE_GATE_EVT \
69 0x04 /* A generic gate is released */
70#define NFA_HCI_CREATE_PIPE_EVT \
71 0x05 /* Pipe is created */
72#define NFA_HCI_OPEN_PIPE_EVT \
73 0x06 /* Pipe is opened / could not open */
74#define NFA_HCI_CLOSE_PIPE_EVT \
75 0x07 /* Pipe is closed / could not close */
76#define NFA_HCI_DELETE_PIPE_EVT \
77 0x08 /* Pipe is deleted */
78#define NFA_HCI_HOST_LIST_EVT \
79 0x09 /* Received list of Host from Host controller */
80/* HCI subsytem initialized */
81#define NFA_HCI_INIT_EVT 0x0A
82/* HCI subsytem exited */
83#define NFA_HCI_EXIT_EVT 0x0B
84/* Response recvd to cmd sent on app owned pipe */
85#define NFA_HCI_RSP_RCVD_EVT 0x0C
86/* Response sent on app owned pipe */
87#define NFA_HCI_RSP_SENT_EVT 0x0D
88/* Command sent on app owned pipe */
89#define NFA_HCI_CMD_SENT_EVT 0x0E
90/* Event sent on app owned pipe */
91#define NFA_HCI_EVENT_SENT_EVT 0x0F
92/* Command received on app owned pipe */
93#define NFA_HCI_CMD_RCVD_EVT 0x10
94/* Event received on app owned pipe */
95#define NFA_HCI_EVENT_RCVD_EVT 0x11
96/* Registry read command sent */
97#define NFA_HCI_GET_REG_CMD_EVT 0x12
98/* Registry write command sent */
99#define NFA_HCI_SET_REG_CMD_EVT 0x13
100/* Received response to read registry command */
101#define NFA_HCI_GET_REG_RSP_EVT 0x14
102/* Received response to write registry command */
103#define NFA_HCI_SET_REG_RSP_EVT 0x15
104/* A static pipe is added */
105#define NFA_HCI_ADD_STATIC_PIPE_EVT 0x16
nxpandroid3e4012e2016-08-01 19:09:55 +0530106#if (NXP_EXTNS == TRUE)
nxf24591c1cbeab2018-02-21 17:32:26 +0530107#define NFA_HCI_CMD_APDU_SENT_EVT 0x17 /* Command APDU sent to server APDU Host */
108#define NFA_HCI_APDU_ABORTED_EVT 0x18 /* Stopped waiting for Response APDU */
109#define NFA_HCI_RSP_APDU_RCVD_EVT 0x19 /* Response APDU received from server APDU Host */
nxpandroid3e4012e2016-08-01 19:09:55 +0530110#endif
nxpandroid8f6d0532017-07-12 18:25:30 +0530111typedef uint8_t tNFA_HCI_EVT;
nxpandroidc7611652015-09-23 16:42:05 +0530112
nxpandroid8f6d0532017-07-12 18:25:30 +0530113/* Max application name length */
114#define NFA_MAX_HCI_APP_NAME_LEN 0x10
115/* Max HCI command length */
116#define NFA_MAX_HCI_CMD_LEN 255
117/* Max HCI event length */
118#define NFA_MAX_HCI_RSP_LEN 255
nxpandroid8f6d0532017-07-12 18:25:30 +0530119/* Max HCI event length */
120#define NFA_MAX_HCI_EVENT_LEN 260
nxpandroid8f6d0532017-07-12 18:25:30 +0530121/* Max HCI data length */
122#define NFA_MAX_HCI_DATA_LEN 260
nxpandroidc7611652015-09-23 16:42:05 +0530123
124/* NFA HCI PIPE states */
nxpandroid8f6d0532017-07-12 18:25:30 +0530125#define NFA_HCI_PIPE_CLOSED 0x00 /* Pipe is closed */
126#define NFA_HCI_PIPE_OPENED 0x01 /* Pipe is opened */
nxf24591c1cbeab2018-02-21 17:32:26 +0530127#if (NXP_EXTNS == TRUE)
suraj4cef7642017-09-15 16:33:37 +0530128 /* HCI Recovery status*/
129 #define NFA_HCI_EE_RECOVERY_STARTED 0x01
130 #define NFA_HCI_EE_RECOVERY_COMPLETED 0x02
nxf24591c1cbeab2018-02-21 17:32:26 +0530131#define NFA_HCI_SESSION_ID_LEN 8 /* HCI Session ID length */
suraj4cef7642017-09-15 16:33:37 +0530132
nxf24591c1cbeab2018-02-21 17:32:26 +0530133/* APDU Pipe information */
134typedef struct
135{
136 bool reg_info_valid; /* Indicates max_cmd_apdu_size, max_wait_time are valid */
137 uint16_t max_cmd_apdu_size; /* Maximum length of msg that can be sent on the APDU pipe */
138 uint16_t max_wait_time; /* Maximum waiting time for the response on the APDU pipe */
139} tNFA_HCI_APDU_PIPE_REG_INFO;
140#endif
nxpandroid8f6d0532017-07-12 18:25:30 +0530141typedef uint8_t tNFA_HCI_PIPE_STATE;
nxpandroidc7611652015-09-23 16:42:05 +0530142/* Dynamic pipe control block */
nxpandroid8f6d0532017-07-12 18:25:30 +0530143typedef struct {
144 uint8_t pipe_id; /* Pipe ID */
145 tNFA_HCI_PIPE_STATE pipe_state; /* State of the Pipe */
146 uint8_t local_gate; /* local gate id */
147 uint8_t dest_host; /* Peer host to which this pipe is connected */
148 uint8_t dest_gate; /* Peer gate to which this pipe is connected */
nxpandroidc7611652015-09-23 16:42:05 +0530149} tNFA_HCI_PIPE_INFO;
Suraj Uday Kotharkar71fc5802018-06-01 16:57:34 +0530150
nxpandroidc7611652015-09-23 16:42:05 +0530151/* Data for NFA_HCI_REGISTER_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +0530152typedef struct {
153 tNFA_STATUS status; /* Status of registration */
154 tNFA_HANDLE hci_handle; /* Handle assigned to the application */
155 uint8_t num_pipes; /* Number of dynamic pipes exist for the application */
156 uint8_t num_gates; /* Number of generic gates exist for the application */
nxpandroidc7611652015-09-23 16:42:05 +0530157} tNFA_HCI_REGISTER;
158
159/* Data for NFA_HCI_DEREGISTER_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +0530160typedef struct {
161 tNFA_STATUS status; /* Status of deregistration */
nxpandroidc7611652015-09-23 16:42:05 +0530162} tNFA_HCI_DEREGISTER;
163
164/* Data for NFA_HCI_GET_GATE_PIPE_LIST_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +0530165typedef struct {
166 tNFA_STATUS status;
167 uint8_t num_pipes; /* Number of dynamic pipes exist for the application */
168 tNFA_HCI_PIPE_INFO
169 pipe[NFA_HCI_MAX_PIPE_CB]; /* List of pipe created for the application */
170 uint8_t num_gates; /* Number of generic gates exist for the application */
171 uint8_t gate[NFA_HCI_MAX_GATE_CB]; /* List of generic gates allocated to the
172 application */
nxf24591c1cbeab2018-02-21 17:32:26 +0530173#if (NXP_EXTNS == TRUE)
174 uint8_t num_host_created_pipes; /* Number of pipes created by host */
175 tNFA_HCI_PIPE_INFO host_created_pipe
176 [NFA_HCI_MAX_PIPE_CB]; /* Pipe information of the pipe created */
177#else
nxpandroid8f6d0532017-07-12 18:25:30 +0530178 uint8_t num_uicc_created_pipes; /* Number of pipes created by UICC host */
179 tNFA_HCI_PIPE_INFO uicc_created_pipe
180 [NFA_HCI_MAX_PIPE_CB]; /* Pipe information of the UICC created pipe */
nxf24591c1cbeab2018-02-21 17:32:26 +0530181#endif
nxpandroidc7611652015-09-23 16:42:05 +0530182} tNFA_HCI_GET_GATE_PIPE_LIST;
183
184/* Data for NFA_HCI_ALLOCATE_GATE_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +0530185typedef struct {
186 tNFA_STATUS status; /* Status of response to allocate gate request */
187 uint8_t gate; /* The gate allocated to the application */
nxpandroidc7611652015-09-23 16:42:05 +0530188} tNFA_HCI_ALLOCATE_GATE;
189
190/* Data for NFA_HCI_DEALLOCATE_GATE_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +0530191typedef struct {
192 tNFA_STATUS status; /* Status of response to deallocate gate request */
193 uint8_t gate; /* The gate deallocated from the application */
nxpandroidc7611652015-09-23 16:42:05 +0530194} tNFA_HCI_DEALLOCATE_GATE;
195
196/* Data for NFA_HCI_CREATE_PIPE_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +0530197typedef struct {
198 tNFA_STATUS status; /* Status of creating dynamic pipe for the application */
199 uint8_t pipe; /* The pipe created for the application */
200 uint8_t
201 source_gate; /* DH host gate to which the one end of pipe is attached */
202 uint8_t
203 dest_host; /* Destination host whose gate is the other end of the pipe is
204 attached to */
205 uint8_t dest_gate; /* Destination host gate to which the other end of pipe is
206 attached */
nxpandroidc7611652015-09-23 16:42:05 +0530207} tNFA_HCI_CREATE_PIPE;
208
209/* Data for NFA_HCI_OPEN_PIPE_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +0530210typedef struct {
211 tNFA_STATUS status; /* Status of open pipe operation */
212 uint8_t pipe; /* The dynamic pipe for open operation */
213} tNFA_HCI_OPEN_PIPE;
nxpandroidc7611652015-09-23 16:42:05 +0530214
215/* Data for NFA_HCI_CLOSE_PIPE_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +0530216typedef struct {
217 tNFA_STATUS status; /* Status of close pipe operation */
218 uint8_t pipe; /* The dynamic pipe for close operation */
219} tNFA_HCI_CLOSE_PIPE;
nxpandroidc7611652015-09-23 16:42:05 +0530220
221/* Data for NFA_HCI_DELETE_PIPE_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +0530222typedef struct {
223 tNFA_STATUS status; /* Status of delete pipe operation */
224 uint8_t pipe; /* The dynamic pipe for delete operation */
nxpandroidc7611652015-09-23 16:42:05 +0530225} tNFA_HCI_DELETE_PIPE;
226
227/* Data for NFA_HCI_HOST_LIST_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +0530228typedef struct {
229 tNFA_STATUS status; /* Status og get host list operation */
230 uint8_t num_hosts; /* Number of hosts in the host network */
231 uint8_t
232 host[NFA_HCI_MAX_HOST_IN_NETWORK]; /* List of host in the host network */
nxpandroidc7611652015-09-23 16:42:05 +0530233} tNFA_HCI_HOST_LIST;
nxf24591c1cbeab2018-02-21 17:32:26 +0530234#if (NXP_EXTNS == TRUE)
235/* Data for NFA_HCI_CMD_APDU_SENT_EVT */
236typedef struct
237{
238 tNFC_STATUS status; /* Status of APDU send operation */
239 uint8_t host_id; /* The APDU Server host to which command APDU is sent */
240} tNFA_HCI_CMD_APDU_SENT;
nxpandroidc7611652015-09-23 16:42:05 +0530241
nxf24591c1cbeab2018-02-21 17:32:26 +0530242/* Data for NFA_HCI_RSP_APDU_RCVD_EVT */
243typedef struct
244{
245 tNFC_STATUS status; /* Status of APDU received */
246 uint8_t host_id; /* The APDU Server host from which response APDU is received */
247 uint16_t apdu_len; /* Length of Response APDU received */
248 uint8_t *p_apdu; /* Response APDU */
249} tNFA_HCI_RSP_APDU_RCVD;
250
251/* Data for NFA_HCI_APDU_ABORTED_EVT */
252typedef struct
253{
254 tNFC_STATUS status; /* Status of aborting APDU command */
255 uint8_t host_id; /* The APDU Server host to which command APDU was addressed is aborted */
256 uint16_t atr_len; /* Length of Response ATR received */
257 uint8_t *p_atr; /* Response ATR */
258} tNFA_HCI_APDU_ABORTED;
259#endif
nxpandroidc7611652015-09-23 16:42:05 +0530260/* Data for NFA_HCI_RSP_RCVD_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +0530261typedef struct {
262 tNFA_STATUS status; /* Status of RSP to HCP CMD sent */
263 uint8_t pipe; /* The pipe on which HCP packet is exchanged */
264 uint8_t rsp_code; /* Response id */
265 uint16_t rsp_len; /* Response parameter length */
266 uint8_t rsp_data[NFA_MAX_HCI_RSP_LEN]; /* Response received */
nxpandroidc7611652015-09-23 16:42:05 +0530267} tNFA_HCI_RSP_RCVD;
268
269/* Data for NFA_HCI_EVENT_RCVD_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +0530270typedef struct {
271 tNFA_STATUS status; /* Status of Event received */
272 uint8_t pipe; /* The pipe on which HCP EVT packet is received */
273 uint8_t evt_code; /* HCP EVT id */
274 uint16_t evt_len; /* HCP EVT parameter length */
275 uint8_t* p_evt_buf; /* HCP EVT Parameter */
nxpandroidc7611652015-09-23 16:42:05 +0530276} tNFA_HCI_EVENT_RCVD;
277
278/* Data for NFA_HCI_CMD_RCVD_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +0530279typedef struct {
280 tNFA_STATUS status; /* Status of Command received */
281 uint8_t pipe; /* The pipe on which HCP CMD packet is received */
282 uint8_t cmd_code; /* HCP CMD id */
283 uint16_t cmd_len; /* HCP CMD parameter length */
284 uint8_t cmd_data[NFA_MAX_HCI_CMD_LEN]; /* HCP CMD Parameter */
nxpandroidc7611652015-09-23 16:42:05 +0530285} tNFA_HCI_CMD_RCVD;
286
287/* Data for NFA_HCI_INIT_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +0530288typedef struct {
289 tNFA_STATUS status; /* Status of Enabling HCI Network */
nxpandroidc7611652015-09-23 16:42:05 +0530290} tNFA_HCI_INIT;
291
292/* Data for NFA_HCI_EXIT_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +0530293typedef struct {
294 tNFA_STATUS status; /* Status of Disabling HCI Network */
nxpandroidc7611652015-09-23 16:42:05 +0530295} tNFA_HCI_EXIT;
296
297/* Data for NFA_HCI_RSP_SENT_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +0530298typedef struct {
299 tNFA_STATUS status; /* Status of HCP response send operation */
nxpandroidc7611652015-09-23 16:42:05 +0530300} tNFA_HCI_RSP_SENT;
301
302/* Data for NFA_HCI_CMD_SENT_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +0530303typedef struct {
304 tNFA_STATUS status; /* Status of Command send operation */
nxpandroidc7611652015-09-23 16:42:05 +0530305} tNFA_HCI_CMD_SENT;
306
307/* Data for NFA_HCI_EVENT_SENT_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +0530308typedef struct {
309 tNFA_STATUS status; /* Status of Event send operation */
nxpandroid70cccc72016-11-18 19:58:22 +0530310#if (NXP_EXTNS == TRUE)
nxpandroid8f6d0532017-07-12 18:25:30 +0530311 uint8_t evt_type;
nxpandroid70cccc72016-11-18 19:58:22 +0530312#endif
nxpandroidc7611652015-09-23 16:42:05 +0530313} tNFA_HCI_EVENT_SENT;
314
315/* Data for NFA_HCI_ADD_STATIC_PIPE_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +0530316typedef struct {
317 tNFA_STATUS status; /* Status of adding proprietary pipe */
nxpandroidc7611652015-09-23 16:42:05 +0530318} tNFA_HCI_ADD_STATIC_PIPE_EVT;
319
320/* data type for all registry-related events */
nxpandroid8f6d0532017-07-12 18:25:30 +0530321typedef struct {
322 tNFA_STATUS status; /* Status of Registry operation */
323 uint8_t pipe; /* Pipe on whose registry is of interest */
324 uint8_t index; /* Index of the registry operated */
325 uint8_t data_len; /* length of the registry parameter */
326 uint8_t reg_data[NFA_MAX_HCI_DATA_LEN]; /* Registry parameter */
nxpandroidc7611652015-09-23 16:42:05 +0530327} tNFA_HCI_REGISTRY;
nxpandroid3e4012e2016-08-01 19:09:55 +0530328#if (NXP_EXTNS == TRUE)
suraj4cef7642017-09-15 16:33:37 +0530329typedef struct {
330 tNFA_STATUS status; /* Status of command on Admin pipe */
331 uint8_t host;
332} tNFA_HCI_EE_RECOVERY_EVT;
nxf24591c1cbeab2018-02-21 17:32:26 +0530333#endif
suraj4cef7642017-09-15 16:33:37 +0530334/* Data for tNFA_HCI_CONFIG_RSP_RCVD */
nxpandroidc7611652015-09-23 16:42:05 +0530335/* Union of all hci callback structures */
nxpandroid8f6d0532017-07-12 18:25:30 +0530336typedef union {
337 tNFA_HCI_REGISTER hci_register; /* NFA_HCI_REGISTER_EVT */
338 tNFA_HCI_DEREGISTER hci_deregister; /* NFA_HCI_DEREGISTER_EVT */
339 tNFA_HCI_GET_GATE_PIPE_LIST gates_pipes; /* NFA_HCI_GET_GATE_PIPE_LIST_EVT */
340 tNFA_HCI_ALLOCATE_GATE allocated; /* NFA_HCI_ALLOCATE_GATE_EVT */
341 tNFA_HCI_DEALLOCATE_GATE deallocated; /* NFA_HCI_DEALLOCATE_GATE_EVT */
342 tNFA_HCI_CREATE_PIPE created; /* NFA_HCI_CREATE_PIPE_EVT */
343 tNFA_HCI_OPEN_PIPE opened; /* NFA_HCI_OPEN_PIPE_EVT */
344 tNFA_HCI_CLOSE_PIPE closed; /* NFA_HCI_CLOSE_PIPE_EVT */
345 tNFA_HCI_DELETE_PIPE deleted; /* NFA_HCI_DELETE_PIPE_EVT */
346 tNFA_HCI_HOST_LIST hosts; /* NFA_HCI_HOST_LIST_EVT */
347 tNFA_HCI_RSP_RCVD rsp_rcvd; /* NFA_HCI_RSP_RCVD_EVT */
348 tNFA_HCI_RSP_SENT rsp_sent; /* NFA_HCI_RSP_SENT_EVT */
349 tNFA_HCI_CMD_SENT cmd_sent; /* NFA_HCI_CMD_SENT_EVT */
350 tNFA_HCI_EVENT_SENT evt_sent; /* NFA_HCI_EVENT_SENT_EVT */
351 tNFA_HCI_CMD_RCVD cmd_rcvd; /* NFA_HCI_CMD_RCVD_EVT */
352 tNFA_HCI_EVENT_RCVD rcvd_evt; /* NFA_HCI_EVENT_RCVD_EVT */
353 tNFA_STATUS status; /* status of api command request */
354 tNFA_HCI_REGISTRY registry; /* all registry-related events -
355 NFA_HCI_GET_REG_CMD_EVT,
356 NFA_HCI_SET_REG_CMD_EVT,
357 NFA_HCI_GET_REG_RSP_EVT,
358 NFA_HCI_SET_REG_RSP_EVT */
359 tNFA_HCI_INIT hci_init; /* NFA_HCI_INIT_EVT */
360 tNFA_HCI_EXIT hci_exit; /* NFA_HCI_EXIT_EVT */
nxf24591c1cbeab2018-02-21 17:32:26 +0530361#if (NXP_EXTNS == TRUE)
362 tNFA_HCI_CMD_APDU_SENT apdu_sent; /* NFA_HCI_CMD_APDU_SENT_EVT */
363 tNFA_HCI_APDU_ABORTED apdu_aborted; /* NFA_HCI_APDU_ABORTED_EVT */
364 tNFA_HCI_RSP_APDU_RCVD apdu_rcvd; /* NFA_HCI_RSP_APDU_RCVD_EVT */
365#endif
nxpandroid8f6d0532017-07-12 18:25:30 +0530366 tNFA_HCI_ADD_STATIC_PIPE_EVT pipe_added; /* NFA_HCI_ADD_STATIC_PIPE_EVT */
nxpandroidc7611652015-09-23 16:42:05 +0530367} tNFA_HCI_EVT_DATA;
368
nxpandroidc7611652015-09-23 16:42:05 +0530369/* NFA HCI callback */
nxpandroid8f6d0532017-07-12 18:25:30 +0530370typedef void(tNFA_HCI_CBACK)(tNFA_HCI_EVT event, tNFA_HCI_EVT_DATA* p_data);
nxpandroidc7611652015-09-23 16:42:05 +0530371
372/*****************************************************************************
373** External Function Declarations
374*****************************************************************************/
nxpandroidc7611652015-09-23 16:42:05 +0530375
nxpandroidc7611652015-09-23 16:42:05 +0530376/*******************************************************************************
377**
378** Function NFA_HciRegister
379**
380** Description This function will register an application with hci and
381** returns an application handle and provides a mechanism to
nxpandroid8f6d0532017-07-12 18:25:30 +0530382** register a callback with HCI to receive NFA HCI event
383** notification. When the application is registered (or if an
384** error occurs), the app will be notified with
385** NFA_HCI_REGISTER_EVT. Previous session information
386** including allocated gates, created pipes and pipes states
387** will be returned as part of tNFA_HCI_REGISTER data.
nxpandroidc7611652015-09-23 16:42:05 +0530388**
389** Returns NFA_STATUS_OK if successfully initiated
390** NFA_STATUS_FAILED otherwise
391**
392*******************************************************************************/
nxpandroid8f6d0532017-07-12 18:25:30 +0530393extern tNFA_STATUS NFA_HciRegister(char* p_app_name, tNFA_HCI_CBACK* p_cback,
394 bool b_send_conn_evts);
nxpandroidc7611652015-09-23 16:42:05 +0530395
396/*******************************************************************************
397**
398** Function NFA_HciGetGateAndPipeList
399**
400** Description This function will retrieve the list of gates allocated to
401** the application and list of dynamic pipes created for the
402** application. The app will be notified with
403** NFA_HCI_GET_GATE_PIPE_LIST_EVT. List of allocated dynamic
404** gates to the application and list of pipes created by the
405** application will be returned as part of
406** tNFA_HCI_GET_GATE_PIPE_LIST data.
407**
408** Returns NFA_STATUS_OK if successfully initiated
409** NFA_STATUS_FAILED otherwise
410**
411*******************************************************************************/
nxpandroid8f6d0532017-07-12 18:25:30 +0530412extern tNFA_STATUS NFA_HciGetGateAndPipeList(tNFA_HANDLE hci_handle);
nxpandroidc7611652015-09-23 16:42:05 +0530413
414/*******************************************************************************
415**
416** Function NFA_HciDeregister
417**
418** Description This function is called to deregister an application
419** from HCI. The app will be notified by NFA_HCI_DEREGISTER_EVT
nxpandroid8f6d0532017-07-12 18:25:30 +0530420** after deleting all the pipes owned by the app and
421** deallocating all the gates allocated to the app or if an
422** error occurs. The app can release the buffer provided for
423** collecting long APDUs after receiving
424** NFA_HCI_DEREGISTER_EVT. Even if deregistration fails, the
425** app has to register again to provide a new cback function
426** and event buffer for receiving long APDUs.
nxpandroidc7611652015-09-23 16:42:05 +0530427**
nxpandroid8f6d0532017-07-12 18:25:30 +0530428** Returns NFA_STATUS_OK if the application is deregistered
429** successfully
nxpandroidc7611652015-09-23 16:42:05 +0530430** NFA_STATUS_FAILED otherwise
431**
432*******************************************************************************/
nxpandroid8f6d0532017-07-12 18:25:30 +0530433extern tNFA_STATUS NFA_HciDeregister(char* p_app_name);
nxpandroidc7611652015-09-23 16:42:05 +0530434
435/*******************************************************************************
436**
437** Function NFA_HciAllocGate
438**
439** Description This function will allocate the gate if any specified or an
440** available generic gate for the app to provide an entry point
441** for a particular service to other host or to establish
442** communication with other host. When the gate is
443** allocated (or if an error occurs), the app will be notified
nxpandroid8f6d0532017-07-12 18:25:30 +0530444** with NFA_HCI_ALLOCATE_GATE_EVT with the gate id. The
445** allocated Gate information will be stored in non volatile
446** memory.
nxpandroidc7611652015-09-23 16:42:05 +0530447**
448** Returns NFA_STATUS_OK if this API started
449** NFA_STATUS_FAILED if no generic gate is available
450**
451*******************************************************************************/
nxpandroid8f6d0532017-07-12 18:25:30 +0530452extern tNFA_STATUS NFA_HciAllocGate(tNFA_HANDLE hci_handle, uint8_t gate);
nxpandroidc7611652015-09-23 16:42:05 +0530453
454/*******************************************************************************
455**
456** Function NFA_HciDeallocGate
457**
458** Description This function will release the specified gate that was
459** previously allocated to the application. When the generic
460** gate is released (or if an error occurs), the app will be
461** notified with NFA_HCI_DEALLOCATE_GATE_EVT with the gate id.
462** The allocated Gate information will be deleted from non
463** volatile memory and all the associated pipes are deleted
464** by informing host controller.
465**
466** Returns NFA_STATUS_OK if successfully initiated
467** NFA_STATUS_BAD_HANDLE if handle is not valid
468** NFA_STATUS_FAILED otherwise
469**
470*******************************************************************************/
nxpandroid8f6d0532017-07-12 18:25:30 +0530471extern tNFA_STATUS NFA_HciDeallocGate(tNFA_HANDLE conn_handle, uint8_t gate);
nxpandroidc7611652015-09-23 16:42:05 +0530472
473/*******************************************************************************
474**
475** Function NFA_HciGetHostList
476**
477** Description This function will request the host controller to return the
478** list of hosts that are present in the host network. When
479** host controller responds with the host list (or if an error
480** occurs), the app will be notified with NFA_HCI_HOST_LIST_EVT
481**
482** Returns NFA_STATUS_OK if successfully initiated
483** NFA_STATUS_BAD_HANDLE if handle is not valid
484** NFA_STATUS_FAILED otherwise
485**
486*******************************************************************************/
nxpandroid8f6d0532017-07-12 18:25:30 +0530487extern tNFA_STATUS NFA_HciGetHostList(tNFA_HANDLE hci_handle);
nxpandroidc7611652015-09-23 16:42:05 +0530488
489/*******************************************************************************
490**
491** Function NFA_HciCreatePipe
492**
493** Description This function is called to create a dynamic pipe with the
494** specified host. When the dynamic pipe is created (or
495** if an error occurs), the app will be notified with
496** NFA_HCI_CREATE_PIPE_EVT with the pipe id. If a pipe exists
497** between the two gates passed as argument and if it was
498** created earlier by the calling application then the pipe
499** id of the existing pipe will be returned and a new pipe
500** will not be created. After successful creation of pipe,
501** registry entry will be created for the dynamic pipe and
502** all information related to the pipe will be stored in non
503** volatile memory.
504**
505** Returns NFA_STATUS_OK if successfully initiated
506** NFA_STATUS_FAILED otherwise
507**
508*******************************************************************************/
nxpandroid8f6d0532017-07-12 18:25:30 +0530509extern tNFA_STATUS NFA_HciCreatePipe(tNFA_HANDLE hci_handle,
510 uint8_t source_gate_id, uint8_t dest_host,
511 uint8_t dest_gate);
nxpandroidc7611652015-09-23 16:42:05 +0530512
513/*******************************************************************************
514**
515** Function NFA_HciOpenPipe
516**
517** Description This function is called to open a dynamic pipe.
518** When the dynamic pipe is opened (or
519** if an error occurs), the app will be notified with
520** NFA_HCI_OPEN_PIPE_EVT with the pipe id.
521**
522** Returns NFA_STATUS_OK if successfully initiated
523** NFA_STATUS_FAILED otherwise
524**
525*******************************************************************************/
nxpandroid8f6d0532017-07-12 18:25:30 +0530526extern tNFA_STATUS NFA_HciOpenPipe(tNFA_HANDLE hci_handle, uint8_t pipe);
nxpandroidc7611652015-09-23 16:42:05 +0530527
528/*******************************************************************************
529**
530** Function NFA_HciGetRegistry
531**
532** Description This function requests a peer host to return the desired
533** registry field value for the gate that the pipe is on.
534**
535** When the peer host responds,the app is notified with
536** NFA_HCI_GET_REG_RSP_EVT or
537** if an error occurs in sending the command the app will be
538** notified by NFA_HCI_CMD_SENT_EVT
539**
540** Returns NFA_STATUS_OK if successfully initiated
541** NFA_STATUS_FAILED otherwise
542**
543*******************************************************************************/
nxpandroid8f6d0532017-07-12 18:25:30 +0530544extern tNFA_STATUS NFA_HciGetRegistry(tNFA_HANDLE hci_handle, uint8_t pipe,
545 uint8_t reg_inx);
nxf24591e1fb2f92018-06-06 14:41:56 +0530546#if (NXP_EXTNS == TRUE)
547/*******************************************************************************
548**
549** Function NFA_HciSetRegistry
550**
551** Description This function requests a peer host to set the desired
552** registry field value for the gate that the pipe is on.
553**
554** When the peer host responds,the app is notified with
555** NFA_HCI_SET_REG_RSP_EVT or
556** if an error occurs in sending the command the app will be
557** notified by NFA_HCI_CMD_SENT_EVT
558**
559** Returns NFA_STATUS_OK if successfully initiated
560** NFA_STATUS_FAILED otherwise
561**
562*******************************************************************************/
563extern tNFA_STATUS NFA_HciSetRegistry(tNFA_HANDLE hci_handle, uint8_t pipe,
564 uint8_t reg_inx, uint8_t data_size,
565 uint8_t* p_data);
566#endif
nxpandroidc7611652015-09-23 16:42:05 +0530567/*******************************************************************************
568**
nxpandroidc7611652015-09-23 16:42:05 +0530569** Function NFA_HciSendCommand
570**
571** Description This function is called to send a command on a pipe created
572** by the application.
573** The app will be notified by NFA_HCI_CMD_SENT_EVT if an error
574** occurs.
575** When the peer host responds,the app is notified with
576** NFA_HCI_RSP_RCVD_EVT
577**
578** Returns NFA_STATUS_OK if successfully initiated
579** NFA_STATUS_FAILED otherwise
580**
581*******************************************************************************/
nxpandroid8f6d0532017-07-12 18:25:30 +0530582extern tNFA_STATUS NFA_HciSendCommand(tNFA_HANDLE hci_handle, uint8_t pipe,
583 uint8_t cmd_code, uint16_t cmd_size,
584 uint8_t* p_data);
nxpandroidc7611652015-09-23 16:42:05 +0530585
586/*******************************************************************************
587**
nxpandroidc7611652015-09-23 16:42:05 +0530588** Function NFA_HciSendEvent
589**
590** Description This function is called to send any event on a pipe created
591** by the application.
592** The app will be notified by NFA_HCI_EVENT_SENT_EVT
593** after successfully sending the event on the specified pipe
594** or if an error occurs. The application should wait for this
595** event before releasing event buffer passed as argument.
596** If the app is expecting a response to the event then it can
597** provide response buffer for collecting the response. If it
598** provides a response buffer it should also provide response
599** timeout indicating duration validity of the response buffer.
600** Maximum of NFA_MAX_HCI_EVENT_LEN bytes APDU can be received
601** using internal buffer if no response buffer is provided by
602** the application. The app will be notified by
603** NFA_HCI_EVENT_RCVD_EVT after receiving the response event
604** or on timeout if app provided response buffer.
605** If response buffer is provided by the application, it should
606** wait for this event before releasing the response buffer.
607**
608** Returns NFA_STATUS_OK if successfully initiated
609** NFA_STATUS_FAILED otherwise
610**
611*******************************************************************************/
nxpandroid8f6d0532017-07-12 18:25:30 +0530612tNFA_STATUS NFA_HciSendEvent(tNFA_HANDLE hci_handle, uint8_t pipe,
613 uint8_t evt_code, uint16_t evt_size,
614 uint8_t* p_data, uint16_t rsp_size,
nxf24591c1cbeab2018-02-21 17:32:26 +0530615 uint8_t* p_rsp_buf, uint16_t rsp_timeout);
nxpandroidc7611652015-09-23 16:42:05 +0530616
617/*******************************************************************************
618**
619** Function NFA_HciClosePipe
620**
621** Description This function is called to close a dynamic pipe.
622** When the dynamic pipe is closed (or
623** if an error occurs), the app will be notified with
624** NFA_HCI_CLOSE_PIPE_EVT with the pipe id.
625**
626** Returns NFA_STATUS_OK if successfully initiated
627** NFA_STATUS_FAILED otherwise
628**
629*******************************************************************************/
nxpandroid8f6d0532017-07-12 18:25:30 +0530630extern tNFA_STATUS NFA_HciClosePipe(tNFA_HANDLE hci_handle, uint8_t pipe);
nxpandroidc7611652015-09-23 16:42:05 +0530631
632/*******************************************************************************
633**
634** Function NFA_HciDeletePipe
635**
636** Description This function is called to delete a particular dynamic pipe.
637** When the dynamic pipe is deleted (or if an error occurs),
638** the app will be notified with NFA_HCI_DELETE_PIPE_EVT with
639** the pipe id. After successful deletion of pipe, registry
640** entry will be deleted for the dynamic pipe and all
641** information related to the pipe will be deleted from non
642** volatile memory.
643**
644** Returns NFA_STATUS_OK if successfully initiated
645** NFA_STATUS_BAD_HANDLE if handle is not valid
646** NFA_STATUS_FAILED otherwise
647**
648*******************************************************************************/
nxpandroid8f6d0532017-07-12 18:25:30 +0530649extern tNFA_STATUS NFA_HciDeletePipe(tNFA_HANDLE hci_handle, uint8_t pipe);
nxpandroidc7611652015-09-23 16:42:05 +0530650
651/*******************************************************************************
652**
653** Function NFA_HciAddStaticPipe
654**
655** Description This function is called to add a static pipe for sending
nxpandroid8f6d0532017-07-12 18:25:30 +0530656** 7816 APDUs. When the static pipe is added (or if an error
657** occurs), the app will be notified with
658** NFA_HCI_ADD_STATIC_PIPE_EVT with status.
nxpandroidc7611652015-09-23 16:42:05 +0530659**
660** Returns NFA_STATUS_OK if successfully initiated
661** NFA_STATUS_FAILED otherwise
662**
663*******************************************************************************/
nxpandroid8f6d0532017-07-12 18:25:30 +0530664extern tNFA_STATUS NFA_HciAddStaticPipe(tNFA_HANDLE hci_handle, uint8_t host,
665 uint8_t gate, uint8_t pipe);
nxpandroidc7611652015-09-23 16:42:05 +0530666
nxpandroid5e589782017-08-14 11:54:50 +0530667#if (NXP_EXTNS == TRUE)
nxpandroid3e4012e2016-08-01 19:09:55 +0530668/*******************************************************************************
669**
nxf24591c1cbeab2018-02-21 17:32:26 +0530670** Function NFA_HciSendResponse
nxpandroid3e4012e2016-08-01 19:09:55 +0530671**
nxf24591c1cbeab2018-02-21 17:32:26 +0530672** Description This function is called to send a response on a pipe created
673** by the application.
674** The app will be notified by NFA_HCI_RSP_SENT_EVT if an error
675** occurs.
676**
677** Returns NFA_STATUS_OK if successfully initiated
678** NFA_STATUS_FAILED otherwise
nxpandroid3e4012e2016-08-01 19:09:55 +0530679**
680*******************************************************************************/
nxf24591c1cbeab2018-02-21 17:32:26 +0530681extern tNFA_STATUS NFA_HciSendResponse(tNFA_HANDLE hci_handle, uint8_t pipe,
682 uint8_t response, uint8_t data_size,
683 uint8_t* p_data);
684/*******************************************************************************
685**
686** Function NFA_HciSendApdu
687**
688** Description This function is called to send APDU commands to one of
689** the host that acts as a server APDU host and to receive
690** response from that host on APDU pipe.
691**
692** The application will be notified by NFA_HCI_CMD_APDU_SENT_EVT
693** after successfully sending the APDU command on APDU pipe of
694** the specified host or if an error occurs. The application
695** should wait for this event before releasing APDU command
696** buffer passed as an argument. The application should provide
697** response APDU buffer for collecting the response APDU.
698** The application will be notified by NFA_HCI_RSP_APDU_RCVD_EVT
699** after receiving the response APDU or on timeout if timeout
700** can be automatically detected on the pipe (If APDU Pipe is
701** connected to APDU Gate implemented as per spec ETSI TS 102
702** 622 V12.1.0) on destination host.
703** If a response buffer is provided by the application, it
704** should wait for NFA_HCI_RSP_APDU_RCVD_EVT event or call
705** NFA_HciAbortApdu and wait for NFA_HCI_APDU_ABORTED_EVT
706** before releasing the response APDU buffer.
707**
708** Returns NFA_STATUS_OK if successfully initiated
709** NFA_STATUS_FAILED otherwise
710**
711*******************************************************************************/
712tNFC_STATUS NFA_HciSendApdu (tNFA_HANDLE hci_handle,
713 uint8_t host_id,
714 uint16_t cmd_apdu_len,
715 uint8_t *p_cmd_apdu,
716 uint16_t rsp_apdu_buf_size,
717 uint8_t *p_rsp_apdu_buf,
718 uint32_t rsp_timeout);
719
720/*******************************************************************************
721**
722** Function NFA_HciAbortApdu
723**
724** Description This function is called to stop waiting for response APDU
725** for the command APDU sent by the application on the APDU pipe
726** of the specified host. The application will be notified by
727** NFA_HCI_APDU_ABORTED_EVT after releasing response buffer
728** provided with NFA_HciSendApdu for collecting the response
729** APDU and releasing the APDU pipe for sending next command
730** APDU on the pipe.
731** If APDU server host supports EVT_ABORT then the server host
732** is also notified to Abort the APDU command and wait for
733** it to confirm with EVT_ATR that it stopped processing the
734** command APDU before releasing the response buffer and
735** reporting NFA_HCI_APDU_ABORTED_EVT to the application
736**
737** Returns NFA_STATUS_OK if successfully initiated
738** NFA_STATUS_FAILED otherwise
739**
740*******************************************************************************/
741tNFC_STATUS NFA_HciAbortApdu (tNFA_HANDLE hci_handle, uint8_t host_id, uint32_t rsp_timeout);
742
nxpandroid3e4012e2016-08-01 19:09:55 +0530743#endif
nxpandroidc7611652015-09-23 16:42:05 +0530744/*******************************************************************************
745**
746** Function NFA_HciDebug
747**
748** Description Debug function.
749**
750*******************************************************************************/
nxf24591c1cbeab2018-02-21 17:32:26 +0530751extern void NFA_HciDebug(uint8_t action, uint8_t size, uint8_t* p_data);
nxpandroidc7611652015-09-23 16:42:05 +0530752
753#endif /* NFA_P2P_API_H */