Tizen Native API
5.0
|
The peer to peer api provide functions to exchange NDEF data with peer target.
Required Header
#include <nfc.h>
Overview
The peer to peer api provides functions to exchange NDEF data with the peer target.
- send ndef message
- receive ndef message
Related Features
This API is related with the following features:
It is recommended to design feature related codes in your application for reliability.
You can check if a device supports the related features for this API by using System Information, thereby controlling the procedure of your application.
To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.
More details on featuring your application can be found from Feature Element.
Functions | |
int | nfc_p2p_set_data_received_cb (nfc_p2p_target_h target, nfc_p2p_data_received_cb callback, void *user_data) |
Registers a callback function for receiving data from NFC peer-to-peer target. | |
int | nfc_p2p_unset_data_received_cb (nfc_p2p_target_h target) |
Unregisters the callback function. | |
int | nfc_p2p_send (nfc_p2p_target_h target, nfc_ndef_message_h message, nfc_p2p_send_completed_cb callback, void *user_data) |
Sends data to NFC peer-to-peer target. | |
int | nfc_snep_start_server (nfc_p2p_target_h target, const char *san, int sap, nfc_snep_event_cb callback, void *user_data) |
Start peer-to-peer server using SNEP protocol. | |
int | nfc_snep_start_client (nfc_p2p_target_h target, const char *san, int sap, nfc_snep_event_cb callback, void *user_data) |
Start peer-to-peer client using SNEP protocol. | |
int | nfc_snep_send_client_request (nfc_p2p_snep_h handle, nfc_snep_type_e type, nfc_ndef_message_h msg, nfc_snep_event_cb callback, void *user_data) |
Send request message to peer-to-peer client using SNEP protocol. | |
int | nfc_snep_stop_service (nfc_p2p_target_h target, nfc_p2p_snep_h service) |
Stop snep server or client. | |
int | nfc_snep_register_server (const char *san, int sap, nfc_snep_event_cb callback, void *user_data) |
Register peer-to-peer server using SNEP protocol. | |
int | nfc_snep_unregister_server (const char *san, int sap) |
Unregister snep server or client. | |
Typedefs | |
typedef void * | nfc_p2p_target_h |
The handle to NFC p2p target. | |
typedef struct _nfc_p2p_snep_s * | nfc_p2p_snep_h |
The handle to NFC p2p snep instance. | |
typedef void(* | nfc_p2p_send_completed_cb )(nfc_error_e result, void *user_data) |
Called after nfc_p2p_send() has completed. | |
typedef void(* | nfc_p2p_data_received_cb )(nfc_p2p_target_h target, nfc_ndef_message_h message, void *user_data) |
Called after nfc_p2p_send() has completed. | |
typedef void(* | nfc_snep_event_cb )(nfc_p2p_snep_h handle, nfc_snep_event_e event, nfc_error_e result, nfc_ndef_message_h msg, void *user_data) |
Called when SNEP event is raised. |
Typedef Documentation
typedef void(* nfc_p2p_data_received_cb)(nfc_p2p_target_h target, nfc_ndef_message_h message, void *user_data) |
Called after nfc_p2p_send() has completed.
- Since :
- 2.3
- Remarks:
- message will be automatically destroyed when the callback function returns. (Do not release message.)
- Parameters:
-
[in] target The handle to p2p target [in] message The received message [in] user_data The user data passed from nfc_p2p_set_recv_cb()
typedef void(* nfc_p2p_send_completed_cb)(nfc_error_e result, void *user_data) |
Called after nfc_p2p_send() has completed.
- Since :
- 2.3
- Parameters:
-
[in] result The result of function call [in] user_data The user data passed from nfc_p2p_send()
- See also:
- nfc_p2p_send()
typedef struct _nfc_p2p_snep_s* nfc_p2p_snep_h |
The handle to NFC p2p snep instance.
- Since :
- 2.3
typedef void* nfc_p2p_target_h |
The handle to NFC p2p target.
- Since :
- 2.3
typedef void(* nfc_snep_event_cb)(nfc_p2p_snep_h handle, nfc_snep_event_e event, nfc_error_e result, nfc_ndef_message_h msg, void *user_data) |
Called when SNEP event is raised.
- Since :
- 2.3
- Parameters:
-
[in] handle The handle of current snep instance [in] event The kind of snep event [in] result The result of snep event [in] msg The ndef message which received from client or result of get request [in] user_data The user data passed from snep apis.
Enumeration Type Documentation
enum nfc_snep_event_e |
Enumerations for SNEP event.
- Since :
- 2.3
enum nfc_snep_type_e |
Function Documentation
int nfc_p2p_send | ( | nfc_p2p_target_h | target, |
nfc_ndef_message_h | message, | ||
nfc_p2p_send_completed_cb | callback, | ||
void * | user_data | ||
) |
Sends data to NFC peer-to-peer target.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/nfc
- Parameters:
-
[in] target The handle to peer target [in] message The message to send [in] callback The callback function to invoke after this function has completed
It can be null if notification is not required[in] user_data The user data to be passed to the callback function
- Returns:
- 0 on success, otherwise a negative error value.
- Return values:
-
NFC_ERROR_NONE Successful NFC_ERROR_NOT_SUPPORTED Not supported NFC NFC_ERROR_NOT_INITIALIZED Not initialized NFC NFC_ERROR_OUT_OF_MEMORY Out of memory NFC_ERROR_OPERATION_FAILED Operation failed NFC_ERROR_INVALID_PARAMETER Invalid parameter NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request NFC_ERROR_NOT_ACTIVATED NFC is not activated
- Postcondition:
- It invokes nfc_p2p_send_completed_cb() when it has completed to p2p send.
The Callback can receive error code when process is done.
int nfc_p2p_set_data_received_cb | ( | nfc_p2p_target_h | target, |
nfc_p2p_data_received_cb | callback, | ||
void * | user_data | ||
) |
Registers a callback function for receiving data from NFC peer-to-peer target.
- Since :
- 2.3
- Parameters:
-
[in] target The handle to peer target [in] callback The callback function to invoke when an NDEF Message is discovered [in] user_data The user data to be passed to the callback function
- Returns:
- 0 on success, otherwise a negative error value.
- Return values:
-
NFC_ERROR_NONE Successful NFC_ERROR_NOT_SUPPORTED Not supported NFC NFC_ERROR_NOT_INITIALIZED Not initialized NFC NFC_ERROR_INVALID_PARAMETER Invalid parameter
int nfc_p2p_unset_data_received_cb | ( | nfc_p2p_target_h | target | ) |
Unregisters the callback function.
- Since :
- 2.3
- Parameters:
-
[in] target The handle to peer target
- Returns:
- 0 on success, otherwise a negative error value.
- Return values:
-
NFC_ERROR_NONE Successful NFC_ERROR_NOT_SUPPORTED Not supported NFC NFC_ERROR_NOT_INITIALIZED Not initialized NFC NFC_ERROR_INVALID_PARAMETER Invalid parameter
int nfc_snep_register_server | ( | const char * | san, |
int | sap, | ||
nfc_snep_event_cb | callback, | ||
void * | user_data | ||
) |
Register peer-to-peer server using SNEP protocol.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/nfc
- Parameters:
-
[in] san The name of service (service access name) [in] sap The number of service (service access point) [in] callback The callback function to invoke after this function has completed
It can be null if notification is not required[in] user_data The user data to be passed to the callback function
- Returns:
- 0 on success, otherwise a negative error value.
- Return values:
-
NFC_ERROR_NONE Successful NFC_ERROR_NOT_SUPPORTED Not supported NFC NFC_ERROR_NOT_INITIALIZED Not initialized NFC NFC_ERROR_OUT_OF_MEMORY Out of memory NFC_ERROR_OPERATION_FAILED Operation failed NFC_ERROR_INVALID_PARAMETER Invalid parameter NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request NFC_ERROR_NOT_ACTIVATED NFC is not activated
- Postcondition:
- It invokes nfc_snep_event_cb() when snep event is occured.
The Callback can receive error code when process is done.
int nfc_snep_send_client_request | ( | nfc_p2p_snep_h | handle, |
nfc_snep_type_e | type, | ||
nfc_ndef_message_h | msg, | ||
nfc_snep_event_cb | callback, | ||
void * | user_data | ||
) |
Send request message to peer-to-peer client using SNEP protocol.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/nfc
- Parameters:
-
[in] handle The handle to connected snep instance [in] type The request type of snep protocol [in] msg The ndef message which will be sent [in] callback The callback function to invoke after this function has completed
It can be null if notification is not required[in] user_data The user data to be passed to the callback function
- Returns:
- 0 on success, otherwise a negative error value.
- Return values:
-
NFC_ERROR_NONE Successful NFC_ERROR_NOT_SUPPORTED Not supported NFC NFC_ERROR_NOT_INITIALIZED Not initialized NFC NFC_ERROR_OUT_OF_MEMORY Out of memory NFC_ERROR_OPERATION_FAILED Operation failed NFC_ERROR_INVALID_PARAMETER Invalid parameter NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request NFC_ERROR_NOT_ACTIVATED NFC is not activated
- Postcondition:
- It invokes nfc_snep_event_cb() when snep event is occured.
The Callback can receive error code when process is done.
int nfc_snep_start_client | ( | nfc_p2p_target_h | target, |
const char * | san, | ||
int | sap, | ||
nfc_snep_event_cb | callback, | ||
void * | user_data | ||
) |
Start peer-to-peer client using SNEP protocol.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/nfc
- Parameters:
-
[in] target The handle to peer target [in] san The name of service (service access name) [in] sap The number of service (service access point) [in] callback The callback function to invoke after this function has completed
It can be null if notification is not required[in] user_data The user data to be passed to the callback function
- Returns:
- 0 on success, otherwise a negative error value.
- Return values:
-
NFC_ERROR_NONE Successful NFC_ERROR_NOT_SUPPORTED Not supported NFC NFC_ERROR_NOT_INITIALIZED Not initialized NFC NFC_ERROR_OUT_OF_MEMORY Out of memory NFC_ERROR_OPERATION_FAILED Operation failed NFC_ERROR_INVALID_PARAMETER Invalid parameter NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request NFC_ERROR_NOT_ACTIVATED NFC is not activated
- Postcondition:
- It invokes nfc_snep_event_cb() when snep event is occured.
The Callback can receive error code when process is done.
int nfc_snep_start_server | ( | nfc_p2p_target_h | target, |
const char * | san, | ||
int | sap, | ||
nfc_snep_event_cb | callback, | ||
void * | user_data | ||
) |
Start peer-to-peer server using SNEP protocol.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/nfc
- Parameters:
-
[in] target The handle to peer target [in] san The name of service (service access name) [in] sap The number of service (service access point) [in] callback The callback function to invoke after this function has completed
It can be null if notification is not required[in] user_data The user data to be passed to the callback function
- Returns:
- 0 on success, otherwise a negative error value.
- Return values:
-
NFC_ERROR_NONE Successful NFC_ERROR_NOT_SUPPORTED Not supported NFC NFC_ERROR_NOT_INITIALIZED Not initialized NFC NFC_ERROR_OUT_OF_MEMORY Out of memory NFC_ERROR_OPERATION_FAILED Operation failed NFC_ERROR_INVALID_PARAMETER Invalid parameter NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request NFC_ERROR_NOT_ACTIVATED NFC is not activated
- Postcondition:
- It invokes nfc_snep_event_cb() when snep event is occured.
The Callback can receive error code when process is done.
int nfc_snep_stop_service | ( | nfc_p2p_target_h | target, |
nfc_p2p_snep_h | service | ||
) |
Stop snep server or client.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/nfc
- Parameters:
-
[in] target The handle to peer target [in] service The handle which will be stopped
- Returns:
- 0 on success, otherwise a negative error value.
- Return values:
-
NFC_ERROR_NONE Successful NFC_ERROR_NOT_SUPPORTED Not supported NFC NFC_ERROR_NOT_INITIALIZED Not initialized NFC NFC_ERROR_OPERATION_FAILED Operation failed NFC_ERROR_INVALID_PARAMETER Invalid parameter NFC_ERROR_NOT_ACTIVATED NFC is not activated
int nfc_snep_unregister_server | ( | const char * | san, |
int | sap | ||
) |
Unregister snep server or client.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/nfc
- Parameters:
-
[in] san The name of service (service access name) [in] sap The number of service (service access point)
- Returns:
- 0 on success, otherwise a negative error value.
- Return values:
-
NFC_ERROR_NONE Successful NFC_ERROR_NOT_SUPPORTED Not supported NFC NFC_ERROR_NOT_INITIALIZED Not initialized NFC NFC_ERROR_OPERATION_FAILED Operation failed NFC_ERROR_INVALID_PARAMETER Invalid parameter NFC_ERROR_NOT_ACTIVATED NFC is not activated