3e186d87de0647813661a49695609cd01f70b353
[platform/core/api/nfc.git] / include / nfc.h
1 /*
2  * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
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 #ifndef __NFC_H__
19 #define __NFC_H__
20
21 #include <tizen.h>
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 /**
28  * @file nfc.h
29  * @brief This file contains the NFC API.
30  */
31
32 #define NFC_ERROR_CLASS TIZEN_ERROR_NETWORK_CLASS | 0x200
33
34
35 /**
36  * @brief Error codes reported by the NFC API.
37  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
38  */
39 typedef enum {
40         NFC_ERROR_NONE = TIZEN_ERROR_NONE,      /**< Successful */
41         NFC_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY,    /**< Out of memory */
42         NFC_ERROR_OPERATION_FAILED = NFC_ERROR_CLASS | 0x01,    /**< Operation failed*/
43         NFC_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER,    /**< Invalid parameter */
44         NFC_ERROR_INVALID_NDEF_MESSAGE = NFC_ERROR_CLASS | 0x02,        /**< Invalid NDEF message */
45         NFC_ERROR_INVALID_RECORD_TYPE  = NFC_ERROR_CLASS | 0x03,        /**< Invalid record type*/
46         NFC_ERROR_TIMED_OUT = TIZEN_ERROR_TIMED_OUT,    /**< Timeout error, no answer */
47         NFC_ERROR_DEVICE_BUSY = TIZEN_ERROR_RESOURCE_BUSY,      /**< Previous operation is not finished still busy */
48         NFC_ERROR_NO_DEVICE = NFC_ERROR_CLASS | 0x04, /**< no device */
49         NFC_ERROR_NOT_ACTIVATED = NFC_ERROR_CLASS | 0x05, /**< NFC is not activated */
50         NFC_ERROR_NOT_SUPPORTED = NFC_ERROR_CLASS | 0x06, /**< Not supported */
51         NFC_ERROR_ALREADY_ACTIVATED = NFC_ERROR_CLASS | 0x07, /**< Already activated */
52         NFC_ERROR_ALREADY_DEACTIVATED = NFC_ERROR_CLASS | 0x08, /**< Already deactivated */
53         NFC_ERROR_READ_ONLY_NDEF = NFC_ERROR_CLASS | 0x09, /**< Read only tag */
54         NFC_ERROR_NO_SPACE_ON_NDEF = NFC_ERROR_CLASS | 0x0a, /**< No enough space on tag */
55         NFC_ERROR_NO_NDEF_MESSAGE = NFC_ERROR_CLASS | 0x0b, /**< No NDEF Message on Tag */
56         NFC_ERROR_NOT_NDEF_FORMAT = NFC_ERROR_CLASS | 0x0c, /**< Not NDEF format Tag */
57         NFC_ERROR_SECURITY_RESTRICTED = NFC_ERROR_CLASS | 0x0d /**<  Restricted by security system policy */
58 } nfc_error_e;
59
60 /**
61  * @brief Enumerations for record TNF (Type Name Format)
62  * @details It is indicate format of type field
63  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
64  */
65 typedef enum {
66         NFC_RECORD_TNF_EMPTY = 0x00,    /**< Empty */
67         NFC_RECORD_TNF_WELL_KNOWN = 0x01,       /**< RTD(Record Type Definition) type format [NFC RTD] */
68         NFC_RECORD_TNF_MIME_MEDIA= 0x02,        /**< MIME Media types in RFC 2046 [RFC 2046] */
69         NFC_RECORD_TNF_URI = 0x03,      /**< Absolute URI as defined in RFC 3986 [RFC 3986] */
70         NFC_RECORD_TNF_EXTERNAL_RTD = 0x04,     /**< NFC Forum external type [NFC RTD] */
71         NFC_RECORD_TNF_UNKNOWN = 0x05,  /**< Unknown\n The payload type is unknown */
72         NFC_RECORD_TNF_UNCHAGNED = 0x06,        /**< It means the payload is an intermediate or final chunk of a chunked NDEF Record */
73 } nfc_record_tnf_e;
74
75
76 /**
77  * @brief Enumerations for NFC encode types
78  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
79  */
80 typedef enum {
81         NFC_ENCODE_UTF_8 = 0x00,        /**< UTF-8 */
82         NFC_ENCODE_UTF_16,      /**< UTF-16 */
83 } nfc_encode_type_e;
84
85 /**
86  * @brief Enumerations for NFC tag types
87  * @ingroup CAPI_NETWORK_NFC_TAG_MODULE
88  */
89 typedef enum {
90         NFC_UNKNOWN_TARGET = 0x00U,     /**< Unknown target */
91         NFC_GENERIC_PICC,       /**< GENERIC PICC*/
92         NFC_ISO14443_A_PICC,    /**< ISO14443_A PICC */
93         NFC_ISO14443_4A_PICC,   /**< ISO14443_4A PICC */
94         NFC_ISO14443_3A_PICC,   /**< ISO14443_3A PICC */
95         NFC_MIFARE_MINI_PICC,   /**< MIFARE_MINI_PICC */
96         NFC_MIFARE_1K_PICC,     /**< MIFARE_1K_PICC */
97         NFC_MIFARE_4K_PICC,     /**< MIFARE_4K_PICC */
98         NFC_MIFARE_ULTRA_PICC,  /**< MIFARE_ULTRA_PICC */
99         NFC_MIFARE_DESFIRE_PICC,        /**< MIFARE_DESFIRE_PICC */
100         NFC_ISO14443_B_PICC,    /**< ISO14443_B PICC */
101         NFC_ISO14443_4B_PICC,   /**< ISO14443_4B PICC */
102         NFC_ISO14443_BPRIME_PICC,       /**< ISO14443_BPRIME PICC */
103         NFC_FELICA_PICC,        /**< FELICA PICC */
104         NFC_JEWEL_PICC, /**< JEWEL PICC */
105         NFC_ISO15693_PICC,      /**< ISO15693 PICC */
106         NFC_NFCIP1_TARGET,      /**< NFCIP1_TARGET */
107         NFC_NFCIP1_INITIATOR,   /**< NFCIP1_INITIATOR */
108 } nfc_tag_type_e;
109
110
111
112 /**
113  * @brief Enumerations for NFC Tag filter
114  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
115  */
116 typedef enum {
117         NFC_TAG_FILTER_ALL_DISABLE = 0x0000,    /**< All disable */
118         NFC_TAG_FILTER_ISO14443A_ENABLE = 0x0001,       /**< ISO14443A enable */
119         NFC_TAG_FILTER_ISO14443B_ENABLE = 0x0002,       /**< ISO14443B enable */
120         NFC_TAG_FILTER_ISO15693_ENABLE = 0x0004,        /**< ISO15693 enable */
121         NFC_TAG_FILTER_FELICA_ENABLE = 0x0008,  /**< FELICA enable */
122         NFC_TAG_FILTER_JEWEL_ENABLE = 0x0010,   /**< JEWEL enable */
123         NFC_TAG_FILTER_IP_ENABLE = 0x0020,      /**< IP enable */
124         NFC_TAG_FILTER_ALL_ENABLE= ~0,  /**< All enable */
125 } nfc_tag_filter_e;
126
127 /**
128  * @brief Enumerations of polling request code for FeliCa tag
129  * @ingroup CAPI_NETWORK_NFC_TAG_FELICA
130  */
131 typedef enum {
132         NFC_TAG_FELICA_POLL_NO_REQUEST = 0x00,  /**< NO REQUEST */
133         NFC_TAG_FELICA_POLL_SYSTEM_CODE_REQUEST= 0x01,  /**< SYSTEM CODE REQUEST */
134         NFC_TAG_FELICA_POLL_COMM_SPEED_REQUEST= 0x02,   /**< COMM SPEED REQUEST */
135 } nfc_tag_felica_poll_request_code_e;
136
137
138 /**
139  * @brief Enumerations for NFC discovered type
140  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
141  */
142 typedef enum {
143         NFC_DISCOVERED_TYPE_ATTACHED,   /**< Attached, discovered, activated event*/
144         NFC_DISCOVERED_TYPE_DETACHED,   /**< detached, disappeared, deactivated event*/
145 } nfc_discovered_type_e;
146
147 /**
148  * @brief Enumerations for NFC Secure Element (SIM/UICC(Universal Integrated Circuit Card)) event
149  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
150  */
151 typedef enum{
152         NFC_SE_EVENT_START_TRANSACTION, /**< This event notifies the terminal host that it shall launch an application associated to an NFC application in a UICC(Universal Integrated Circuit Card) host. */
153         NFC_SE_EVENT_END_TRANSACTION,   /**< This event notifies the terminal host that current transaction in process was ended. */
154         NFC_SE_EVENT_CONNECTIVITY, /**< It's ready signal to communicate UICC(Universal Integrated Circuit Card) with terminal host. \nUICC(Universal Integrated Circuit Card) create pipe and open the pipe chanel.\nThen it sends the signal to terminal host or host controller. */
155         NFC_SE_EVENT_FIELD_ON, /**< When the CLF(Contactless Front-end) detects a RF field, the card RF gate sends the event #NFC_SE_EVENT_FIELD_ON to the card application gate.\nWhen there are multiple open card RF gates the CLF shall send the #NFC_SE_EVENT_FIELD_ON on all open pipes to these gates.Next the CLF starts the initialization and anti-collision process as defined in ISO/IEC 14443-3 [6]*/
156         NFC_SE_EVENT_FIELD_OFF, /**< When the CLF(Contactless Front-end) detects that the RF field is off, the card RF gate shall send #NFC_SE_EVENT_FIELD_OFF to the card application gate.\nWhen there are multiple open card RF gates the CLF shall send the #NFC_SE_EVENT_FIELD_OFF to one gate only.*/
157         NFC_SE_EVENT_TRANSACTION, /**< This event  notifies , external reader trys to access secure element */
158         NFC_SE_EVENT_SE_TYPE_CHANGED, /**< This event notifies, changing the emulated secure element type */
159         NFC_SE_EVENT_CARD_EMULATION_CHANGED, /**< This event notifies, changing the card emulation mode */
160 } nfc_se_event_e;
161
162 /**
163  * @brief Enumerations for NFC Secure Element (SIM/UICC(Universal Integrated Circuit Card)) type
164  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
165  */
166 typedef enum{
167         NFC_SE_TYPE_DISABLE = 0x00, /**< Disable card emulation */
168         NFC_SE_TYPE_ESE = 0x01, /**< SmartMX type card emulation */
169         NFC_SE_TYPE_UICC = 0x02 /**< UICC type card emulation */
170 } nfc_se_type_e;
171
172 /**
173  * @brief Enumerations for NFC Card Emulation Mode type
174  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
175  */
176 typedef enum{
177         NFC_SE_CARD_EMULATION_MODE_OFF = 0x00, /**< Card Emulation mode OFF */
178         NFC_SE_CARD_EMULATION_MODE_ON = 0x01, /**< Card Emulation mode ON */
179 } nfc_se_card_emulation_mode_type_e;
180
181 /**
182  * @brief Enumerations for NFC AC(Alternative Carrier)
183  * @ingroup CAPI_NETWORK_NFC_P2P_MODULE
184  */
185 typedef enum {
186         NFC_AC_TYPE_BT = 0x00, /**< Bluetooth AC*/
187         NFC_AC_TYPE_WIFI, /**<Wifi AC*/
188         NFC_AC_TYPE_WIFI_DIRECT,/**<Wifi-direct AC*/
189         NFC_AC_TYPE_UNKNOWN, /* No selected preferred AC */
190 } nfc_ac_type_e ;
191
192 /**
193  * @brief Enumerations for SNEP event
194  * @ingroup CAPI_NETWORK_NFC_P2P_MODULE
195  */
196 typedef enum {
197         NFC_SNEP_EVENT_STOP = 0x00, /**< server or client stopped */
198         NFC_SNEP_EVENT_START = 0x01, /**< server started or client connected */
199         NFC_SNEP_EVENT_GET = 0x02, /**< server received get request */
200         NFC_SNEP_EVENT_PUT = 0x03, /**< server received put request */
201         NFC_SNEP_EVENT_REGISTER = 0x04, /**< service registered */
202         NFC_SNEP_EVENT_UNREGISTER = 0x05, /**< service unregistered */
203 } nfc_snep_event_e;
204
205 /**
206  * @brief Enumerations for SNEP request type
207  * @ingroup CAPI_NETWORK_NFC_P2P_MODULE
208  */
209 typedef enum {
210         NFC_SNEP_GET = 0x01, /**< get request */
211         NFC_SNEP_PUT = 0x02, /**< put request */
212 } nfc_snep_type_e;
213
214 /**
215  * @brief Enumerations for PRBS technology type
216  * @ingroup CAPI_NETWORK_NFC_TEST_MODULE
217  */
218 typedef enum {
219         NFC_PRBS_TECH_NONE = 0x00, /**< Unknown NFC technology */
220         NFC_PRBS_TECH_A = 0x01, /**< NFC technology A */
221         NFC_PRBS_TECH_B = 0x02, /**< NFC technology B */
222         NFC_PRBS_TECH_F = 0x03, /**< NFC technology F */
223 } nfc_prbs_tech_e;
224
225 /**
226  * @brief Enumerations for PRBS speed rate type
227  * @ingroup CAPI_NETWORK_NFC_TEST_MODULE
228  */
229 typedef enum {
230         NFC_PRBS_RATE_NONE = 0x00, /**< Unknown NFC speed */
231         NFC_PRBS_RATE_106K = 0x01, /**< 106kbps */
232         NFC_PRBS_RATE_212K = 0x02, /**< 212kbps */
233         NFC_PRBS_RATE_424K = 0x03, /**< 424kbps */
234 } nfc_prbs_rate_e;
235
236 /**
237  * @brief The handle to the NDEF record
238  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
239  */
240 typedef struct _ndef_record_s *nfc_ndef_record_h;
241
242 /**
243  * @brief The handle to the NDEF message
244  * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
245  */
246 typedef struct _ndef_message_s *nfc_ndef_message_h;
247
248 /**
249  * @brief The handle to the NFC tag
250  * @ingroup CAPI_NETWORK_NFC_TAG_MODULE
251  */
252 typedef struct _net_nfc_target_info_s *nfc_tag_h;
253
254
255 /**
256  * @brief The handle to NFC p2p target
257  * @ingroup CAPI_NETWORK_NFC_P2P_MODULE
258  */
259 typedef void *nfc_p2p_target_h;
260
261 /**
262  * @brief The handle to NFC p2p snep instance
263  * @ingroup CAPI_NETWORK_NFC_P2P_MODULE
264  */
265 typedef struct _nfc_p2p_snep_s *nfc_p2p_snep_h;
266
267 /**
268  * @brief The handle to NFC secure element instance
269  * @ingroup CAPI_NETWORK_NFC_TAG_MODULE
270  */
271 typedef void *nfc_se_h;
272
273 /**
274  * @brief The default factory key.
275  * @details The key is 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
276  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
277  */
278 extern const unsigned char NFC_TAG_MIFARE_KEY_DEFAULT[6];
279
280 /**
281  * @brief The well-known key for tags formatted according to the MIFARE Application Directory (MAD) specification.
282  * @details The key is 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5
283  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
284  */
285 extern const unsigned char NFC_TAG_MIFARE_KEY_APPLICATION_DIRECTORY[6];
286
287 /**
288  * @brief The well-known key for tags formatted according to the NDEF on Mifare Classic specification.
289  * @details The key is 0xD3, 0xF7, 0xD3, 0xF7, 0xD3, 0xF7
290  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
291  */
292 extern const unsigned char NFC_TAG_MIFARE_KEY_NFC_FORUM[6];
293
294
295 /**
296  * @brief RTD(Record type definition) Type - Smart Poster type.
297  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
298  */
299 extern const unsigned char NFC_RECORD_SMART_POSTER_TYPE[2];
300
301 /**
302  * @brief  RTD(Record type definition) Type - Text type.
303  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
304  */
305 extern const unsigned char NFC_RECORD_TEXT_TYPE[1];
306 /**
307  * @brief  RTD(Record type definition) Type - URI type.
308  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
309  */
310 extern const unsigned char NFC_RECORD_URI_TYPE[1];
311 /**
312  * @brief  RTD(Record type definition) Type - Alternative Carrier type.
313  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
314  */
315 extern const unsigned char NFC_RECORD_ALTERNATIVE_CARRIER_TYPE[2];
316 /**
317  * @brief  RTD(Record type definition) Type - Handover Carrier type.
318  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
319  */
320 extern const unsigned char NFC_RECORD_HANDOVER_CARRIER_TYPE[2];
321 /**
322  * @brief  RTD(Record type definition) Type - Handover Request type.
323  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
324  */
325 extern const unsigned char NFC_RECORD_HANDOVER_REQUEST_TYPE[2];
326 /**
327  * @brief  RTD(Record type definition) Type - Handover Select type.
328  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
329  */
330 extern const unsigned char NFC_RECORD_HANDOVER_SELECT_TYPE[2];
331
332 /**
333  * @brief Called after nfc_manager_set_activation() has completed.
334  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
335  *
336  * @param [in] error The result
337  * @param [in] user_data The user data passed from the callback registration function
338  *
339  * @see nfc_manager_set_activation()
340  */
341 typedef void (* nfc_activation_completed_cb)(nfc_error_e error, void *user_data);
342
343 /**
344  * @brief Called when nfc activation state is changed.
345  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
346  *
347  * @param [in] activated The activation state
348  * @param [in] user_data The user data passed from the callback registration function
349  *
350  * @see nfc_manager_set_activation_changed_cb()
351  */
352 typedef void (*nfc_activation_changed_cb)(bool activated , void *user_data);
353
354 /**
355  * @brief Called after nfc_manager_initialize() has completed.
356  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
357  *
358  * @param [in] error The result
359  * @param [in] user_data The user data passed from the callback registration function
360  *
361  * @see nfc_manager_initialize()
362  */
363 typedef void (* nfc_initialize_completed_cb)(nfc_error_e error, void *user_data);
364
365
366 /**
367  * @brief Called after nfc_manager_set_card_emulation_se_type() has completed.
368  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
369  *
370  * @param [in] error The result
371  * @param [in] user_data The user data passed from the callback registration function
372  *
373  * @see nfc_manager_set_card_emulation_se_type()
374  */
375 typedef void (* nfc_set_card_emulation_completed_cb)(nfc_error_e error, void *user_data);
376
377 /**
378  * @brief Called when an NFC tag appears or disappears
379  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
380  *
381  * @remarks  The tag handle does not have detail target info when an NFC tag disappeared.\n
382  *      So then do not use nfc_tag_get_keys().
383  *
384  * @param [in] type The discovered type attached or detached
385  * @param [in] tag The handle to NFC tag
386  * @param [in] user_data The user data passed from the callback registration function
387  *
388  * @see nfc_manager_set_tag_discovered_cb()
389  * @see nfc_manager_unset_tag_discovered_cb()
390  * @see nfc_manager_set_tag_filter()
391  */
392 typedef void (* nfc_tag_discovered_cb)(nfc_discovered_type_e type, nfc_tag_h tag, void *user_data);
393
394 /**
395  * @brief Called when an NDEF Message is discovered
396  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
397  *
398  * @remarks @a message will be automatically destroyed when the callback function returns. (Do not release @a message.)
399  *
400  * @param [in] message The handle to NDEF message
401  * @param [in] user_data The user data passed from the callback registration function
402  *
403  * @see nfc_manager_set_ndef_discovered_cb()
404  * @see nfc_manager_unset_ndef_discovered_cb()
405  */
406 typedef void (* nfc_ndef_discovered_cb)(nfc_ndef_message_h message, void *user_data);
407
408
409 /**
410  * @brief Called once for each tag information.
411  * @ingroup CAPI_NETWORK_NFC_TAG_MODULE
412  *
413  * @remarks @a key and value will be automatically destroyed when the callback function returns. (Do not release @a key and value.)
414  *
415  * @param[in] key The key of information
416  * @param[in] value The value of information
417  * @param[in] value_size The data size in bytes
418  * @param[in] user_data The user data passed from the foreach function
419  *
420  * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop.
421  * @pre nfc_tag_foreach_informations() invokes this callback.
422  *
423  * @see nfc_tag_foreach_informations()
424  */
425
426 typedef bool (*nfc_tag_information_cb)(const char *key, const unsigned char *value, int value_size, void *user_data);
427
428
429 /**
430  * @brief Called after nfc_tag_transceive() has completed.
431  * @ingroup CAPI_NETWORK_NFC_TAG_MODULE
432  *
433  * @remarks @a buffer will be automatically destroyed when the callback function returns. (Do not release @a buffer.)
434  *
435  * @param [in] result The result of function call
436  * @param [in] buffer   The result data
437  * @param [in] buffer_size The size of buffer in bytes
438  * @param [in] user_data The user data passed from nfc_tag_transceive()
439  *
440  * @see nfc_tag_transceive()
441  */
442 typedef void (* nfc_tag_transceive_completed_cb)(nfc_error_e result, unsigned char *buffer, int buffer_size, void *user_data);
443
444 /**
445  * @brief Called after the nfc_tag_write_ndef() has completed.
446  * @ingroup CAPI_NETWORK_NFC_TAG_MODULE
447  *
448  * @param [in] result The result of function call
449  * @param [in] user_data The user data passed from nfc_manager_initialize()
450  *
451  * @see nfc_tag_write_ndef()
452  */
453 typedef void (* nfc_tag_write_completed_cb)(nfc_error_e result, void *user_data);
454
455 /**
456  * @brief Called after the nfc_tag_read_ndef() has completed.
457  * @ingroup CAPI_NETWORK_NFC_TAG_MODULE
458  *
459  * @remarks @a message will be automatically destroyed when the callback function returns. (Do not release @a message.)
460  *
461  * @param [in] result The result of function call
462  * @param [in] message The NDEF message
463  * @param [in] user_data The user data passed from nfc_tag_read_ndef()
464  *
465  * @see nfc_tag_read_ndef()
466  */
467 typedef void (* nfc_tag_read_completed_cb)(nfc_error_e result, nfc_ndef_message_h message, void *user_data);
468
469 /**
470  * @brief   Called after the nfc_tag_format_ndef() has completed.
471  * @ingroup CAPI_NETWORK_NFC_TAG_MODULE
472  *
473  * @param [in] result The result of function call
474  * @param [in] user_data The user data passed from nfc_tag_format_ndef()
475  *
476  * @see nfc_tag_format_ndef()
477  */
478 typedef void (* nfc_tag_format_completed_cb)(nfc_error_e result, void *user_data);
479
480
481 /**
482  * @brief Called after nfc_mifare_authenticate_with_keyA() has completed
483  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
484  *
485  * @param [in] result The result of nfc_mifare_authenticate_with_keyA()
486  * @param [in] user_data The user data passed from nfc_mifare_authenticate_with_keyA()
487  *
488  * @see nfc_mifare_authenticate_with_keyA()
489  */
490 typedef void (* nfc_mifare_authenticate_with_keyA_completed_cb)(nfc_error_e result, void *user_data);
491
492 /**
493  * @brief Called after nfc_mifare_authenticate_with_keyB() has completed
494  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
495  *
496  * @param [in] result The result of function call
497  * @param [in] user_data The user data passed from nfc_mifare_authenticate_with_keyB()
498  *
499  * @see nfc_mifare_authenticate_with_keyB()
500  */
501 typedef void (* nfc_mifare_authenticate_with_keyB_completed_cb)(nfc_error_e result, void *user_data);
502
503 /**
504  * @brief Called after nfc_mifare_write_block() has completed
505  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
506  *
507  * @param [in] result The result of nfc_mifare_write_block()
508  * @param [in] user_data The user data passed from nfc_mifare_write_block()
509  *
510  * @see nfc_mifare_write_block()
511  */
512 typedef void (* nfc_mifare_write_block_completed_cb)(nfc_error_e result, void *user_data);
513
514 /**
515  * @brief Called after nfc_mifare_write_page() has completed
516  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
517  *
518  * @param [in] result The result of function call
519  * @param [in] user_data The user data passed from nfc_mifare_write_page()
520  *
521  * @see nfc_mifare_write_page()
522  */
523 typedef void (* nfc_mifare_write_page_completed_cb)(nfc_error_e result, void *user_data);
524
525 /**
526  * @brief Called after nfc_mifare_read_block() has completed
527  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
528  *
529  * @remarks @a buffer will be automatically destroyed when the callback function returns. (Do not release @a buffer.)
530  *
531  * @param [in] result The result of function call
532  * @param [in] buffer The read buffer
533  * @param [in] size The size of buffer in bytes
534  * @param [in] user_data The user data passed from nfc_mifare_read_block()
535  *
536  * @see nfc_mifare_read_block()
537  */
538 typedef void (* nfc_mifare_read_block_completed_cb)(nfc_error_e result, unsigned char *buffer, int bufer_size, void *user_data);
539
540 /**
541  * @brief Called after nfc_mifare_read_page() has completed
542  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
543  *
544  * @remarks @a buffer will be automatically destroyed when the callback function returns. (Do not release @a buffer.)
545  *
546  * @param [in] result The result of nfc_mifare_read_page()
547  * @param [in] buffer The read buffer
548  * @param [in] size The size of read buffer in bytes
549  * @param [in] user_data The user data passed from nfc_mifare_read_page()
550  *
551  * @see nfc_mifare_read_page()
552  */
553 typedef void (* nfc_mifare_read_page_completed_cb)(nfc_error_e result, unsigned char *buffer, int bufer_size, void *user_data);
554
555 /**
556  * @brief Called after nfc_mifare_increment() has completed
557  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
558  *
559  * @param [in] result The result of nfc_mifare_increment()
560  * @param [in] user_data The user data passed from nfc_mifare_increment()
561  *
562  * @see nfc_mifare_increment()
563  */
564 typedef void (* nfc_mifare_increment_completed_cb)(nfc_error_e result, void *user_data);
565
566 /**
567  * @brief Called after nfc_mifare_decrement() has completed
568  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
569  *
570  * @param [in] result The result of nfc_mifare_decrement()
571  * @param [in] user_data The user data passed from nfc_mifare_decrement()
572  *
573  * @see nfc_mifare_decrement()
574  */
575 typedef void (* nfc_mifare_decrement_completed_cb)(nfc_error_e result, void *user_data);
576
577 /**
578  * @brief Called after nfc_mifare_transfer() has completed
579  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
580  *
581  * @param [in] result The result of nfc_mifare_transfer()
582  * @param [in] user_data The user data passed from nfc_mifare_transfer()
583  *
584  * @see nfc_mifare_transfer()
585  */
586 typedef void (* nfc_mifare_transfer_completed_cb)(nfc_error_e result, void *user_data);
587
588 /**
589  * @brief Called after nfc_mifare_restore() has completed
590  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
591  *
592  * @param [in] result The result of nfc_mifare_restore()
593  * @param [in] user_data The user data passed from nfc_mifare_restore()
594  *
595  * @see nfc_mifare_restore()
596  */
597 typedef void (* nfc_mifare_restore_completed_cb)(nfc_error_e result, void *user_data);
598
599
600
601 /**
602  * @brief Called when NFC peer-to-peer target appeared or disappeared
603  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
604  *
605  * @param [in] type The discovered type attached or detached
606  * @param [in] target The handle to p2p target
607  * @param [in] user_data The user data passed from nfc_manager_set_p2p_target_discovered_cb()
608  *
609  * @see nfc_manager_set_p2p_target_discovered_cb()
610  * @see nfc_manager_unset_p2p_target_discovered_cb()
611  */
612 typedef void (*nfc_p2p_target_discovered_cb)(nfc_discovered_type_e type, nfc_p2p_target_h target, void *user_data);
613
614 /**
615  * @brief Called when receiving  Secure Element (SIM/UICC(Universal Integrated Circuit Card)) event.
616  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
617  *
618  * @param [in] event The Secure Element event
619  * @param [in] user_data The user data passed from nfc_manager_set_se_event_cb()
620  *
621  * @see nfc_manager_set_se_event_cb()
622  * @see nfc_manager_unset_se_event_cb()
623  */
624 typedef void (*nfc_se_event_cb)(nfc_se_event_e event , void *user_data);
625
626
627 /**
628  * @brief Called when receiving Secure Element(SIM/UICC(Universal Integrated Circuit Card)) transaction event data
629  * @remarks This event  notifies , external reader trys to access secure element.
630  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
631  *
632  * @param [in] se type
633  * @param [in] aid Application Id, specified in ISO/IEC 7816-4
634  * @param [in] aid_size The size of aid (5~16)
635  * @param [in] param The parameter list, specified in ISO/IEC 8825-1
636  * @param [in] param The size of param (0~65535)
637  * @param [in] user_data The user data passed from nfc_manager_set_se_transaction_event_cb()
638  *
639  * @see nfc_manager_set_se_transaction_event_cb()
640  * @see nfc_manager_unset_se_transaction_event_cb()
641  */
642 typedef void (*nfc_se_transaction_event_cb)(nfc_se_type_e se_type, unsigned char* aid, int aid_size , unsigned char* param, int param_size,  void *user_data);
643
644
645
646 /**
647  * @brief Called after nfc_p2p_send() has completed.
648  * @ingroup CAPI_NETWORK_NFC_P2P_MODULE
649  *
650  * @param [in] result The result of function call
651  * @param [in] user_data The user data passed from nfc_p2p_send()
652  *
653  * @see nfc_p2p_send()
654  */
655 typedef void (*nfc_p2p_send_completed_cb)(nfc_error_e result, void *user_data);
656
657
658 /**
659  * @brief Called after nfc_p2p_send() has completed.
660  * @ingroup CAPI_NETWORK_NFC_P2P_MODULE
661  *
662  * @remarks @a message will be automatically destroyed when the callback function returns. (Do not release @a message.)
663  *
664  * @param [in] target The handle to p2p target
665  * @param [in] message The received message
666  * @param [in] user_data The user data passed from nfc_p2p_set_recv_cb()
667  *
668  * @see nfc_p2p_set_data_received_cb()
669  * @see nfc_p2p_unset_data_received_cb()
670  */
671 typedef void (*nfc_p2p_data_recived_cb)(nfc_p2p_target_h target, nfc_ndef_message_h message, void *user_data);
672
673
674 /**
675  * @brief Called after nfc_p2p_connection_handover() has completed.
676  * @ingroup CAPI_NETWORK_NFC_P2P_MODULE
677  *
678  * @remark To use the @a ac_data outside this function, copy the @a ac_data.
679  * @remark @a ac_data could be NULL, if nfc_p2p_connection_handover failed.
680  * @remark If @a carrier is #NFC_AC_TYPE_BT, @ac_data should be converted to 'char *' type. This is bluetooth address information.
681  *
682  * @param [in] result The result of function call
683  * @param [in] carrier The type of Alternative Carrier
684  * @param [in] ac_data The connected remote device AC(Alternative Carrier) information data
685  * @param [in] ac_data_size The connected remote device AC(Alternative Carrier) information data size
686  * @param [in] user_data The user data passed from nfc_p2p_connection_handover()
687  *
688  * @see nfc_p2p_connection_handover()
689  */
690 typedef void (*nfc_p2p_connection_handover_completed_cb)(nfc_error_e result, nfc_ac_type_e carrior, void * ac_data, int ac_data_size , void *user_data);
691
692
693 /**
694  * @brief Called when SNEP event is raised
695  * @ingroup CAPI_NETWORK_NFC_P2P_MODULE
696  *
697  * @param [in] handle The handle of current snep instance
698  * @param [in] event The kind of snep event
699  * @param [in] result The result of snep event
700  * @param [in] msg The ndef message which received from client or result of get request
701  * @param [in] user_data The user data passed from snep apis.
702  *
703  * @see nfc_snep_start_server()
704  * @see nfc_snep_send_request()
705  */
706 typedef void (*nfc_snep_event_cb)(nfc_p2p_snep_h handle,
707         nfc_snep_event_e event, nfc_error_e result,
708         nfc_ndef_message_h msg, void *user_data);
709
710 /**
711  * @brief Gets the value that indicates whether NFC is supported.
712  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
713  *
714  * @remarks This function can executed Regardless of nfc_manager_initialize state.
715  *
716  * @return true on NFC supported,  otherwise false
717  *
718  * @see nfc_manager_set_activation()
719  */
720 bool nfc_manager_is_supported(void);
721
722 /**
723  * @brief Sets NFC Activation
724  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
725  *
726  * @param [in] activation The NFC state for setting
727  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
728  * @param [in] user_data The user data to be passed to the callback function
729  *
730  * @return 0 on success, otherwise a negative error value.
731  * @retval #NFC_ERROR_NONE Successful
732  * @retval #NFC_ERROR_OPERATION_FAILED Operation fail
733  * @retval #NFC_ERROR_NOT_SUPPORTED Not supported NFC
734  * @retval #NFC_ERROR_ALREADY_ACTIVATED Already activated
735  * @retval #NFC_ERROR_ALREADY_DEACTIVATED Already deactivated
736  *
737  * @see nfc_manager_is_activated()
738  * @see nfc_activation_completed_cb()
739  */
740 int nfc_manager_set_activation(bool activation, nfc_activation_completed_cb callback, void *user_data);
741
742 /**
743  * @brief Set NFC Activation state changed callback
744  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
745  *
746  * @param [in] callback The callback function to invoke when activation state is changed.
747  * @param [in] user_data The user data to be passed to the callback function
748  *
749  * @return 0 on success, otherwise a negative error value.
750  * @retval #NFC_ERROR_NONE Successful
751  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
752  *
753  * @see nfc_activation_changed_cb()
754  * @see nfc_manager_unset_activation_changed_cb()
755  */
756 int nfc_manager_set_activation_changed_cb(nfc_activation_changed_cb callback , void *user_data);
757
758 /**
759  * @brief Unregisters the callback function.
760  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
761  *
762  * @see nfc_manager_set_activation_changed_cb()
763  * @see nfc_activation_changed_cb()
764  */
765 void nfc_manager_unset_activation_changed_cb(void);
766
767
768 /**
769  * @brief Gets NFC Activation state
770  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
771  *
772  * @remarks This function can executed Regardless of nfc_manager_initialize state.
773  *
774  * @return true on NFC activated,  otherwise false
775  *
776  * @see nfc_manager_set_activation()
777  */
778
779 bool nfc_manager_is_activated(void);
780
781 /**
782  * @brief Initializes NFC Manager.
783  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
784  * @remarks This function must be called before proceeding any other nfc functions\n
785  *      Internally it makes socket connection to NFC manager.\n
786  *      When an application crashes or exits without the deinitialization. NFC manager automatically deinitializes the process itself.\n
787  *      This function is asynchronous.
788  *
789  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
790  * @param [in] user_data The user data to be passed to the callback function
791  *
792  * @return 0 on success, otherwise a negative error value.
793  * @retval #NFC_ERROR_NONE Successful
794  * @retval #NFC_ERROR_OPERATION_FAILED Operation fail
795  *
796  * @see nfc_manager_initialize_sync()
797  * @see nfc_manager_deinitialize()
798  */
799 int nfc_manager_initialize(nfc_initialize_completed_cb callback, void *user_data);
800
801 /**
802  * @brief Initializes NFC Manager.
803  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
804  * @remarks This function must be called before proceeding any other nfc functions\n
805  *      Internally it makes socket connection to NFC manager.\n
806  *      When an application crashes or exits without the deinitialization. NFC manager automatically deinitializes the process itself.\n
807  *      This function is synchronous.
808  *
809  * @return 0 on success, otherwise a negative error value.
810  * @retval #NFC_ERROR_NONE Successful
811  * @retval #NFC_ERROR_OPERATION_FAILED Operation fail
812  *
813  * @see nfc_manager_initialize()
814  * @see nfc_manager_deinitialize()
815  */
816 int nfc_manager_initialize_sync();
817
818
819 /**
820  * @brief Releases all the resource of the NFC Manager and disconnect the session between an application and NFC Manager.
821  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
822  *
823  * @return 0 on success, otherwise a negative error value.
824  * @retval #NFC_ERROR_NONE Successful
825  * @retval #NFC_ERROR_OPERATION_FAILED Operation fail
826  *
827  * @see nfc_manager_initialize()
828  */
829 int nfc_manager_deinitialize(void);
830
831 /**
832  * @brief Registers a callback function for receiving tag discovered notification.
833  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
834  *
835  * @param [in] callback The callback function called when a tag is appeared or disappeared
836  * @param [in] user_data The user data to be passed to the callback function
837  *
838  * @return 0 on success, otherwise a negative error value.
839  * @retval #NFC_ERROR_NONE Successful
840  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
841  *
842  * @see nfc_manager_unset_tag_discovered_cb()
843  * @see nfc_tag_discovered_cb()
844  */
845 int nfc_manager_set_tag_discovered_cb(nfc_tag_discovered_cb callback, void *user_data);
846
847 /**
848  * @brief Unregisters the callback function.
849  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
850  *
851  * @see nfc_manager_set_tag_discovered_cb()
852  * @see nfc_tag_discovered_cb()
853  */
854 void nfc_manager_unset_tag_discovered_cb(void);
855
856 /**
857  * @brief Registers a callback function for receiving NDEF Message discovered notification
858  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
859  *
860  * @param [in] callback The callback function called when NDEF Message is discovered
861  * @param [in] user_data The user data to be passed to the callback function
862  *
863  * @return 0 on success, otherwise a negative error value.
864  * @retval #NFC_ERROR_NONE Successful
865  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
866  *
867  * @see nfc_manager_unset_ndef_discovered_cb()
868  * @see nfc_ndef_discovered_cb()
869  */
870 int nfc_manager_set_ndef_discovered_cb(nfc_ndef_discovered_cb callback, void *user_data);
871
872 /**
873  * @brief Unregisters the callback function.
874  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
875  *
876  * @see nfc_manager_set_ndef_discovered_cb()
877  * @see nfc_ndef_discovered_cb()
878  */
879 void nfc_manager_unset_ndef_discovered_cb(void);
880
881 /**
882  * @brief Registers a callback function for receiving NFC peer-to-peer target discovered notification.
883  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
884  *
885  * @param [in] callback The callback function called when NFC peer-to-peer target is discovered
886  * @param [in] user_data The user data to be passed to the callback function
887  *
888  * @return 0 on success, otherwise a negative error value.
889  * @retval #NFC_ERROR_NONE Successful
890  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
891  *
892  * @see nfc_manager_unset_ndef_discovered_cb()
893  * @see nfc_p2p_target_discovered_cb()
894  */
895 int nfc_manager_set_p2p_target_discovered_cb(nfc_p2p_target_discovered_cb callback, void *user_data);
896
897 /**
898  * @brief Unregisters the callback function.
899  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
900  *
901  * @see nfc_manager_set_p2p_target_discovered_cb()
902  * @see nfc_p2p_target_discovered_cb()
903  */
904 void nfc_manager_unset_p2p_target_discovered_cb(void);
905
906
907 /**
908  * @brief Registers a callback function for receiving  Secure Element (SIM/UICC(Universal Integrated Circuit Card)) event.
909  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
910  *
911  * @param [in] callback The callback function called when occurred Secure Element (SIM/UICC(Universal Integrated Circuit Card)) event.
912  * @param [in] user_data The user data to be passed to the callback function
913  *
914  * @return 0 on success, otherwise a negative error value.
915  * @retval #NFC_ERROR_NONE Successful
916  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
917  *
918  * @see nfc_se_event_cb()
919  * @see nfc_manager_unset_se_event_cb()
920  */
921
922 int nfc_manager_set_se_event_cb(nfc_se_event_cb callback, void *user_data);
923
924 /**
925  * @brief Unregisters the callback function.
926  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
927  *
928  * @see nfc_se_event_cb()
929  * @see nfc_manager_set_se_event_cb()
930  */
931 void nfc_manager_unset_se_event_cb(void);
932
933 /**
934  * @brief Registers a callback function for receiving  Secure Element (SIM/UICC(Universal Integrated Circuit Card)) transaction event(#NFC_SE_EVENT_TRANSACTION) data.
935  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
936  *
937  * @param [in] se_type The type of secure element.
938  * @param [in] callback The callback function called when occurred SE transaction event.
939  * @param [in] user_data The user data to be passed to the callback function
940  *
941  * @return 0 on success, otherwise a negative error value.
942  * @retval #NFC_ERROR_NONE Successful
943  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
944  *
945  * @see nfc_se_transaction_event_cb()
946  * @see nfc_manager_unset_se_transaction_event_cb()
947  */
948 int nfc_manager_set_se_transaction_event_cb(nfc_se_type_e se_type, 
949                 nfc_se_transaction_event_cb callback, void *user_data);
950
951 /**
952  * @brief Unregisters the callback function.
953  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
954  *
955  * @param [in] se_type The type of secure element.
956  *
957  * @see nfc_se_transaction_event_cb()
958  * @see nfc_manager_set_se_transaction_event_cb()
959  */
960 void nfc_manager_unset_se_transaction_event_cb(nfc_se_type_e se_type);
961
962 /**
963  * @brief Gets NDEF message cached when the tag is detected or when data received from NFC peer-to-peer target.
964  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
965  *
966  * @remarks This function is used to get the ndef message that was read before launched your application.
967  * @param [out] ndef_message The cached NDEF message
968  *
969  * @return 0 on success, otherwise a negative error value.
970  * @retval #NFC_ERROR_NONE Successful
971  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
972  * @retval #NFC_ERROR_INVALID_NDEF_MESSAGE The cached message does not exist
973  */
974 int nfc_manager_get_cached_message(nfc_ndef_message_h *ndef_message);
975
976
977 /**
978  * @brief Sets filter of target types.
979  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
980  * @remarks Bit operator OR(|) can be used in the configure parameter (like  NFC_TAG_FILTER_ISO14443A_ENABLE | NFC_TAG_FILTER_ISO14443B_ENABLE)
981  *      or you may choose "NFC_TAG_ALL_ENABLE" enum value to get all result.
982  *      It prevent getting tag types from RF level.
983  *      If the client api does call this function, default is always NFC_TAG_ALL_ENABLE.
984  *
985  * @param [in] filter The filter value with bits operation #nfc_tag_filter_e
986  *
987  * @see nfc_manager_get_tag_filter()
988  * @see nfc_tag_discovered_cb()
989  */
990 void nfc_manager_set_tag_filter(int filter);
991
992 /**
993  * @brief Gets the current filter status.
994  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
995  *
996  * @remarks Bit operation OR(|) is used in return data\n
997  * The default value is NFC_TAG_FILTER_ALL_ENABLE
998  *
999  * @return The filter which is set #nfc_tag_filter_e
1000  *
1001  * @see nfc_manager_set_tag_filter()
1002  */
1003 int nfc_manager_get_tag_filter(void);
1004
1005 /**
1006  * @brief Gets current connected tag.
1007  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
1008  *
1009  * @param [out] tag The connected tag
1010  *
1011  * @return 0 on success, otherwise a negative error value.
1012  * @retval #NFC_ERROR_NONE Successful
1013  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1014  * @retval #NFC_ERROR_NO_DEVICE There is no connected tag
1015  */
1016 int nfc_manager_get_connected_tag(nfc_tag_h *tag);
1017
1018 /**
1019  * @brief Gets current connected p2p target
1020  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
1021  *
1022  * @param [out] target The connected target
1023  *
1024  * @return 0 on success, otherwise a negative error value.
1025  * @retval #NFC_ERROR_NONE Successful
1026  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1027  * @retval #NFC_ERROR_NO_DEVICE There is no connected target
1028  */
1029 int nfc_manager_get_connected_target(nfc_p2p_target_h *target);
1030
1031
1032 /**
1033  * @brief Enable or disable the system handling for tag and target discovered event
1034  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
1035  * @remarks By default, The system handling is enabled.
1036  *
1037  * @param [in] enable The state of enable
1038  *
1039  * @return 0 on success, otherwise a negative error value.
1040  * @retval #NFC_ERROR_NONE Successful
1041  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1042  *
1043  * @see nfc_manager_is_system_handler_enabled()
1044  */
1045 int nfc_manager_set_system_handler_enable(bool enable);
1046
1047 /**
1048  * @brief Enable or disable the system handling for tag and target discovered event
1049  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
1050  * @remarks By default, The system handling is enabled.
1051  *
1052  * @param [in] enable The state of enable
1053  *
1054  * @return 0 on success, otherwise a negative error value.
1055  * @retval #NFC_ERROR_NONE Successful
1056  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1057  *
1058  * @see nfc_manager_is_system_handler_enabled()
1059  */
1060 int nfc_manager_set_system_handler_enable_force(bool enable);
1061
1062 /**
1063  * @brief Gets the state of the system handler
1064  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
1065  * @remarks By default, The system handling is enabled.
1066  *
1067  * @return true on enabled, otherwise false.
1068  *
1069  * @see nfc_manager_set_system_handler_enable()
1070  */
1071 bool nfc_manager_is_system_handler_enabled(void);
1072
1073 /**
1074  * @brief Sets the card emulation Secure Element type
1075  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
1076  * @remarks To disable card emulation mode, set NFC_SE_TYPE_DISABLE\n
1077  * This API is asynchronous function, This operation is completed when NFC_SE_EVENT_SE_TYPE_CHANGED event or nfc_set_card_emulation_completed_cb was invoked.
1078  *
1079  * @param [in] type The type of Secure Element
1080  * @param [in] callback The callback function to invoke after this function has completed\nIt can be null if notification is not required
1081  * @param [in] The user data to be passed to the callback function
1082  *
1083  * @return 0 on success, otherwise a negative error value.
1084  * @retval #NFC_ERROR_NONE Successful
1085  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1086  *
1087  * @see nfc_manager_get_card_emulation_se_type()
1088  */
1089 int nfc_manager_set_card_emulation_se_type(nfc_se_type_e type, nfc_set_card_emulation_completed_cb callback, void* user_data);
1090
1091 /**
1092  * @brief Gets the card emulation Secure Element type
1093  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
1094  *
1095  * @param [out] type The type of Secure Element
1096  *
1097  * @return 0 on success, otherwise a negative error value.
1098  * @retval #NFC_ERROR_NONE Successful
1099  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1100  *
1101  * @see nfc_manager_set_card_emulation_se_type()
1102  */
1103 int nfc_manager_get_card_emulation_se_type(nfc_se_type_e* type);
1104
1105 /**
1106  * @brief Gets the card emulation Secure Element type
1107  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
1108  *
1109  * @param [in] type The type of Secure Element
1110  *
1111  * @return 0 on success, otherwise a negative error value.
1112  * @retval #NFC_ERROR_NONE Successful
1113  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1114  *
1115  */
1116 int nfc_manager_set_se_type(nfc_se_type_e type);
1117
1118 /**
1119  * @brief Creates a record with given parameter value.
1120  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
1121  *
1122  * @remarks Every data buffer is deeply copied.\n
1123  * Every data is a byte array(binary data).
1124  *
1125  * @param [out] record A handle to record
1126  * @param [in] tnf The type name format
1127  * @param [in] type The specified type name
1128  * @param [in] type_size The byte size of type
1129  * @param [in] id The record ID
1130  * @param [in] id_size The byte size of ID
1131  * @param [in] payload The payload of this record
1132  * @param [in] payload_size The byte size of payload
1133  *
1134  * @return 0 on success, otherwise a negative error value.
1135  * @retval #NFC_ERROR_NONE Successful
1136  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1137  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1138  *
1139  * @see nfc_ndef_record_create_text()
1140  * @see nfc_ndef_record_create_uri()
1141  * @see nfc_ndef_record_create_mime()
1142  * @see nfc_ndef_record_destroy()
1143  */
1144 int nfc_ndef_record_create(nfc_ndef_record_h *record, nfc_record_tnf_e tnf, const unsigned char *type, int type_size, const unsigned char *id, int id_size, const unsigned char *payload, int payload_size);
1145
1146
1147 /**
1148  * @brief Creates a record with text type payload
1149  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
1150  *
1151  * @remarks This function does not encode the text. @a text will be assumed as that it is already encoded with encode type.\n
1152  * The text buffer will be deeply copied.\n
1153  * The record is created in this format\n
1154  * - TNF : NFC_RECORD_TNF_WELL_KNOWN\n
1155  * - type : "T"\n
1156  * - payload : encode and header information + language code + text \n
1157  * Defined in Record Type Definition Technical Specifications.
1158  *
1159  * @param [out] record A handle to record
1160  * @param [in] text The encoded text
1161  * @param [in] lang_code The language code string value followed by IANA[RFC 3066] (ex: en-US, ko-KR)
1162  * @param [in] encode The encoding type
1163  *
1164  * @return 0 on success, otherwise a negative error value.
1165  * @retval #NFC_ERROR_NONE Successful
1166  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1167  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1168  *
1169  * @see nfc_ndef_record_create()
1170  * @see nfc_ndef_record_create_uri()
1171  * @see nfc_ndef_record_create_mime()
1172  * @see nfc_ndef_record_destroy()
1173  * @see nfc_ndef_record_get_text()
1174  * @see nfc_ndef_record_get_langcode()
1175  * @see nfc_ndef_record_get_encode_type()
1176  */
1177 int nfc_ndef_record_create_text(nfc_ndef_record_h *record, const char *text, const char *lang_code, nfc_encode_type_e encode);
1178
1179 /**
1180  * @brief Creates a record with URI type payload
1181  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
1182  *
1183  * @remarks The uri string will be deep copied.\n
1184  * The record is created in this format\n
1185  * - TNF : NFC_RECORD_TNF_WELL_KNOWN\n
1186  * - type : "U"\n
1187  * - payload : protocol scheme + uri\n
1188  * Defined in Record Type Definition Technical Specifications.
1189  *
1190  * @param [out] record A handle to record
1191  * @param [in] protocol_scheme  The protocol scheme
1192  * @param [in] uri      The URI string that will be stored in the payload
1193  *
1194  * @return 0 on success, otherwise a negative error value.
1195  * @retval #NFC_ERROR_NONE Successful
1196  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1197  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1198  *
1199  * @see nfc_ndef_record_create()
1200  * @see nfc_ndef_record_create_text()
1201  * @see nfc_ndef_record_create_mime()
1202  * @see nfc_ndef_record_destroy()
1203  * @see nfc_ndef_record_get_uri()
1204  */
1205 int nfc_ndef_record_create_uri(nfc_ndef_record_h* record, const char *uri);
1206
1207
1208 /**
1209  * @brief Creates a record with MIME type payload
1210  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
1211  *
1212  * @remarks The data buffer will be deep copied.\n
1213  * The data are bytes array(binary data).\n
1214  * The mime_type string will deep copied.\n
1215  * The record is created in this format\n
1216  * - TNF : NFC_RECORD_TNF_MIME_MEDIA\n
1217  * - type : mime type\n
1218  * - payload : data\n
1219  * Defined in Record Type Definition Technical Specifications.
1220  *
1221  * @param [out] record A handle to record
1222  * @param [in] mime_type        The mime type [RFC 2046] (ex. text/plain, image/jpeg )\nThis value is stored in type field
1223  * @param [in] data     The pointer of data
1224  * @param [in] data_size        The size of data
1225  *
1226  * @return 0 on success, otherwise a negative error value.
1227  * @retval #NFC_ERROR_NONE Successful
1228  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1229  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1230  *
1231  * @see nfc_ndef_record_create()
1232  * @see nfc_ndef_record_create_uri()
1233  * @see nfc_ndef_record_create_text()
1234  * @see nfc_ndef_record_destroy()
1235  * @see nfc_ndef_record_get_mime_type()
1236  */
1237 int nfc_ndef_record_create_mime(nfc_ndef_record_h* record, const char *mime_type, const unsigned char *data, int data_size);
1238
1239
1240 /**
1241  * @brief Destroys the record handle
1242  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
1243  *
1244  * @param [in] record The handle to record
1245  *
1246  * @return 0 on success, otherwise a negative error value.
1247  * @retval #NFC_ERROR_NONE Successful
1248  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1249  *
1250  * @see nfc_ndef_record_create()
1251  * @see nfc_ndef_record_create_text()
1252  * @see nfc_ndef_record_create_uri()
1253  * @see nfc_ndef_record_create_mime()
1254  */
1255 int nfc_ndef_record_destroy(nfc_ndef_record_h record);
1256
1257 /**
1258  * @brief Sets record ID
1259  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
1260  *
1261  * @remarks The ID buffer are deep copied.
1262  *
1263  * @param [in] record The handle to record
1264  * @param [in] id The record ID
1265  * @param [in] id_size The size of ID in bytes
1266  *
1267  * @return 0 on success, otherwise a negative error value.
1268  * @retval      #NFC_ERROR_NONE Successful
1269  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1270  *
1271  * @see nfc_ndef_record_get_id()
1272  */
1273 int nfc_ndef_record_set_id(nfc_ndef_record_h record, unsigned char *id, int id_size);
1274
1275 /**
1276  * @brief Gets record ID
1277  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
1278  *
1279  * @remarks It may return NULL pointer if the ID is not exist\n
1280  *  This function gives you  the pointer of ID that is contained by record\n
1281  *  Do not free the ID. It will be released when @a record is destroyed by nfc_ndef_record_destroy().
1282  *
1283  * @param [in] record The handle to record
1284  * @param [out] id The record ID ( do not free )
1285  * @param [out] id_size The size of ID in bytes
1286  *
1287  * @return 0 on success, otherwise a negative error value.
1288  * @retval #NFC_ERROR_NONE Successful
1289  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1290  *
1291  * @see nfc_ndef_record_set_id()
1292  */
1293 int nfc_ndef_record_get_id(nfc_ndef_record_h record, unsigned char **id, int *size);
1294
1295 /**
1296  * @brief Gets record payload.
1297  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
1298  *
1299  * @remarks This function gives you  the pointer of payload that is contained by record\n
1300  * Do not free the payload. it will be freed when @a record is destroyed by nfc_ndef_record_destroy().
1301  *
1302  * @param [in] record The handle to record
1303  * @param [out] payload The payload  ( do not free this pointer )
1304  * @param [out] size the size of payload in byte
1305  *
1306  * @return 0 on success, otherwise a negative error value.
1307  * @retval #NFC_ERROR_NONE Successful
1308  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1309  */
1310 int nfc_ndef_record_get_payload(nfc_ndef_record_h record, unsigned char ** payload, unsigned int *size);
1311
1312 /**
1313  * @brief Gets record type.
1314  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
1315  *
1316  * @remarks This function gives you  the pointer of type that is contained by record.\n
1317  * Do not free the type. it will be freed when the record is freed.
1318  *
1319  * @param [in] record The handle to record
1320  * @param [out] type    The record type  ( do not free this pointer )
1321  * @param [out] size The size of type in byte
1322  *
1323  * @return 0 on success, otherwise a negative error value.
1324  * @retval #NFC_ERROR_NONE Successful
1325  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1326  */
1327 int nfc_ndef_record_get_type(nfc_ndef_record_h record, unsigned char **type, int *size);
1328
1329 /**
1330  * @brief Gets record TNF(Type Name Format) value.
1331  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
1332  *
1333  * @param [in] record The handle to record
1334  * @param [out] tnf The TNF(Type Name Format) value
1335  *
1336  * @return 0 on success, otherwise a negative error value.
1337  * @retval #NFC_ERROR_NONE Successful
1338  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1339  */
1340 int nfc_ndef_record_get_tnf(nfc_ndef_record_h record, nfc_record_tnf_e *tnf);
1341
1342 /**
1343  * @brief Gets text from text record
1344  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
1345  *
1346  * @remarks This function returns newly allocated string, this value must be deallocated by caller.\n
1347  * This function is valid only for text type record.\n
1348  * The text type record 's tnf is NFC_RECORD_TNF_WELL_KNOWN and it's type is "T"
1349  *
1350  * @param [in] record The handle to record
1351  * @param [out] text The text in record payload ( should be freed by caller )
1352  *
1353  * @return 0 on success, otherwise a negative error value.
1354  * @retval #NFC_ERROR_NONE Successful
1355  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1356  * @retval #NFC_ERROR_INVALID_RECORD_TYPE Invalid record type
1357  *
1358  * @see nfc_ndef_record_create_text()
1359  */
1360 int nfc_ndef_record_get_text(nfc_ndef_record_h record, char **text);
1361
1362 /**
1363  * @brief Gets language code from text record
1364  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
1365  * @remarks This function returns newly allocated string, this value must be deallocated by caller.\n
1366  * This function is valid only for text type record.\n
1367  * The text type record 's tnf is NFC_RECORD_TNF_WELL_KNOWN and it's type is "T"
1368  *
1369  * @param [in] record   The handle to record
1370  * @param [out] lang_code lang code ( should be freed by caller )
1371  *
1372  * @return 0 on success, otherwise a negative error value.
1373  * @retval #NFC_ERROR_NONE Successful
1374  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1375  * @retval #NFC_ERROR_INVALID_RECORD_TYPE Invalid record type
1376  *
1377  * @see nfc_ndef_record_create_text()
1378  */
1379 int nfc_ndef_record_get_langcode(nfc_ndef_record_h record, char **lang_code);
1380
1381 /**
1382  * @brief Gets encoding type from text record
1383  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
1384  *
1385  * @remarks  This function is valid only for text type record.\n
1386  * The text type record 's tnf is NFC_RECORD_TNF_WELL_KNOWN and it's type is "T"
1387  *
1388  * @param [in] record   The handle to record
1389  * @param [out] encode encode type #nfc_encode_type_e
1390  *
1391  * @return 0 on success, otherwise a negative error value.
1392  * @retval #NFC_ERROR_NONE Successful
1393  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1394  * @retval #NFC_ERROR_INVALID_RECORD_TYPE Invalid record type
1395  *
1396  * @see nfc_ndef_record_create_text()
1397  */
1398 int nfc_ndef_record_get_encode_type(nfc_ndef_record_h record, nfc_encode_type_e *encode);
1399
1400 /**
1401  * @brief Gets URI from uri record
1402  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
1403  *
1404  * @remarks The function returns newly allocated string, this value must be deallocated by caller.\n
1405  * This function is valid only for uri type record.
1406  * The uri type record 's tnf is NFC_RECORD_TNF_WELL_KNOWN and it's type is "U"
1407  *
1408  * @param [in] record   The handle to record
1409  * @param [out] uri     The uri in record payload ( should be freed by caller )
1410  *
1411  * @return 0 on success, otherwise a negative error value.
1412  * @retval #NFC_ERROR_NONE Successful
1413  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1414  * @retval #NFC_ERROR_INVALID_RECORD_TYPE Invalid record type
1415  *
1416  * @see nfc_ndef_record_create_uri()
1417  */
1418 int nfc_ndef_record_get_uri(nfc_ndef_record_h record, char **uri);
1419
1420
1421 /**
1422  * @brief Gets mime type from mime type record
1423  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
1424  *
1425  * @remarks The function returns newly allocated string, this value must be deallocated by caller.\n
1426  * This function is valid only for mime type record.\n
1427  * The uri type record 's tnf is NFC_RECORD_TNF_MIME_MEDIA.
1428  *
1429  * @param [in] record   The handle to record
1430  * @param [out] mime_type       The mime type in record payload ( should be freed by caller )
1431  *
1432  * @return 0 on success, otherwise a negative error value.
1433  * @retval #NFC_ERROR_NONE Successful
1434  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1435  * @retval #NFC_ERROR_INVALID_RECORD_TYPE Invalid record type
1436  *
1437  * @see nfc_ndef_record_create_mime()
1438  */
1439 int nfc_ndef_record_get_mime_type(nfc_ndef_record_h record, char **mime_type);
1440
1441
1442 /**
1443  * @brief Creates NDEF message handle
1444  * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
1445  *
1446  * @param [out] ndef_message A handle to NDEF message
1447  *
1448  * @return 0 on success, otherwise a negative error value.
1449  * @retval #NFC_ERROR_NONE Successful
1450  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1451  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1452  *
1453  * @see nfc_ndef_message_create_from_rawdata()
1454  * @see nfc_ndef_message_destroy()
1455  */
1456 int nfc_ndef_message_create(nfc_ndef_message_h *ndef_message);
1457
1458 /**
1459  * @brief Creates NDEF message handle from raw serial bytes.
1460  * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
1461  *
1462  * @remarks It consumes the bytes array until get the ME(Message End) flag*. It returns error if the bytes array does not have ME flag.\n
1463  * *The ME flag is a 1-bit field that when set indicates the end of an NDEF message.
1464  *
1465  * @param [out] ndef_message The handle to NDEF message
1466  * @param [in] rawdata The NDEF message in form of bytes array
1467  * @param [in] rawdata_size The size of bytes array
1468  *
1469  * @return 0 on success, otherwise a negative error value.
1470  * @retval #NFC_ERROR_NONE Successful
1471  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1472  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1473  *
1474  * @see nfc_ndef_message_create()
1475  * @see nfc_ndef_message_destroy()
1476  * @see nfc_ndef_message_get_rawdata()
1477  */
1478 int nfc_ndef_message_create_from_rawdata(nfc_ndef_message_h *ndef_message, const unsigned char *rawdata, unsigned int rawdata_size);
1479
1480 /**
1481  * @brief Destroys NDEF message handle
1482  * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
1483  *
1484  * @remarks This function will free all these memory including record handles.
1485  *
1486  * @param [in] ndef_message The handle to NDEF message to destroy
1487  *
1488  * @return 0 on success, otherwise a negative error value.
1489  * @retval #NFC_ERROR_NONE Successful
1490  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1491  *
1492  * @see nfc_ndef_message_create()
1493  * @see nfc_ndef_message_create_from_rawdata()
1494  */
1495 int nfc_ndef_message_destroy(nfc_ndef_message_h ndef_message);
1496
1497 /**
1498  * @brief Gets the number of record in NDEF message
1499  * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
1500  *
1501  * @param [in] ndef_message The handle to NDEF message
1502  * @param [out] count The number of record
1503  *
1504  * @return 0 on success, otherwise a negative error value.
1505  * @retval #NFC_ERROR_NONE Successful
1506  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1507  */
1508 int nfc_ndef_message_get_record_count(nfc_ndef_message_h ndef_message, int *count);
1509
1510 /**
1511  * @brief Gets serial bytes array of NDEF message.
1512  * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
1513  *
1514  * @remarks It gets copy of the bytes array from NDEF message. @a rawdata must be released with free() by you.
1515  *
1516  * @param [in] ndef_message The handle to NDEF message
1517  * @param [out] rawdata The bytes array of bytes array
1518  * @param [out] rawdata_size The size of bytes array in byte
1519  *
1520  * @return 0 on success, otherwise a negative error value.
1521  * @retval #NFC_ERROR_NONE Successful
1522  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1523  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1524  * @retval #NFC_ERROR_INVALID_NDEF_MESSAGE Invalid NDEF message
1525  *
1526  * @see nfc_ndef_message_create_from_rawdata()
1527  */
1528 int nfc_ndef_message_get_rawdata(nfc_ndef_message_h ndef_message, unsigned char **rawdata, unsigned int *rawdata_size);
1529
1530 /**
1531  * @brief Appends a record into NDEF message
1532  * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
1533  *
1534  * @remarks Appended record is handled by frameworks. The record is released by frameworks when message is released.
1535  *
1536  * @param [in] ndef_message The handle to NDEF message
1537  * @param [in] record The record that will be appended into NDEF message
1538  *
1539  * @return 0 on success, otherwise a negative error value.
1540  * @retval #NFC_ERROR_NONE Successful
1541  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1542  *
1543  * @see nfc_ndef_message_insert_record()
1544  * @see nfc_ndef_message_remove_record()
1545  */
1546 int nfc_ndef_message_append_record(nfc_ndef_message_h ndef_message, nfc_ndef_record_h record);
1547
1548 /**
1549  * @brief Inserts a record at index into NDEF message
1550  * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
1551  *
1552  * @remarks Appended record is handled by frameworks. The record is released by frameworks when message is released.\n
1553  * The index value should not bigger than nfc_ndef_message_get_record_count()
1554  *
1555  * @param [in] ndef_message The handle to NDEF message
1556  * @param [in] index The index of record ( starts from 0 )
1557  * @param [in] record The record that will be appended into NDEF message
1558  *
1559  * @return 0 on success, otherwise a negative error value.
1560  * @retval #NFC_ERROR_NONE Successful
1561  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1562  * @retval #NFC_ERROR_INVALID_NDEF_MESSAGE      Invalid NDEF message
1563  *
1564  * @see nfc_ndef_message_append_record()
1565  * @see nfc_ndef_message_remove_record()
1566  */
1567 int nfc_ndef_message_insert_record(nfc_ndef_message_h ndef_message, int index, nfc_ndef_record_h record);
1568
1569 /**
1570  * @brief Removes the record that indicated by index number and this deleted record will be freed.
1571  * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
1572  *
1573  * @param [in] ndef_message The handle to NDEF message
1574  * @param [in] index    The index of record ( starts from 0 )
1575  *
1576  * @return 0 on success, otherwise a negative error value.
1577  * @retval #NFC_ERROR_NONE Successful
1578  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1579  * @retval #NFC_ERROR_INVALID_NDEF_MESSAGE      Invalid NDEF message
1580  *
1581  * @see nfc_ndef_message_append_record()
1582  * @see nfc_ndef_message_insert_record()
1583  */
1584 int nfc_ndef_message_remove_record(nfc_ndef_message_h ndef_message, int index);
1585
1586 /**
1587  * @brief Gets record by index.
1588  * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
1589  *
1590  * @remarks This function just return the pointer of record. if you change the record value it directly affects the NDEF message
1591  *
1592  * @param [in] ndef_message The handle to NDEF message
1593  * @param [in] index The index of record ( starts from 0 )
1594  * @param [out] record The handle to record
1595  *
1596  * @return 0 on success, otherwise a negative error value.
1597  * @retval #NFC_ERROR_NONE Successful
1598  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1599  */
1600 int nfc_ndef_message_get_record(nfc_ndef_message_h ndef_message, int index, nfc_ndef_record_h *record);
1601
1602 /**
1603  * @brief Gets the type of NFC tag
1604  * @ingroup CAPI_NETWORK_NFC_TAG_MODULE
1605  *
1606  * @param [in] tag The handle to NFC tag
1607  * @param [out] type The type of NFC tag
1608  *
1609  * @return 0 on success, otherwise a negative error value.
1610  * @retval #NFC_ERROR_NONE Successful
1611  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1612  */
1613 int nfc_tag_get_type(nfc_tag_h tag, nfc_tag_type_e *type);
1614
1615 /**
1616  * @brief Checks whether the given NFC tag supports NDEF messages.
1617  * @ingroup CAPI_NETWORK_NFC_TAG_MODULE
1618  *
1619  * @param [in] tag The handle to NFC tag
1620  * @param [out] is_supported @c true when NFC tag supports NDEF messages, otherwise @c false
1621  *
1622  * @return 0 on success, otherwise a negative error value.
1623  * @retval #NFC_ERROR_NONE Successful
1624  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1625  *
1626  * @see nfc_tag_read_ndef()
1627  */
1628 int nfc_tag_is_support_ndef(nfc_tag_h tag, bool *is_supported);
1629
1630 /**
1631  * @brief Gets the maximum NDEF message size that can be stored in NFC tag.
1632  * @ingroup CAPI_NETWORK_NFC_TAG_MODULE
1633  *
1634  * @remarks This max size indicates the maximum size of NDEF message that can be stored in this detected tag.
1635  *
1636  * @param [in] tag The handle to NFC tag
1637  * @param [out] maximum_ndef_bytes_size The maximum bytes size of NDEF message that can be stored in this detected tag.
1638  *
1639  * @return 0 on success, otherwise a negative error value.
1640  * @retval #NFC_ERROR_NONE Successful
1641  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1642  */
1643 int nfc_tag_get_maximum_ndef_size(nfc_tag_h tag, unsigned int *maximum_ndef_bytes_size);
1644
1645 /**
1646  * @brief Gets size of NDEF message that stored in the tag
1647  * @ingroup CAPI_NETWORK_NFC_TAG_MODULE
1648  *
1649  * @param [in] tag The handle to NFC tag
1650  * @param [out] ndef_bytes_size The NDEF message bytes size that stored in the tag
1651  *
1652  * @return 0 on success, otherwise a negative error value.
1653  * @retval #NFC_ERROR_NONE Successful
1654  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1655  *
1656  */
1657 int nfc_tag_get_ndef_size(nfc_tag_h tag, unsigned int *ndef_bytes_size);
1658
1659
1660 /**
1661  * @brief Retrieves all tag information
1662  * @ingroup CAPI_NETWORK_NFC_TAG_MODULE
1663  *
1664  * @param[in] tag The handle to NFC tag
1665  * @param[in] callback  The callback function to invoke
1666  * @param[in] user_data The user data to be passed to the callback function
1667  *
1668  * @return 0 on success, otherwise a negative error value.
1669  * @retval #NFC_ERROR_NONE Successful
1670  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1671  *
1672  */
1673 int nfc_tag_foreach_information(nfc_tag_h tag, nfc_tag_information_cb callback, void *user_data);
1674
1675
1676 /**
1677  * @brief Transceives the data of the raw format card.
1678  * @details This function is the only way to access the raw format card (not formated),
1679         each tag type requires own command to access tags. \n
1680         This function provides the low level access of tag operation and you require the knowledge of each tag technology.
1681 * @ingroup CAPI_NETWORK_NFC_TAG_MODULE
1682 *
1683 * @param [in] tag The handle to NFC tag
1684 * @param [in] buffer The binary data for parameter or additional commands
1685 * @param [in] buffer_size The size of buffer in bytes
1686 * @param [in] callback The callback function to invoke after this function has completed\n It can be null if a notification is not required
1687 * @param [in] user_data The user data to be passed to the callback function
1688 *
1689 * @return 0 on success, otherwise a negative error value.
1690 * @retval #NFC_ERROR_NONE Successful
1691 * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1692 * @retval #NFC_ERROR_INVALID_PARAMETER  Invalid parameter
1693 * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
1694 * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
1695 * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag
1696 * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
1697 *
1698 * @post It invokes nfc_tag_transceive_completed_cb() when it has completed to t
1699 * @see nfc_tag_read_ndef()
1700 * @see nfc_tag_is_support_ndef()
1701 */
1702 int nfc_tag_transceive(nfc_tag_h tag, unsigned char *buffer, int buffer_size, nfc_tag_transceive_completed_cb callback, void *user_data);
1703
1704 /**
1705  * @brief Reads NDEF formatted data from NFC tag.
1706  * @ingroup CAPI_NETWORK_NFC_TAG_MODULE
1707  *
1708  * @param [in] tag The handle to NFC tag
1709  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
1710  * @param [in] user_data The user data to be passed to the callback function
1711  *
1712  * @return 0 on success, otherwise a negative error value.
1713  * @retval #NFC_ERROR_NONE Successful
1714  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1715  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1716  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
1717  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
1718  * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag
1719  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
1720  * @retval #NFC_ERROR_NOT_NDEF_FORMAT Not ndef format tag
1721  *
1722  * @post It invokes nfc_tag_read_completed_cb() when it has completed to read NDEF formatted data.
1723  *
1724  * @see nfc_tag_transceive()
1725  * @see nfc_tag_is_support_ndef()
1726  * @see nfc_tag_write_ndef()
1727  */
1728 int nfc_tag_read_ndef(nfc_tag_h tag, nfc_tag_read_completed_cb callback, void *user_data);
1729
1730 /**
1731  * @brief Writes NDEF formatted data.
1732  * @ingroup CAPI_NETWORK_NFC_TAG_MODULE
1733  *
1734  * @param [in] tag The handle to NFC tag
1735  * @param [in] msg The message will be write to the tag
1736  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
1737  * @param [in] user_dataa The user data to be passed to the callback function
1738  *
1739  * @return 0 on success, otherwise a negative error value.
1740  * @retval #NFC_ERROR_NONE Successful
1741  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1742  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1743
1744  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
1745  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
1746  * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag
1747  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
1748  * @retval #NFC_ERROR_NOT_NDEF_FORMAT Not ndef format tag
1749  *
1750  * @post It invokes nfc_tag_write_completed_cb() when it has completed to write NDEF data.
1751  * @see nfc_tag_is_support_ndef()
1752  * @see nfc_tag_read_ndef()
1753  */
1754 int nfc_tag_write_ndef(nfc_tag_h tag, nfc_ndef_message_h msg, nfc_tag_write_completed_cb callback, void *user_data);
1755
1756 /**
1757  * @brief Formats the detected tag that can store NDEF message.
1758  * @details Some tags are required authentication. If the detected target doesn't need authentication, @a key can be NULL.
1759  * @ingroup CAPI_NETWORK_NFC_TAG_MODULE
1760  *
1761  * @param [in] tag The handle to NFC tag
1762  * @param [in] key The key value that may need to format the tag
1763  * @param [in] key_size The size of key in byte
1764  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
1765  * @param [in] user_data The user data to be passed to the callback function
1766  *
1767  * @return 0 on success, otherwise a negative error value.
1768  * @retval #NFC_ERROR_NONE Successful
1769  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1770  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1771  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
1772  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
1773  * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag
1774  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
1775  * @retval #NFC_ERROR_NOT_NDEF_FORMAT Not ndef format tag
1776  *
1777  * @post It invokes nfc_tag_format_completed_cb() when it has completed to format the NFC tag.
1778  *
1779  * @see nfc_tag_is_support_ndef()
1780  */
1781 int nfc_tag_format_ndef(nfc_tag_h tag, unsigned char *key, int key_size, nfc_tag_format_completed_cb callback, void *user_data);
1782
1783 /**
1784  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
1785  * @brief Authenticates a sector with key A.
1786  * @remarks I/O operations(read / write / increment / decrement / transfer / restore) will be available after successful authentication.\n
1787  * This function is only available for MIFARE classic.\n
1788  *      \n
1789  *      MIFARE CLASSIC MINI \n
1790  *              => 0 ~ 4 : 5 sectors having 4 block each with block size of 16 bytes \n
1791  *      \n
1792  *      MIFARE CLASSIC 1K \n
1793  *              => 0 ~ 15 : 16 sectors having 4 block each with block size of 16 bytes \n
1794  *      \n
1795  *      MIFARE CLASSIC 4K \n
1796  *              => 0 ~ 31 : 32 sectors having 4 block each with block size of 16 bytes  \n
1797  *              => 32 ~ 39 : 8 sectors having 16 block each with block size of 16 bytes
1798  *
1799  * @param[in] tag The handle to NFC tag
1800  * @param[in] sector_index The index of sector to authenticate with key A, starting from 0
1801  * @param[in] auth_key 6-byte authentication key
1802  * @param[in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
1803  * @param[in] user_data The user data to be passed to the callback function
1804  *
1805  * @return 0 on success, otherwise a negative error value.
1806  * @retval #NFC_ERROR_NONE Successful
1807  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1808  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1809  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
1810  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
1811  * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag
1812  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
1813  *
1814  * @post It invokes nfc_mifare_authenticate_with_keyA_completed_cb() when it has completed to authenticate the given sector with key A.
1815  * @see nfc_mifare_authenticate_with_keyB()
1816  * @see nfc_mifare_read_block()
1817  * @see nfc_mifare_read_page()
1818  * @see nfc_mifare_write_block()
1819  * @see nfc_mifare_write_page()
1820  * @see nfc_mifare_increment()
1821  * @see nfc_mifare_decrement()
1822 */
1823 int nfc_mifare_authenticate_with_keyA(nfc_tag_h tag, int sector_index, unsigned char *auth_key, nfc_mifare_authenticate_with_keyA_completed_cb callback, void *user_data);
1824
1825
1826 /**
1827  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
1828  * @brief Authenticates a sector with key B.
1829  * @remarks I/O operations(read / write / increment / decrement / transfer / restore) will be available after successful authentication.\n
1830  * This function is only available for MIFARE classic.\n
1831  *      \n
1832  *      MIFARE CLASSIC MINI\n
1833  *              => 0 ~ 4 : 5 sector and 4 block with 16 bytes\n
1834  *      \n
1835  *      MIFARE CLASSIC 1K \n
1836  *              => 0 ~ 15 : 16 sector and 4 block with 16 bytes\n
1837  *      \n
1838  *      MIFARE CLASSIC 4K\n
1839  *              => 0 ~ 31 : 32 sector and 4 block with 16 bytes \n
1840  *              => 32 ~ 39 : 8 sector and 16 block with 16 bytes
1841  *
1842  * @param [in] tag The handle to NFC tag
1843  * @param [in] sector_index The index of sector to authenticate with key B, starting from 0
1844  * @param [in] auth_key 6-byte authentication key
1845  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
1846  * @param [in] user_data The user data to be passed to the callback function
1847  *
1848  * @return 0 on success, otherwise a negative error value.
1849  * @retval #NFC_ERROR_NONE Successful
1850  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1851  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1852  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
1853  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
1854  * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag
1855  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
1856  *
1857  * @post It invokes nfc_mifare_authenticate_with_keyB_completed_cb() when it has completed to authenticate the given sector with key B.
1858  * @see nfc_mifare_authenticate_with_keyA()
1859  * @see nfc_mifare_read_block()
1860  * @see nfc_mifare_read_page()
1861  * @see nfc_mifare_write_block()
1862  * @see nfc_mifare_write_page()
1863  * @see nfc_mifare_increment()
1864  * @see nfc_mifare_decrement()
1865 */
1866 int nfc_mifare_authenticate_with_keyB(nfc_tag_h tag, int sector_index, unsigned char *auth_key, nfc_mifare_authenticate_with_keyB_completed_cb callback, void *user_data);
1867
1868
1869 /**
1870  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
1871  * @brief Reads a 16-byte block.
1872  * @remarks This function is only available for MIFARE classic.
1873  *
1874  * @param [in] tag The handle to NFC tag
1875  * @param [in] block_index The block or starting page number
1876  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
1877  * @param [in] user_data The user data to be passed to the callback function
1878  *
1879  * @return 0 on success, otherwise a negative error value.
1880  * @retval #NFC_ERROR_NONE Successful
1881  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1882  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1883  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
1884  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
1885  * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag
1886  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
1887  *
1888  * @post It invokes nfc_mifare_read_block_completed_cb() when it has completed to read a block.
1889  * @see nfc_mifare_read_page()
1890  * @see nfc_mifare_write_block()
1891 */
1892 int nfc_mifare_read_block(nfc_tag_h tag, int block_index, nfc_mifare_read_block_completed_cb callback, void *user_data);
1893
1894 /**
1895  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
1896  * @brief Reads 4 pages(16 bytes).
1897  * @remarks This function is only available for MIFARE Ultra light.\n
1898  * The MIFARE Ultralight protocol always reads 4 pages at a time, to reduce the number of commands required to read an entire tag.
1899  *
1900  * @param [in] tag The handle to NFC tag
1901  * @param [in] page_index  The index of page to read, starting from 0
1902  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
1903  * @param [in] user_data The user data to be passed to the callback function
1904  *
1905  *
1906  * @return 0 on success, otherwise a negative error value.
1907  * @retval #NFC_ERROR_NONE Successful
1908  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1909  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1910  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
1911  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
1912  * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag
1913  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
1914  *
1915  * @post It invokes nfc_mifare_read_page_completed_cb() when it has completed to read a page.
1916  * @see nfc_mifare_read_block()
1917  * @see nfc_mifare_write_page()
1918 */
1919 int nfc_mifare_read_page(nfc_tag_h tag, int page_index, nfc_mifare_read_page_completed_cb callback, void *user_data);
1920
1921 /**
1922  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
1923  * @brief Writes block (16 byte) of data to the tag at a given block index.
1924  * @remarks This function is only available for MIFARE classic.
1925  *
1926  * @param [in] tag The handle to NFC tag
1927  * @param [in] block_index The index of block to read, starting from 0
1928  * @param [in] buffer 16 bytes of data to write
1929  * @param [in] buffer_size The size of buffer in bytes
1930  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
1931  * @param [in] user_data The user data to be passed to the callback function
1932  *
1933  * @return 0 on success, otherwise a negative error value.
1934  * @retval #NFC_ERROR_NONE Successful
1935  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1936  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1937  * @retval #NFC_ERROR_NOT_INITIALIZED Not initialized
1938  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
1939  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
1940  * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag
1941  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
1942  *
1943  * @post It invokes nfc_mifare_write_block_completed_cb() when it has completed to write a block.
1944  *
1945  * @see nfc_mifare_write_page()
1946  * @see nfc_mifare_read_block()
1947 */
1948 int nfc_mifare_write_block(nfc_tag_h tag, int block_index, unsigned char *buffer, int buffer_size, nfc_mifare_write_block_completed_cb callback, void *user_data);
1949
1950 /**
1951  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
1952  * @brief Writes a page (4 bytes) of data to the tag at a given page index
1953  * @remarks This function is only available for MIFARE Ultra light
1954  *
1955  * @param [in] tag The handle to NFC tag
1956  * @param [in] page_index The index of page to write, starting from 0
1957  * @param [in] buffer 4 bytes of data to write
1958  * @param [in] buffer_size The size of buffer in bytes
1959  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
1960  * @param [in] user_data The user data to be passed to the callback function
1961  *
1962  * @return 0 on success, otherwise a negative error value.
1963  * @retval #NFC_ERROR_NONE Successful
1964  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1965  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1966  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
1967  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
1968  * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag
1969  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
1970  *
1971  * @post It invokes nfc_mifare_write_page_completed_cb() when it has completed to write a page.
1972  *
1973  * @see nfc_mifare_write_block()
1974  * @see nfc_mifare_read_page()
1975 */
1976 int nfc_mifare_write_page(nfc_tag_h tag, int page_index, unsigned char *buffer, int buffer_size, nfc_mifare_write_page_completed_cb callback, void *user_data);
1977
1978 /**
1979  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
1980  * @brief Increases a value block, storing the result in the temporary block on the tag.
1981  * @remarks This function is only available for MIFARE classic
1982  *
1983  * @param [in] tag The handle to NFC tag
1984  * @param [in] block_index The index of block to increase, starting from 0
1985  * @param [in] value Non-negative to increment by
1986  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
1987  * @param [in] user_data The user data to be passed to the callback function
1988  *
1989  * @return 0 on success, otherwise a negative error value.
1990  * @retval #NFC_ERROR_NONE Successful
1991  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1992  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1993  * @retval #NFC_ERROR_NOT_INITIALIZED Not initialized
1994  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
1995  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
1996  * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag
1997  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
1998  *
1999  * @see nfc_mifare_decrement()
2000  * @see nfc_mifare_write_block()
2001 */
2002 int nfc_mifare_increment(nfc_tag_h tag, int block_index, int value, nfc_mifare_increment_completed_cb callback, void *user_data);
2003
2004 /**
2005  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
2006  * @brief Decreases a value block, storing the result in the temporary block on the tag.
2007  * @remarks  This function is only available for MIFARE classic
2008  *
2009  * @param [in] tag The handle to NFC tag
2010  * @param [in] block_index The index of block to decrease, starting from 0
2011  * @param [in] value non-negative to decrement by
2012  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
2013  * @param [in] user_data The user data to be passed to the callback function
2014  *
2015  * @return 0 on success, otherwise a negative error value.
2016  * @retval #NFC_ERROR_NONE Successful
2017  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
2018  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
2019  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
2020  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
2021  * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag
2022  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
2023  *
2024  * @see nfc_mifare_increment()
2025  * @see nfc_mifare_write_block()
2026 */
2027 int nfc_mifare_decrement(nfc_tag_h tag, int block_index, int value, nfc_mifare_decrement_completed_cb callback, void *user_data);
2028
2029 /**
2030  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
2031  * @brief Copy from the temporary block to the specified block.
2032  * @remarks This function is only available for MIFARE classic
2033  *
2034  * @param [in] tag The handle to NFC tag
2035  * @param [in] block_index The index of block to copy to, starting from 0
2036  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
2037  * @param [in] user_data The user data to be passed to the callback function
2038  *
2039  * @return 0 on success, otherwise a negative error value.
2040  * @retval #NFC_ERROR_NONE Successful
2041  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
2042  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
2043  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
2044  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
2045  * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag
2046  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
2047  *
2048  * @see nfc_mifare_restore()
2049 */
2050 int nfc_mifare_transfer(nfc_tag_h tag, int block_index, nfc_mifare_transfer_completed_cb callback, void *user_data);
2051
2052 /**
2053  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
2054  * @brief Copy from a value block to the temporary block.
2055  * @remarks This function is only available for MIFARE classic
2056  *
2057  * @param [in] tag The handle to NFC tag
2058  * @param [in] block_index The index of block to copy from, starting from 0
2059  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
2060  * @param [in] user_data The user data to be passed to the callback function
2061  *
2062  * @return 0 on success, otherwise a negative error value.
2063  * @retval #NFC_ERROR_NONE Successful
2064  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
2065  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
2066  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
2067  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
2068  * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag
2069  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
2070  *
2071  * @see nfc_mifare_transfer()
2072 */
2073 int nfc_mifare_restore(nfc_tag_h tag, int block_index, nfc_mifare_restore_completed_cb callback, void *user_data);
2074
2075
2076 /**
2077  * @brief Registers a callback function for receiving data from NFC peer-to-peer target.
2078  * @ingroup CAPI_NETWORK_NFC_P2P_MODULE
2079  *
2080  * @param [in] target The handle to peer target
2081  * @param [in] callback The callback function to invoke when an NDEF Message is discovered
2082  * @param [in] user_data The user data to be passed to the callback function
2083  *
2084  * @return 0 on success, otherwise a negative error value.
2085  * @retval #NFC_ERROR_NONE Successful
2086  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
2087  *
2088  * @see nfc_p2p_unset_data_received_cb()
2089  * @see nfc_p2p_data_recived_cb()
2090  * @see nfc_p2p_target_discovered_cb()
2091  */
2092 int nfc_p2p_set_data_received_cb(nfc_p2p_target_h target, nfc_p2p_data_recived_cb callback, void *user_data);
2093
2094 /**
2095  * @brief Unregisters the callback function.
2096  * @ingroup CAPI_NETWORK_NFC_P2P_MODULE
2097  *
2098  * @param [in] target The handle to peer target
2099  *
2100  * @return 0 on success, otherwise a negative error value.
2101  * @retval #NFC_ERROR_NONE Successful
2102  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
2103  *
2104  * @see nfc_p2p_set_data_received_cb()
2105  * @see nfc_p2p_data_recived_cb()
2106  * @see nfc_p2p_target_discovered_cb()
2107  */
2108 int nfc_p2p_unset_data_received_cb(nfc_p2p_target_h target);
2109
2110 /**
2111  * @brief Sends data to NFC peer-to-peer target
2112  * @ingroup CAPI_NETWORK_NFC_P2P_MODULE
2113  *
2114  * @param [in] tag The handle to NFC tag
2115  * @param [in] message The message to send
2116  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
2117  * @param [in] user_data The user data to be passed to the callback function
2118  *
2119  * @return 0 on success, otherwise a negative error value.
2120  * @retval #NFC_ERROR_NONE Successful
2121  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
2122  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
2123  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
2124  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
2125  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
2126  *
2127  * @see nfc_p2p_send_completed_cb()
2128  * @see nfc_p2p_target_discovered_cb()
2129 */
2130 int nfc_p2p_send(nfc_p2p_target_h target, nfc_ndef_message_h message, nfc_p2p_send_completed_cb callback, void *user_data);
2131
2132
2133 /**
2134  * @brief Sends data to NFC peer-to-peer target without permission check
2135  * @ingroup CAPI_NETWORK_NFC_P2P_MODULE
2136  *
2137  * @param [in] tag The handle to NFC tag
2138  * @param [in] message The message to send
2139  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
2140  * @param [in] user_data The user data to be passed to the callback function
2141  *
2142  * @return 0 on success, otherwise a negative error value.
2143  * @retval #NFC_ERROR_NONE Successful
2144  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
2145  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
2146  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
2147  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
2148  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
2149  *
2150  * @see nfc_p2p_send_completed_cb()
2151  * @see nfc_p2p_target_discovered_cb()
2152 */
2153 int nfc_p2p_send_no_permission(nfc_p2p_target_h target, nfc_ndef_message_h message, nfc_p2p_send_completed_cb callback, void *user_data);
2154
2155
2156
2157 /**
2158  * @brief NFC Connection handover between NFC peer-to-peer target
2159  * @ingroup CAPI_NETWORK_NFC_P2P_MODULE
2160  *
2161  * @param [in] target The handle to NFC device
2162  * @param [in] type Preferred Alternative Carrier
2163  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
2164  * @param [in] user_data The user data to be passed to the callback function
2165  *
2166  * @return 0 on success, otherwise a negative error value.
2167  * @retval #NFC_ERROR_NONE Successful
2168  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
2169  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
2170  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
2171  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
2172  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
2173  *
2174  * @see nfc_p2p_connection_handover_completed_cb()
2175 */
2176 int nfc_p2p_connection_handover(nfc_p2p_target_h target , nfc_ac_type_e type, nfc_p2p_connection_handover_completed_cb callback, void *user_data);
2177
2178 /**
2179  * @brief Check available Alternative Carrier(AC) for NFC handover between NFC peer-to-peer target
2180  * @ingroup CAPI_NETWORK_NFC_P2P_MODULE
2181  *
2182  * @param [in] carrier Alternative Carrier when to be checked whether supported or not
2183  *
2184  * @retval #true Supported
2185  * @retval #false Not Supported
2186  *
2187  * @see nfc_p2p_is_supported_ac_type()
2188 */
2189 bool nfc_p2p_is_supported_ac_type( nfc_ac_type_e carrior);
2190
2191
2192 /**
2193  * @brief Start peer-to-peer server using SNEP protocol
2194  * @ingroup CAPI_NETWORK_NFC_P2P_MODULE
2195  *
2196  * @param [in] target The handle to peer target
2197  * @param [in] san The name of service (service access name)
2198  * @param [in] sap The number of service (service access point)
2199  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
2200  * @param [in] user_data The user data to be passed to the callback function
2201  *
2202  * @return 0 on success, otherwise a negative error value.
2203  * @retval #NFC_ERROR_NONE Successful
2204  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
2205  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
2206  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
2207  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
2208  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
2209  *
2210  * @see nfc_snep_event_cb()
2211 */
2212 int nfc_snep_start_server(nfc_p2p_target_h target, const char *san, int sap, nfc_snep_event_cb callback, void *user_data);
2213
2214 /**
2215  * @brief Start peer-to-peer client using SNEP protocol
2216  * @ingroup CAPI_NETWORK_NFC_P2P_MODULE
2217  *
2218  * @param [in] target The handle to peer target
2219  * @param [in] san The name of service (service access name)
2220  * @param [in] sap The number of service (service access point)
2221  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
2222  * @param [in] user_data The user data to be passed to the callback function
2223  *
2224  * @return 0 on success, otherwise a negative error value.
2225  * @retval #NFC_ERROR_NONE Successful
2226  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
2227  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
2228  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
2229  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
2230  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
2231  *
2232  * @see nfc_snep_event_cb()
2233  * @see nfc_snep_send_client_request()
2234  * @see nfc_snep_stop_service
2235 */
2236 int nfc_snep_start_client(nfc_p2p_target_h target, const char *san, int sap, nfc_snep_event_cb callback, void *user_data);
2237
2238 /**
2239  * @brief Send request message to peer-to-peer client using SNEP protocol
2240  * @ingroup CAPI_NETWORK_NFC_P2P_MODULE
2241  *
2242  * @param [in] handle The handle to connected snep instance
2243  * @param [in] type The request type of snep protocol
2244  * @param [in] msg The ndef message which will be sent
2245  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
2246  * @param [in] user_data The user data to be passed to the callback function
2247  *
2248  * @return 0 on success, otherwise a negative error value.
2249  * @retval #NFC_ERROR_NONE Successful
2250  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
2251  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
2252  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
2253  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
2254  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
2255  *
2256  * @see nfc_snep_event_cb()
2257 */
2258 int nfc_snep_send_client_request(nfc_p2p_snep_h handle, nfc_snep_type_e type, nfc_ndef_message_h msg, nfc_snep_event_cb callback, void *user_data);
2259
2260 /**
2261  * @brief Stop snep server or client
2262  * @ingroup CAPI_NETWORK_NFC_P2P_MODULE
2263  *
2264  * @param [in] target The handle to peer target
2265  * @param [in] service The handle which will be stopped
2266  *
2267  * @return 0 on success, otherwise a negative error value.
2268  * @retval #NFC_ERROR_NONE Successful
2269  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
2270  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
2271  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
2272  *
2273  * @see nfc_snep_event_cb()
2274 */
2275 int nfc_snep_stop_service(nfc_p2p_target_h target, nfc_p2p_snep_h service);
2276
2277 /**
2278  * @brief Register peer-to-peer server using SNEP protocol
2279  * @ingroup CAPI_NETWORK_NFC_P2P_MODULE
2280  *
2281  * @param [in] san The name of service (service access name)
2282  * @param [in] sap The number of service (service access point)
2283  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
2284  * @param [in] user_data The user data to be passed to the callback function
2285  *
2286  * @return 0 on success, otherwise a negative error value.
2287  * @retval #NFC_ERROR_NONE Successful
2288  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
2289  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
2290  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
2291  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
2292  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
2293  *
2294  * @see nfc_snep_event_cb()
2295 */
2296 int nfc_snep_register_server(const char *san, int sap, nfc_snep_event_cb callback, void *user_data);
2297
2298 /**
2299  * @brief Unregister snep server or client
2300  * @ingroup CAPI_NETWORK_NFC_P2P_MODULE
2301  *
2302  * @param [in] san The name of service (service access name)
2303  * @param [in] sap The number of service (service access point)
2304  *
2305  * @return 0 on success, otherwise a negative error value.
2306  * @retval #NFC_ERROR_NONE Successful
2307  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
2308  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
2309  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
2310  *
2311  * @see nfc_snep_event_cb()
2312 */
2313 int nfc_snep_unregister_server(const char *san, int sap);
2314
2315 /**
2316  * @brief Open connection to secure element.
2317  * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
2318  *
2319  * @param [in] se_type   The type you want to open
2320  * @param [out] handle    The handle of connected secure element
2321  *
2322  * @return 0 on success, otherwise a negative error value.
2323  * @retval #NFC_ERROR_NONE Successful
2324  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
2325  * @retval #NFC_ERROR_INVALID_NDEF_MESSAGE Invalid NDEF message
2326  *
2327  * @see nfc_se_close_secure_element()
2328  */
2329 int nfc_se_open_secure_element(nfc_se_type_e se_type, nfc_se_h *handle);
2330
2331 /**
2332  * @brief Enable card emulation mode.
2333  * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
2334  *
2335  * @return 0 on success, otherwise a negative error value.
2336  *
2337  * @see nfc_se_disable_card_emulation()
2338  */
2339 int nfc_se_enable_card_emulation();
2340
2341 /**
2342  * @brief Disable card emulation mode.
2343  * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
2344  *
2345  * @return 0 on success, otherwise a negative error value.
2346  *
2347  * @see nfc_se_enable_card_emulation()
2348  */
2349 int nfc_se_disable_card_emulation();
2350
2351 /**
2352  * @brief Get the current card emulation mode.
2353  * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
2354  *
2355  * @param [out]  type   The current card emulation mode type
2356  *
2357  * @return 0 on success, otherwise a negative error value.
2358  * @retval #NFC_ERROR_NONE Successful
2359  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
2360  *
2361  */
2362 int nfc_se_get_card_emulation_mode(nfc_se_card_emulation_mode_type_e *type);
2363
2364 /**
2365  * @brief Open connection to secure element.
2366  * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
2367  *
2368  * @remarks It gets the allocated bytes array including data. @a resp must be released with free() by you.
2369  *
2370  * @param [in]  handle   The handle of connected secure element
2371  * @param [in]  cmd      The bytes array of apdu command data
2372  * @param [in]  cmd_len  The size of apdu command bytes array
2373  * @param [out] resp     The bytes array of response data
2374  * @param [out] resp_len The size of response bytes array
2375  *
2376  * @return 0 on success, otherwise a negative error value.
2377  * @retval #NFC_ERROR_NONE Successful
2378  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
2379  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
2380  * @retval #NFC_ERROR_INVALID_NDEF_MESSAGE Invalid NDEF message
2381  *
2382  * @see nfc_se_open_secure_element()
2383  * @see nfc_se_close_secure_element()
2384  */
2385 int nfc_se_send_apdu(nfc_se_h handle, unsigned char *cmd, unsigned int cmd_len, unsigned char **resp, unsigned int *resp_len);
2386
2387 /**
2388  * @brief Get ATR(Answer to Reset) of connected secure element.
2389  * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
2390  *
2391  * @remarks It gets the allocated bytes array including data. @a atr must be released with free() by you.
2392  *
2393  * @param [in]  handle  The handle of connected secure element
2394  * @param [out] atr     The bytes array of atr data
2395  * @param [out] atr_len The size of atr bytes array
2396  *
2397  * @return 0 on success, otherwise a negative error value.
2398  * @retval #NFC_ERROR_NONE Successful
2399  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
2400  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
2401  * @retval #NFC_ERROR_INVALID_NDEF_MESSAGE Invalid NDEF message
2402  *
2403  * @see nfc_se_open_secure_element()
2404  * @see nfc_se_close_secure_element()
2405  */
2406 int nfc_se_get_atr(nfc_se_h handle, unsigned char **atr, unsigned int *atr_len);
2407
2408 /**
2409  * @brief Close connection to secure element.
2410  * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
2411  *
2412  * @param [in] handle   The handle of connected secure element
2413  *
2414  * @return 0 on success, otherwise a negative error value.
2415  * @retval #NFC_ERROR_NONE Successful
2416  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
2417  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
2418  * @retval #NFC_ERROR_INVALID_NDEF_MESSAGE Invalid NDEF message
2419  *
2420  * @see nfc_se_open_secure_element()
2421  */
2422 int nfc_se_close_secure_element(nfc_se_h handle);
2423
2424 #ifdef __cplusplus
2425 }
2426 #endif
2427
2428
2429 #endif /* __NFC_H__ */
2430