1 /******************************************************************************
2  *
3  *  Copyright (C) 2010-2014 Broadcom Corporation
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at:
8  *
9  *  http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  ******************************************************************************/
18 
19 /******************************************************************************
20  *
21  *  This is the public interface file for NFA HCI, Broadcom's NFC
22  *  application layer for mobile phones.
23  *
24  ******************************************************************************/
25 #ifndef NFA_HCI_API_H
26 #define NFA_HCI_API_H
27 
28 #include "nfa_api.h"
29 
30 /*****************************************************************************
31 **  Constants and data types
32 *****************************************************************************/
33 
34 /* NFA HCI Debug constants */
35 #define NFA_HCI_DEBUG_DISPLAY_CB 0
36 #define NFA_HCI_DEBUG_SIM_HCI_EVENT 1
37 #define NFA_HCI_DEBUG_ENABLE_LOOPBACK 101
38 #define NFA_HCI_DEBUG_DISABLE_LOOPBACK 102
39 
40 /* NFA HCI callback events */
41 #define NFA_HCI_REGISTER_EVT \
42   0x00 /* Application registered                       */
43 /* Application deregistered                     */
44 #define NFA_HCI_DEREGISTER_EVT 0x01
45 /* Retrieved gates,pipes assoc. to application  */
46 #define NFA_HCI_GET_GATE_PIPE_LIST_EVT 0x02
47 #define NFA_HCI_ALLOCATE_GATE_EVT \
48   0x03 /* A generic gate allocated to the application  */
49 #define NFA_HCI_DEALLOCATE_GATE_EVT \
50   0x04 /* A generic gate is released                   */
51 #define NFA_HCI_CREATE_PIPE_EVT \
52   0x05 /* Pipe is created                              */
53 #define NFA_HCI_OPEN_PIPE_EVT \
54   0x06 /* Pipe is opened / could not open              */
55 #define NFA_HCI_CLOSE_PIPE_EVT \
56   0x07 /* Pipe is closed / could not close             */
57 #define NFA_HCI_DELETE_PIPE_EVT \
58   0x08 /* Pipe is deleted                              */
59 #define NFA_HCI_HOST_LIST_EVT \
60   0x09 /* Received list of Host from Host controller   */
61 /* HCI subsytem initialized                     */
62 #define NFA_HCI_INIT_EVT 0x0A
63 /* HCI subsytem exited                          */
64 #define NFA_HCI_EXIT_EVT 0x0B
65 /* Response recvd to cmd sent on app owned pipe */
66 #define NFA_HCI_RSP_RCVD_EVT 0x0C
67 /* Response sent on app owned pipe              */
68 #define NFA_HCI_RSP_SENT_EVT 0x0D
69 /* Command sent on app owned pipe               */
70 #define NFA_HCI_CMD_SENT_EVT 0x0E
71 /* Event sent on app owned pipe                 */
72 #define NFA_HCI_EVENT_SENT_EVT 0x0F
73 /* Command received on app owned pipe           */
74 #define NFA_HCI_CMD_RCVD_EVT 0x10
75 /* Event received on app owned pipe             */
76 #define NFA_HCI_EVENT_RCVD_EVT 0x11
77 /* Registry read command sent                   */
78 #define NFA_HCI_GET_REG_CMD_EVT 0x12
79 /* Registry write command sent                  */
80 #define NFA_HCI_SET_REG_CMD_EVT 0x13
81 /* Received response to read registry command   */
82 #define NFA_HCI_GET_REG_RSP_EVT 0x14
83 /* Received response to write registry command  */
84 #define NFA_HCI_SET_REG_RSP_EVT 0x15
85 /* A static pipe is added                       */
86 #define NFA_HCI_ADD_STATIC_PIPE_EVT 0x16
87 
88 typedef uint8_t tNFA_HCI_EVT;
89 
90 /* Max application name length */
91 #define NFA_MAX_HCI_APP_NAME_LEN 0x10
92 /* Max HCI command length */
93 #define NFA_MAX_HCI_CMD_LEN 255
94 /* Max HCI event length */
95 #define NFA_MAX_HCI_RSP_LEN 255
96 /* Max HCI event length */
97 #define NFA_MAX_HCI_EVENT_LEN 300
98 /* Max HCI data length */
99 #define NFA_MAX_HCI_DATA_LEN 260
100 
101 /* NFA HCI PIPE states */
102 #define NFA_HCI_PIPE_CLOSED 0x00 /* Pipe is closed */
103 #define NFA_HCI_PIPE_OPENED 0x01 /* Pipe is opened */
104 
105 typedef uint8_t tNFA_HCI_PIPE_STATE;
106 /* Dynamic pipe control block */
107 typedef struct {
108   uint8_t pipe_id;                /* Pipe ID */
109   tNFA_HCI_PIPE_STATE pipe_state; /* State of the Pipe */
110   uint8_t local_gate;             /* local gate id */
111   uint8_t dest_host; /* Peer host to which this pipe is connected */
112   uint8_t dest_gate; /* Peer gate to which this pipe is connected */
113 } tNFA_HCI_PIPE_INFO;
114 
115 /* Data for NFA_HCI_REGISTER_EVT */
116 typedef struct {
117   tNFA_STATUS status;     /* Status of registration */
118   tNFA_HANDLE hci_handle; /* Handle assigned to the application */
119   uint8_t num_pipes; /* Number of dynamic pipes exist for the application */
120   uint8_t num_gates; /* Number of generic gates exist for the application */
121 } tNFA_HCI_REGISTER;
122 
123 /* Data for NFA_HCI_DEREGISTER_EVT */
124 typedef struct {
125   tNFA_STATUS status; /* Status of deregistration */
126 } tNFA_HCI_DEREGISTER;
127 
128 /* Data for NFA_HCI_GET_GATE_PIPE_LIST_EVT */
129 typedef struct {
130   tNFA_STATUS status;
131   uint8_t num_pipes; /* Number of dynamic pipes exist for the application */
132   tNFA_HCI_PIPE_INFO
133       pipe[NFA_HCI_MAX_PIPE_CB]; /* List of pipe created for the application */
134   uint8_t num_gates; /* Number of generic gates exist for the application */
135   uint8_t gate[NFA_HCI_MAX_GATE_CB]; /* List of generic gates allocated to the
136                                         application */
137   uint8_t num_uicc_created_pipes;    /* Number of pipes created by UICC host */
138   tNFA_HCI_PIPE_INFO uicc_created_pipe
139       [NFA_HCI_MAX_PIPE_CB]; /* Pipe information of the UICC created pipe */
140 } tNFA_HCI_GET_GATE_PIPE_LIST;
141 
142 /* Data for NFA_HCI_ALLOCATE_GATE_EVT */
143 typedef struct {
144   tNFA_STATUS status; /* Status of response to allocate gate request */
145   uint8_t gate;       /* The gate allocated to the application */
146 } tNFA_HCI_ALLOCATE_GATE;
147 
148 /* Data for NFA_HCI_DEALLOCATE_GATE_EVT */
149 typedef struct {
150   tNFA_STATUS status; /* Status of response to deallocate gate request */
151   uint8_t gate;       /* The gate deallocated from the application */
152 } tNFA_HCI_DEALLOCATE_GATE;
153 
154 /* Data for NFA_HCI_CREATE_PIPE_EVT */
155 typedef struct {
156   tNFA_STATUS status; /* Status of creating dynamic pipe for the application */
157   uint8_t pipe;       /* The pipe created for the application */
158   uint8_t
159       source_gate; /* DH host gate to which the one end of pipe is attached */
160   uint8_t
161       dest_host; /* Destination host whose gate is the other end of the pipe is
162                     attached to */
163   uint8_t dest_gate; /* Destination host gate to which the other end of pipe is
164                         attached */
165 } tNFA_HCI_CREATE_PIPE;
166 
167 /* Data for NFA_HCI_OPEN_PIPE_EVT */
168 typedef struct {
169   tNFA_STATUS status; /* Status of open pipe operation */
170   uint8_t pipe;       /* The dynamic pipe for open operation */
171 } tNFA_HCI_OPEN_PIPE;
172 
173 /* Data for NFA_HCI_CLOSE_PIPE_EVT */
174 typedef struct {
175   tNFA_STATUS status; /* Status of close pipe operation */
176   uint8_t pipe;       /* The dynamic pipe for close operation */
177 } tNFA_HCI_CLOSE_PIPE;
178 
179 /* Data for NFA_HCI_DELETE_PIPE_EVT */
180 typedef struct {
181   tNFA_STATUS status; /* Status of delete pipe operation */
182   uint8_t pipe;       /* The dynamic pipe for delete operation */
183 } tNFA_HCI_DELETE_PIPE;
184 
185 /* Data for NFA_HCI_HOST_LIST_EVT */
186 typedef struct {
187   tNFA_STATUS status; /* Status og get host list operation */
188   uint8_t num_hosts;  /* Number of hosts in the host network */
189   uint8_t
190       host[NFA_HCI_MAX_HOST_IN_NETWORK]; /* List of host in the host network */
191 } tNFA_HCI_HOST_LIST;
192 
193 /* Data for NFA_HCI_RSP_RCVD_EVT */
194 typedef struct {
195   tNFA_STATUS status; /* Status of RSP to HCP CMD sent */
196   uint8_t pipe;       /* The pipe on which HCP packet is exchanged */
197   uint8_t rsp_code;   /* Response id */
198   uint16_t rsp_len;   /* Response parameter length */
199   uint8_t rsp_data[NFA_MAX_HCI_RSP_LEN]; /* Response received */
200 } tNFA_HCI_RSP_RCVD;
201 
202 /* Data for NFA_HCI_EVENT_RCVD_EVT */
203 typedef struct {
204   tNFA_STATUS status; /* Status of Event received */
205   uint8_t pipe;       /* The pipe on which HCP EVT packet is received */
206   uint8_t evt_code;   /* HCP EVT id */
207   uint16_t evt_len;   /* HCP EVT parameter length */
208   uint8_t* p_evt_buf; /* HCP EVT Parameter */
209 } tNFA_HCI_EVENT_RCVD;
210 
211 /* Data for NFA_HCI_CMD_RCVD_EVT */
212 typedef struct {
213   tNFA_STATUS status; /* Status of Command received */
214   uint8_t pipe;       /* The pipe on which HCP CMD packet is received */
215   uint8_t cmd_code;   /* HCP CMD id */
216   uint16_t cmd_len;   /* HCP CMD parameter length */
217   uint8_t cmd_data[NFA_MAX_HCI_CMD_LEN]; /* HCP CMD Parameter */
218 } tNFA_HCI_CMD_RCVD;
219 
220 /* Data for NFA_HCI_INIT_EVT */
221 typedef struct {
222   tNFA_STATUS status; /* Status of Enabling HCI Network */
223 } tNFA_HCI_INIT;
224 
225 /* Data for NFA_HCI_EXIT_EVT */
226 typedef struct {
227   tNFA_STATUS status; /* Status of Disabling HCI Network */
228 } tNFA_HCI_EXIT;
229 
230 /* Data for NFA_HCI_RSP_SENT_EVT */
231 typedef struct {
232   tNFA_STATUS status; /* Status of HCP response send operation */
233 } tNFA_HCI_RSP_SENT;
234 
235 /* Data for NFA_HCI_CMD_SENT_EVT */
236 typedef struct {
237   tNFA_STATUS status; /* Status of Command send operation */
238 } tNFA_HCI_CMD_SENT;
239 
240 /* Data for NFA_HCI_EVENT_SENT_EVT */
241 typedef struct {
242   tNFA_STATUS status; /* Status of Event send operation */
243 } tNFA_HCI_EVENT_SENT;
244 
245 /* Data for NFA_HCI_ADD_STATIC_PIPE_EVT */
246 typedef struct {
247   tNFA_STATUS status; /* Status of adding proprietary pipe */
248 } tNFA_HCI_ADD_STATIC_PIPE_EVT;
249 
250 /* data type for all registry-related events */
251 typedef struct {
252   tNFA_STATUS status; /* Status of Registry operation */
253   uint8_t pipe;       /* Pipe on whose registry is of interest */
254   uint8_t index;      /* Index of the registry operated */
255   uint8_t data_len;   /* length of the registry parameter */
256   uint8_t reg_data[NFA_MAX_HCI_DATA_LEN]; /* Registry parameter */
257 } tNFA_HCI_REGISTRY;
258 
259 /* Union of all hci callback structures */
260 typedef union {
261   tNFA_HCI_REGISTER hci_register;          /* NFA_HCI_REGISTER_EVT           */
262   tNFA_HCI_DEREGISTER hci_deregister;      /* NFA_HCI_DEREGISTER_EVT         */
263   tNFA_HCI_GET_GATE_PIPE_LIST gates_pipes; /* NFA_HCI_GET_GATE_PIPE_LIST_EVT */
264   tNFA_HCI_ALLOCATE_GATE allocated;        /* NFA_HCI_ALLOCATE_GATE_EVT      */
265   tNFA_HCI_DEALLOCATE_GATE deallocated;    /* NFA_HCI_DEALLOCATE_GATE_EVT    */
266   tNFA_HCI_CREATE_PIPE created;            /* NFA_HCI_CREATE_PIPE_EVT        */
267   tNFA_HCI_OPEN_PIPE opened;               /* NFA_HCI_OPEN_PIPE_EVT          */
268   tNFA_HCI_CLOSE_PIPE closed;              /* NFA_HCI_CLOSE_PIPE_EVT         */
269   tNFA_HCI_DELETE_PIPE deleted;            /* NFA_HCI_DELETE_PIPE_EVT        */
270   tNFA_HCI_HOST_LIST hosts;                /* NFA_HCI_HOST_LIST_EVT          */
271   tNFA_HCI_RSP_RCVD rsp_rcvd;              /* NFA_HCI_RSP_RCVD_EVT           */
272   tNFA_HCI_RSP_SENT rsp_sent;              /* NFA_HCI_RSP_SENT_EVT           */
273   tNFA_HCI_CMD_SENT cmd_sent;              /* NFA_HCI_CMD_SENT_EVT           */
274   tNFA_HCI_EVENT_SENT evt_sent;            /* NFA_HCI_EVENT_SENT_EVT         */
275   tNFA_HCI_CMD_RCVD cmd_rcvd;              /* NFA_HCI_CMD_RCVD_EVT           */
276   tNFA_HCI_EVENT_RCVD rcvd_evt;            /* NFA_HCI_EVENT_RCVD_EVT         */
277   tNFA_STATUS status;                      /* status of api command request  */
278   tNFA_HCI_REGISTRY registry;              /* all registry-related events -
279                                               NFA_HCI_GET_REG_CMD_EVT,
280                                               NFA_HCI_SET_REG_CMD_EVT,
281                                               NFA_HCI_GET_REG_RSP_EVT,
282                                               NFA_HCI_SET_REG_RSP_EVT */
283   tNFA_HCI_INIT hci_init;                  /* NFA_HCI_INIT_EVT               */
284   tNFA_HCI_EXIT hci_exit;                  /* NFA_HCI_EXIT_EVT               */
285   tNFA_HCI_ADD_STATIC_PIPE_EVT pipe_added; /* NFA_HCI_ADD_STATIC_PIPE_EVT    */
286 } tNFA_HCI_EVT_DATA;
287 
288 /* NFA HCI callback */
289 typedef void(tNFA_HCI_CBACK)(tNFA_HCI_EVT event, tNFA_HCI_EVT_DATA* p_data);
290 
291 /*****************************************************************************
292 **  External Function Declarations
293 *****************************************************************************/
294 
295 /*******************************************************************************
296 **
297 ** Function         NFA_HciRegister
298 **
299 ** Description      This function will register an application with hci and
300 **                  returns an application handle and provides a mechanism to
301 **                  register a callback with HCI to receive NFA HCI event
302 **                  notification. When the application is registered (or if an
303 **                  error occurs), the app will be notified with
304 **                  NFA_HCI_REGISTER_EVT. Previous session information
305 **                  including allocated gates, created pipes and pipes states
306 **                  will be returned as part of tNFA_HCI_REGISTER data.
307 **
308 ** Returns          NFA_STATUS_OK if successfully initiated
309 **                  NFA_STATUS_FAILED otherwise
310 **
311 *******************************************************************************/
312 extern tNFA_STATUS NFA_HciRegister(char* p_app_name, tNFA_HCI_CBACK* p_cback,
313                                    bool b_send_conn_evts);
314 
315 /*******************************************************************************
316 **
317 ** Function         NFA_HciGetGateAndPipeList
318 **
319 ** Description      This function will retrieve the list of gates allocated to
320 **                  the application and list of dynamic pipes created for the
321 **                  application. The app will be notified with
322 **                  NFA_HCI_GET_GATE_PIPE_LIST_EVT. List of allocated dynamic
323 **                  gates to the application and list of pipes created by the
324 **                  application will be returned as part of
325 **                  tNFA_HCI_GET_GATE_PIPE_LIST data.
326 **
327 ** Returns          NFA_STATUS_OK if successfully initiated
328 **                  NFA_STATUS_FAILED otherwise
329 **
330 *******************************************************************************/
331 extern tNFA_STATUS NFA_HciGetGateAndPipeList(tNFA_HANDLE hci_handle);
332 
333 /*******************************************************************************
334 **
335 ** Function         NFA_HciDeregister
336 **
337 ** Description      This function is called to deregister an application
338 **                  from HCI. The app will be notified by NFA_HCI_DEREGISTER_EVT
339 **                  after deleting all the pipes owned by the app and
340 **                  deallocating all the gates allocated to the app or if an
341 **                  error occurs. The app can release the buffer provided for
342 **                  collecting long APDUs after receiving
343 **                  NFA_HCI_DEREGISTER_EVT. Even if deregistration fails, the
344 **                  app has to register again to provide a new cback function
345 **                  and event buffer for receiving long APDUs.
346 **
347 ** Returns          NFA_STATUS_OK if the application is deregistered
348 **                  successfully
349 **                  NFA_STATUS_FAILED otherwise
350 **
351 *******************************************************************************/
352 extern tNFA_STATUS NFA_HciDeregister(char* p_app_name);
353 
354 /*******************************************************************************
355 **
356 ** Function         NFA_HciAllocGate
357 **
358 ** Description      This function will allocate the gate if any specified or an
359 **                  available generic gate for the app to provide an entry point
360 **                  for a particular service to other host or to establish
361 **                  communication with other host. When the gate is
362 **                  allocated (or if an error occurs), the app will be notified
363 **                  with NFA_HCI_ALLOCATE_GATE_EVT with the gate id. The
364 **                  allocated Gate information will be stored in non volatile
365 **                  memory.
366 **
367 ** Returns          NFA_STATUS_OK if this API started
368 **                  NFA_STATUS_FAILED if no generic gate is available
369 **
370 *******************************************************************************/
371 extern tNFA_STATUS NFA_HciAllocGate(tNFA_HANDLE hci_handle, uint8_t gate);
372 
373 /*******************************************************************************
374 **
375 ** Function         NFA_HciDeallocGate
376 **
377 ** Description      This function will release the specified gate that was
378 **                  previously allocated to the application. When the generic
379 **                  gate is released (or if an error occurs), the app will be
380 **                  notified with NFA_HCI_DEALLOCATE_GATE_EVT with the gate id.
381 **                  The allocated Gate information will be deleted from non
382 **                  volatile memory and all the associated pipes are deleted
383 **                  by informing host controller.
384 **
385 ** Returns          NFA_STATUS_OK if successfully initiated
386 **                  NFA_STATUS_BAD_HANDLE if handle is not valid
387 **                  NFA_STATUS_FAILED otherwise
388 **
389 *******************************************************************************/
390 extern tNFA_STATUS NFA_HciDeallocGate(tNFA_HANDLE conn_handle, uint8_t gate);
391 
392 /*******************************************************************************
393 **
394 ** Function         NFA_HciGetHostList
395 **
396 ** Description      This function will request the host controller to return the
397 **                  list of hosts that are present in the host network. When
398 **                  host controller responds with the host list (or if an error
399 **                  occurs), the app will be notified with NFA_HCI_HOST_LIST_EVT
400 **
401 ** Returns          NFA_STATUS_OK if successfully initiated
402 **                  NFA_STATUS_BAD_HANDLE if handle is not valid
403 **                  NFA_STATUS_FAILED otherwise
404 **
405 *******************************************************************************/
406 extern tNFA_STATUS NFA_HciGetHostList(tNFA_HANDLE hci_handle);
407 
408 /*******************************************************************************
409 **
410 ** Function         NFA_HciCreatePipe
411 **
412 ** Description      This function is called to create a dynamic pipe with the
413 **                  specified host. When the dynamic pipe is created (or
414 **                  if an error occurs), the app will be notified with
415 **                  NFA_HCI_CREATE_PIPE_EVT with the pipe id. If a pipe exists
416 **                  between the two gates passed as argument and if it was
417 **                  created earlier by the calling application then the pipe
418 **                  id of the existing pipe will be returned and a new pipe
419 **                  will not be created. After successful creation of pipe,
420 **                  registry entry will be created for the dynamic pipe and
421 **                  all information related to the pipe will be stored in non
422 **                  volatile memory.
423 **
424 ** Returns          NFA_STATUS_OK if successfully initiated
425 **                  NFA_STATUS_FAILED otherwise
426 **
427 *******************************************************************************/
428 extern tNFA_STATUS NFA_HciCreatePipe(tNFA_HANDLE hci_handle,
429                                      uint8_t source_gate_id, uint8_t dest_host,
430                                      uint8_t dest_gate);
431 
432 /*******************************************************************************
433 **
434 ** Function         NFA_HciOpenPipe
435 **
436 ** Description      This function is called to open a dynamic pipe.
437 **                  When the dynamic pipe is opened (or
438 **                  if an error occurs), the app will be notified with
439 **                  NFA_HCI_OPEN_PIPE_EVT with the pipe id.
440 **
441 ** Returns          NFA_STATUS_OK if successfully initiated
442 **                  NFA_STATUS_FAILED otherwise
443 **
444 *******************************************************************************/
445 extern tNFA_STATUS NFA_HciOpenPipe(tNFA_HANDLE hci_handle, uint8_t pipe);
446 
447 /*******************************************************************************
448 **
449 ** Function         NFA_HciGetRegistry
450 **
451 ** Description      This function requests a peer host to return the desired
452 **                  registry field value for the gate that the pipe is on.
453 **
454 **                  When the peer host responds,the app is notified with
455 **                  NFA_HCI_GET_REG_RSP_EVT or
456 **                  if an error occurs in sending the command the app will be
457 **                  notified by NFA_HCI_CMD_SENT_EVT
458 **
459 ** Returns          NFA_STATUS_OK if successfully initiated
460 **                  NFA_STATUS_FAILED otherwise
461 **
462 *******************************************************************************/
463 extern tNFA_STATUS NFA_HciGetRegistry(tNFA_HANDLE hci_handle, uint8_t pipe,
464                                       uint8_t reg_inx);
465 
466 /*******************************************************************************
467 **
468 ** Function         NFA_HciSendCommand
469 **
470 ** Description      This function is called to send a command on a pipe created
471 **                  by the application.
472 **                  The app will be notified by NFA_HCI_CMD_SENT_EVT if an error
473 **                  occurs.
474 **                  When the peer host responds,the app is notified with
475 **                  NFA_HCI_RSP_RCVD_EVT
476 **
477 ** Returns          NFA_STATUS_OK if successfully initiated
478 **                  NFA_STATUS_FAILED otherwise
479 **
480 *******************************************************************************/
481 extern tNFA_STATUS NFA_HciSendCommand(tNFA_HANDLE hci_handle, uint8_t pipe,
482                                       uint8_t cmd_code, uint16_t cmd_size,
483                                       uint8_t* p_data);
484 
485 /*******************************************************************************
486 **
487 ** Function         NFA_HciSendEvent
488 **
489 ** Description      This function is called to send any event on a pipe created
490 **                  by the application.
491 **                  The app will be notified by NFA_HCI_EVENT_SENT_EVT
492 **                  after successfully sending the event on the specified pipe
493 **                  or if an error occurs. The application should wait for this
494 **                  event before releasing event buffer passed as argument.
495 **                  If the app is expecting a response to the event then it can
496 **                  provide response buffer for collecting the response. If it
497 **                  provides a response buffer it should also provide response
498 **                  timeout indicating duration validity of the response buffer.
499 **                  Maximum of NFA_MAX_HCI_EVENT_LEN bytes APDU can be received
500 **                  using internal buffer if no response buffer is provided by
501 **                  the application. The app will be notified by
502 **                  NFA_HCI_EVENT_RCVD_EVT after receiving the response event
503 **                  or on timeout if app provided response buffer.
504 **                  If response buffer is provided by the application, it should
505 **                  wait for this event before releasing the response buffer.
506 **
507 ** Returns          NFA_STATUS_OK if successfully initiated
508 **                  NFA_STATUS_FAILED otherwise
509 **
510 *******************************************************************************/
511 tNFA_STATUS NFA_HciSendEvent(tNFA_HANDLE hci_handle, uint8_t pipe,
512                              uint8_t evt_code, uint16_t evt_size,
513                              uint8_t* p_data, uint16_t rsp_size,
514                              uint8_t* p_rsp_buf, uint16_t rsp_timeout);
515 
516 /*******************************************************************************
517 **
518 ** Function         NFA_HciClosePipe
519 **
520 ** Description      This function is called to close a dynamic pipe.
521 **                  When the dynamic pipe is closed (or
522 **                  if an error occurs), the app will be notified with
523 **                  NFA_HCI_CLOSE_PIPE_EVT with the pipe id.
524 **
525 ** Returns          NFA_STATUS_OK if successfully initiated
526 **                  NFA_STATUS_FAILED otherwise
527 **
528 *******************************************************************************/
529 extern tNFA_STATUS NFA_HciClosePipe(tNFA_HANDLE hci_handle, uint8_t pipe);
530 
531 /*******************************************************************************
532 **
533 ** Function         NFA_HciDeletePipe
534 **
535 ** Description      This function is called to delete a particular dynamic pipe.
536 **                  When the dynamic pipe is deleted (or if an error occurs),
537 **                  the app will be notified with NFA_HCI_DELETE_PIPE_EVT with
538 **                  the pipe id. After successful deletion of pipe, registry
539 **                  entry will be deleted for the dynamic pipe and all
540 **                  information related to the pipe will be deleted from non
541 **                  volatile memory.
542 **
543 ** Returns          NFA_STATUS_OK if successfully initiated
544 **                  NFA_STATUS_BAD_HANDLE if handle is not valid
545 **                  NFA_STATUS_FAILED otherwise
546 **
547 *******************************************************************************/
548 extern tNFA_STATUS NFA_HciDeletePipe(tNFA_HANDLE hci_handle, uint8_t pipe);
549 
550 /*******************************************************************************
551 **
552 ** Function         NFA_HciAddStaticPipe
553 **
554 ** Description      This function is called to add a static pipe for sending
555 **                  7816 APDUs. When the static pipe is added (or if an error
556 **                  occurs), the app will be notified with
557 **                  NFA_HCI_ADD_STATIC_PIPE_EVT with status.
558 **
559 ** Returns          NFA_STATUS_OK if successfully initiated
560 **                  NFA_STATUS_FAILED otherwise
561 **
562 *******************************************************************************/
563 extern tNFA_STATUS NFA_HciAddStaticPipe(tNFA_HANDLE hci_handle, uint8_t host,
564                                         uint8_t gate, uint8_t pipe);
565 
566 /*******************************************************************************
567 **
568 ** Function         NFA_HciDebug
569 **
570 ** Description      Debug function.
571 **
572 *******************************************************************************/
573 extern void NFA_HciDebug(uint8_t action, uint8_t size, uint8_t* p_data);
574 
575 #endif /* NFA_P2P_API_H */
576