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  *  NFA card emulation API functions
22  *
23  ******************************************************************************/
24 #ifndef NFA_CE_API_H
25 #define NFA_CE_API_H
26 
27 #include "nfa_api.h"
28 #include "nfc_target.h"
29 
30 /*****************************************************************************
31 **  Constants and data types
32 *****************************************************************************/
33 
34 /*****************************************************************************
35 **  External Function Declarations
36 *****************************************************************************/
37 
38 /*******************************************************************************
39 **
40 ** Function         NFA_CeConfigureLocalTag
41 **
42 ** Description      Configure local NDEF tag.
43 **
44 **                  Tag events will be notifed using the tNFA_CONN_CBACK
45 **                  (registered during NFA_Enable)
46 **
47 **                  The NFA_CE_LOCAL_TAG_CONFIGURED_EVT reports the status of
48 **                  the operation.
49 **
50 **                  Activation and deactivation are reported using the
51 **                  NFA_ACTIVATED_EVT and NFA_DEACTIVATED_EVT events
52 **
53 **                  If a write-request is received to update the tag memory,
54 **                  an NFA_CE_NDEF_WRITE_CPLT_EVT will notify the application,
55 **                  along with a buffer containing the updated contents.
56 **
57 **                  To disable the local NDEF tag, set protocol_mask=0
58 **
59 **                  The NDEF data provided by p_ndef_data must be persistent
60 **                  as long as the local NDEF tag is enabled. Also, Input
61 **                  parameters p_uid and uid_len are reserved for future use.
62 **
63 **
64 ** Note:            If RF discovery is started,
65 **                  NFA_StopRfDiscovery()/NFA_RF_DISCOVERY_STOPPED_EVT should
66 **                  happen before calling this function.
67 **
68 ** Returns:
69 **                  NFA_STATUS_OK,            if command accepted
70 **                  NFA_STATUS_INVALID_PARAM,
71 **                      if protocol_maks is not 0 and p_ndef_data is NULL
72 **                  (or) uid_len is not 0
73 **                  (or) if protocol mask is set for Type 1 or Type 2
74 **
75 **                  NFA_STATUS_FAILED:        otherwise
76 **
77 *******************************************************************************/
78 extern tNFA_STATUS NFA_CeConfigureLocalTag(tNFA_PROTOCOL_MASK protocol_mask,
79                                            uint8_t* p_ndef_data,
80                                            uint16_t ndef_cur_size,
81                                            uint16_t ndef_max_size,
82                                            bool read_only, uint8_t uid_len,
83                                            uint8_t* p_uid);
84 
85 /*******************************************************************************
86 **
87 ** Function         NFA_CeConfigureUiccListenTech
88 **
89 ** Description      Configure listening for the UICC, using the specified
90 **                  technologies.
91 **
92 **                  Events will be notifed using the tNFA_CONN_CBACK
93 **                  (registered during NFA_Enable)
94 **
95 **                  The NFA_CE_UICC_LISTEN_CONFIGURED_EVT reports the status of
96 **                  the operation.
97 **
98 **                  Activation and deactivation are reported using the
99 **                  NFA_ACTIVATED_EVT and NFA_DEACTIVATED_EVT events
100 **
101 ** Note:            If RF discovery is started,
102 **                  NFA_StopRfDiscovery()/NFA_RF_DISCOVERY_STOPPED_EVT should
103 **                  happen before calling this function
104 **
105 ** Returns:
106 **                  NFA_STATUS_OK, if command accepted
107 **                  NFA_STATUS_FAILED: otherwise
108 **
109 *******************************************************************************/
110 extern tNFA_STATUS NFA_CeConfigureUiccListenTech(
111     tNFA_HANDLE ee_handle, tNFA_TECHNOLOGY_MASK tech_mask);
112 
113 /*******************************************************************************
114 **
115 ** Function         NFA_CeRegisterFelicaSystemCodeOnDH
116 **
117 ** Description      Register listening callback for Felica system code
118 **
119 **                  The NFA_CE_REGISTERED_EVT reports the status of the
120 **                  operation.
121 **
122 ** Note:            If RF discovery is started,
123 **                  NFA_StopRfDiscovery()/NFA_RF_DISCOVERY_STOPPED_EVT should
124 **                  happen before calling this function
125 **
126 ** Returns:
127 **                  NFA_STATUS_OK, if command accepted
128 **                  NFA_STATUS_FAILED: otherwise
129 **
130 *******************************************************************************/
131 extern tNFA_STATUS NFA_CeRegisterFelicaSystemCodeOnDH(
132     uint16_t system_code, uint8_t nfcid2[NCI_RF_F_UID_LEN],
133     uint8_t t3tPmm[NCI_T3T_PMM_LEN], tNFA_CONN_CBACK* p_conn_cback);
134 
135 /*******************************************************************************
136 **
137 ** Function         NFA_CeDeregisterFelicaSystemCodeOnDH
138 **
139 ** Description      Deregister listening callback for Felica
140 **                  (previously registered using
141 **                  NFA_CeRegisterFelicaSystemCodeOnDH)
142 **
143 **                  The NFA_CE_DEREGISTERED_EVT reports the status of the
144 **                  operation.
145 **
146 ** Note:            If RF discovery is started,
147 **                  NFA_StopRfDiscovery()/NFA_RF_DISCOVERY_STOPPED_EVT should
148 **                  happen before calling this function
149 **
150 ** Returns          NFA_STATUS_OK if successfully initiated
151 **                  NFA_STATUS_BAD_HANDLE if invalid handle
152 **                  NFA_STATUS_FAILED otherwise
153 **
154 *******************************************************************************/
155 extern tNFA_STATUS NFA_CeDeregisterFelicaSystemCodeOnDH(tNFA_HANDLE handle);
156 
157 /*******************************************************************************
158 **
159 ** Function         NFA_CeRegisterAidOnDH
160 **
161 ** Description      Register listening callback for the specified ISODEP AID
162 **
163 **                  The NFA_CE_REGISTERED_EVT reports the status of the
164 **                  operation.
165 **
166 **                  If no AID is specified (aid_len=0), then p_conn_cback will
167 **                  will get notifications for any AIDs routed to the DH. This
168 **                  over-rides callbacks registered for specific AIDs.
169 **
170 ** Note:            If RF discovery is started,
171 **                  NFA_StopRfDiscovery()/NFA_RF_DISCOVERY_STOPPED_EVT should
172 **                  happen before calling this function
173 **
174 ** Returns:
175 **                  NFA_STATUS_OK, if command accepted
176 **                  NFA_STATUS_FAILED: otherwise
177 **
178 *******************************************************************************/
179 extern tNFA_STATUS NFA_CeRegisterAidOnDH(uint8_t aid[NFC_MAX_AID_LEN],
180                                          uint8_t aid_len,
181                                          tNFA_CONN_CBACK* p_conn_cback);
182 
183 /*******************************************************************************
184 **
185 ** Function         NFA_CeDeregisterAidOnDH
186 **
187 ** Description      Deregister listening callback for ISODEP AID
188 **                  (previously registered using NFA_CeRegisterAidOnDH)
189 **
190 **                  The NFA_CE_DEREGISTERED_EVT reports the status of the
191 **                  operation.
192 **
193 ** Note:            If RF discovery is started,
194 **                  NFA_StopRfDiscovery()/NFA_RF_DISCOVERY_STOPPED_EVT should
195 **                  happen before calling this function
196 **
197 ** Returns          NFA_STATUS_OK if successfully initiated
198 **                  NFA_STATUS_BAD_HANDLE if invalid handle
199 **                  NFA_STATUS_FAILED otherwise
200 **
201 *******************************************************************************/
202 extern tNFA_STATUS NFA_CeDeregisterAidOnDH(tNFA_HANDLE handle);
203 
204 /*******************************************************************************
205 **
206 ** Function         NFA_CeSetIsoDepListenTech
207 **
208 ** Description      Set the technologies (NFC-A and/or NFC-B) to listen for when
209 **                  NFA_CeConfigureLocalTag or NFA_CeDeregisterAidOnDH are
210 **                  called.
211 **
212 **                  By default (if this API is not called), NFA will listen
213 **                  for both NFC-A and NFC-B for ISODEP.
214 **
215 ** Note:            If listening for ISODEP on UICC, the DH listen callbacks
216 **                  may still get activate notifications for ISODEP if the
217 **                  reader/writer selects an AID that is not routed to the UICC
218 **                  (regardless of whether A or B was disabled using
219 **                  NFA_CeSetIsoDepListenTech)
220 **
221 ** Note:            If RF discovery is started,
222 **                  NFA_StopRfDiscovery()/NFA_RF_DISCOVERY_STOPPED_EVT should
223 **                  happen before calling this function
224 **
225 ** Returns:
226 **                  NFA_STATUS_OK, if command accepted
227 **                  NFA_STATUS_FAILED: otherwise
228 **
229 *******************************************************************************/
230 extern tNFA_STATUS NFA_CeSetIsoDepListenTech(tNFA_TECHNOLOGY_MASK tech_mask);
231 
232 #endif /* NFA_CE_API_H */
233