• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 SNEP, Broadcom's NFC
22  *  application layer for mobile phones.
23  *
24  ******************************************************************************/
25 #ifndef NFA_SNEP_API_H
26 #define NFA_SNEP_API_H
27 
28 #include "nfa_api.h"
29 
30 /*****************************************************************************
31 **  Constants and data types
32 *****************************************************************************/
33 
34 /* return an NDEF message           */
35 #define NFA_SNEP_REQ_CODE_GET 0x01
36 /* accept an NDEF message           */
37 #define NFA_SNEP_REQ_CODE_PUT 0x02
38 /* do not send remaining fragments  */
39 
40 #define tNFA_SNEP_REQ_CODE uint8_t
41 
42 #define tNFA_SNEP_RESP_CODE uint8_t
43 
44 /* NFA SNEP callback events */
45 /* Server/client Registeration Status   */
46 #define NFA_SNEP_REG_EVT 0x00
47 /* LLCP link has been activated, client only   */
48 #define NFA_SNEP_ACTIVATED_EVT 0x01
49 /* LLCP link has been deactivated, client only */
50 #define NFA_SNEP_DEACTIVATED_EVT 0x02
51 /* Data link has been created           */
52 #define NFA_SNEP_CONNECTED_EVT 0x03
53 /* GET request from client              */
54 #define NFA_SNEP_GET_REQ_EVT 0x04
55 /* PUT request from client              */
56 #define NFA_SNEP_PUT_REQ_EVT 0x05
57 /* GET response from server             */
58 #define NFA_SNEP_GET_RESP_EVT 0x06
59 /* PUT response from server             */
60 #define NFA_SNEP_PUT_RESP_EVT 0x07
61 /* Failed to connect or disconnected    */
62 #define NFA_SNEP_DISC_EVT 0x08
63 
64 #define NFA_SNEP_ALLOC_BUFF_EVT                                         \
65   0x09                              /* Request to allocate a buffer for \
66                                        NDEF*/
67 #define NFA_SNEP_FREE_BUFF_EVT 0x0A /* Request to deallocate buffer for NDEF*/
68 /* GET response sent to client          */
69 #define NFA_SNEP_GET_RESP_CMPL_EVT 0x0B
70 
71 typedef uint8_t tNFA_SNEP_EVT;
72 
73 /* Data for NFA_SNEP_REG_EVT */
74 typedef struct {
75   tNFA_STATUS status;
76   tNFA_HANDLE reg_handle; /* handle for registered server/client */
77   char service_name[LLCP_MAX_SN_LEN + 1]; /* only for server */
78 } tNFA_SNEP_REG;
79 
80 /* Data for NFA_SNEP_ACTIVATED_EVT */
81 typedef struct {
82   tNFA_HANDLE client_handle; /* handle for registered client    */
83 } tNFA_SNEP_ACTIVATED;
84 
85 /* Data for NFA_SNEP_DEACTIVATED_EVT */
86 typedef tNFA_SNEP_ACTIVATED tNFA_SNEP_DEACTIVATED;
87 
88 /* Data for NFA_SNEP_CONNECTED_EVT */
89 /*
90 ** for server, new handle will be assigned for conn_handle
91 ** for client, handle used in NFA_SnepConnect () is returned in conn_handle
92 */
93 typedef struct {
94   tNFA_HANDLE reg_handle;  /* server/client handle            */
95   tNFA_HANDLE conn_handle; /* handle for data link connection */
96 } tNFA_SNEP_CONNECT;
97 
98 /* Data for NFA_SNEP_GET_REQ_EVT */
99 typedef struct {
100   tNFA_HANDLE conn_handle;    /* handle for data link connection */
101   uint32_t acceptable_length; /* acceptable length from client   */
102   uint32_t ndef_length;       /* NDEF message length             */
103   uint8_t* p_ndef;            /* NDEF message                    */
104 } tNFA_SNEP_GET_REQ;
105 
106 /* Data for NFA_SNEP_PUT_REQ_EVT */
107 typedef struct {
108   tNFA_HANDLE conn_handle; /* handle for data link connection */
109   uint32_t ndef_length;    /* NDEF message length             */
110   uint8_t* p_ndef;         /* NDEF message                    */
111 } tNFA_SNEP_PUT_REQ;
112 
113 /* Data for NFA_SNEP_GET_RESP_EVT */
114 typedef struct {
115   tNFA_HANDLE conn_handle;       /* handle for data link connection */
116   tNFA_SNEP_RESP_CODE resp_code; /* response code from server       */
117   uint32_t ndef_length;          /* NDEF message length             */
118   uint8_t* p_ndef;               /* NDEF message                    */
119 } tNFA_SNEP_GET_RESP;
120 
121 /* Data for NFA_SNEP_PUT_RESP_EVT */
122 typedef struct {
123   tNFA_HANDLE conn_handle;       /* handle for data link connection */
124   tNFA_SNEP_RESP_CODE resp_code; /* response code from server       */
125 } tNFA_SNEP_PUT_RESP;
126 
127 /* Data for NFA_SNEP_DISC_EVT */
128 typedef struct {
129   tNFA_HANDLE conn_handle; /* handle for data link connection */
130                            /* client_handle if connection failed */
131 } tNFA_SNEP_DISC;
132 
133 /* Data for NFA_SNEP_ALLOC_BUFF_EVT */
134 typedef struct {
135   tNFA_HANDLE conn_handle; /* handle for data link connection                */
136   tNFA_SNEP_REQ_CODE
137       req_code; /* NFA_SNEP_REQ_CODE_GET or NFA_SNEP_REQ_CODE_PUT */
138   tNFA_SNEP_RESP_CODE resp_code; /* Response code if cannot allocate buffer */
139   uint32_t ndef_length; /* NDEF message length                            */
140   uint8_t* p_buff;      /* buffer for NDEF message                        */
141 } tNFA_SNEP_ALLOC;
142 
143 /* Data for NFA_SNEP_FREE_BUFF_EVT */
144 typedef struct {
145   tNFA_HANDLE conn_handle; /* handle for data link connection */
146   uint8_t* p_buff;         /* buffer to free                  */
147 } tNFA_SNEP_FREE;
148 
149 /* Data for NFA_SNEP_GET_RESP_CMPL_EVT */
150 typedef struct {
151   tNFA_HANDLE conn_handle; /* handle for data link connection */
152   uint8_t* p_buff;         /* buffer for NDEF message         */
153 } tNFA_SNEP_GET_RESP_CMPL;
154 
155 /* Union of all SNEP callback structures */
156 typedef union {
157   tNFA_SNEP_REG reg;                     /* NFA_SNEP_REG_EVT             */
158   tNFA_SNEP_ACTIVATED activated;         /* NFA_SNEP_ACTIVATED_EVT       */
159   tNFA_SNEP_DEACTIVATED deactivated;     /* NFA_SNEP_DEACTIVATED_EVT     */
160   tNFA_SNEP_CONNECT connect;             /* NFA_SNEP_CONNECTED_EVT       */
161   tNFA_SNEP_GET_REQ get_req;             /* NFA_SNEP_GET_REQ_EVT         */
162   tNFA_SNEP_PUT_REQ put_req;             /* NFA_SNEP_PUT_REQ_EVT         */
163   tNFA_SNEP_GET_RESP get_resp;           /* NFA_SNEP_GET_RESP_EVT        */
164   tNFA_SNEP_PUT_RESP put_resp;           /* NFA_SNEP_PUT_RESP_EVT        */
165   tNFA_SNEP_DISC disc;                   /* NFA_SNEP_DISC_EVT            */
166   tNFA_SNEP_ALLOC alloc;                 /* NFA_SNEP_ALLOC_BUFF_EVT      */
167   tNFA_SNEP_FREE free;                   /* NFA_SNEP_FREE_BUFF_EVT       */
168   tNFA_SNEP_GET_RESP_CMPL get_resp_cmpl; /* NFA_SNEP_GET_RESP_CMPL_EVT   */
169 } tNFA_SNEP_EVT_DATA;
170 
171 /* NFA SNEP callback */
172 typedef void(tNFA_SNEP_CBACK)(tNFA_SNEP_EVT event, tNFA_SNEP_EVT_DATA* p_data);
173 
174 #endif /* NFA_P2P_API_H */
175