Home | History | Annotate | Download | only in include
      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 260
     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 #ifdef __cplusplus
    295 extern "C" {
    296 #endif
    297 
    298 /*******************************************************************************
    299 **
    300 ** Function         NFA_HciRegister
    301 **
    302 ** Description      This function will register an application with hci and
    303 **                  returns an application handle and provides a mechanism to
    304 **                  register a callback with HCI to receive NFA HCI event
    305 **                  notification. When the application is registered (or if an
    306 **                  error occurs), the app will be notified with
    307 **                  NFA_HCI_REGISTER_EVT. Previous session information
    308 **                  including allocated gates, created pipes and pipes states
    309 **                  will be returned as part of tNFA_HCI_REGISTER data.
    310 **
    311 ** Returns          NFA_STATUS_OK if successfully initiated
    312 **                  NFA_STATUS_FAILED otherwise
    313 **
    314 *******************************************************************************/
    315 extern tNFA_STATUS NFA_HciRegister(char* p_app_name, tNFA_HCI_CBACK* p_cback,
    316                                    bool b_send_conn_evts);
    317 
    318 /*******************************************************************************
    319 **
    320 ** Function         NFA_HciGetGateAndPipeList
    321 **
    322 ** Description      This function will retrieve the list of gates allocated to
    323 **                  the application and list of dynamic pipes created for the
    324 **                  application. The app will be notified with
    325 **                  NFA_HCI_GET_GATE_PIPE_LIST_EVT. List of allocated dynamic
    326 **                  gates to the application and list of pipes created by the
    327 **                  application will be returned as part of
    328 **                  tNFA_HCI_GET_GATE_PIPE_LIST data.
    329 **
    330 ** Returns          NFA_STATUS_OK if successfully initiated
    331 **                  NFA_STATUS_FAILED otherwise
    332 **
    333 *******************************************************************************/
    334 extern tNFA_STATUS NFA_HciGetGateAndPipeList(tNFA_HANDLE hci_handle);
    335 
    336 /*******************************************************************************
    337 **
    338 ** Function         NFA_HciDeregister
    339 **
    340 ** Description      This function is called to deregister an application
    341 **                  from HCI. The app will be notified by NFA_HCI_DEREGISTER_EVT
    342 **                  after deleting all the pipes owned by the app and
    343 **                  deallocating all the gates allocated to the app or if an
    344 **                  error occurs. The app can release the buffer provided for
    345 **                  collecting long APDUs after receiving
    346 **                  NFA_HCI_DEREGISTER_EVT. Even if deregistration fails, the
    347 **                  app has to register again to provide a new cback function
    348 **                  and event buffer for receiving long APDUs.
    349 **
    350 ** Returns          NFA_STATUS_OK if the application is deregistered
    351 **                  successfully
    352 **                  NFA_STATUS_FAILED otherwise
    353 **
    354 *******************************************************************************/
    355 extern tNFA_STATUS NFA_HciDeregister(char* p_app_name);
    356 
    357 /*******************************************************************************
    358 **
    359 ** Function         NFA_HciAllocGate
    360 **
    361 ** Description      This function will allocate the gate if any specified or an
    362 **                  available generic gate for the app to provide an entry point
    363 **                  for a particular service to other host or to establish
    364 **                  communication with other host. When the gate is
    365 **                  allocated (or if an error occurs), the app will be notified
    366 **                  with NFA_HCI_ALLOCATE_GATE_EVT with the gate id. The
    367 **                  allocated Gate information will be stored in non volatile
    368 **                  memory.
    369 **
    370 ** Returns          NFA_STATUS_OK if this API started
    371 **                  NFA_STATUS_FAILED if no generic gate is available
    372 **
    373 *******************************************************************************/
    374 extern tNFA_STATUS NFA_HciAllocGate(tNFA_HANDLE hci_handle, uint8_t gate);
    375 
    376 /*******************************************************************************
    377 **
    378 ** Function         NFA_HciDeallocGate
    379 **
    380 ** Description      This function will release the specified gate that was
    381 **                  previously allocated to the application. When the generic
    382 **                  gate is released (or if an error occurs), the app will be
    383 **                  notified with NFA_HCI_DEALLOCATE_GATE_EVT with the gate id.
    384 **                  The allocated Gate information will be deleted from non
    385 **                  volatile memory and all the associated pipes are deleted
    386 **                  by informing host controller.
    387 **
    388 ** Returns          NFA_STATUS_OK if successfully initiated
    389 **                  NFA_STATUS_BAD_HANDLE if handle is not valid
    390 **                  NFA_STATUS_FAILED otherwise
    391 **
    392 *******************************************************************************/
    393 extern tNFA_STATUS NFA_HciDeallocGate(tNFA_HANDLE conn_handle, uint8_t gate);
    394 
    395 /*******************************************************************************
    396 **
    397 ** Function         NFA_HciGetHostList
    398 **
    399 ** Description      This function will request the host controller to return the
    400 **                  list of hosts that are present in the host network. When
    401 **                  host controller responds with the host list (or if an error
    402 **                  occurs), the app will be notified with NFA_HCI_HOST_LIST_EVT
    403 **
    404 ** Returns          NFA_STATUS_OK if successfully initiated
    405 **                  NFA_STATUS_BAD_HANDLE if handle is not valid
    406 **                  NFA_STATUS_FAILED otherwise
    407 **
    408 *******************************************************************************/
    409 extern tNFA_STATUS NFA_HciGetHostList(tNFA_HANDLE hci_handle);
    410 
    411 /*******************************************************************************
    412 **
    413 ** Function         NFA_HciCreatePipe
    414 **
    415 ** Description      This function is called to create a dynamic pipe with the
    416 **                  specified host. When the dynamic pipe is created (or
    417 **                  if an error occurs), the app will be notified with
    418 **                  NFA_HCI_CREATE_PIPE_EVT with the pipe id. If a pipe exists
    419 **                  between the two gates passed as argument and if it was
    420 **                  created earlier by the calling application then the pipe
    421 **                  id of the existing pipe will be returned and a new pipe
    422 **                  will not be created. After successful creation of pipe,
    423 **                  registry entry will be created for the dynamic pipe and
    424 **                  all information related to the pipe will be stored in non
    425 **                  volatile memory.
    426 **
    427 ** Returns          NFA_STATUS_OK if successfully initiated
    428 **                  NFA_STATUS_FAILED otherwise
    429 **
    430 *******************************************************************************/
    431 extern tNFA_STATUS NFA_HciCreatePipe(tNFA_HANDLE hci_handle,
    432                                      uint8_t source_gate_id, uint8_t dest_host,
    433                                      uint8_t dest_gate);
    434 
    435 /*******************************************************************************
    436 **
    437 ** Function         NFA_HciOpenPipe
    438 **
    439 ** Description      This function is called to open a dynamic pipe.
    440 **                  When the dynamic pipe is opened (or
    441 **                  if an error occurs), the app will be notified with
    442 **                  NFA_HCI_OPEN_PIPE_EVT with the pipe id.
    443 **
    444 ** Returns          NFA_STATUS_OK if successfully initiated
    445 **                  NFA_STATUS_FAILED otherwise
    446 **
    447 *******************************************************************************/
    448 extern tNFA_STATUS NFA_HciOpenPipe(tNFA_HANDLE hci_handle, uint8_t pipe);
    449 
    450 /*******************************************************************************
    451 **
    452 ** Function         NFA_HciGetRegistry
    453 **
    454 ** Description      This function requests a peer host to return the desired
    455 **                  registry field value for the gate that the pipe is on.
    456 **
    457 **                  When the peer host responds,the app is notified with
    458 **                  NFA_HCI_GET_REG_RSP_EVT or
    459 **                  if an error occurs in sending the command the app will be
    460 **                  notified by NFA_HCI_CMD_SENT_EVT
    461 **
    462 ** Returns          NFA_STATUS_OK if successfully initiated
    463 **                  NFA_STATUS_FAILED otherwise
    464 **
    465 *******************************************************************************/
    466 extern tNFA_STATUS NFA_HciGetRegistry(tNFA_HANDLE hci_handle, uint8_t pipe,
    467                                       uint8_t reg_inx);
    468 
    469 /*******************************************************************************
    470 **
    471 ** Function         NFA_HciSetRegistry
    472 **
    473 ** Description      This function requests a peer host to set the desired
    474 **                  registry field value for the gate that the pipe is on.
    475 **
    476 **                  When the peer host responds,the app is notified with
    477 **                  NFA_HCI_SET_REG_RSP_EVT or
    478 **                  if an error occurs in sending the command the app will be
    479 **                  notified by NFA_HCI_CMD_SENT_EVT
    480 **
    481 ** Returns          NFA_STATUS_OK if successfully initiated
    482 **                  NFA_STATUS_FAILED otherwise
    483 **
    484 *******************************************************************************/
    485 extern tNFA_STATUS NFA_HciSetRegistry(tNFA_HANDLE hci_handle, uint8_t pipe,
    486                                       uint8_t reg_inx, uint8_t data_size,
    487                                       uint8_t* p_data);
    488 
    489 /*******************************************************************************
    490 **
    491 ** Function         NFA_HciSendCommand
    492 **
    493 ** Description      This function is called to send a command on a pipe created
    494 **                  by the application.
    495 **                  The app will be notified by NFA_HCI_CMD_SENT_EVT if an error
    496 **                  occurs.
    497 **                  When the peer host responds,the app is notified with
    498 **                  NFA_HCI_RSP_RCVD_EVT
    499 **
    500 ** Returns          NFA_STATUS_OK if successfully initiated
    501 **                  NFA_STATUS_FAILED otherwise
    502 **
    503 *******************************************************************************/
    504 extern tNFA_STATUS NFA_HciSendCommand(tNFA_HANDLE hci_handle, uint8_t pipe,
    505                                       uint8_t cmd_code, uint16_t cmd_size,
    506                                       uint8_t* p_data);
    507 
    508 /*******************************************************************************
    509 **
    510 ** Function         NFA_HciSendResponse
    511 **
    512 ** Description      This function is called to send a response on a pipe created
    513 **                  by the application.
    514 **                  The app will be notified by NFA_HCI_RSP_SENT_EVT if an error
    515 **                  occurs.
    516 **
    517 ** Returns          NFA_STATUS_OK if successfully initiated
    518 **                  NFA_STATUS_FAILED otherwise
    519 **
    520 *******************************************************************************/
    521 extern tNFA_STATUS NFA_HciSendResponse(tNFA_HANDLE hci_handle, uint8_t pipe,
    522                                        uint8_t response, uint8_t data_size,
    523                                        uint8_t* p_data);
    524 
    525 /*******************************************************************************
    526 **
    527 ** Function         NFA_HciSendEvent
    528 **
    529 ** Description      This function is called to send any event on a pipe created
    530 **                  by the application.
    531 **                  The app will be notified by NFA_HCI_EVENT_SENT_EVT
    532 **                  after successfully sending the event on the specified pipe
    533 **                  or if an error occurs. The application should wait for this
    534 **                  event before releasing event buffer passed as argument.
    535 **                  If the app is expecting a response to the event then it can
    536 **                  provide response buffer for collecting the response. If it
    537 **                  provides a response buffer it should also provide response
    538 **                  timeout indicating duration validity of the response buffer.
    539 **                  Maximum of NFA_MAX_HCI_EVENT_LEN bytes APDU can be received
    540 **                  using internal buffer if no response buffer is provided by
    541 **                  the application. The app will be notified by
    542 **                  NFA_HCI_EVENT_RCVD_EVT after receiving the response event
    543 **                  or on timeout if app provided response buffer.
    544 **                  If response buffer is provided by the application, it should
    545 **                  wait for this event before releasing the response buffer.
    546 **
    547 ** Returns          NFA_STATUS_OK if successfully initiated
    548 **                  NFA_STATUS_FAILED otherwise
    549 **
    550 *******************************************************************************/
    551 tNFA_STATUS NFA_HciSendEvent(tNFA_HANDLE hci_handle, uint8_t pipe,
    552                              uint8_t evt_code, uint16_t evt_size,
    553                              uint8_t* p_data, uint16_t rsp_size,
    554                              uint8_t* p_rsp_buf, uint16_t rsp_timeout);
    555 
    556 /*******************************************************************************
    557 **
    558 ** Function         NFA_HciClosePipe
    559 **
    560 ** Description      This function is called to close a dynamic pipe.
    561 **                  When the dynamic pipe is closed (or
    562 **                  if an error occurs), the app will be notified with
    563 **                  NFA_HCI_CLOSE_PIPE_EVT with the pipe id.
    564 **
    565 ** Returns          NFA_STATUS_OK if successfully initiated
    566 **                  NFA_STATUS_FAILED otherwise
    567 **
    568 *******************************************************************************/
    569 extern tNFA_STATUS NFA_HciClosePipe(tNFA_HANDLE hci_handle, uint8_t pipe);
    570 
    571 /*******************************************************************************
    572 **
    573 ** Function         NFA_HciDeletePipe
    574 **
    575 ** Description      This function is called to delete a particular dynamic pipe.
    576 **                  When the dynamic pipe is deleted (or if an error occurs),
    577 **                  the app will be notified with NFA_HCI_DELETE_PIPE_EVT with
    578 **                  the pipe id. After successful deletion of pipe, registry
    579 **                  entry will be deleted for the dynamic pipe and all
    580 **                  information related to the pipe will be deleted from non
    581 **                  volatile memory.
    582 **
    583 ** Returns          NFA_STATUS_OK if successfully initiated
    584 **                  NFA_STATUS_BAD_HANDLE if handle is not valid
    585 **                  NFA_STATUS_FAILED otherwise
    586 **
    587 *******************************************************************************/
    588 extern tNFA_STATUS NFA_HciDeletePipe(tNFA_HANDLE hci_handle, uint8_t pipe);
    589 
    590 /*******************************************************************************
    591 **
    592 ** Function         NFA_HciAddStaticPipe
    593 **
    594 ** Description      This function is called to add a static pipe for sending
    595 **                  7816 APDUs. When the static pipe is added (or if an error
    596 **                  occurs), the app will be notified with
    597 **                  NFA_HCI_ADD_STATIC_PIPE_EVT with status.
    598 **
    599 ** Returns          NFA_STATUS_OK if successfully initiated
    600 **                  NFA_STATUS_FAILED otherwise
    601 **
    602 *******************************************************************************/
    603 extern tNFA_STATUS NFA_HciAddStaticPipe(tNFA_HANDLE hci_handle, uint8_t host,
    604                                         uint8_t gate, uint8_t pipe);
    605 
    606 /*******************************************************************************
    607 **
    608 ** Function         NFA_HciDebug
    609 **
    610 ** Description      Debug function.
    611 **
    612 *******************************************************************************/
    613 extern void NFA_HciDebug(uint8_t action, uint8_t size, uint8_t* p_data);
    614 
    615 #ifdef __cplusplus
    616 }
    617 #endif
    618 
    619 #endif /* NFA_P2P_API_H */
    620