58719674bdea21f6cf79f80d4904d4f4516bf6c1
[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_SE_CARD_EMULATION_CHANGED
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
194
195 /**
196  * @brief The handle to the NDEF record
197  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
198  */
199 typedef struct _ndef_record_s *nfc_ndef_record_h;
200
201 /**
202  * @brief The handle to the NDEF message
203  * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
204  */
205 typedef struct _ndef_message_s *nfc_ndef_message_h;
206
207 /**
208  * @brief The handle to the NFC tag
209  * @ingroup CAPI_NETWORK_NFC_TAG_MODULE
210  */
211 typedef struct _net_nfc_target_info_s *nfc_tag_h;
212
213
214 /**
215  * @brief The handle to NFC p2p target
216  * @ingroup CAPI_NETWORK_NFC_P2P_MODULE
217  */
218 typedef void *nfc_p2p_target_h;
219
220 /**
221  * @brief The default factory key.
222  * @details The key is 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
223  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
224  */
225 extern const unsigned char NFC_TAG_MIFARE_KEY_DEFAULT[6];
226
227 /**
228  * @brief The well-known key for tags formatted according to the MIFARE Application Directory (MAD) specification.
229  * @details The key is 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5
230  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
231  */
232 extern const unsigned char NFC_TAG_MIFARE_KEY_APPLICATION_DIRECTORY[6];
233
234 /**
235  * @brief The well-known key for tags formatted according to the NDEF on Mifare Classic specification.
236  * @details The key is 0xD3, 0xF7, 0xD3, 0xF7, 0xD3, 0xF7
237  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
238  */
239 extern const unsigned char NFC_TAG_MIFARE_KEY_NFC_FORUM[6];
240
241
242 /**
243  * @brief RTD(Record type definition) Type - Smart Poster type.
244  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
245  */
246 extern const unsigned char NFC_RECORD_SMART_POSTER_TYPE[2];
247
248 /**
249  * @brief  RTD(Record type definition) Type - Text type.
250  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
251  */
252 extern const unsigned char NFC_RECORD_TEXT_TYPE[1];
253 /**
254  * @brief  RTD(Record type definition) Type - URI type.
255  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
256  */
257 extern const unsigned char NFC_RECORD_URI_TYPE[1];
258 /**
259  * @brief  RTD(Record type definition) Type - Alternative Carrier type.
260  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
261  */
262 extern const unsigned char NFC_RECORD_ALTERNATIVE_CARRIER_TYPE[2];
263 /**
264  * @brief  RTD(Record type definition) Type - Handover Carrier type.
265  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
266  */
267 extern const unsigned char NFC_RECORD_HANDOVER_CARRIER_TYPE[2];
268 /**
269  * @brief  RTD(Record type definition) Type - Handover Request type.
270  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
271  */
272 extern const unsigned char NFC_RECORD_HANDOVER_REQUEST_TYPE[2];
273 /**
274  * @brief  RTD(Record type definition) Type - Handover Select type.
275  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
276  */
277 extern const unsigned char NFC_RECORD_HANDOVER_SELECT_TYPE[2];
278
279 /**
280  * @brief Called after nfc_manager_set_activation() has completed.
281  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
282  *
283  * @param [in] error The result
284  * @param [in] user_data The user data passed from the callback registration function
285  *
286  * @see nfc_manager_set_activation()
287  */
288 typedef void (* nfc_activation_completed_cb)(nfc_error_e error, void *user_data);
289
290 /**
291  * @brief Called when nfc activation state is changed.
292  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
293  *
294  * @param [in] activated The activation state
295  * @param [in] user_data The user data passed from the callback registration function
296  *
297  * @see nfc_manager_set_activation_changed_cb()
298  */
299 typedef void (*nfc_activation_changed_cb)(bool activated , void *user_data);
300
301 /**
302  * @brief Called after nfc_manager_initialize() has completed.
303  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
304  *
305  * @param [in] error The result
306  * @param [in] user_data The user data passed from the callback registration function
307  *
308  * @see nfc_manager_initialize()
309  */
310 typedef void (* nfc_initialize_completed_cb)(nfc_error_e error, void *user_data);
311
312
313 /**
314  * @brief Called after nfc_manager_set_card_emulation_se_type() has completed.
315  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
316  *
317  * @param [in] error The result
318  * @param [in] user_data The user data passed from the callback registration function
319  *
320  * @see nfc_manager_set_card_emulation_se_type()
321  */
322 typedef void (* nfc_set_card_emulation_completed_cb)(nfc_error_e error, void *user_data);
323
324 /**
325  * @brief Called when an NFC tag appears or disappears
326  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
327  *
328  * @remarks  The tag handle does not have detail target info when an NFC tag disappeared.\n
329  *      So then do not use nfc_tag_get_keys().
330  *
331  * @param [in] type The discovered type attached or detached
332  * @param [in] tag The handle to NFC tag
333  * @param [in] user_data The user data passed from the callback registration function
334  *
335  * @see nfc_manager_set_tag_discovered_cb()
336  * @see nfc_manager_unset_tag_discovered_cb()
337  * @see nfc_manager_set_tag_filter()
338  */
339 typedef void (* nfc_tag_discovered_cb)(nfc_discovered_type_e type, nfc_tag_h tag, void *user_data);
340
341 /**
342  * @brief Called when an NDEF Message is discovered
343  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
344  *
345  * @remarks @a message will be automatically destroyed when the callback function returns. (Do not release @a message.)
346  *
347  * @param [in] message The handle to NDEF message
348  * @param [in] user_data The user data passed from the callback registration function
349  *
350  * @see nfc_manager_set_ndef_discovered_cb()
351  * @see nfc_manager_unset_ndef_discovered_cb()
352  */
353 typedef void (* nfc_ndef_discovered_cb)(nfc_ndef_message_h message, void *user_data);
354
355
356 /**
357  * @brief Called once for each tag information.
358  * @ingroup CAPI_NETWORK_NFC_TAG_MODULE
359  *
360  * @remarks @a key and value will be automatically destroyed when the callback function returns. (Do not release @a key and value.)
361  *
362  * @param[in] key The key of information
363  * @param[in] value The value of information
364  * @param[in] value_size The data size in bytes
365  * @param[in] user_data The user data passed from the foreach function
366  *
367  * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop.
368  * @pre nfc_tag_foreach_informations() invokes this callback.
369  *
370  * @see nfc_tag_foreach_informations()
371  */
372
373 typedef bool (*nfc_tag_information_cb)(const char *key, const unsigned char *value, int value_size, void *user_data);
374
375
376 /**
377  * @brief Called after nfc_tag_transceive() has completed.
378  * @ingroup CAPI_NETWORK_NFC_TAG_MODULE
379  *
380  * @remarks @a buffer will be automatically destroyed when the callback function returns. (Do not release @a buffer.)
381  *
382  * @param [in] result The result of function call
383  * @param [in] buffer   The result data
384  * @param [in] buffer_size The size of buffer in bytes
385  * @param [in] user_data The user data passed from nfc_tag_transceive()
386  *
387  * @see nfc_tag_transceive()
388  */
389 typedef void (* nfc_tag_transceive_completed_cb)(nfc_error_e result, unsigned char *buffer, int buffer_size, void *user_data);
390
391 /**
392  * @brief Called after the nfc_tag_write_ndef() has completed.
393  * @ingroup CAPI_NETWORK_NFC_TAG_MODULE
394  *
395  * @param [in] result The result of function call
396  * @param [in] user_data The user data passed from nfc_manager_initialize()
397  *
398  * @see nfc_tag_write_ndef()
399  */
400 typedef void (* nfc_tag_write_completed_cb)(nfc_error_e result, void *user_data);
401
402 /**
403  * @brief Called after the nfc_tag_read_ndef() has completed.
404  * @ingroup CAPI_NETWORK_NFC_TAG_MODULE
405  *
406  * @remarks @a message will be automatically destroyed when the callback function returns. (Do not release @a message.)
407  *
408  * @param [in] result The result of function call
409  * @param [in] message The NDEF message
410  * @param [in] user_data The user data passed from nfc_tag_read_ndef()
411  *
412  * @see nfc_tag_read_ndef()
413  */
414 typedef void (* nfc_tag_read_completed_cb)(nfc_error_e result, nfc_ndef_message_h message, void *user_data);
415
416 /**
417  * @brief   Called after the nfc_tag_format_ndef() has completed.
418  * @ingroup CAPI_NETWORK_NFC_TAG_MODULE
419  *
420  * @param [in] result The result of function call
421  * @param [in] user_data The user data passed from nfc_tag_format_ndef()
422  *
423  * @see nfc_tag_format_ndef()
424  */
425 typedef void (* nfc_tag_format_completed_cb)(nfc_error_e result, void *user_data);
426
427
428 /**
429  * @brief Called after nfc_mifare_authenticate_with_keyA() has completed
430  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
431  *
432  * @param [in] result The result of nfc_mifare_authenticate_with_keyA()
433  * @param [in] user_data The user data passed from nfc_mifare_authenticate_with_keyA()
434  *
435  * @see nfc_mifare_authenticate_with_keyA()
436  */
437 typedef void (* nfc_mifare_authenticate_with_keyA_completed_cb)(nfc_error_e result, void *user_data);
438
439 /**
440  * @brief Called after nfc_mifare_authenticate_with_keyB() has completed
441  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
442  *
443  * @param [in] result The result of function call
444  * @param [in] user_data The user data passed from nfc_mifare_authenticate_with_keyB()
445  *
446  * @see nfc_mifare_authenticate_with_keyB()
447  */
448 typedef void (* nfc_mifare_authenticate_with_keyB_completed_cb)(nfc_error_e result, void *user_data);
449
450 /**
451  * @brief Called after nfc_mifare_write_block() has completed
452  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
453  *
454  * @param [in] result The result of nfc_mifare_write_block()
455  * @param [in] user_data The user data passed from nfc_mifare_write_block()
456  *
457  * @see nfc_mifare_write_block()
458  */
459 typedef void (* nfc_mifare_write_block_completed_cb)(nfc_error_e result, void *user_data);
460
461 /**
462  * @brief Called after nfc_mifare_write_page() has completed
463  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
464  *
465  * @param [in] result The result of function call
466  * @param [in] user_data The user data passed from nfc_mifare_write_page()
467  *
468  * @see nfc_mifare_write_page()
469  */
470 typedef void (* nfc_mifare_write_page_completed_cb)(nfc_error_e result, void *user_data);
471
472 /**
473  * @brief Called after nfc_mifare_read_block() has completed
474  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
475  *
476  * @remarks @a buffer will be automatically destroyed when the callback function returns. (Do not release @a buffer.)
477  *
478  * @param [in] result The result of function call
479  * @param [in] buffer The read buffer
480  * @param [in] size The size of buffer in bytes
481  * @param [in] user_data The user data passed from nfc_mifare_read_block()
482  *
483  * @see nfc_mifare_read_block()
484  */
485 typedef void (* nfc_mifare_read_block_completed_cb)(nfc_error_e result, unsigned char *buffer, int bufer_size, void *user_data);
486
487 /**
488  * @brief Called after nfc_mifare_read_page() has completed
489  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
490  *
491  * @remarks @a buffer will be automatically destroyed when the callback function returns. (Do not release @a buffer.)
492  *
493  * @param [in] result The result of nfc_mifare_read_page()
494  * @param [in] buffer The read buffer
495  * @param [in] size The size of read buffer in bytes
496  * @param [in] user_data The user data passed from nfc_mifare_read_page()
497  *
498  * @see nfc_mifare_read_page()
499  */
500 typedef void (* nfc_mifare_read_page_completed_cb)(nfc_error_e result, unsigned char *buffer, int bufer_size, void *user_data);
501
502 /**
503  * @brief Called after nfc_mifare_increment() has completed
504  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
505  *
506  * @param [in] result The result of nfc_mifare_increment()
507  * @param [in] user_data The user data passed from nfc_mifare_increment()
508  *
509  * @see nfc_mifare_increment()
510  */
511 typedef void (* nfc_mifare_increment_completed_cb)(nfc_error_e result, void *user_data);
512
513 /**
514  * @brief Called after nfc_mifare_decrement() has completed
515  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
516  *
517  * @param [in] result The result of nfc_mifare_decrement()
518  * @param [in] user_data The user data passed from nfc_mifare_decrement()
519  *
520  * @see nfc_mifare_decrement()
521  */
522 typedef void (* nfc_mifare_decrement_completed_cb)(nfc_error_e result, void *user_data);
523
524 /**
525  * @brief Called after nfc_mifare_transfer() has completed
526  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
527  *
528  * @param [in] result The result of nfc_mifare_transfer()
529  * @param [in] user_data The user data passed from nfc_mifare_transfer()
530  *
531  * @see nfc_mifare_transfer()
532  */
533 typedef void (* nfc_mifare_transfer_completed_cb)(nfc_error_e result, void *user_data);
534
535 /**
536  * @brief Called after nfc_mifare_restore() has completed
537  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
538  *
539  * @param [in] result The result of nfc_mifare_restore()
540  * @param [in] user_data The user data passed from nfc_mifare_restore()
541  *
542  * @see nfc_mifare_restore()
543  */
544 typedef void (* nfc_mifare_restore_completed_cb)(nfc_error_e result, void *user_data);
545
546
547
548 /**
549  * @brief Called when NFC peer-to-peer target appeared or disappeared
550  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
551  *
552  * @param [in] type The discovered type attached or detached
553  * @param [in] target The handle to p2p target
554  * @param [in] user_data The user data passed from nfc_manager_set_p2p_target_discovered_cb()
555  *
556  * @see nfc_manager_set_p2p_target_discovered_cb()
557  * @see nfc_manager_unset_p2p_target_discovered_cb()
558  */
559 typedef void (*nfc_p2p_target_discovered_cb)(nfc_discovered_type_e type, nfc_p2p_target_h target, void *user_data);
560
561 /**
562  * @brief Called when receiving  Secure Element (SIM/UICC(Universal Integrated Circuit Card)) event.
563  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
564  *
565  * @param [in] event The Secure Element event
566  * @param [in] user_data The user data passed from nfc_manager_set_se_event_cb()
567  *
568  * @see nfc_manager_set_se_event_cb()
569  * @see nfc_manager_unset_se_event_cb()
570  */
571 typedef void (*nfc_se_event_cb)(nfc_se_event_e event , void *user_data);
572
573
574 /**
575  * @brief Called when receiving Secure Element(SIM/UICC(Universal Integrated Circuit Card)) transaction event data
576  * @remarks This event  notifies , external reader trys to access secure element.
577  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
578  *
579  * @param [in] se type
580  * @param [in] aid Application Id, specified in ISO/IEC 7816-4
581  * @param [in] aid_size The size of aid (5~16)
582  * @param [in] param The parameter list, specified in ISO/IEC 8825-1
583  * @param [in] param The size of param (0~65535)
584  * @param [in] user_data The user data passed from nfc_manager_set_se_transaction_event_cb()
585  *
586  * @see nfc_manager_set_se_transaction_event_cb()
587  * @see nfc_manager_unset_se_transaction_event_cb()
588  */
589 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);
590
591
592
593 /**
594  * @brief Called after nfc_p2p_send() has completed.
595  * @ingroup CAPI_NETWORK_NFC_P2P_MODULE
596  *
597  * @param [in] result The result of function call
598  * @param [in] user_data The user data passed from nfc_p2p_send()
599  *
600  * @see nfc_p2p_send()
601  */
602 typedef void (*nfc_p2p_send_completed_cb)(nfc_error_e result, void *user_data);
603
604
605 /**
606  * @brief Called after nfc_p2p_send() has completed.
607  * @ingroup CAPI_NETWORK_NFC_P2P_MODULE
608  *
609  * @remarks @a message will be automatically destroyed when the callback function returns. (Do not release @a message.)
610  *
611  * @param [in] target The handle to p2p target
612  * @param [in] message The received message
613  * @param [in] user_data The user data passed from nfc_p2p_set_recv_cb()
614  *
615  * @see nfc_p2p_set_data_received_cb()
616  * @see nfc_p2p_unset_data_received_cb()
617  */
618 typedef void (*nfc_p2p_data_recived_cb)(nfc_p2p_target_h target, nfc_ndef_message_h message, void *user_data);
619
620
621 /**
622  * @brief Called after nfc_p2p_connection_handover() has completed.
623  * @ingroup CAPI_NETWORK_NFC_P2P_MODULE
624  *
625  * @remark To use the @a ac_data outside this function, copy the @a ac_data.
626  * @remark @a ac_data could be NULL, if nfc_p2p_connection_handover failed.
627  * @remark If @a carrier is #NFC_AC_TYPE_BT, @ac_data should be converted to 'char *' type. This is bluetooth address information.
628  *
629  * @param [in] result The result of function call
630  * @param [in] carrier The type of Alternative Carrier
631  * @param [in] ac_data The connected remote device AC(Alternative Carrier) information data
632  * @param [in] ac_data_size The connected remote device AC(Alternative Carrier) information data size
633  * @param [in] user_data The user data passed from nfc_p2p_connection_handover()
634  *
635  * @see nfc_p2p_connection_handover()
636  */
637 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);
638
639 /**
640  * @brief Gets the value that indicates whether NFC is supported.
641  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
642  *
643  * @remarks This function can executed Regardless of nfc_manager_initialize state.
644  *
645  * @return true on NFC supported,  otherwise false
646  *
647  * @see nfc_manager_set_activation()
648  */
649
650 bool nfc_manager_is_supported(void);
651
652 /**
653  * @brief Sets NFC Activation
654  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
655  *
656  * @param [in] activation The NFC state for setting
657  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
658  * @param [in] user_data The user data to be passed to the callback function
659  *
660  * @return 0 on success, otherwise a negative error value.
661  * @retval #NFC_ERROR_NONE Successful
662  * @retval #NFC_ERROR_OPERATION_FAILED Operation fail
663  * @retval #NFC_ERROR_NOT_SUPPORTED Not supported NFC
664  * @retval #NFC_ERROR_ALREADY_ACTIVATED Already activated
665  * @retval #NFC_ERROR_ALREADY_DEACTIVATED Already deactivated
666  *
667  * @see nfc_manager_is_activated()
668  * @see nfc_activation_completed_cb()
669  */
670 int nfc_manager_set_activation(bool activation, nfc_activation_completed_cb callback, void *user_data);
671
672 /**
673  * @brief Set NFC Activation state changed callback
674  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
675  *
676  * @param [in] callback The callback function to invoke when activation state is changed.
677  * @param [in] user_data The user data to be passed to the callback function
678  *
679  * @return 0 on success, otherwise a negative error value.
680  * @retval #NFC_ERROR_NONE Successful
681  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
682  *
683  * @see nfc_activation_changed_cb()
684  * @see nfc_manager_unset_activation_changed_cb()
685  */
686 int nfc_manager_set_activation_changed_cb(nfc_activation_changed_cb callback , void *user_data);
687
688 /**
689  * @brief Unregisters the callback function.
690  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
691  *
692  * @see nfc_manager_set_activation_changed_cb()
693  * @see nfc_activation_changed_cb()
694  */
695 void nfc_manager_unset_activation_changed_cb(void);
696
697
698 /**
699  * @brief Gets NFC Activation state
700  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
701  *
702  * @remarks This function can executed Regardless of nfc_manager_initialize state.
703  *
704  * @return true on NFC activated,  otherwise false
705  *
706  * @see nfc_manager_set_activation()
707  */
708
709 bool nfc_manager_is_activated(void);
710
711 /**
712  * @brief Initializes NFC Manager.
713  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
714  * @remarks This function must be called before proceeding any other nfc functions\n
715  *      Internally it makes socket connection to NFC manager.\n
716  *      When an application crashes or exits without the deinitialization. NFC manager automatically deinitializes the process itself.\n
717  *      This function is asynchronous.
718  *
719  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
720  * @param [in] user_data The user data to be passed to the callback function
721  *
722  * @return 0 on success, otherwise a negative error value.
723  * @retval #NFC_ERROR_NONE Successful
724  * @retval #NFC_ERROR_OPERATION_FAILED Operation fail
725  *
726  * @see nfc_manager_initialize_sync()
727  * @see nfc_manager_deinitialize()
728  */
729 int nfc_manager_initialize(nfc_initialize_completed_cb callback, void *user_data);
730
731 /**
732  * @brief Initializes NFC Manager.
733  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
734  * @remarks This function must be called before proceeding any other nfc functions\n
735  *      Internally it makes socket connection to NFC manager.\n
736  *      When an application crashes or exits without the deinitialization. NFC manager automatically deinitializes the process itself.\n
737  *      This function is synchronous.
738  *
739  * @return 0 on success, otherwise a negative error value.
740  * @retval #NFC_ERROR_NONE Successful
741  * @retval #NFC_ERROR_OPERATION_FAILED Operation fail
742  *
743  * @see nfc_manager_initialize()
744  * @see nfc_manager_deinitialize()
745  */
746 int nfc_manager_initialize_sync();
747
748
749 /**
750  * @brief Releases all the resource of the NFC Manager and disconnect the session between an application and NFC Manager.
751  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
752  *
753  * @return 0 on success, otherwise a negative error value.
754  * @retval #NFC_ERROR_NONE Successful
755  * @retval #NFC_ERROR_OPERATION_FAILED Operation fail
756  *
757  * @see nfc_manager_initialize()
758  */
759 int nfc_manager_deinitialize(void);
760
761 /**
762  * @brief Registers a callback function for receiving tag discovered notification.
763  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
764  *
765  * @param [in] callback The callback function called when a tag is appeared or disappeared
766  * @param [in] user_data The user data to be passed to the callback function
767  *
768  * @return 0 on success, otherwise a negative error value.
769  * @retval #NFC_ERROR_NONE Successful
770  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
771  *
772  * @see nfc_manager_unset_tag_discovered_cb()
773  * @see nfc_tag_discovered_cb()
774  */
775 int nfc_manager_set_tag_discovered_cb(nfc_tag_discovered_cb callback, void *user_data);
776
777 /**
778  * @brief Unregisters the callback function.
779  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
780  *
781  * @see nfc_manager_set_tag_discovered_cb()
782  * @see nfc_tag_discovered_cb()
783  */
784 void nfc_manager_unset_tag_discovered_cb(void);
785
786 /**
787  * @brief Registers a callback function for receiving NDEF Message discovered notification
788  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
789  *
790  * @param [in] callback The callback function called when NDEF Message is discovered
791  * @param [in] user_data The user data to be passed to the callback function
792  *
793  * @return 0 on success, otherwise a negative error value.
794  * @retval #NFC_ERROR_NONE Successful
795  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
796  *
797  * @see nfc_manager_unset_ndef_discovered_cb()
798  * @see nfc_ndef_discovered_cb()
799  */
800 int nfc_manager_set_ndef_discovered_cb(nfc_ndef_discovered_cb callback, void *user_data);
801
802 /**
803  * @brief Unregisters the callback function.
804  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
805  *
806  * @see nfc_manager_set_ndef_discovered_cb()
807  * @see nfc_ndef_discovered_cb()
808  */
809 void nfc_manager_unset_ndef_discovered_cb(void);
810
811 /**
812  * @brief Registers a callback function for receiving NFC peer-to-peer target discovered notification.
813  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
814  *
815  * @param [in] callback The callback function called when NFC peer-to-peer target is discovered
816  * @param [in] user_data The user data to be passed to the callback function
817  *
818  * @return 0 on success, otherwise a negative error value.
819  * @retval #NFC_ERROR_NONE Successful
820  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
821  *
822  * @see nfc_manager_unset_ndef_discovered_cb()
823  * @see nfc_p2p_target_discovered_cb()
824  */
825 int nfc_manager_set_p2p_target_discovered_cb(nfc_p2p_target_discovered_cb callback, void *user_data);
826
827 /**
828  * @brief Unregisters the callback function.
829  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
830  *
831  * @see nfc_manager_set_p2p_target_discovered_cb()
832  * @see nfc_p2p_target_discovered_cb()
833  */
834 void nfc_manager_unset_p2p_target_discovered_cb(void);
835
836
837 /**
838  * @brief Registers a callback function for receiving  Secure Element (SIM/UICC(Universal Integrated Circuit Card)) event.
839  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
840  *
841  * @param [in] callback The callback function called when occurred Secure Element (SIM/UICC(Universal Integrated Circuit Card)) event.
842  * @param [in] user_data The user data to be passed to the callback function
843  *
844  * @return 0 on success, otherwise a negative error value.
845  * @retval #NFC_ERROR_NONE Successful
846  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
847  *
848  * @see nfc_se_event_cb()
849  * @see nfc_manager_unset_se_event_cb()
850  */
851
852 int nfc_manager_set_se_event_cb(nfc_se_event_cb callback, void *user_data);
853
854 /**
855  * @brief Unregisters the callback function.
856  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
857  *
858  * @see nfc_se_event_cb()
859  * @see nfc_manager_set_se_event_cb()
860  */
861 void nfc_manager_unset_se_event_cb(void);
862
863 /**
864  * @brief Registers a callback function for receiving  Secure Element (SIM/UICC(Universal Integrated Circuit Card)) transaction event(#NFC_SE_EVENT_TRANSACTION) data.
865  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
866  *
867  * @param [in] se_type The type os secure element
868  * @param [in] callback The callback function called when occurred SE transaction event.
869  * @param [in] user_data The user data to be passed to the callback function
870  *
871  * @return 0 on success, otherwise a negative error value.
872  * @retval #NFC_ERROR_NONE Successful
873  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
874  *
875  * @see nfc_se_transaction_event_cb()
876  * @see nfc_manager_unset_se_transaction_event_cb()
877  */
878 int nfc_manager_set_se_transaction_event_cb(nfc_se_type_e se_type,
879                 nfc_se_transaction_event_cb callback, void *user_data);
880
881 /**
882  * @brief Unregisters the callback function.
883  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
884  *
885  * @param [in] se_type The type of secure element.
886  *
887  * @see nfc_se_transaction_event_cb()
888  * @see nfc_manager_set_se_transaction_event_cb()
889  */
890 void nfc_manager_unset_se_transaction_event_cb(nfc_se_type_e se_type);
891
892 /**
893  * @brief Gets NDEF message cached when the tag is detected or when data received from NFC peer-to-peer target.
894  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
895  *
896  * @remarks This function is used to get the ndef message that was read before launched your application.
897  * @param [out] ndef_message The cached NDEF message
898  *
899  * @return 0 on success, otherwise a negative error value.
900  * @retval #NFC_ERROR_NONE Successful
901  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
902  * @retval #NFC_ERROR_INVALID_NDEF_MESSAGE The cached message does not exist
903  */
904 int nfc_manager_get_cached_message(nfc_ndef_message_h *ndef_message);
905
906
907 /**
908  * @brief Sets filter of target types.
909  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
910  * @remarks Bit operator OR(|) can be used in the configure parameter (like  NFC_TAG_FILTER_ISO14443A_ENABLE | NFC_TAG_FILTER_ISO14443B_ENABLE)
911  *      or you may choose "NFC_TAG_ALL_ENABLE" enum value to get all result.
912  *      It prevent getting tag types from RF level.
913  *      If the client api does call this function, default is always NFC_TAG_ALL_ENABLE.
914  *
915  * @param [in] filter The filter value with bits operation #nfc_tag_filter_e
916  *
917  * @see nfc_manager_get_tag_filter()
918  * @see nfc_tag_discovered_cb()
919  */
920 void nfc_manager_set_tag_filter(int filter);
921
922 /**
923  * @brief Gets the current filter status.
924  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
925  *
926  * @remarks Bit operation OR(|) is used in return data\n
927  * The default value is NFC_TAG_FILTER_ALL_ENABLE
928  *
929  * @return The filter which is set #nfc_tag_filter_e
930  *
931  * @see nfc_manager_set_tag_filter()
932  */
933 int nfc_manager_get_tag_filter(void);
934
935 /**
936  * @brief Gets current connected tag.
937  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
938  *
939  * @param [out] tag The connected tag
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  * @retval #NFC_ERROR_NO_DEVICE There is no connected tag
945  */
946 int nfc_manager_get_connected_tag(nfc_tag_h *tag);
947
948 /**
949  * @brief Gets current connected p2p target
950  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
951  *
952  * @param [out] target The connected target
953  *
954  * @return 0 on success, otherwise a negative error value.
955  * @retval #NFC_ERROR_NONE Successful
956  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
957  * @retval #NFC_ERROR_NO_DEVICE There is no connected target
958  */
959 int nfc_manager_get_connected_target(nfc_p2p_target_h *target);
960
961
962 /**
963  * @brief Enable or disable the system handling for tag and target discovered event
964  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
965  * @remarks In default, The system handling is enabled.
966  *
967  * @param [in] enable The state of enable
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  *
973  * @see nfc_manager_is_system_handler_enabled()
974  */
975 int nfc_manager_set_system_handler_enable(bool enable);
976
977 /**
978  * @brief Gets the state of the system handler
979  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
980  * @remarks In default, The system handling is enabled.
981  *
982  * @return true on enabled, otherwise false.
983  *
984  * @see nfc_manager_set_system_handler_enable()
985  */
986 bool nfc_manager_is_system_handler_enabled(void);
987
988 /**
989  * @brief Sets the card emulation Secure Element type
990  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
991  * @remarks To disable card emulation mode, set NFC_SE_TYPE_DISABLE\n
992  * 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.
993  *
994  * @param [in] type The type of Secure Element
995  * @param [in] callback The callback function to invoke after this function has completed\nIt can be null if notification is not required
996  * @param [in] The user data to be passed to the callback function
997  *
998  * @return 0 on success, otherwise a negative error value.
999  * @retval #NFC_ERROR_NONE Successful
1000  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1001  *
1002  * @see nfc_manager_get_card_emulation_se_type()
1003  */
1004 int nfc_manager_set_card_emulation_se_type(nfc_se_type_e type, nfc_set_card_emulation_completed_cb callback, void* user_data);
1005
1006 /**
1007  * @brief Gets the card emulation Secure Element type
1008  * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
1009  *
1010  * @param [out] type The type of Secure Element
1011  *
1012  * @return 0 on success, otherwise a negative error value.
1013  * @retval #NFC_ERROR_NONE Successful
1014  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1015  *
1016  * @see nfc_manager_set_card_emulation_se_type()
1017  */
1018 int nfc_manager_get_card_emulation_se_type(nfc_se_type_e* type);
1019
1020 /**
1021  * @brief Creates a record with given parameter value.
1022  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
1023  *
1024  * @remarks Every data buffer is deeply copied.\n
1025  * Every data is a byte array(binary data).
1026  *
1027  * @param [out] record A handle to record
1028  * @param [in] tnf The type name format
1029  * @param [in] type The specified type name
1030  * @param [in] type_size The byte size of type
1031  * @param [in] id The record ID
1032  * @param [in] id_size The byte size of ID
1033  * @param [in] payload The payload of this record
1034  * @param [in] payload_size The byte size of payload
1035  *
1036  * @return 0 on success, otherwise a negative error value.
1037  * @retval #NFC_ERROR_NONE Successful
1038  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1039  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1040  *
1041  * @see nfc_ndef_record_create_text()
1042  * @see nfc_ndef_record_create_uri()
1043  * @see nfc_ndef_record_create_mime()
1044  * @see nfc_ndef_record_destroy()
1045  */
1046 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);
1047
1048
1049 /**
1050  * @brief Creates a record with text type payload
1051  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
1052  *
1053  * @remarks This function does not encode the text. @a text will be assumed as that it is already encoded with encode type.\n
1054  * The text buffer will be deeply copied.\n
1055  * The record is created in this format\n
1056  * - TNF : NFC_RECORD_TNF_WELL_KNOWN\n
1057  * - type : "T"\n
1058  * - payload : encode and header information + language code + text \n
1059  * Defined in Record Type Definition Technical Specifications.
1060  *
1061  * @param [out] record A handle to record
1062  * @param [in] text The encoded text
1063  * @param [in] lang_code The language code string value followed by IANA[RFC 3066] (ex: en-US, ko-KR)
1064  * @param [in] encode The encoding type
1065  *
1066  * @return 0 on success, otherwise a negative error value.
1067  * @retval #NFC_ERROR_NONE Successful
1068  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1069  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1070  *
1071  * @see nfc_ndef_record_create()
1072  * @see nfc_ndef_record_create_uri()
1073  * @see nfc_ndef_record_create_mime()
1074  * @see nfc_ndef_record_destroy()
1075  * @see nfc_ndef_record_get_text()
1076  * @see nfc_ndef_record_get_langcode()
1077  * @see nfc_ndef_record_get_encode_type()
1078  */
1079 int nfc_ndef_record_create_text(nfc_ndef_record_h *record, const char *text, const char *lang_code, nfc_encode_type_e encode);
1080
1081 /**
1082  * @brief Creates a record with URI type payload
1083  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
1084  *
1085  * @remarks The uri string will be deep copied.\n
1086  * The record is created in this format\n
1087  * - TNF : NFC_RECORD_TNF_WELL_KNOWN\n
1088  * - type : "U"\n
1089  * - payload : protocol scheme + uri\n
1090  * Defined in Record Type Definition Technical Specifications.
1091  *
1092  * @param [out] record A handle to record
1093  * @param [in] protocol_scheme  The protocol scheme
1094  * @param [in] uri      The URI string that will be stored in the payload
1095  *
1096  * @return 0 on success, otherwise a negative error value.
1097  * @retval #NFC_ERROR_NONE Successful
1098  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1099  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1100  *
1101  * @see nfc_ndef_record_create()
1102  * @see nfc_ndef_record_create_text()
1103  * @see nfc_ndef_record_create_mime()
1104  * @see nfc_ndef_record_destroy()
1105  * @see nfc_ndef_record_get_uri()
1106  */
1107 int nfc_ndef_record_create_uri(nfc_ndef_record_h* record, const char *uri);
1108
1109
1110 /**
1111  * @brief Creates a record with MIME type payload
1112  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
1113  *
1114  * @remarks The data buffer will be deep copied.\n
1115  * The data are bytes array(binary data).\n
1116  * The mime_type string will deep copied.\n
1117  * The record is created in this format\n
1118  * - TNF : NFC_RECORD_TNF_MIME_MEDIA\n
1119  * - type : mime type\n
1120  * - payload : data\n
1121  * Defined in Record Type Definition Technical Specifications.
1122  *
1123  * @param [out] record A handle to record
1124  * @param [in] mime_type        The mime type [RFC 2046] (ex. text/plain, image/jpeg )\nThis value is stored in type field
1125  * @param [in] data     The pointer of data
1126  * @param [in] data_size        The size of data
1127  *
1128  * @return 0 on success, otherwise a negative error value.
1129  * @retval #NFC_ERROR_NONE Successful
1130  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1131  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1132  *
1133  * @see nfc_ndef_record_create()
1134  * @see nfc_ndef_record_create_uri()
1135  * @see nfc_ndef_record_create_text()
1136  * @see nfc_ndef_record_destroy()
1137  * @see nfc_ndef_record_get_mime_type()
1138  */
1139 int nfc_ndef_record_create_mime(nfc_ndef_record_h* record, const char *mime_type, const unsigned char *data, int data_size);
1140
1141
1142 /**
1143  * @brief Destroys the record handle
1144  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
1145  *
1146  * @param [in] record The handle to record
1147  *
1148  * @return 0 on success, otherwise a negative error value.
1149  * @retval #NFC_ERROR_NONE Successful
1150  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1151  *
1152  * @see nfc_ndef_record_create()
1153  * @see nfc_ndef_record_create_text()
1154  * @see nfc_ndef_record_create_uri()
1155  * @see nfc_ndef_record_create_mime()
1156  */
1157 int nfc_ndef_record_destroy(nfc_ndef_record_h record);
1158
1159 /**
1160  * @brief Sets record ID
1161  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
1162  *
1163  * @remarks The ID buffer are deep copied.
1164  *
1165  * @param [in] record The handle to record
1166  * @param [in] id The record ID
1167  * @param [in] id_size The size of ID in bytes
1168  *
1169  * @return 0 on success, otherwise a negative error value.
1170  * @retval      #NFC_ERROR_NONE Successful
1171  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1172  *
1173  * @see nfc_ndef_record_get_id()
1174  */
1175 int nfc_ndef_record_set_id(nfc_ndef_record_h record, unsigned char *id, int id_size);
1176
1177 /**
1178  * @brief Gets record ID
1179  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
1180  *
1181  * @remarks It may return NULL pointer if the ID is not exist\n
1182  *  This function gives you  the pointer of ID that is contained by record\n
1183  *  Do not free the ID. It will be released when @a record is destroyed by nfc_ndef_record_destroy().
1184  *
1185  * @param [in] record The handle to record
1186  * @param [out] id The record ID ( do not free )
1187  * @param [out] id_size The size of ID in bytes
1188  *
1189  * @return 0 on success, otherwise a negative error value.
1190  * @retval #NFC_ERROR_NONE Successful
1191  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1192  *
1193  * @see nfc_ndef_record_set_id()
1194  */
1195 int nfc_ndef_record_get_id(nfc_ndef_record_h record, unsigned char **id, int *size);
1196
1197 /**
1198  * @brief Gets record payload.
1199  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
1200  *
1201  * @remarks This function gives you  the pointer of payload that is contained by record\n
1202  * Do not free the payload. it will be freed when @a record is destroyed by nfc_ndef_record_destroy().
1203  *
1204  * @param [in] record The handle to record
1205  * @param [out] payload The payload  ( do not free this pointer )
1206  * @param [out] size the size of payload in byte
1207  *
1208  * @return 0 on success, otherwise a negative error value.
1209  * @retval #NFC_ERROR_NONE Successful
1210  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1211  */
1212 int nfc_ndef_record_get_payload(nfc_ndef_record_h record, unsigned char ** payload, unsigned int *size);
1213
1214 /**
1215  * @brief Gets record type.
1216  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
1217  *
1218  * @remarks This function gives you  the pointer of type that is contained by record.\n
1219  * Do not free the type. it will be freed when the record is freed.
1220  *
1221  * @param [in] record The handle to record
1222  * @param [out] type    The record type  ( do not free this pointer )
1223  * @param [out] size The size of type in byte
1224  *
1225  * @return 0 on success, otherwise a negative error value.
1226  * @retval #NFC_ERROR_NONE Successful
1227  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1228  */
1229 int nfc_ndef_record_get_type(nfc_ndef_record_h record, unsigned char **type, int *size);
1230
1231 /**
1232  * @brief Gets record TNF(Type Name Format) value.
1233  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
1234  *
1235  * @param [in] record The handle to record
1236  * @param [out] tnf The TNF(Type Name Format) value
1237  *
1238  * @return 0 on success, otherwise a negative error value.
1239  * @retval #NFC_ERROR_NONE Successful
1240  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1241  */
1242 int nfc_ndef_record_get_tnf(nfc_ndef_record_h record, nfc_record_tnf_e *tnf);
1243
1244 /**
1245  * @brief Gets text from text record
1246  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
1247  *
1248  * @remarks This function returns newly allocated string, this value must be deallocated by caller.\n
1249  * This function is valid only for text type record.\n
1250  * The text type record 's tnf is NFC_RECORD_TNF_WELL_KNOWN and it's type is "T"
1251  *
1252  * @param [in] record The handle to record
1253  * @param [out] text The text in record payload ( should be freed by caller )
1254  *
1255  * @return 0 on success, otherwise a negative error value.
1256  * @retval #NFC_ERROR_NONE Successful
1257  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1258  * @retval #NFC_ERROR_INVALID_RECORD_TYPE Invalid record type
1259  *
1260  * @see nfc_ndef_record_create_text()
1261  */
1262 int nfc_ndef_record_get_text(nfc_ndef_record_h record, char **text);
1263
1264 /**
1265  * @brief Gets language code from text record
1266  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
1267  * @remarks This function returns newly allocated string, this value must be deallocated by caller.\n
1268  * This function is valid only for text type record.\n
1269  * The text type record 's tnf is NFC_RECORD_TNF_WELL_KNOWN and it's type is "T"
1270  *
1271  * @param [in] record   The handle to record
1272  * @param [out] lang_code lang code ( should be freed by caller )
1273  *
1274  * @return 0 on success, otherwise a negative error value.
1275  * @retval #NFC_ERROR_NONE Successful
1276  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1277  * @retval #NFC_ERROR_INVALID_RECORD_TYPE Invalid record type
1278  *
1279  * @see nfc_ndef_record_create_text()
1280  */
1281 int nfc_ndef_record_get_langcode(nfc_ndef_record_h record, char **lang_code);
1282
1283 /**
1284  * @brief Gets encoding type from text record
1285  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
1286  *
1287  * @remarks  This function is valid only for text type record.\n
1288  * The text type record 's tnf is NFC_RECORD_TNF_WELL_KNOWN and it's type is "T"
1289  *
1290  * @param [in] record   The handle to record
1291  * @param [out] encode encode type #nfc_encode_type_e
1292  *
1293  * @return 0 on success, otherwise a negative error value.
1294  * @retval #NFC_ERROR_NONE Successful
1295  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1296  * @retval #NFC_ERROR_INVALID_RECORD_TYPE Invalid record type
1297  *
1298  * @see nfc_ndef_record_create_text()
1299  */
1300 int nfc_ndef_record_get_encode_type(nfc_ndef_record_h record, nfc_encode_type_e *encode);
1301
1302 /**
1303  * @brief Gets URI from uri record
1304  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
1305  *
1306  * @remarks The function returns newly allocated string, this value must be deallocated by caller.\n
1307  * This function is valid only for uri type record.
1308  * The uri type record 's tnf is NFC_RECORD_TNF_WELL_KNOWN and it's type is "U"
1309  *
1310  * @param [in] record   The handle to record
1311  * @param [out] uri     The uri in record payload ( should be freed by caller )
1312  *
1313  * @return 0 on success, otherwise a negative error value.
1314  * @retval #NFC_ERROR_NONE Successful
1315  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1316  * @retval #NFC_ERROR_INVALID_RECORD_TYPE Invalid record type
1317  *
1318  * @see nfc_ndef_record_create_uri()
1319  */
1320 int nfc_ndef_record_get_uri(nfc_ndef_record_h record, char **uri);
1321
1322
1323 /**
1324  * @brief Gets mime type from mime type record
1325  * @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
1326  *
1327  * @remarks The function returns newly allocated string, this value must be deallocated by caller.\n
1328  * This function is valid only for mime type record.\n
1329  * The uri type record 's tnf is NFC_RECORD_TNF_MIME_MEDIA.
1330  *
1331  * @param [in] record   The handle to record
1332  * @param [out] mime_type       The mime type in record payload ( should be freed by caller )
1333  *
1334  * @return 0 on success, otherwise a negative error value.
1335  * @retval #NFC_ERROR_NONE Successful
1336  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1337  * @retval #NFC_ERROR_INVALID_RECORD_TYPE Invalid record type
1338  *
1339  * @see nfc_ndef_record_create_mime()
1340  */
1341 int nfc_ndef_record_get_mime_type(nfc_ndef_record_h record, char **mime_type);
1342
1343
1344 /**
1345  * @brief Creates NDEF message handle
1346  * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
1347  *
1348  * @param [out] ndef_message A handle to NDEF message
1349  *
1350  * @return 0 on success, otherwise a negative error value.
1351  * @retval #NFC_ERROR_NONE Successful
1352  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1353  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1354  *
1355  * @see nfc_ndef_message_create_from_rawdata()
1356  * @see nfc_ndef_message_destroy()
1357  */
1358 int nfc_ndef_message_create(nfc_ndef_message_h *ndef_message);
1359
1360 /**
1361  * @brief Creates NDEF message handle from raw serial bytes.
1362  * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
1363  *
1364  * @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
1365  * *The ME flag is a 1-bit field that when set indicates the end of an NDEF message.
1366  *
1367  * @param [out] ndef_message The handle to NDEF message
1368  * @param [in] rawdata The NDEF message in form of bytes array
1369  * @param [in] rawdata_size The size of bytes array
1370  *
1371  * @return 0 on success, otherwise a negative error value.
1372  * @retval #NFC_ERROR_NONE Successful
1373  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1374  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1375  *
1376  * @see nfc_ndef_message_create()
1377  * @see nfc_ndef_message_destroy()
1378  * @see nfc_ndef_message_get_rawdata()
1379  */
1380 int nfc_ndef_message_create_from_rawdata(nfc_ndef_message_h *ndef_message,
1381                 const unsigned char *rawdata, unsigned int rawdata_size);
1382
1383 /**
1384  * @brief Destroys NDEF message handle
1385  * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
1386  *
1387  * @remarks This function will free all these memory including record handles.
1388  *
1389  * @param [in] ndef_message The handle to NDEF message to destroy
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  *
1395  * @see nfc_ndef_message_create()
1396  * @see nfc_ndef_message_create_from_rawdata()
1397  */
1398 int nfc_ndef_message_destroy(nfc_ndef_message_h ndef_message);
1399
1400 /**
1401  * @brief Gets the number of record in NDEF message
1402  * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
1403  *
1404  * @param [in] ndef_message The handle to NDEF message
1405  * @param [out] count The number of record
1406  *
1407  * @return 0 on success, otherwise a negative error value.
1408  * @retval #NFC_ERROR_NONE Successful
1409  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1410  */
1411 int nfc_ndef_message_get_record_count(nfc_ndef_message_h ndef_message, int *count);
1412
1413 /**
1414  * @brief Gets serial bytes array of NDEF message.
1415  * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
1416  *
1417  * @remarks It gets copy of the bytes array from NDEF message. @a rawdata must be released with free() by you.
1418  *
1419  * @param [in] ndef_message The handle to NDEF message
1420  * @param [out] rawdata The bytes array of bytes array
1421  * @param [out] rawdata_size The size of bytes array in byte
1422  *
1423  * @return 0 on success, otherwise a negative error value.
1424  * @retval #NFC_ERROR_NONE Successful
1425  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1426  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1427  * @retval #NFC_ERROR_INVALID_NDEF_MESSAGE Invalid NDEF message
1428  *
1429  * @see nfc_ndef_message_create_from_rawdata()
1430  */
1431 int nfc_ndef_message_get_rawdata(nfc_ndef_message_h ndef_message,
1432                 unsigned char **rawdata, unsigned int *rawdata_size);
1433
1434 /**
1435  * @brief Appends a record into NDEF message
1436  * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
1437  *
1438  * @remarks Appended record is handled by frameworks. The record is released by frameworks when message is released.
1439  *
1440  * @param [in] ndef_message The handle to NDEF message
1441  * @param [in] record The record that will be appended into NDEF message
1442  *
1443  * @return 0 on success, otherwise a negative error value.
1444  * @retval #NFC_ERROR_NONE Successful
1445  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1446  *
1447  * @see nfc_ndef_message_insert_record()
1448  * @see nfc_ndef_message_remove_record()
1449  */
1450 int nfc_ndef_message_append_record(nfc_ndef_message_h ndef_message, nfc_ndef_record_h record);
1451
1452 /**
1453  * @brief Inserts a record at index into NDEF message
1454  * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
1455  *
1456  * @remarks Appended record is handled by frameworks. The record is released by frameworks when message is released.\n
1457  * The index value should not bigger than nfc_ndef_message_get_record_count()
1458  *
1459  * @param [in] ndef_message The handle to NDEF message
1460  * @param [in] index The index of record ( starts from 0 )
1461  * @param [in] record The record that will be appended into NDEF message
1462  *
1463  * @return 0 on success, otherwise a negative error value.
1464  * @retval #NFC_ERROR_NONE Successful
1465  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1466  * @retval #NFC_ERROR_INVALID_NDEF_MESSAGE      Invalid NDEF message
1467  *
1468  * @see nfc_ndef_message_append_record()
1469  * @see nfc_ndef_message_remove_record()
1470  */
1471 int nfc_ndef_message_insert_record(nfc_ndef_message_h ndef_message, int index, nfc_ndef_record_h record);
1472
1473 /**
1474  * @brief Removes the record that indicated by index number and this deleted record will be freed.
1475  * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
1476  *
1477  * @param [in] ndef_message The handle to NDEF message
1478  * @param [in] index    The index of record ( starts from 0 )
1479  *
1480  * @return 0 on success, otherwise a negative error value.
1481  * @retval #NFC_ERROR_NONE Successful
1482  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1483  * @retval #NFC_ERROR_INVALID_NDEF_MESSAGE      Invalid NDEF message
1484  *
1485  * @see nfc_ndef_message_append_record()
1486  * @see nfc_ndef_message_insert_record()
1487  */
1488 int nfc_ndef_message_remove_record(nfc_ndef_message_h ndef_message, int index);
1489
1490 /**
1491  * @brief Gets record by index.
1492  * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
1493  *
1494  * @remarks This function just return the pointer of record. if you change the record value it directly affects the NDEF message
1495  *
1496  * @param [in] ndef_message The handle to NDEF message
1497  * @param [in] index The index of record ( starts from 0 )
1498  * @param [out] record The handle to record
1499  *
1500  * @return 0 on success, otherwise a negative error value.
1501  * @retval #NFC_ERROR_NONE Successful
1502  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1503  */
1504 int nfc_ndef_message_get_record(nfc_ndef_message_h ndef_message, int index, nfc_ndef_record_h *record);
1505
1506 /**
1507  * @brief Gets the type of NFC tag
1508  * @ingroup CAPI_NETWORK_NFC_TAG_MODULE
1509  *
1510  * @param [in] tag The handle to NFC tag
1511  * @param [out] type The type of NFC tag
1512  *
1513  * @return 0 on success, otherwise a negative error value.
1514  * @retval #NFC_ERROR_NONE Successful
1515  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1516  */
1517 int nfc_tag_get_type(nfc_tag_h tag, nfc_tag_type_e *type);
1518
1519 /**
1520  * @brief Checks whether the given NFC tag supports NDEF messages.
1521  * @ingroup CAPI_NETWORK_NFC_TAG_MODULE
1522  *
1523  * @param [in] tag The handle to NFC tag
1524  * @param [out] is_supported @c true when NFC tag supports NDEF messages, otherwise @c false
1525  *
1526  * @return 0 on success, otherwise a negative error value.
1527  * @retval #NFC_ERROR_NONE Successful
1528  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1529  *
1530  * @see nfc_tag_read_ndef()
1531  */
1532 int nfc_tag_is_support_ndef(nfc_tag_h tag, bool *is_supported);
1533
1534 /**
1535  * @brief Gets the maximum NDEF message size that can be stored in NFC tag.
1536  * @ingroup CAPI_NETWORK_NFC_TAG_MODULE
1537  *
1538  * @remarks This max size indicates the maximum size of NDEF message that can be stored in this detected tag.
1539  *
1540  * @param [in] tag The handle to NFC tag
1541  * @param [out] maximum_ndef_bytes_size The maximum bytes size of NDEF message that can be stored in this detected tag.
1542  *
1543  * @return 0 on success, otherwise a negative error value.
1544  * @retval #NFC_ERROR_NONE Successful
1545  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1546  */
1547 int nfc_tag_get_maximum_ndef_size(nfc_tag_h tag, unsigned int *maximum_ndef_bytes_size);
1548
1549 /**
1550  * @brief Gets size of NDEF message that stored in the tag
1551  * @ingroup CAPI_NETWORK_NFC_TAG_MODULE
1552  *
1553  * @param [in] tag The handle to NFC tag
1554  * @param [out] ndef_bytes_size The NDEF message bytes size that stored in the tag
1555  *
1556  * @return 0 on success, otherwise a negative error value.
1557  * @retval #NFC_ERROR_NONE Successful
1558  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1559  *
1560  */
1561 int nfc_tag_get_ndef_size(nfc_tag_h tag, unsigned int *ndef_bytes_size);
1562
1563
1564 /**
1565  * @brief Retrieves all tag information
1566  * @ingroup CAPI_NETWORK_NFC_TAG_MODULE
1567  *
1568  * @param[in] tag The handle to NFC tag
1569  * @param[in] callback  The callback function to invoke
1570  * @param[in] user_data The user data to be passed to the callback function
1571  *
1572  * @return 0 on success, otherwise a negative error value.
1573  * @retval #NFC_ERROR_NONE Successful
1574  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1575  *
1576  */
1577 int nfc_tag_foreach_information(nfc_tag_h tag, nfc_tag_information_cb callback, void *user_data);
1578
1579
1580 /**
1581  * @brief Transceives the data of the raw format card.
1582  * @details This function is the only way to access the raw format card (not formated),
1583         each tag type requires own command to access tags. \n
1584         This function provides the low level access of tag operation and you require the knowledge of each tag technology.
1585 * @ingroup CAPI_NETWORK_NFC_TAG_MODULE
1586 *
1587 * @param [in] tag The handle to NFC tag
1588 * @param [in] buffer The binary data for parameter or additional commands
1589 * @param [in] buffer_size The size of buffer in bytes
1590 * @param [in] callback The callback function to invoke after this function has completed\n It can be null if a notification is not required
1591 * @param [in] user_data The user data to be passed to the callback function
1592 *
1593 * @return 0 on success, otherwise a negative error value.
1594 * @retval #NFC_ERROR_NONE Successful
1595 * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1596 * @retval #NFC_ERROR_INVALID_PARAMETER  Invalid parameter
1597 * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
1598 * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
1599 * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag
1600 * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
1601 *
1602 * @post It invokes nfc_tag_transceive_completed_cb() when it has completed to t
1603 * @see nfc_tag_read_ndef()
1604 * @see nfc_tag_is_support_ndef()
1605 */
1606 int nfc_tag_transceive(nfc_tag_h tag, unsigned char *buffer, int buffer_size, nfc_tag_transceive_completed_cb callback, void *user_data);
1607
1608 /**
1609  * @brief Reads NDEF formatted data from NFC tag.
1610  * @ingroup CAPI_NETWORK_NFC_TAG_MODULE
1611  *
1612  * @param [in] tag The handle to NFC tag
1613  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
1614  * @param [in] user_data The user data to be passed to the callback function
1615  *
1616  * @return 0 on success, otherwise a negative error value.
1617  * @retval #NFC_ERROR_NONE Successful
1618  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1619  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1620  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
1621  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
1622  * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag
1623  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
1624  * @retval #NFC_ERROR_NOT_NDEF_FORMAT Not ndef format tag
1625  *
1626  * @post It invokes nfc_tag_read_completed_cb() when it has completed to read NDEF formatted data.
1627  *
1628  * @see nfc_tag_transceive()
1629  * @see nfc_tag_is_support_ndef()
1630  * @see nfc_tag_write_ndef()
1631  */
1632 int nfc_tag_read_ndef(nfc_tag_h tag, nfc_tag_read_completed_cb callback, void *user_data);
1633
1634 /**
1635  * @brief Writes NDEF formatted data.
1636  * @ingroup CAPI_NETWORK_NFC_TAG_MODULE
1637  *
1638  * @param [in] tag The handle to NFC tag
1639  * @param [in] msg The message will be write to the tag
1640  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
1641  * @param [in] user_dataa The user data to be passed to the callback function
1642  *
1643  * @return 0 on success, otherwise a negative error value.
1644  * @retval #NFC_ERROR_NONE Successful
1645  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1646  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1647
1648  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
1649  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
1650  * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag
1651  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
1652  * @retval #NFC_ERROR_NOT_NDEF_FORMAT Not ndef format tag
1653  *
1654  * @post It invokes nfc_tag_write_completed_cb() when it has completed to write NDEF data.
1655  * @see nfc_tag_is_support_ndef()
1656  * @see nfc_tag_read_ndef()
1657  */
1658 int nfc_tag_write_ndef(nfc_tag_h tag, nfc_ndef_message_h msg, nfc_tag_write_completed_cb callback, void *user_data);
1659
1660 /**
1661  * @brief Formats the detected tag that can store NDEF message.
1662  * @details Some tags are required authentication. If the detected target doesn't need authentication, @a key can be NULL.
1663  * @ingroup CAPI_NETWORK_NFC_TAG_MODULE
1664  *
1665  * @param [in] tag The handle to NFC tag
1666  * @param [in] key The key value that may need to format the tag
1667  * @param [in] key_size The size of key in byte
1668  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
1669  * @param [in] user_data The user data to be passed to the callback function
1670  *
1671  * @return 0 on success, otherwise a negative error value.
1672  * @retval #NFC_ERROR_NONE Successful
1673  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1674  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1675  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
1676  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
1677  * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag
1678  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
1679  * @retval #NFC_ERROR_NOT_NDEF_FORMAT Not ndef format tag
1680  *
1681  * @post It invokes nfc_tag_format_completed_cb() when it has completed to format the NFC tag.
1682  *
1683  * @see nfc_tag_is_support_ndef()
1684  */
1685 int nfc_tag_format_ndef(nfc_tag_h tag, unsigned char *key, int key_size, nfc_tag_format_completed_cb callback, void *user_data);
1686
1687 /**
1688  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
1689  * @brief Authenticates a sector with key A.
1690  * @remarks I/O operations(read / write / increment / decrement / transfer / restore) will be available after successful authentication.\n
1691  * This function is only available for MIFARE classic.\n
1692  *      \n
1693  *      MIFARE CLASSIC MINI \n
1694  *              => 0 ~ 4 : 5 sectors having 4 block each with block size of 16 bytes \n
1695  *      \n
1696  *      MIFARE CLASSIC 1K \n
1697  *              => 0 ~ 15 : 16 sectors having 4 block each with block size of 16 bytes \n
1698  *      \n
1699  *      MIFARE CLASSIC 4K \n
1700  *              => 0 ~ 31 : 32 sectors having 4 block each with block size of 16 bytes  \n
1701  *              => 32 ~ 39 : 8 sectors having 16 block each with block size of 16 bytes
1702  *
1703  * @param[in] tag The handle to NFC tag
1704  * @param[in] sector_index The index of sector to authenticate with key A, starting from 0
1705  * @param[in] auth_key 6-byte authentication key
1706  * @param[in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
1707  * @param[in] user_data The user data to be passed to the callback function
1708  *
1709  * @return 0 on success, otherwise a negative error value.
1710  * @retval #NFC_ERROR_NONE Successful
1711  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1712  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1713  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
1714  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
1715  * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag
1716  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
1717  *
1718  * @post It invokes nfc_mifare_authenticate_with_keyA_completed_cb() when it has completed to authenticate the given sector with key A.
1719  * @see nfc_mifare_authenticate_with_keyB()
1720  * @see nfc_mifare_read_block()
1721  * @see nfc_mifare_read_page()
1722  * @see nfc_mifare_write_block()
1723  * @see nfc_mifare_write_page()
1724  * @see nfc_mifare_increment()
1725  * @see nfc_mifare_decrement()
1726 */
1727 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);
1728
1729
1730 /**
1731  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
1732  * @brief Authenticates a sector with key B.
1733  * @remarks I/O operations(read / write / increment / decrement / transfer / restore) will be available after successful authentication.\n
1734  * This function is only available for MIFARE classic.\n
1735  *      \n
1736  *      MIFARE CLASSIC MINI\n
1737  *              => 0 ~ 4 : 5 sector and 4 block with 16 bytes\n
1738  *      \n
1739  *      MIFARE CLASSIC 1K \n
1740  *              => 0 ~ 15 : 16 sector and 4 block with 16 bytes\n
1741  *      \n
1742  *      MIFARE CLASSIC 4K\n
1743  *              => 0 ~ 31 : 32 sector and 4 block with 16 bytes \n
1744  *              => 32 ~ 39 : 8 sector and 16 block with 16 bytes
1745  *
1746  * @param [in] tag The handle to NFC tag
1747  * @param [in] sector_index The index of sector to authenticate with key B, starting from 0
1748  * @param [in] auth_key 6-byte authentication key
1749  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
1750  * @param [in] user_data The user data to be passed to the callback function
1751  *
1752  * @return 0 on success, otherwise a negative error value.
1753  * @retval #NFC_ERROR_NONE Successful
1754  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1755  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1756  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
1757  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
1758  * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag
1759  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
1760  *
1761  * @post It invokes nfc_mifare_authenticate_with_keyB_completed_cb() when it has completed to authenticate the given sector with key B.
1762  * @see nfc_mifare_authenticate_with_keyA()
1763  * @see nfc_mifare_read_block()
1764  * @see nfc_mifare_read_page()
1765  * @see nfc_mifare_write_block()
1766  * @see nfc_mifare_write_page()
1767  * @see nfc_mifare_increment()
1768  * @see nfc_mifare_decrement()
1769 */
1770 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);
1771
1772
1773 /**
1774  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
1775  * @brief Reads a 16-byte block.
1776  * @remarks This function is only available for MIFARE classic.
1777  *
1778  * @param [in] tag The handle to NFC tag
1779  * @param [in] block_index The block or starting page number
1780  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
1781  * @param [in] user_data The user data to be passed to the callback function
1782  *
1783  * @return 0 on success, otherwise a negative error value.
1784  * @retval #NFC_ERROR_NONE Successful
1785  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1786  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1787  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
1788  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
1789  * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag
1790  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
1791  *
1792  * @post It invokes nfc_mifare_read_block_completed_cb() when it has completed to read a block.
1793  * @see nfc_mifare_read_page()
1794  * @see nfc_mifare_write_block()
1795 */
1796 int nfc_mifare_read_block(nfc_tag_h tag, int block_index, nfc_mifare_read_block_completed_cb callback, void *user_data);
1797
1798 /**
1799  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
1800  * @brief Reads 4 pages(16 bytes).
1801  * @remarks This function is only available for MIFARE Ultra light.\n
1802  * The MIFARE Ultralight protocol always reads 4 pages at a time, to reduce the number of commands required to read an entire tag.
1803  *
1804  * @param [in] tag The handle to NFC tag
1805  * @param [in] page_index  The index of page to read, starting from 0
1806  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
1807  * @param [in] user_data The user data to be passed to the callback function
1808  *
1809  *
1810  * @return 0 on success, otherwise a negative error value.
1811  * @retval #NFC_ERROR_NONE Successful
1812  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1813  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1814  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
1815  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
1816  * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag
1817  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
1818  *
1819  * @post It invokes nfc_mifare_read_page_completed_cb() when it has completed to read a page.
1820  * @see nfc_mifare_read_block()
1821  * @see nfc_mifare_write_page()
1822 */
1823 int nfc_mifare_read_page(nfc_tag_h tag, int page_index, nfc_mifare_read_page_completed_cb callback, void *user_data);
1824
1825 /**
1826  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
1827  * @brief Writes block (16 byte) of data to the tag at a given block index.
1828  * @remarks This function is only available for MIFARE classic.
1829  *
1830  * @param [in] tag The handle to NFC tag
1831  * @param [in] block_index The index of block to read, starting from 0
1832  * @param [in] buffer 16 bytes of data to write
1833  * @param [in] buffer_size The size of buffer in bytes
1834  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
1835  * @param [in] user_data The user data to be passed to the callback function
1836  *
1837  * @return 0 on success, otherwise a negative error value.
1838  * @retval #NFC_ERROR_NONE Successful
1839  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1840  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1841  * @retval #NFC_ERROR_NOT_INITIALIZED Not initialized
1842  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
1843  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
1844  * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag
1845  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
1846  *
1847  * @post It invokes nfc_mifare_write_block_completed_cb() when it has completed to write a block.
1848  *
1849  * @see nfc_mifare_write_page()
1850  * @see nfc_mifare_read_block()
1851 */
1852 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);
1853
1854 /**
1855  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
1856  * @brief Writes a page (4 bytes) of data to the tag at a given page index
1857  * @remarks This function is only available for MIFARE Ultra light
1858  *
1859  * @param [in] tag The handle to NFC tag
1860  * @param [in] page_index The index of page to write, starting from 0
1861  * @param [in] buffer 4 bytes of data to write
1862  * @param [in] buffer_size The size of buffer in bytes
1863  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
1864  * @param [in] user_data The user data to be passed to the callback function
1865  *
1866  * @return 0 on success, otherwise a negative error value.
1867  * @retval #NFC_ERROR_NONE Successful
1868  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1869  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1870  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
1871  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
1872  * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag
1873  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
1874  *
1875  * @post It invokes nfc_mifare_write_page_completed_cb() when it has completed to write a page.
1876  *
1877  * @see nfc_mifare_write_block()
1878  * @see nfc_mifare_read_page()
1879 */
1880 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);
1881
1882 /**
1883  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
1884  * @brief Increases a value block, storing the result in the temporary block on the tag.
1885  * @remarks This function is only available for MIFARE classic
1886  *
1887  * @param [in] tag The handle to NFC tag
1888  * @param [in] block_index The index of block to increase, starting from 0
1889  * @param [in] value Non-negative to increment by
1890  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
1891  * @param [in] user_data The user data to be passed to the callback function
1892  *
1893  * @return 0 on success, otherwise a negative error value.
1894  * @retval #NFC_ERROR_NONE Successful
1895  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1896  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1897  * @retval #NFC_ERROR_NOT_INITIALIZED Not initialized
1898  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
1899  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
1900  * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag
1901  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
1902  *
1903  * @see nfc_mifare_decrement()
1904  * @see nfc_mifare_write_block()
1905 */
1906 int nfc_mifare_increment(nfc_tag_h tag, int block_index, int value, nfc_mifare_increment_completed_cb callback, void *user_data);
1907
1908 /**
1909  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
1910  * @brief Decreases a value block, storing the result in the temporary block on the tag.
1911  * @remarks  This function is only available for MIFARE classic
1912  *
1913  * @param [in] tag The handle to NFC tag
1914  * @param [in] block_index The index of block to decrease, starting from 0
1915  * @param [in] value non-negative to decrement by
1916  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
1917  * @param [in] user_data The user data to be passed to the callback function
1918  *
1919  * @return 0 on success, otherwise a negative error value.
1920  * @retval #NFC_ERROR_NONE Successful
1921  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1922  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1923  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
1924  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
1925  * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag
1926  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
1927  *
1928  * @see nfc_mifare_increment()
1929  * @see nfc_mifare_write_block()
1930 */
1931 int nfc_mifare_decrement(nfc_tag_h tag, int block_index, int value, nfc_mifare_decrement_completed_cb callback, void *user_data);
1932
1933 /**
1934  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
1935  * @brief Copy from the temporary block to the specified block.
1936  * @remarks This function is only available for MIFARE classic
1937  *
1938  * @param [in] tag The handle to NFC tag
1939  * @param [in] block_index The index of block to copy to, starting from 0
1940  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
1941  * @param [in] user_data The user data to be passed to the callback function
1942  *
1943  * @return 0 on success, otherwise a negative error value.
1944  * @retval #NFC_ERROR_NONE Successful
1945  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1946  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1947  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
1948  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
1949  * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag
1950  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
1951  *
1952  * @see nfc_mifare_restore()
1953 */
1954 int nfc_mifare_transfer(nfc_tag_h tag, int block_index, nfc_mifare_transfer_completed_cb callback, void *user_data);
1955
1956 /**
1957  * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE
1958  * @brief Copy from a value block to the temporary block.
1959  * @remarks This function is only available for MIFARE classic
1960  *
1961  * @param [in] tag The handle to NFC tag
1962  * @param [in] block_index The index of block to copy from, starting from 0
1963  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
1964  * @param [in] user_data The user data to be passed to the callback function
1965  *
1966  * @return 0 on success, otherwise a negative error value.
1967  * @retval #NFC_ERROR_NONE Successful
1968  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
1969  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1970  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
1971  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
1972  * @retval #NFC_ERROR_TIMED_OUT Timeout is reached while communicating with tag
1973  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
1974  *
1975  * @see nfc_mifare_transfer()
1976 */
1977 int nfc_mifare_restore(nfc_tag_h tag, int block_index, nfc_mifare_restore_completed_cb callback, void *user_data);
1978
1979
1980 /**
1981  * @brief Registers a callback function for receiving data from NFC peer-to-peer target.
1982  * @ingroup CAPI_NETWORK_NFC_P2P_MODULE
1983  *
1984  * @param [in] target The handle to peer target
1985  * @param [in] callback The callback function to invoke when an NDEF Message is discovered
1986  * @param [in] user_data The user data to be passed to the callback function
1987  *
1988  * @return 0 on success, otherwise a negative error value.
1989  * @retval #NFC_ERROR_NONE Successful
1990  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
1991  *
1992  * @see nfc_p2p_unset_data_received_cb()
1993  * @see nfc_p2p_data_recived_cb()
1994  * @see nfc_p2p_target_discovered_cb()
1995  */
1996 int nfc_p2p_set_data_received_cb(nfc_p2p_target_h target, nfc_p2p_data_recived_cb callback, void *user_data);
1997
1998 /**
1999  * @brief Unregisters the callback function.
2000  * @ingroup CAPI_NETWORK_NFC_P2P_MODULE
2001  *
2002  * @param [in] target The handle to peer target
2003  *
2004  * @return 0 on success, otherwise a negative error value.
2005  * @retval #NFC_ERROR_NONE Successful
2006  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
2007  *
2008  * @see nfc_p2p_set_data_received_cb()
2009  * @see nfc_p2p_data_recived_cb()
2010  * @see nfc_p2p_target_discovered_cb()
2011  */
2012 int nfc_p2p_unset_data_received_cb(nfc_p2p_target_h target);
2013
2014 /**
2015  * @brief Sends data to NFC peer-to-peer target
2016  * @ingroup CAPI_NETWORK_NFC_P2P_MODULE
2017  *
2018  * @param [in] tag The handle to NFC tag
2019  * @param [in] message The message to send
2020  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
2021  * @param [in] user_data The user data to be passed to the callback function
2022  *
2023  * @return 0 on success, otherwise a negative error value.
2024  * @retval #NFC_ERROR_NONE Successful
2025  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
2026  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
2027  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
2028  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
2029  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
2030  *
2031  * @see nfc_p2p_send_completed_cb()
2032  * @see nfc_p2p_target_discovered_cb()
2033 */
2034 int nfc_p2p_send(nfc_p2p_target_h target, nfc_ndef_message_h message, nfc_p2p_send_completed_cb callback, void *user_data);
2035
2036
2037 /**
2038  * @brief Sends data to NFC peer-to-peer target without permission check
2039  * @ingroup CAPI_NETWORK_NFC_P2P_MODULE
2040  *
2041  * @param [in] tag The handle to NFC tag
2042  * @param [in] message The message to send
2043  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
2044  * @param [in] user_data The user data to be passed to the callback function
2045  *
2046  * @return 0 on success, otherwise a negative error value.
2047  * @retval #NFC_ERROR_NONE Successful
2048  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
2049  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
2050  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
2051  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
2052  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
2053  *
2054  * @see nfc_p2p_send_completed_cb()
2055  * @see nfc_p2p_target_discovered_cb()
2056 */
2057 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);
2058
2059
2060
2061 /**
2062  * @brief NFC Connection handover between NFC peer-to-peer target
2063  * @ingroup CAPI_NETWORK_NFC_P2P_MODULE
2064  *
2065  * @param [in] target The handle to NFC device
2066  * @param [in] type Preferred Alternative Carrier
2067  * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required
2068  * @param [in] user_data The user data to be passed to the callback function
2069  *
2070  * @return 0 on success, otherwise a negative error value.
2071  * @retval #NFC_ERROR_NONE Successful
2072  * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory
2073  * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
2074  * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
2075  * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request
2076  * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated
2077  *
2078  * @see nfc_p2p_connection_handover_completed_cb()
2079 */
2080 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);
2081
2082 /**
2083  * @brief Check available Alternative Carrier(AC) for NFC handover between NFC peer-to-peer target
2084  * @ingroup CAPI_NETWORK_NFC_P2P_MODULE
2085  *
2086  * @param [in] carrier Alternative Carrier when to be checked whether supported or not
2087  *
2088  * @retval #true Supported
2089  * @retval #false Not Supported
2090  *
2091  * @see nfc_p2p_is_supported_ac_type()
2092 */
2093 bool nfc_p2p_is_supported_ac_type( nfc_ac_type_e carrior);
2094
2095
2096 #ifdef __cplusplus
2097 }
2098 #endif
2099
2100
2101 #endif /* __NFC_H__ */
2102