1 /*
2  * Copyright (C) 2015 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 /*
18  * NFC Status Values - Function Return Codes
19  */
20 
21 #ifndef PHNFCSTATUS_H
22 #define PHNFCSTATUS_H
23 
24 #include <phNfcTypes.h>
25 
26 /* Internally required by PHNFCSTVAL. */
27 #define PHNFCSTSHL8                          (8U)
28 /* Required by PHNFCSTVAL. */
29 #define PHNFCSTBLOWER                        ((NFCSTATUS)(0x00FFU))
30 
31 /*
32  *  NFC Status Composition Macro
33  *
34  *  This is the macro which must be used to compose status values.
35  *
36  *  phNfcCompID Component ID, as defined in phNfcCompId.h .
37  *  phNfcStatus Status values, as defined in phNfcStatus.h .
38  *
39  *  The macro is not required for the NFCSTATUS_SUCCESS value.
40  *  This is the only return value to be used directly.
41  *  For all other values it shall be used in assignment and conditional statements, e.g.:
42  *     NFCSTATUS status = PHNFCSTVAL(phNfcCompID, phNfcStatus); ...
43  *     if (status == PHNFCSTVAL(phNfcCompID, phNfcStatus)) ...
44  */
45 #define PHNFCSTVAL(phNfcCompID, phNfcStatus)                                  \
46             ( ((phNfcStatus) == (NFCSTATUS_SUCCESS)) ? (NFCSTATUS_SUCCESS) :  \
47                 ( (((NFCSTATUS)(phNfcStatus)) & (PHNFCSTBLOWER)) |            \
48                     (((uint16_t)(phNfcCompID)) << (PHNFCSTSHL8)) ) )
49 
50 /*
51  * PHNFCSTATUS
52  * Get grp_retval from Status Code
53  */
54 #define PHNFCSTATUS(phNfcStatus)  ((phNfcStatus) & 0x00FFU)
55 #define PHNFCCID(phNfcStatus)  (((phNfcStatus) & 0xFF00U)>>8)
56 
57 /*
58  *  Status Codes
59  *
60  *  Generic Status codes for the NFC components. Combined with the Component ID
61  *  they build the value (status) returned by each function.
62  *  Example:
63  *      grp_comp_id "Component ID" -  e.g. 0x10, plus
64  *      status code as listed in this file - e.g. 0x03
65  *      result in a status value of 0x0003.
66  */
67 
68 /*
69  * The function indicates successful completion
70  */
71 #define NFCSTATUS_SUCCESS                                     (0x0000)
72 
73 /*
74  *  The function indicates successful completion
75  */
76 #define NFCSTATUS_OK                                (NFCSTATUS_SUCCESS)
77 
78 /*
79  * At least one parameter could not be properly interpreted
80  */
81 #define NFCSTATUS_INVALID_PARAMETER                           (0x0001)
82 
83 /*
84  * The buffer provided by the caller is too small
85  */
86 #define NFCSTATUS_BUFFER_TOO_SMALL                            (0x0003)
87 
88 /*
89  * Device specifier/handle value is invalid for the operation
90  */
91 #define NFCSTATUS_INVALID_DEVICE                              (0x0006)
92 
93 /*
94  * The function executed successfully but could have returned
95  * more information than space provided by the caller
96  */
97 #define NFCSTATUS_MORE_INFORMATION                            (0x0008)
98 
99 /*
100  * No response from the remote device received: Time-out
101  */
102 #define NFCSTATUS_RF_TIMEOUT                                  (0x0009)
103 
104 /*
105  * RF Error during data transaction with the remote device
106  */
107 #define NFCSTATUS_RF_ERROR                                    (0x000A)
108 
109 /*
110  * Not enough resources Memory, Timer etc(e.g. allocation failed.)
111  */
112 #define NFCSTATUS_INSUFFICIENT_RESOURCES                      (0x000C)
113 
114 /*
115  * A non-blocking function returns this immediately to indicate
116  * that an internal operation is in progress
117  */
118 #define NFCSTATUS_PENDING                                     (0x000D)
119 
120 /*
121  * A board communication error occurred
122  * (e.g. Configuration went wrong)
123  */
124 #define NFCSTATUS_BOARD_COMMUNICATION_ERROR                   (0x000F)
125 
126 /*
127  * Invalid State of the particular state machine
128  */
129 #define NFCSTATUS_INVALID_STATE                               (0x0011)
130 
131 
132 /*
133  * This Layer is Not initialized, hence initialization required.
134  */
135 #define NFCSTATUS_NOT_INITIALISED                             (0x0031)
136 
137 
138 /*
139  * The Layer is already initialized, hence initialization repeated.
140  */
141 #define NFCSTATUS_ALREADY_INITIALISED                         (0x0032)
142 
143 
144 /*
145  * Feature not supported
146  */
147 #define NFCSTATUS_FEATURE_NOT_SUPPORTED                       (0x0033)
148 
149 /*  The Unregistration command has failed because the user wants to unregister on
150  * an element for which he was not registered
151  */
152 #define NFCSTATUS_NOT_REGISTERED                              (0x0034)
153 
154 
155 /* The Registration command has failed because the user wants to register on
156  * an element for which he is already registered
157  */
158 #define NFCSTATUS_ALREADY_REGISTERED                          (0x0035)
159 
160 /*  Single Tag with Multiple
161     Protocol support detected */
162 #define NFCSTATUS_MULTIPLE_PROTOCOLS                          (0x0036)
163 
164 /*
165  * Feature not supported
166  */
167 #define NFCSTATUS_MULTIPLE_TAGS                               (0x0037)
168 
169 /*
170  * A DESELECT event has occurred
171  */
172 #define NFCSTATUS_DESELECTED                                  (0x0038)
173 
174 /*
175  * A RELEASE event has occurred
176  */
177 #define NFCSTATUS_RELEASED                                    (0x0039)
178 
179 /*
180  * The operation is currently not possible or not allowed
181  */
182 #define NFCSTATUS_NOT_ALLOWED                                 (0x003A)
183 
184 /*
185  *  The system is busy with the previous operation.
186  */
187 #define NFCSTATUS_BUSY                                        (0x006F)
188 
189 
190 /* NDEF Mapping error codes */
191 
192 /* The remote device (type) is not valid for this request. */
193 #define NFCSTATUS_INVALID_REMOTE_DEVICE                       (0x001D)
194 
195 /* Read operation failed */
196 #define NFCSTATUS_READ_FAILED                                 (0x0014)
197 
198 /*
199  * Write operation failed
200  */
201 #define NFCSTATUS_WRITE_FAILED                                (0x0015)
202 
203 /* Non Ndef Compliant */
204 #define NFCSTATUS_NO_NDEF_SUPPORT                             (0x0016)
205 
206 /* Could not proceed further with the write operation: reached card EOF*/
207 #define NFCSTATUS_EOF_NDEF_CONTAINER_REACHED                  (0x001A)
208 
209 /* Incorrect number of bytes received from the card*/
210 #define NFCSTATUS_INVALID_RECEIVE_LENGTH                      (0x001B)
211 
212 /* The data format/composition is not understood/correct. */
213 #define NFCSTATUS_INVALID_FORMAT                              (0x001C)
214 
215 
216 /* There is not sufficient storage available. */
217 #define NFCSTATUS_INSUFFICIENT_STORAGE                        (0x001F)
218 
219 /* The Ndef Format procedure has failed. */
220 #define NFCSTATUS_FORMAT_ERROR                                (0x0023)
221 
222 /* The NCI Cedit error */
223 #define NFCSTATUS_CREDIT_TIMEOUT                              (0x0024)
224 
225 /*
226  * Response Time out for the control message(NFCC not responded)
227  */
228 #define NFCSTATUS_RESPONSE_TIMEOUT                            (0x0025)
229 
230 /*
231  * Device is already connected
232  */
233 #define NFCSTATUS_ALREADY_CONNECTED                           (0x0026)
234 
235 /*
236  * Device is already connected
237  */
238 #define NFCSTATUS_ANOTHER_DEVICE_CONNECTED                    (0x0027)
239 
240 /*
241  * Single Target Detected and Activated
242  */
243 #define NFCSTATUS_SINGLE_TAG_ACTIVATED                        (0x0028)
244 
245 /*
246  * Single Target Detected
247  */
248 #define NFCSTATUS_SINGLE_TAG_DISCOVERED                       (0x0029)
249 
250 /*
251  * Secure element Detected and Activated
252  */
253 #define NFCSTATUS_SECURE_ELEMENT_ACTIVATED                    (0x0028)
254 
255 /*
256  * Unknown error Status Codes
257  */
258 #define NFCSTATUS_UNKNOWN_ERROR                               (0x00FE)
259 
260 /*
261  * Status code for failure
262  */
263 #define NFCSTATUS_FAILED                                      (0x00FF)
264 
265 /*
266  * The function/command has been aborted
267  */
268 #define NFCSTATUS_CMD_ABORTED                                 (0x0002)
269 
270 /*
271  * No target found after poll
272  */
273 #define NFCSTATUS_NO_TARGET_FOUND                             (0x000A)
274 
275 /* Attempt to disconnect a not connected remote device. */
276 #define NFCSTATUS_NO_DEVICE_CONNECTED                         (0x000B)
277 
278 /* External RF field detected. */
279 #define NFCSTATUS_EXTERNAL_RF_DETECTED                        (0x000E)
280 
281 /* Message is not allowed by the state machine
282  * (e.g. configuration went wrong)
283  */
284 #define NFCSTATUS_MSG_NOT_ALLOWED_BY_FSM                      (0x0010)
285 
286 /*
287  * No access has been granted
288  */
289 #define NFCSTATUS_ACCESS_DENIED                               (0x001E)
290 
291 /* No registry node matches the specified input data. */
292 #define NFCSTATUS_NODE_NOT_FOUND                              (0x0017)
293 
294 /* The current module is busy ; one might retry later */
295 #define NFCSTATUS_SMX_BAD_STATE                               (0x00F0)
296 
297 
298 /* The Abort mechanism has failed for unexpected reason: user can try again*/
299 #define NFCSTATUS_ABORT_FAILED                                (0x00F2)
300 
301 
302 /* The Registration command has failed because the user wants to register as target
303  * on a operating mode not supported
304  */
305 #define NFCSTATUS_REG_OPMODE_NOT_SUPPORTED                    (0x00F5)
306 
307 /*
308  * Shutdown in progress, cannot handle the request at this time.
309  */
310 #define NFCSTATUS_SHUTDOWN                  (0x0091)
311 
312 /*
313  * Target is no more in RF field
314  */
315 #define NFCSTATUS_TARGET_LOST               (0x0092)
316 
317 /*
318  * Request is rejected
319  */
320 #define NFCSTATUS_REJECTED                  (0x0093)
321 
322 /*
323  * Target is not connected
324  */
325 #define NFCSTATUS_TARGET_NOT_CONNECTED      (0x0094)
326 
327 /*
328  * Invalid handle for the operation
329  */
330 #define NFCSTATUS_INVALID_HANDLE            (0x0095)
331 
332 /*
333  * Process aborted
334  */
335 #define NFCSTATUS_ABORTED                   (0x0096)
336 
337 /*
338  * Requested command is not supported
339  */
340 #define NFCSTATUS_COMMAND_NOT_SUPPORTED     (0x0097)
341 
342 /*
343  * Tag is not NDEF compliant
344  */
345 #define NFCSTATUS_NON_NDEF_COMPLIANT        (0x0098)
346 
347 /*
348  * Not enough memory available to complete the requested operation
349  */
350 #define NFCSTATUS_NOT_ENOUGH_MEMORY         (0x001F)
351 
352 /*
353  * Indicates incoming connection
354  */
355 #define NFCSTATUS_INCOMING_CONNECTION        (0x0045)
356 
357 /*
358  * Indicates Connection was successful
359  */
360 #define NFCSTATUS_CONNECTION_SUCCESS         (0x0046)
361 
362 /*
363  * Indicates Connection failed
364  */
365 #define NFCSTATUS_CONNECTION_FAILED          (0x0047)
366 
367 #endif /* PHNFCSTATUS_H */
368