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
The handle to NFC p2p snep instance.
- Since :
- 2.3
The handle to NFC p2p target.
- Since :
- 2.3
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. |
- See also:
- nfc_snep_start_server()
-
nfc_snep_send_client_request()
Enumeration Type Documentation
Enumerations for SNEP event.
- Since :
- 2.3
- Enumerator:
NFC_SNEP_EVENT_STOP |
server or client stopped
|
NFC_SNEP_EVENT_START |
server started or client connected
|
NFC_SNEP_EVENT_GET |
server received get request
|
NFC_SNEP_EVENT_PUT |
server received put request
|
NFC_SNEP_EVENT_REGISTER |
service registered
|
NFC_SNEP_EVENT_UNREGISTER |
service unregistered
|
Enumerations for SNEP request type.
- Since :
- 2.3
- Enumerator:
NFC_SNEP_GET |
get request
|
NFC_SNEP_PUT |
put request
|
Function Documentation
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:
-
- 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.
- See also:
- nfc_p2p_send_completed_cb()
-
nfc_p2p_target_discovered_cb()
-
nfc_manager_initialize()
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:
-
- Postcondition:
- It invokes nfc_snep_event_cb() when snep event is occured.
The Callback can receive error code when process is done.
- See also:
- nfc_snep_event_cb()
-
nfc_manager_initialize()
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:
-
- Postcondition:
- It invokes nfc_snep_event_cb() when snep event is occured.
The Callback can receive error code when process is done.
- See also:
- nfc_snep_event_cb()
-
nfc_manager_initialize()
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:
-
- Postcondition:
- It invokes nfc_snep_event_cb() when snep event is occured.
The Callback can receive error code when process is done.
- See also:
- nfc_snep_event_cb()
-
nfc_snep_send_client_request()
-
nfc_snep_stop_service()
-
nfc_manager_initialize()
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:
-
- Postcondition:
- It invokes nfc_snep_event_cb() when snep event is occured.
The Callback can receive error code when process is done.
- See also:
- nfc_snep_event_cb()
-
nfc_manager_initialize()
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:
-
- See also:
- nfc_snep_event_cb()
-
nfc_manager_initialize()
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:
-
- See also:
- nfc_snep_event_cb()
-
nfc_manager_initialize()