0b2c5acbee4f7add8d9190b1cd9791af454af96c
[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,
1479                 const unsigned char *rawdata, unsigned int rawdata_size);
1480
1481 /**
1482  * @brief Destroys NDEF message handle
1483  * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
1484  *
1485  * @remarks This function will free all these memory including record handles.
1486  *
1487  * @param [in] ndef_message The handle to NDEF message to destroy
1488  *
1489  * @return 0 on success, otherwise a negative error value.
1490  * @retval #NFC_ERROR_NONE Successful
1491  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1492  *
1493  * @see nfc_ndef_message_create()
1494  * @see nfc_ndef_message_create_from_rawdata()
1495  */
1496 int nfc_ndef_message_destroy(nfc_ndef_message_h ndef_message);
1497
1498 /**
1499  * @brief Gets the number of record in NDEF message
1500  * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
1501  *
1502  * @param [in] ndef_message The handle to NDEF message
1503  * @param [out] count The number of record
1504  *
1505  * @return 0 on success, otherwise a negative error value.
1506  * @retval #NFC_ERROR_NONE Successful
1507  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1508  */
1509 int nfc_ndef_message_get_record_count(nfc_ndef_message_h ndef_message, int *count);
1510
1511 /**
1512  * @brief Gets serial bytes array of NDEF message.
1513  * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
1514  *
1515  * @remarks It gets copy of the bytes array from NDEF message. @a rawdata must be released with free() by you.
1516  *
1517  * @param [in] ndef_message The handle to NDEF message
1518  * @param [out] rawdata The bytes array of bytes array
1519  * @param [out] rawdata_size The size of bytes array in byte
1520  *
1521  * @return 0 on success, otherwise a negative error value.
1522  * @retval #NFC_ERROR_NONE Successful
1523  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1524  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1525  * @retval #NFC_ERROR_INVALID_NDEF_MESSAGE Invalid NDEF message
1526  *
1527  * @see nfc_ndef_message_create_from_rawdata()
1528  */
1529 int nfc_ndef_message_get_rawdata(nfc_ndef_message_h ndef_message,
1530                 unsigned char **rawdata, unsigned int *rawdata_size);
1531
1532 /**
1533  * @brief Appends a record into NDEF message
1534  * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
1535  *
1536  * @remarks Appended record is handled by frameworks. The record is released by frameworks when message is released.
1537  *
1538  * @param [in] ndef_message The handle to NDEF message
1539  * @param [in] record The record that will be appended into NDEF message
1540  *
1541  * @return 0 on success, otherwise a negative error value.
1542  * @retval #NFC_ERROR_NONE Successful
1543  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1544  *
1545  * @see nfc_ndef_message_insert_record()
1546  * @see nfc_ndef_message_remove_record()
1547  */
1548 int nfc_ndef_message_append_record(nfc_ndef_message_h ndef_message, nfc_ndef_record_h record);
1549
1550 /**
1551  * @brief Inserts a record at index into NDEF message
1552  * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
1553  *
1554  * @remarks Appended record is handled by frameworks. The record is released by frameworks when message is released.\n
1555  * The index value should not bigger than nfc_ndef_message_get_record_count()
1556  *
1557  * @param [in] ndef_message The handle to NDEF message
1558  * @param [in] index The index of record ( starts from 0 )
1559  * @param [in] record The record that will be appended into NDEF message
1560  *
1561  * @return 0 on success, otherwise a negative error value.
1562  * @retval #NFC_ERROR_NONE Successful
1563  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1564  * @retval #NFC_ERROR_INVALID_NDEF_MESSAGE      Invalid NDEF message
1565  *
1566  * @see nfc_ndef_message_append_record()
1567  * @see nfc_ndef_message_remove_record()
1568  */
1569 int nfc_ndef_message_insert_record(nfc_ndef_message_h ndef_message, int index, nfc_ndef_record_h record);
1570
1571 /**
1572  * @brief Removes the record that indicated by index number and this deleted record will be freed.
1573  * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
1574  *
1575  * @param [in] ndef_message The handle to NDEF message
1576  * @param [in] index    The index of record ( starts from 0 )
1577  *
1578  * @return 0 on success, otherwise a negative error value.
1579  * @retval #NFC_ERROR_NONE Successful
1580  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1581  * @retval #NFC_ERROR_INVALID_NDEF_MESSAGE      Invalid NDEF message
1582  *
1583  * @see nfc_ndef_message_append_record()
1584  * @see nfc_ndef_message_insert_record()
1585  */
1586 int nfc_ndef_message_remove_record(nfc_ndef_message_h ndef_message, int index);
1587
1588 /**
1589  * @brief Gets record by index.
1590  * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
1591  *
1592  * @remarks This function just return the pointer of record. if you change the record value it directly affects the NDEF message
1593  *
1594  * @param [in] ndef_message The handle to NDEF message
1595  * @param [in] index The index of record ( starts from 0 )
1596  * @param [out] record The handle to record
1597  *
1598  * @return 0 on success, otherwise a negative error value.
1599  * @retval #NFC_ERROR_NONE Successful
1600  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1601  */
1602 int nfc_ndef_message_get_record(nfc_ndef_message_h ndef_message, int index, nfc_ndef_record_h *record);
1603
1604 /**
1605  * @brief Gets the type of NFC tag
1606  * @ingroup CAPI_NETWORK_NFC_TAG_MODULE
1607  *
1608  * @param [in] tag The handle to NFC tag
1609  * @param [out] type The type of NFC tag
1610  *
1611  * @return 0 on success, otherwise a negative error value.
1612  * @retval #NFC_ERROR_NONE Successful
1613  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1614  */
1615 int nfc_tag_get_type(nfc_tag_h tag, nfc_tag_type_e *type);
1616
1617 /**
1618  * @brief Checks whether the given NFC tag supports NDEF messages.
1619  * @ingroup CAPI_NETWORK_NFC_TAG_MODULE
1620  *
1621  * @param [in] tag The handle to NFC tag
1622  * @param [out] is_supported @c true when NFC tag supports NDEF messages, otherwise @c false
1623  *
1624  * @return 0 on success, otherwise a negative error value.
1625  * @retval #NFC_ERROR_NONE Successful
1626  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1627  *
1628  * @see nfc_tag_read_ndef()
1629  */
1630 int nfc_tag_is_support_ndef(nfc_tag_h tag, bool *is_supported);
1631
1632 /**
1633  * @brief Gets the maximum NDEF message size that can be stored in NFC tag.
1634  * @ingroup CAPI_NETWORK_NFC_TAG_MODULE
1635  *
1636  * @remarks This max size indicates the maximum size of NDEF message that can be stored in this detected tag.
1637  *
1638  * @param [in] tag The handle to NFC tag
1639  * @param [out] maximum_ndef_bytes_size The maximum bytes size of NDEF message that can be stored in this detected tag.
1640  *
1641  * @return 0 on success, otherwise a negative error value.
1642  * @retval #NFC_ERROR_NONE Successful
1643  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1644  */
1645 int nfc_tag_get_maximum_ndef_size(nfc_tag_h tag, unsigned int *maximum_ndef_bytes_size);
1646
1647 /**
1648  * @brief Gets size of NDEF message that stored in the tag
1649  * @ingroup CAPI_NETWORK_NFC_TAG_MODULE
1650  *
1651  * @param [in] tag The handle to NFC tag
1652  * @param [out] ndef_bytes_size The NDEF message bytes size that stored in the tag
1653  *
1654  * @return 0 on success, otherwise a negative error value.
1655  * @retval #NFC_ERROR_NONE Successful
1656  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1657  *
1658  */
1659 int nfc_tag_get_ndef_size(nfc_tag_h tag, unsigned int *ndef_bytes_size);
1660
1661
1662 /**
1663  * @brief Retrieves all tag information
1664  * @ingroup CAPI_NETWORK_NFC_TAG_MODULE
1665  *
1666  * @param[in] tag The handle to NFC tag
1667  * @param[in] callback  The callback function to invoke
1668  * @param[in] user_data The user data to be passed to the callback function
1669  *
1670  * @return 0 on success, otherwise a negative error value.
1671  * @retval #NFC_ERROR_NONE Successful
1672  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1673  *
1674  */
1675 int nfc_tag_foreach_information(nfc_tag_h tag, nfc_tag_information_cb callback, void *user_data);
1676
1677
1678 /**
1679  * @brief Transceives the data of the raw format card.
1680  * @details This function is the only way to access the raw format card (not formated),
1681         each tag type requires own command to access tags. \n
1682         This function provides the low level access of tag operation and you require the knowledge of each tag technology.
1683 * @ingroup CAPI_NETWORK_NFC_TAG_MODULE
1684 *
1685 * @param [in] tag The handle to NFC tag
1686 * @param [in] buffer The binary data for parameter or additional commands
1687 * @param [in] buffer_size The size of buffer in bytes
1688 * @param [in] callback The callback function to invoke after this function has completed\n It can be null if a notification is not required
1689 * @param [in] user_data The user data to be passed to the callback function
1690 *
1691 * @return 0 on success, otherwise a negative error value.
1692 * @retval #NFC_ERROR_NONE Successful
1693 * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1694 * @retval #NFC_ERROR_INVALID_PARAMETER  Invalid parameter
1695 * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
1696 * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
1697 * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag
1698 * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
1699 *
1700 * @post It invokes nfc_tag_transceive_completed_cb() when it has completed to t
1701 * @see nfc_tag_read_ndef()
1702 * @see nfc_tag_is_support_ndef()
1703 */
1704 int nfc_tag_transceive(nfc_tag_h tag, unsigned char *buffer, int buffer_size, nfc_tag_transceive_completed_cb callback, void *user_data);
1705
1706 /**
1707  * @brief Reads NDEF formatted data from NFC tag.
1708  * @ingroup CAPI_NETWORK_NFC_TAG_MODULE
1709  *
1710  * @param [in] tag The handle to NFC tag
1711  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
1712  * @param [in] user_data The user data to be passed to the callback function
1713  *
1714  * @return 0 on success, otherwise a negative error value.
1715  * @retval #NFC_ERROR_NONE Successful
1716  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1717  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1718  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
1719  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
1720  * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag
1721  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
1722  * @retval #NFC_ERROR_NOT_NDEF_FORMAT Not ndef format tag
1723  *
1724  * @post It invokes nfc_tag_read_completed_cb() when it has completed to read NDEF formatted data.
1725  *
1726  * @see nfc_tag_transceive()
1727  * @see nfc_tag_is_support_ndef()
1728  * @see nfc_tag_write_ndef()
1729  */
1730 int nfc_tag_read_ndef(nfc_tag_h tag, nfc_tag_read_completed_cb callback, void *user_data);
1731
1732 /**
1733  * @brief Writes NDEF formatted data.
1734  * @ingroup CAPI_NETWORK_NFC_TAG_MODULE
1735  *
1736  * @param [in] tag The handle to NFC tag
1737  * @param [in] msg The message will be write to the tag
1738  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
1739  * @param [in] user_dataa The user data to be passed to the callback function
1740  *
1741  * @return 0 on success, otherwise a negative error value.
1742  * @retval #NFC_ERROR_NONE Successful
1743  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1744  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1745
1746  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
1747  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
1748  * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag
1749  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
1750  * @retval #NFC_ERROR_NOT_NDEF_FORMAT Not ndef format tag
1751  *
1752  * @post It invokes nfc_tag_write_completed_cb() when it has completed to write NDEF data.
1753  * @see nfc_tag_is_support_ndef()
1754  * @see nfc_tag_read_ndef()
1755  */
1756 int nfc_tag_write_ndef(nfc_tag_h tag, nfc_ndef_message_h msg, nfc_tag_write_completed_cb callback, void *user_data);
1757
1758 /**
1759  * @brief Formats the detected tag that can store NDEF message.
1760  * @details Some tags are required authentication. If the detected target doesn't need authentication, @a key can be NULL.
1761  * @ingroup CAPI_NETWORK_NFC_TAG_MODULE
1762  *
1763  * @param [in] tag The handle to NFC tag
1764  * @param [in] key The key value that may need to format the tag
1765  * @param [in] key_size The size of key in byte
1766  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
1767  * @param [in] user_data The user data to be passed to the callback function
1768  *
1769  * @return 0 on success, otherwise a negative error value.
1770  * @retval #NFC_ERROR_NONE Successful
1771  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1772  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1773  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
1774  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
1775  * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag
1776  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
1777  * @retval #NFC_ERROR_NOT_NDEF_FORMAT Not ndef format tag
1778  *
1779  * @post It invokes nfc_tag_format_completed_cb() when it has completed to format the NFC tag.
1780  *
1781  * @see nfc_tag_is_support_ndef()
1782  */
1783 int nfc_tag_format_ndef(nfc_tag_h tag, unsigned char *key, int key_size, nfc_tag_format_completed_cb callback, void *user_data);
1784
1785 /**
1786  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
1787  * @brief Authenticates a sector with key A.
1788  * @remarks I/O operations(read / write / increment / decrement / transfer / restore) will be available after successful authentication.\n
1789  * This function is only available for MIFARE classic.\n
1790  *      \n
1791  *      MIFARE CLASSIC MINI \n
1792  *              => 0 ~ 4 : 5 sectors having 4 block each with block size of 16 bytes \n
1793  *      \n
1794  *      MIFARE CLASSIC 1K \n
1795  *              => 0 ~ 15 : 16 sectors having 4 block each with block size of 16 bytes \n
1796  *      \n
1797  *      MIFARE CLASSIC 4K \n
1798  *              => 0 ~ 31 : 32 sectors having 4 block each with block size of 16 bytes  \n
1799  *              => 32 ~ 39 : 8 sectors having 16 block each with block size of 16 bytes
1800  *
1801  * @param[in] tag The handle to NFC tag
1802  * @param[in] sector_index The index of sector to authenticate with key A, starting from 0
1803  * @param[in] auth_key 6-byte authentication key
1804  * @param[in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
1805  * @param[in] user_data The user data to be passed to the callback function
1806  *
1807  * @return 0 on success, otherwise a negative error value.
1808  * @retval #NFC_ERROR_NONE Successful
1809  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1810  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1811  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
1812  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
1813  * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag
1814  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
1815  *
1816  * @post It invokes nfc_mifare_authenticate_with_keyA_completed_cb() when it has completed to authenticate the given sector with key A.
1817  * @see nfc_mifare_authenticate_with_keyB()
1818  * @see nfc_mifare_read_block()
1819  * @see nfc_mifare_read_page()
1820  * @see nfc_mifare_write_block()
1821  * @see nfc_mifare_write_page()
1822  * @see nfc_mifare_increment()
1823  * @see nfc_mifare_decrement()
1824 */
1825 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);
1826
1827
1828 /**
1829  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
1830  * @brief Authenticates a sector with key B.
1831  * @remarks I/O operations(read / write / increment / decrement / transfer / restore) will be available after successful authentication.\n
1832  * This function is only available for MIFARE classic.\n
1833  *      \n
1834  *      MIFARE CLASSIC MINI\n
1835  *              => 0 ~ 4 : 5 sector and 4 block with 16 bytes\n
1836  *      \n
1837  *      MIFARE CLASSIC 1K \n
1838  *              => 0 ~ 15 : 16 sector and 4 block with 16 bytes\n
1839  *      \n
1840  *      MIFARE CLASSIC 4K\n
1841  *              => 0 ~ 31 : 32 sector and 4 block with 16 bytes \n
1842  *              => 32 ~ 39 : 8 sector and 16 block with 16 bytes
1843  *
1844  * @param [in] tag The handle to NFC tag
1845  * @param [in] sector_index The index of sector to authenticate with key B, starting from 0
1846  * @param [in] auth_key 6-byte authentication key
1847  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
1848  * @param [in] user_data The user data to be passed to the callback function
1849  *
1850  * @return 0 on success, otherwise a negative error value.
1851  * @retval #NFC_ERROR_NONE Successful
1852  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1853  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1854  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
1855  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
1856  * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag
1857  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
1858  *
1859  * @post It invokes nfc_mifare_authenticate_with_keyB_completed_cb() when it has completed to authenticate the given sector with key B.
1860  * @see nfc_mifare_authenticate_with_keyA()
1861  * @see nfc_mifare_read_block()
1862  * @see nfc_mifare_read_page()
1863  * @see nfc_mifare_write_block()
1864  * @see nfc_mifare_write_page()
1865  * @see nfc_mifare_increment()
1866  * @see nfc_mifare_decrement()
1867 */
1868 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);
1869
1870
1871 /**
1872  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
1873  * @brief Reads a 16-byte block.
1874  * @remarks This function is only available for MIFARE classic.
1875  *
1876  * @param [in] tag The handle to NFC tag
1877  * @param [in] block_index The block or starting page number
1878  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
1879  * @param [in] user_data The user data to be passed to the callback function
1880  *
1881  * @return 0 on success, otherwise a negative error value.
1882  * @retval #NFC_ERROR_NONE Successful
1883  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1884  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1885  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
1886  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
1887  * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag
1888  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
1889  *
1890  * @post It invokes nfc_mifare_read_block_completed_cb() when it has completed to read a block.
1891  * @see nfc_mifare_read_page()
1892  * @see nfc_mifare_write_block()
1893 */
1894 int nfc_mifare_read_block(nfc_tag_h tag, int block_index, nfc_mifare_read_block_completed_cb callback, void *user_data);
1895
1896 /**
1897  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
1898  * @brief Reads 4 pages(16 bytes).
1899  * @remarks This function is only available for MIFARE Ultra light.\n
1900  * The MIFARE Ultralight protocol always reads 4 pages at a time, to reduce the number of commands required to read an entire tag.
1901  *
1902  * @param [in] tag The handle to NFC tag
1903  * @param [in] page_index  The index of page to read, starting from 0
1904  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
1905  * @param [in] user_data The user data to be passed to the callback function
1906  *
1907  *
1908  * @return 0 on success, otherwise a negative error value.
1909  * @retval #NFC_ERROR_NONE Successful
1910  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1911  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1912  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
1913  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
1914  * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag
1915  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
1916  *
1917  * @post It invokes nfc_mifare_read_page_completed_cb() when it has completed to read a page.
1918  * @see nfc_mifare_read_block()
1919  * @see nfc_mifare_write_page()
1920 */
1921 int nfc_mifare_read_page(nfc_tag_h tag, int page_index, nfc_mifare_read_page_completed_cb callback, void *user_data);
1922
1923 /**
1924  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
1925  * @brief Writes block (16 byte) of data to the tag at a given block index.
1926  * @remarks This function is only available for MIFARE classic.
1927  *
1928  * @param [in] tag The handle to NFC tag
1929  * @param [in] block_index The index of block to read, starting from 0
1930  * @param [in] buffer 16 bytes of data to write
1931  * @param [in] buffer_size The size of buffer in bytes
1932  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
1933  * @param [in] user_data The user data to be passed to the callback function
1934  *
1935  * @return 0 on success, otherwise a negative error value.
1936  * @retval #NFC_ERROR_NONE Successful
1937  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1938  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1939  * @retval #NFC_ERROR_NOT_INITIALIZED Not initialized
1940  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
1941  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
1942  * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag
1943  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
1944  *
1945  * @post It invokes nfc_mifare_write_block_completed_cb() when it has completed to write a block.
1946  *
1947  * @see nfc_mifare_write_page()
1948  * @see nfc_mifare_read_block()
1949 */
1950 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);
1951
1952 /**
1953  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
1954  * @brief Writes a page (4 bytes) of data to the tag at a given page index
1955  * @remarks This function is only available for MIFARE Ultra light
1956  *
1957  * @param [in] tag The handle to NFC tag
1958  * @param [in] page_index The index of page to write, starting from 0
1959  * @param [in] buffer 4 bytes of data to write
1960  * @param [in] buffer_size The size of buffer in bytes
1961  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
1962  * @param [in] user_data The user data to be passed to the callback function
1963  *
1964  * @return 0 on success, otherwise a negative error value.
1965  * @retval #NFC_ERROR_NONE Successful
1966  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1967  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1968  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
1969  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
1970  * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag
1971  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
1972  *
1973  * @post It invokes nfc_mifare_write_page_completed_cb() when it has completed to write a page.
1974  *
1975  * @see nfc_mifare_write_block()
1976  * @see nfc_mifare_read_page()
1977 */
1978 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);
1979
1980 /**
1981  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
1982  * @brief Increases a value block, storing the result in the temporary block on the tag.
1983  * @remarks This function is only available for MIFARE classic
1984  *
1985  * @param [in] tag The handle to NFC tag
1986  * @param [in] block_index The index of block to increase, starting from 0
1987  * @param [in] value Non-negative to increment by
1988  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
1989  * @param [in] user_data The user data to be passed to the callback function
1990  *
1991  * @return 0 on success, otherwise a negative error value.
1992  * @retval #NFC_ERROR_NONE Successful
1993  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1994  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1995  * @retval #NFC_ERROR_NOT_INITIALIZED Not initialized
1996  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
1997  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
1998  * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag
1999  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
2000  *
2001  * @see nfc_mifare_decrement()
2002  * @see nfc_mifare_write_block()
2003 */
2004 int nfc_mifare_increment(nfc_tag_h tag, int block_index, int value, nfc_mifare_increment_completed_cb callback, void *user_data);
2005
2006 /**
2007  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
2008  * @brief Decreases a value block, storing the result in the temporary block on the tag.
2009  * @remarks  This function is only available for MIFARE classic
2010  *
2011  * @param [in] tag The handle to NFC tag
2012  * @param [in] block_index The index of block to decrease, starting from 0
2013  * @param [in] value non-negative to decrement by
2014  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
2015  * @param [in] user_data The user data to be passed to the callback function
2016  *
2017  * @return 0 on success, otherwise a negative error value.
2018  * @retval #NFC_ERROR_NONE Successful
2019  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
2020  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
2021  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
2022  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
2023  * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag
2024  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
2025  *
2026  * @see nfc_mifare_increment()
2027  * @see nfc_mifare_write_block()
2028 */
2029 int nfc_mifare_decrement(nfc_tag_h tag, int block_index, int value, nfc_mifare_decrement_completed_cb callback, void *user_data);
2030
2031 /**
2032  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
2033  * @brief Copy from the temporary block to the specified block.
2034  * @remarks This function is only available for MIFARE classic
2035  *
2036  * @param [in] tag The handle to NFC tag
2037  * @param [in] block_index The index of block to copy to, starting from 0
2038  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
2039  * @param [in] user_data The user data to be passed to the callback function
2040  *
2041  * @return 0 on success, otherwise a negative error value.
2042  * @retval #NFC_ERROR_NONE Successful
2043  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
2044  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
2045  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
2046  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
2047  * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag
2048  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
2049  *
2050  * @see nfc_mifare_restore()
2051 */
2052 int nfc_mifare_transfer(nfc_tag_h tag, int block_index, nfc_mifare_transfer_completed_cb callback, void *user_data);
2053
2054 /**
2055  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
2056  * @brief Copy from a value block to the temporary block.
2057  * @remarks This function is only available for MIFARE classic
2058  *
2059  * @param [in] tag The handle to NFC tag
2060  * @param [in] block_index The index of block to copy from, starting from 0
2061  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
2062  * @param [in] user_data The user data to be passed to the callback function
2063  *
2064  * @return 0 on success, otherwise a negative error value.
2065  * @retval #NFC_ERROR_NONE Successful
2066  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
2067  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
2068  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
2069  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
2070  * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag
2071  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
2072  *
2073  * @see nfc_mifare_transfer()
2074 */
2075 int nfc_mifare_restore(nfc_tag_h tag, int block_index, nfc_mifare_restore_completed_cb callback, void *user_data);
2076
2077
2078 /**
2079  * @brief Registers a callback function for receiving data from NFC peer-to-peer target.
2080  * @ingroup CAPI_NETWORK_NFC_P2P_MODULE
2081  *
2082  * @param [in] target The handle to peer target
2083  * @param [in] callback The callback function to invoke when an NDEF Message is discovered
2084  * @param [in] user_data The user data to be passed to the callback function
2085  *
2086  * @return 0 on success, otherwise a negative error value.
2087  * @retval #NFC_ERROR_NONE Successful
2088  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
2089  *
2090  * @see nfc_p2p_unset_data_received_cb()
2091  * @see nfc_p2p_data_recived_cb()
2092  * @see nfc_p2p_target_discovered_cb()
2093  */
2094 int nfc_p2p_set_data_received_cb(nfc_p2p_target_h target, nfc_p2p_data_recived_cb callback, void *user_data);
2095
2096 /**
2097  * @brief Unregisters the callback function.
2098  * @ingroup CAPI_NETWORK_NFC_P2P_MODULE
2099  *
2100  * @param [in] target The handle to peer target
2101  *
2102  * @return 0 on success, otherwise a negative error value.
2103  * @retval #NFC_ERROR_NONE Successful
2104  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
2105  *
2106  * @see nfc_p2p_set_data_received_cb()
2107  * @see nfc_p2p_data_recived_cb()
2108  * @see nfc_p2p_target_discovered_cb()
2109  */
2110 int nfc_p2p_unset_data_received_cb(nfc_p2p_target_h target);
2111
2112 /**
2113  * @brief Sends data to NFC peer-to-peer target
2114  * @ingroup CAPI_NETWORK_NFC_P2P_MODULE
2115  *
2116  * @param [in] tag The handle to NFC tag
2117  * @param [in] message The message to send
2118  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
2119  * @param [in] user_data The user data to be passed to the callback function
2120  *
2121  * @return 0 on success, otherwise a negative error value.
2122  * @retval #NFC_ERROR_NONE Successful
2123  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
2124  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
2125  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
2126  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
2127  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
2128  *
2129  * @see nfc_p2p_send_completed_cb()
2130  * @see nfc_p2p_target_discovered_cb()
2131 */
2132 int nfc_p2p_send(nfc_p2p_target_h target, nfc_ndef_message_h message, nfc_p2p_send_completed_cb callback, void *user_data);
2133
2134
2135 /**
2136  * @brief Sends data to NFC peer-to-peer target without permission check
2137  * @ingroup CAPI_NETWORK_NFC_P2P_MODULE
2138  *
2139  * @param [in] tag The handle to NFC tag
2140  * @param [in] message The message to send
2141  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
2142  * @param [in] user_data The user data to be passed to the callback function
2143  *
2144  * @return 0 on success, otherwise a negative error value.
2145  * @retval #NFC_ERROR_NONE Successful
2146  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
2147  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
2148  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
2149  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
2150  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
2151  *
2152  * @see nfc_p2p_send_completed_cb()
2153  * @see nfc_p2p_target_discovered_cb()
2154 */
2155 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);
2156
2157
2158
2159 /**
2160  * @brief NFC Connection handover between NFC peer-to-peer target
2161  * @ingroup CAPI_NETWORK_NFC_P2P_MODULE
2162  *
2163  * @param [in] target The handle to NFC device
2164  * @param [in] type Preferred Alternative Carrier
2165  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
2166  * @param [in] user_data The user data to be passed to the callback function
2167  *
2168  * @return 0 on success, otherwise a negative error value.
2169  * @retval #NFC_ERROR_NONE Successful
2170  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
2171  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
2172  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
2173  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
2174  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
2175  *
2176  * @see nfc_p2p_connection_handover_completed_cb()
2177 */
2178 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);
2179
2180 /**
2181  * @brief Check available Alternative Carrier(AC) for NFC handover between NFC peer-to-peer target
2182  * @ingroup CAPI_NETWORK_NFC_P2P_MODULE
2183  *
2184  * @param [in] carrier Alternative Carrier when to be checked whether supported or not
2185  *
2186  * @retval #true Supported
2187  * @retval #false Not Supported
2188  *
2189  * @see nfc_p2p_is_supported_ac_type()
2190 */
2191 bool nfc_p2p_is_supported_ac_type( nfc_ac_type_e carrior);
2192
2193
2194 /**
2195  * @brief Start peer-to-peer server using SNEP protocol
2196  * @ingroup CAPI_NETWORK_NFC_P2P_MODULE
2197  *
2198  * @param [in] target The handle to peer target
2199  * @param [in] san The name of service (service access name)
2200  * @param [in] sap The number of service (service access point)
2201  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
2202  * @param [in] user_data The user data to be passed to the callback function
2203  *
2204  * @return 0 on success, otherwise a negative error value.
2205  * @retval #NFC_ERROR_NONE Successful
2206  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
2207  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
2208  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
2209  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
2210  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
2211  *
2212  * @see nfc_snep_event_cb()
2213 */
2214 int nfc_snep_start_server(nfc_p2p_target_h target, const char *san, int sap, nfc_snep_event_cb callback, void *user_data);
2215
2216 /**
2217  * @brief Start peer-to-peer client using SNEP protocol
2218  * @ingroup CAPI_NETWORK_NFC_P2P_MODULE
2219  *
2220  * @param [in] target The handle to peer target
2221  * @param [in] san The name of service (service access name)
2222  * @param [in] sap The number of service (service access point)
2223  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
2224  * @param [in] user_data The user data to be passed to the callback function
2225  *
2226  * @return 0 on success, otherwise a negative error value.
2227  * @retval #NFC_ERROR_NONE Successful
2228  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
2229  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
2230  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
2231  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
2232  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
2233  *
2234  * @see nfc_snep_event_cb()
2235  * @see nfc_snep_send_client_request()
2236  * @see nfc_snep_stop_service
2237 */
2238 int nfc_snep_start_client(nfc_p2p_target_h target, const char *san, int sap, nfc_snep_event_cb callback, void *user_data);
2239
2240 /**
2241  * @brief Send request message to peer-to-peer client using SNEP protocol
2242  * @ingroup CAPI_NETWORK_NFC_P2P_MODULE
2243  *
2244  * @param [in] handle The handle to connected snep instance
2245  * @param [in] type The request type of snep protocol
2246  * @param [in] msg The ndef message which will be sent
2247  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
2248  * @param [in] user_data The user data to be passed to the callback function
2249  *
2250  * @return 0 on success, otherwise a negative error value.
2251  * @retval #NFC_ERROR_NONE Successful
2252  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
2253  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
2254  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
2255  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
2256  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
2257  *
2258  * @see nfc_snep_event_cb()
2259 */
2260 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);
2261
2262 /**
2263  * @brief Stop snep server or client
2264  * @ingroup CAPI_NETWORK_NFC_P2P_MODULE
2265  *
2266  * @param [in] target The handle to peer target
2267  * @param [in] service The handle which will be stopped
2268  *
2269  * @return 0 on success, otherwise a negative error value.
2270  * @retval #NFC_ERROR_NONE Successful
2271  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
2272  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
2273  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
2274  *
2275  * @see nfc_snep_event_cb()
2276 */
2277 int nfc_snep_stop_service(nfc_p2p_target_h target, nfc_p2p_snep_h service);
2278
2279 /**
2280  * @brief Register peer-to-peer server using SNEP protocol
2281  * @ingroup CAPI_NETWORK_NFC_P2P_MODULE
2282  *
2283  * @param [in] san The name of service (service access name)
2284  * @param [in] sap The number of service (service access point)
2285  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
2286  * @param [in] user_data The user data to be passed to the callback function
2287  *
2288  * @return 0 on success, otherwise a negative error value.
2289  * @retval #NFC_ERROR_NONE Successful
2290  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
2291  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
2292  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
2293  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
2294  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
2295  *
2296  * @see nfc_snep_event_cb()
2297 */
2298 int nfc_snep_register_server(const char *san, int sap, nfc_snep_event_cb callback, void *user_data);
2299
2300 /**
2301  * @brief Unregister snep server or client
2302  * @ingroup CAPI_NETWORK_NFC_P2P_MODULE
2303  *
2304  * @param [in] san The name of service (service access name)
2305  * @param [in] sap The number of service (service access point)
2306  *
2307  * @return 0 on success, otherwise a negative error value.
2308  * @retval #NFC_ERROR_NONE Successful
2309  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
2310  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
2311  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
2312  *
2313  * @see nfc_snep_event_cb()
2314 */
2315 int nfc_snep_unregister_server(const char *san, int sap);
2316
2317 /**
2318  * @brief Open connection to secure element.
2319  * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
2320  *
2321  * @param [in] se_type   The type you want to open
2322  * @param [out] handle    The handle of connected secure element
2323  *
2324  * @return 0 on success, otherwise a negative error value.
2325  * @retval #NFC_ERROR_NONE Successful
2326  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
2327  * @retval #NFC_ERROR_INVALID_NDEF_MESSAGE Invalid NDEF message
2328  *
2329  * @see nfc_se_close_secure_element()
2330  */
2331 int nfc_se_open_secure_element(nfc_se_type_e se_type, nfc_se_h *handle);
2332
2333 /**
2334  * @brief Enable card emulation mode.
2335  * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
2336  *
2337  * @return 0 on success, otherwise a negative error value.
2338  *
2339  * @see nfc_se_disable_card_emulation()
2340  */
2341 int nfc_se_enable_card_emulation();
2342
2343 /**
2344  * @brief Disable card emulation mode.
2345  * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
2346  *
2347  * @return 0 on success, otherwise a negative error value.
2348  *
2349  * @see nfc_se_enable_card_emulation()
2350  */
2351 int nfc_se_disable_card_emulation();
2352
2353 /**
2354  * @brief Get the current card emulation mode.
2355  * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
2356  *
2357  * @param [out]  type   The current card emulation mode type
2358  *
2359  * @return 0 on success, otherwise a negative error value.
2360  * @retval #NFC_ERROR_NONE Successful
2361  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
2362  *
2363  */
2364 int nfc_se_get_card_emulation_mode(nfc_se_card_emulation_mode_type_e *type);
2365
2366 /**
2367  * @brief Open connection to secure element.
2368  * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
2369  *
2370  * @remarks It gets the allocated bytes array including data. @a resp must be released with free() by you.
2371  *
2372  * @param [in]  handle   The handle of connected secure element
2373  * @param [in]  cmd      The bytes array of apdu command data
2374  * @param [in]  cmd_len  The size of apdu command bytes array
2375  * @param [out] resp     The bytes array of response data
2376  * @param [out] resp_len The size of response bytes array
2377  *
2378  * @return 0 on success, otherwise a negative error value.
2379  * @retval #NFC_ERROR_NONE Successful
2380  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
2381  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
2382  * @retval #NFC_ERROR_INVALID_NDEF_MESSAGE Invalid NDEF message
2383  *
2384  * @see nfc_se_open_secure_element()
2385  * @see nfc_se_close_secure_element()
2386  */
2387 int nfc_se_send_apdu(nfc_se_h handle, unsigned char *cmd, unsigned int cmd_len, unsigned char **resp, unsigned int *resp_len);
2388
2389 /**
2390  * @brief Get ATR(Answer to Reset) of connected secure element.
2391  * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
2392  *
2393  * @remarks It gets the allocated bytes array including data. @a atr must be released with free() by you.
2394  *
2395  * @param [in]  handle  The handle of connected secure element
2396  * @param [out] atr     The bytes array of atr data
2397  * @param [out] atr_len The size of atr bytes array
2398  *
2399  * @return 0 on success, otherwise a negative error value.
2400  * @retval #NFC_ERROR_NONE Successful
2401  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
2402  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
2403  * @retval #NFC_ERROR_INVALID_NDEF_MESSAGE Invalid NDEF message
2404  *
2405  * @see nfc_se_open_secure_element()
2406  * @see nfc_se_close_secure_element()
2407  */
2408 int nfc_se_get_atr(nfc_se_h handle, unsigned char **atr, unsigned int *atr_len);
2409
2410 /**
2411  * @brief Close connection to secure element.
2412  * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
2413  *
2414  * @param [in] handle   The handle of connected secure element
2415  *
2416  * @return 0 on success, otherwise a negative error value.
2417  * @retval #NFC_ERROR_NONE Successful
2418  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
2419  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
2420  * @retval #NFC_ERROR_INVALID_NDEF_MESSAGE Invalid NDEF message
2421  *
2422  * @see nfc_se_open_secure_element()
2423  */
2424 int nfc_se_close_secure_element(nfc_se_h handle);
2425
2426 #ifdef __cplusplus
2427 }
2428 #endif
2429
2430
2431 #endif /* __NFC_H__ */
2432