Tizen Native API  9.0
Wi-Fi Aware

Wi-Fi Aware provides API to manage Wi-Fi Aware framework.

Required Header

#include <wifi-aware.h>

Overview

The Wi-Fi Aware API provides functions for initializing, enabling, and disabling Wi-Fi Aware functionalities. It allows users to create and destroy Wi-Fi Aware sessions, set callbacks for session termination notifications, stop sessions, and more. Additionally, there are functions available for publishing and subscribing to Wi-Fi Aware services, updating existing subscriptions, sending messages to peers, setting up data paths between peers, and managing security aspects of the data path. Overall, the Wi-Fi Aware API offers comprehensive control over Wi-Fi Aware operations and interactions.

Functions

int wifi_aware_initialize (void)
 Initializes Wi-Fi Aware.
int wifi_aware_deinitialize (void)
 Deinitializes Wi-Fi Aware.
int wifi_aware_enable (wifi_aware_enabled_cb callback, void *user_data)
 Enables Wi-Fi Aware functions.
int wifi_aware_disable (wifi_aware_disabled_cb callback, void *user_data)
 Disables Wi-Fi Aware functions.
int wifi_aware_session_create (wifi_aware_session_type_e session_type, wifi_aware_session_h *session)
 Creates the Wi-Fi Aware Session.
int wifi_aware_session_destroy (wifi_aware_session_h session)
 Destroys the Wi-Fi Aware Session.
int wifi_aware_session_set_terminated_cb (wifi_aware_session_h session, wifi_aware_session_terminated_cb callback, void *user_data)
 Sets a callback function to notify session is terminated.
int wifi_aware_session_unset_terminated_cb (wifi_aware_session_h session)
 Unsets the session terminated callback function.
int wifi_aware_session_stop (wifi_aware_session_h session)
 Stops a Wi-Fi Aware session.
int wifi_aware_session_publish (wifi_aware_session_h session, wifi_aware_publish_h publish, wifi_aware_published_cb callback, void *user_data)
 Publishes a Wi-Fi Aware service so that neighboring devices can find it.
int wifi_aware_session_update_publish (wifi_aware_session_h session, wifi_aware_publish_h publish, wifi_aware_published_cb callback, void *user_data)
 Updates the configuration for a Wi-Fi Aware service that has already been published.
int wifi_aware_session_subscribe (wifi_aware_session_h session, wifi_aware_subscribe_h subscribe, wifi_aware_subscribed_cb callback, void *user_data)
 Starts to find Wi-Fi Aware services.
int wifi_aware_session_update_subscribe (wifi_aware_session_h session, wifi_aware_subscribe_h subscribe, wifi_aware_subscribed_cb callback, void *user_data)
 Updates the configuration for a Wi-Fi Aware service that has already been subscribed.
int wifi_aware_session_set_service_discovered_cb (wifi_aware_session_h session, wifi_aware_service_discovered_cb callback, void *user_data)
 Sets a callback function to notify a service is discovered.
int wifi_aware_session_unset_service_discovered_cb (wifi_aware_session_h session)
 Unsets the service discovered callback function.
int wifi_aware_session_send_message (wifi_aware_session_h session, wifi_aware_peer_h peer, const unsigned char *message, size_t len, wifi_aware_send_message_result_cb callback, void *user_data)
 Sends the message to a peer.
int wifi_aware_session_set_message_received_cb (wifi_aware_session_h session, wifi_aware_message_received_cb callback, void *user_data)
 Sets a callback function to deliver received message from a peer.
int wifi_aware_session_unset_message_received_cb (wifi_aware_session_h session)
 Unsets a callback function for received message.
int wifi_aware_peer_clone (wifi_aware_peer_h *cloned, wifi_aware_peer_h origin)
 Copies a Peer handle.
int wifi_aware_peer_destroy (wifi_aware_peer_h peer)
 Destroys a Peer handle.
int wifi_aware_peer_get_mac (wifi_aware_peer_h peer, unsigned char **mac)
 Gets the MAC address (NAN Management Interface) of Wi-Fi Aware peer.
int wifi_aware_data_path_create (wifi_aware_session_h session, wifi_aware_peer_h peer, wifi_aware_data_path_h *data_path)
 Creates a handle to be used for Wi-Fi Aware Data Path.
int wifi_aware_data_path_set_security (wifi_aware_data_path_h data_path, wifi_aware_security_type_e security_type)
 Sets a security type for Wi-Fi Aware Data Path.
int wifi_aware_data_path_set_psk (wifi_aware_data_path_h data_path, const char *key)
 Sets a passphrase for Wi-Fi Aware Data Path.
int wifi_aware_data_path_set_pmk (wifi_aware_data_path_h data_path, const unsigned char *key)
 Sets a PMK for Wi-Fi Aware Data Path.
int wifi_aware_data_path_set_port (wifi_aware_data_path_h data_path, int port)
 Sets a port for Wi-Fi Aware Data Path.
int wifi_aware_data_path_destroy (wifi_aware_data_path_h data_path)
 Destroys a handle for Wi-Fi Aware Data Path.
int wifi_aware_data_path_open (wifi_aware_data_path_h data_path, wifi_aware_data_path_open_cb callback, void *user_data)
 Requests to open a Wi-Fi Aware Data Path.
int wifi_aware_data_path_close (wifi_aware_data_path_h data_path)
 Closes a Wi-Fi Aware Data Path.
int wifi_aware_data_path_get_peer_port (wifi_aware_data_path_h data_path, int *port)
 Gets a port of a peer.
int wifi_aware_data_path_get_peer_ipv6_address (wifi_aware_data_path_h data_path, char **ipv6_address)
 Gets an IPv6 address of a peer.
int wifi_aware_data_path_get_interface (wifi_aware_data_path_h data_path, char **interface)
 Gets Interface name for Wi-Fi Aware Data Path.
int wifi_aware_data_path_set_terminated_cb (wifi_aware_data_path_h data_path, wifi_aware_data_path_terminated_cb callback, void *user_data)
 Sets a callback function to notify a Data Path termination.
int wifi_aware_data_path_unset_terminated_cb (wifi_aware_data_path_h data_path)
 Unsets the Data Path terminated callback function.

Typedefs

typedef void * wifi_aware_session_h
 Wi-Fi Aware Session.
typedef void * wifi_aware_publish_h
 Handle for Wi-Fi Aware Publish configuration.
typedef void * wifi_aware_subscribe_h
 Handle for Wi-Fi Aware Subscribe configuration.
typedef void * wifi_aware_peer_h
 Handle for Wi-Fi Aware peer.
typedef void * wifi_aware_data_path_h
 Handle for Wi-Fi Aware Data Path.
typedef void(* wifi_aware_enabled_cb )(wifi_aware_error_e error, void *user_data)
 Called when Wi-Fi Aware is enabled.
typedef void(* wifi_aware_disabled_cb )(wifi_aware_error_e error, void *user_data)
 Called when Wi-Fi Aware is disabled.
typedef void(* wifi_aware_session_terminated_cb )(wifi_aware_session_h session, wifi_aware_termination_reason_e reason, void *user_data)
 Called when the Wi-Fi Aware Session has been lost.
typedef void(* wifi_aware_published_cb )(wifi_aware_session_h session, wifi_aware_error_e error, void *user_data)
 Called when publish request is finished.
typedef void(* wifi_aware_subscribed_cb )(wifi_aware_session_h session, wifi_aware_error_e error, void *user_data)
 Called when Subscribe request is finished.
typedef void(* wifi_aware_service_discovered_cb )(wifi_aware_session_h session, wifi_aware_peer_h peer, const unsigned char *service_specific_info, size_t service_specific_info_len, int distance, void *user_data)
 Called whenever a matched service for the subscribe configurations is found.
typedef void(* wifi_aware_send_message_result_cb )(wifi_aware_session_h session, wifi_aware_error_e error, void *user_data)
 Called when a message is sent to a peer.
typedef void(* wifi_aware_message_received_cb )(wifi_aware_session_h session, wifi_aware_peer_h peer, const unsigned char *message, size_t len, void *user_data)
 Called whenever receiving a message from a peer.
typedef void(* wifi_aware_data_path_open_cb )(wifi_aware_data_path_h data_path, wifi_aware_error_e error, void *user_data)
 Called when Data Path open request is done.
typedef void(* wifi_aware_data_path_terminated_cb )(wifi_aware_data_path_h data_path, wifi_aware_termination_reason_e reason, void *user_data)
 Called when the Wi-Fi Aware Data Path has been lost.

Typedef Documentation

typedef void* wifi_aware_data_path_h

Handle for Wi-Fi Aware Data Path.

Since :
9.0
typedef void(* wifi_aware_data_path_open_cb)(wifi_aware_data_path_h data_path, wifi_aware_error_e error, void *user_data)

Called when Data Path open request is done.

The following error codes can be received:
WIFI_AWARE_ERROR_NONE Successful
WIFI_AWARE_ERROR_NOT_SUPPORTED Not supported
WIFI_AWARE_ERROR_PERMISSION_DENIED Permission denied
WIFI_AWARE_ERROR_INVALID_PARAMETER Invalid function parameter
WIFI_AWARE_ERROR_INVALID_OPERATION Invalid operation
WIFI_AWARE_ERROR_OPERATION_FAILED Operation failed

Since :
9.0
Remarks:
The data_path should not be released.
Parameters:
[in]data_pathThe Data Path handle
[in]errorThe result of the open request
[in]user_dataThe user data passed from request function
See also:
wifi_aware_data_path_open()

Called when the Wi-Fi Aware Data Path has been lost.

Since :
9.0
Remarks:
The data_path should not be released.
Parameters:
[in]data_pathThe terminated Data Path handle
[in]reasonThe reason of termination
[in]user_dataThe user data passed from request function
See also:
wifi_aware_data_path_set_terminated_cb()
wifi_aware_data_path_unset_terminated_cb()
typedef void(* wifi_aware_disabled_cb)(wifi_aware_error_e error, void *user_data)

Called when Wi-Fi Aware is disabled.

The following error codes can be received:
WIFI_AWARE_ERROR_NONE Successful
WIFI_AWARE_ERROR_NOT_SUPPORTED Not supported
WIFI_AWARE_ERROR_PERMISSION_DENIED Permission denied
WIFI_AWARE_ERROR_INVALID_PARAMETER Invalid function parameter
WIFI_AWARE_ERROR_INVALID_OPERATION Invalid operation
WIFI_AWARE_ERROR_OPERATION_FAILED Operation failed

Since :
9.0
Parameters:
[in]errorThe error code
[in]user_dataThe user data passed from the request function
See also:
wifi_aware_disable()
typedef void(* wifi_aware_enabled_cb)(wifi_aware_error_e error, void *user_data)

Called when Wi-Fi Aware is enabled.

The following error codes can be received:
WIFI_AWARE_ERROR_NONE Successful
WIFI_AWARE_ERROR_NOT_SUPPORTED Not supported
WIFI_AWARE_ERROR_PERMISSION_DENIED Permission denied
WIFI_AWARE_ERROR_INVALID_PARAMETER Invalid function parameter
WIFI_AWARE_ERROR_INVALID_OPERATION Invalid operation
WIFI_AWARE_ERROR_OPERATION_FAILED Operation failed

Since :
9.0
Parameters:
[in]errorThe error code
[in]user_dataThe user data passed from the request function
See also:
wifi_aware_enable()
typedef void(* wifi_aware_message_received_cb)(wifi_aware_session_h session, wifi_aware_peer_h peer, const unsigned char *message, size_t len, void *user_data)

Called whenever receiving a message from a peer.

Since :
9.0
Remarks:
The session and peer should not be released.
Parameters:
[in]sessionThe Wi-Fi Aware Session handle
[in]peerThe peer who sent the message
[in]messageThe message which is sent
[in]lenThe length of the message
[in]user_dataThe user data passed to the callback function
See also:
wifi_aware_session_set_message_received_cb()
wifi_aware_session_unset_message_received_cb()
typedef void* wifi_aware_peer_h

Handle for Wi-Fi Aware peer.

Since :
9.0
typedef void* wifi_aware_publish_h

Handle for Wi-Fi Aware Publish configuration.

Since :
9.0
typedef void(* wifi_aware_published_cb)(wifi_aware_session_h session, wifi_aware_error_e error, void *user_data)

Called when publish request is finished.

The following error codes can be received:
WIFI_AWARE_ERROR_NONE Successful
WIFI_AWARE_ERROR_NOT_SUPPORTED Not supported
WIFI_AWARE_ERROR_PERMISSION_DENIED Permission denied
WIFI_AWARE_ERROR_INVALID_PARAMETER Invalid function parameter
WIFI_AWARE_ERROR_INVALID_OPERATION Invalid operation
WIFI_AWARE_ERROR_OPERATION_FAILED Operation failed

Since :
9.0
Remarks:
The session should not be released.
Parameters:
[in]sessionThe Wi-Fi Aware Session handle
[in]errorThe error code
[in]user_dataThe user data passed from request function
See also:
wifi_aware_session_publish()
wifi_aware_session_update_publish()
typedef void(* wifi_aware_send_message_result_cb)(wifi_aware_session_h session, wifi_aware_error_e error, void *user_data)

Called when a message is sent to a peer.

The following error codes can be received:
WIFI_AWARE_ERROR_NONE Successful
WIFI_AWARE_ERROR_NOT_SUPPORTED Not supported
WIFI_AWARE_ERROR_PERMISSION_DENIED Permission denied
WIFI_AWARE_ERROR_INVALID_PARAMETER Invalid function parameter
WIFI_AWARE_ERROR_INVALID_OPERATION Invalid operation
WIFI_AWARE_ERROR_OPERATION_FAILED Operation failed

Since :
9.0
Remarks:
The session should not be released.
Parameters:
[in]sessionThe Wi-Fi Aware Session handle
[in]errorThe error code
[in]user_dataThe user data passed from request function
typedef void(* wifi_aware_service_discovered_cb)(wifi_aware_session_h session, wifi_aware_peer_h peer, const unsigned char *service_specific_info, size_t service_specific_info_len, int distance, void *user_data)

Called whenever a matched service for the subscribe configurations is found.

Since :
9.0
Remarks:
If the publisher doesn't enabled ranging or the subscriber doesn't set both max and min distance,
distance would be negative value.
The session and peer should not be released.
Parameters:
[in]sessionThe Wi-Fi Aware Session handle
[in]peerThe found Peer information
[in]service_specific_infoSequence of octets which were received from published service
[in]service_specific_info_lenThe length of service_specific_info
[in]distanceThe distance to the peer
[in]user_dataThe user data passed to the callback function
See also:
wifi_aware_session_set_service_discovered_cb()
wifi_aware_session_unset_service_discovered_cb()
typedef void* wifi_aware_session_h

Wi-Fi Aware Session.

Since :
9.0

Called when the Wi-Fi Aware Session has been lost.

Since :
9.0
Remarks:
The session should not be released.
Parameters:
[in]sessionThe Wi-Fi Aware Session handle
[in]reasonThe reason of termination
[in]user_dataThe user data passed from request function
See also:
wifi_aware_session_set_terminated_cb()
wifi_aware_session_unset_terminated_cb()
typedef void* wifi_aware_subscribe_h

Handle for Wi-Fi Aware Subscribe configuration.

Since :
9.0
typedef void(* wifi_aware_subscribed_cb)(wifi_aware_session_h session, wifi_aware_error_e error, void *user_data)

Called when Subscribe request is finished.

The following error codes can be received:
WIFI_AWARE_ERROR_NONE Successful
WIFI_AWARE_ERROR_NOT_SUPPORTED Not supported
WIFI_AWARE_ERROR_PERMISSION_DENIED Permission denied
WIFI_AWARE_ERROR_INVALID_PARAMETER Invalid function parameter
WIFI_AWARE_ERROR_INVALID_OPERATION Invalid operation
WIFI_AWARE_ERROR_OPERATION_FAILED Operation failed

Since :
9.0
Remarks:
The session should not be released.
Parameters:
[in]sessionThe Wi-Fi Aware Session handle
[in]errorThe error code
[in]user_dataThe user data passed from request function
See also:
wifi_aware_session_subscribe()

Enumeration Type Documentation

Enumeration for Wi-Fi Aware error code.

Since :
9.0
Enumerator:
WIFI_AWARE_ERROR_NONE 

Successful

WIFI_AWARE_ERROR_NOT_PERMITTED 

Operation not permitted(1)

WIFI_AWARE_ERROR_OUT_OF_MEMORY 

Out of memory(12)

WIFI_AWARE_ERROR_PERMISSION_DENIED 

Permission denied(13)

WIFI_AWARE_ERROR_RESOURCE_BUSY 

Device or resource busy(16)

WIFI_AWARE_ERROR_INVALID_PARAMETER 

Invalid function parameter(22)

WIFI_AWARE_ERROR_INVALID_OPERATION 

Invalid operation(38)

WIFI_AWARE_ERROR_NOW_IN_PROGRESS 

Connection timed out(110) Now in progress(115)

WIFI_AWARE_ERROR_NOT_SUPPORTED 

Not supported

WIFI_AWARE_ERROR_NOT_INITIALIZED 

Not initialized

WIFI_AWARE_ERROR_ALREADY_INITIALIZED 

Already initialized

WIFI_AWARE_ERROR_ALREADY_ENABLED 

Already enabled

WIFI_AWARE_ERROR_OPERATION_FAILED 

Operation failed

WIFI_AWARE_ERROR_REJECTED_BY_PEER 

Rejected by peer

WIFI_AWARE_ERROR_INTERFACE_DOWN 

Wi-Fi Interface is down

Enumeration for Wi-Fi Aware security type.

Since :
9.0
Enumerator:
WIFI_AWARE_SECURITY_TYPE_OPEN 

Wi-Fi Aware security type: Open

WIFI_AWARE_SECURITY_TYPE_PSK 

Wi-Fi Aware security type: PSK

WIFI_AWARE_SECURITY_TYPE_PMK 

Wi-Fi Aware security type: PMK

Enumeration for Wi-Fi Aware session type.

Since :
9.0
Enumerator:
WIFI_AWARE_SESSION_PUBLISH 

Publish type

WIFI_AWARE_SESSION_SUBSCRIBE 

Subscribe type

Enumeration for Wi-Fi Aware termination reason.

Since :
9.0
Enumerator:
WIFI_AWARE_TERMINATION_REASON_UNKNOWN 

Unknown reason


Function Documentation

Closes a Wi-Fi Aware Data Path.

Since :
9.0
Privilege Level:
public
Privilege:
http://tizen.org/privilege/network.set
Parameters:
[in]data_pathThe Data Path handle
Returns:
0 on success, otherwise a negative error value
Return values:
WIFI_AWARE_ERROR_NONESuccessful
WIFI_AWARE_ERROR_NOT_SUPPORTEDNot supported
WIFI_AWARE_ERROR_PERMISSION_DENIEDPermission denied
WIFI_AWARE_ERROR_INVALID_PARAMETERInvalid function parameter
WIFI_AWARE_ERROR_NOT_INITIALIZEDNot initialized
WIFI_AWARE_ERROR_INVALID_OPERATIONInvalid operation
WIFI_AWARE_ERROR_OPERATION_FAILEDOperation failed
See also:
wifi_aware_data_path_open()

Creates a handle to be used for Wi-Fi Aware Data Path.

Since :
9.0
Remarks:
The data_path should be released using wifi_aware_data_path_destroy().
Parameters:
[in]sessionThe Wi-Fi Aware Session handle
[in]peerThe Peer handle
[out]data_pathThe Data Path handle
Returns:
0 on success, otherwise a negative error value
Return values:
WIFI_AWARE_ERROR_NONESuccessful
WIFI_AWARE_ERROR_NOT_SUPPORTEDNot supported
WIFI_AWARE_ERROR_INVALID_PARAMETERInvalid function parameter
WIFI_AWARE_ERROR_NOT_INITIALIZEDNot initialized
WIFI_AWARE_ERROR_OUT_OF_MEMORYOut of memory
Here is an example of the usage:
    wifi_aware_data_path_h data_path;
    int ret = 0;

    ret = wifi_aware_data_path_create(g_session, g_peer, &data_path);
    if (ret != WIFI_AWARE_ERROR_NONE) {
        printf("Failed to create data path\n");
        return;
    }

 // Do stuff here for the data path

    wifi_aware_data_path_destroy(data_path);
See also:
wifi_aware_data_path_destroy()

Destroys a handle for Wi-Fi Aware Data Path.

Since :
9.0
Parameters:
[in]data_pathThe Data Path handle
Returns:
0 on success, otherwise a negative error value
Return values:
WIFI_AWARE_ERROR_NONESuccessful
WIFI_AWARE_ERROR_NOT_SUPPORTEDNot supported
WIFI_AWARE_ERROR_INVALID_PARAMETERInvalid function parameter
WIFI_AWARE_ERROR_NOT_INITIALIZEDNot initialized
See also:
wifi_aware_data_path_create()
int wifi_aware_data_path_get_interface ( wifi_aware_data_path_h  data_path,
char **  interface 
)

Gets Interface name for Wi-Fi Aware Data Path.

Since :
9.0
Remarks:
The interface should be freed by using free().
Parameters:
[in]data_pathThe Data Path handle
[out]interfaceThe interface name
Returns:
0 on success, otherwise a negative error value
Return values:
WIFI_AWARE_ERROR_NONESuccessful
WIFI_AWARE_ERROR_NOT_SUPPORTEDNot supported
WIFI_AWARE_ERROR_INVALID_PARAMETERInvalid function parameter
WIFI_AWARE_ERROR_NOT_INITIALIZEDNot initialized
WIFI_AWARE_ERROR_INVALID_OPERATIONInvalid operation
Here is an example of the usage:
    int ret = 0;
    char *interface = NULL;

    ret = wifi_aware_data_path_get_interface(g_data_path, &interface);
    if (ret != WIFI_AWARE_ERROR_NONE) {
        printf("Failed to get interface name\n");
        return;
    }

    // Do stuff here for the interface name

    free(interface);
int wifi_aware_data_path_get_peer_ipv6_address ( wifi_aware_data_path_h  data_path,
char **  ipv6_address 
)

Gets an IPv6 address of a peer.

Since :
9.0
Remarks:
The ipv6_address should be freed by using free().
Parameters:
[in]data_pathThe Data Path handle
[out]ipv6_addressThe IPv6 address of a peer
Returns:
0 on success, otherwise a negative error value
Return values:
WIFI_AWARE_ERROR_NONESuccessful
WIFI_AWARE_ERROR_NOT_SUPPORTEDNot supported
WIFI_AWARE_ERROR_INVALID_PARAMETERInvalid function parameter
WIFI_AWARE_ERROR_NOT_INITIALIZEDNot initialized
WIFI_AWARE_ERROR_INVALID_OPERATIONInvalid operation
Here is an example of the usage:
    int ret = 0;
    char *ipv6 = NULL;

    ret = wifi_aware_data_path_get_peer_ipv6_address(g_data_path, &ipv6);
    if (ret != WIFI_AWARE_ERROR_NONE) {
        printf("Failed to get IPv6 address of the peer\n");
        return;
    }

    // Do stuff here for the IPv6 address of the peer

    free(ipv6);
int wifi_aware_data_path_get_peer_port ( wifi_aware_data_path_h  data_path,
int *  port 
)

Gets a port of a peer.

Since :
9.0
Parameters:
[in]data_pathThe Data Path handle
[out]portThe port
Returns:
0 on success, otherwise a negative error value
Return values:
WIFI_AWARE_ERROR_NONESuccessful
WIFI_AWARE_ERROR_NOT_SUPPORTEDNot supported
WIFI_AWARE_ERROR_INVALID_PARAMETERInvalid function parameter
WIFI_AWARE_ERROR_NOT_INITIALIZEDNot initialized
WIFI_AWARE_ERROR_INVALID_OPERATIONInvalid operation
int wifi_aware_data_path_open ( wifi_aware_data_path_h  data_path,
wifi_aware_data_path_open_cb  callback,
void *  user_data 
)

Requests to open a Wi-Fi Aware Data Path.

Since :
9.0
Privilege Level:
public
Privilege:
http://tizen.org/privilege/network.set
Remarks:
The callback will be always invoked whether the open request succeeds or fails.
Parameters:
[in]data_pathThe Data Path handle
[in]callbackThe callback function
[in]user_dataThe user data passed to the callback function
Returns:
0 on success, otherwise a negative error value
Return values:
WIFI_AWARE_ERROR_NONESuccessful
WIFI_AWARE_ERROR_NOT_SUPPORTEDNot supported
WIFI_AWARE_ERROR_PERMISSION_DENIEDPermission denied
WIFI_AWARE_ERROR_INVALID_PARAMETERInvalid function parameter
WIFI_AWARE_ERROR_NOT_INITIALIZEDNot initialized
WIFI_AWARE_ERROR_INVALID_OPERATIONInvalid operation
WIFI_AWARE_ERROR_OPERATION_FAILEDOperation failed
See also:
wifi_aware_data_path_close()
int wifi_aware_data_path_set_pmk ( wifi_aware_data_path_h  data_path,
const unsigned char *  key 
)

Sets a PMK for Wi-Fi Aware Data Path.

Since :
9.0
Remarks:
The key can be used only when security type is WIFI_AWARE_SECURITY_TYPE_PMK.
Parameters:
[in]data_pathThe Data Path handle
[in]keyPairwise Master Key. Its length shall be of length 32.
Returns:
0 on success, otherwise a negative error value
Return values:
WIFI_AWARE_ERROR_NONESuccessful
WIFI_AWARE_ERROR_NOT_SUPPORTEDNot supported
WIFI_AWARE_ERROR_INVALID_PARAMETERInvalid function parameter
WIFI_AWARE_ERROR_NOT_INITIALIZEDNot initialized
WIFI_AWARE_ERROR_INVALID_OPERATIONInvalid operation
See also:
wifi_aware_data_path_create()
int wifi_aware_data_path_set_port ( wifi_aware_data_path_h  data_path,
int  port 
)

Sets a port for Wi-Fi Aware Data Path.

Since :
9.0
Remarks:
The port cannot be exceed 65535.
Parameters:
[in]data_pathThe Data Path handle
[in]portThe port
Returns:
0 on success, otherwise a negative error value
Return values:
WIFI_AWARE_ERROR_NONESuccessful
WIFI_AWARE_ERROR_NOT_SUPPORTEDNot supported
WIFI_AWARE_ERROR_INVALID_PARAMETERInvalid function parameter
WIFI_AWARE_ERROR_NOT_INITIALIZEDNot initialized
See also:
wifi_aware_data_path_create()
int wifi_aware_data_path_set_psk ( wifi_aware_data_path_h  data_path,
const char *  key 
)

Sets a passphrase for Wi-Fi Aware Data Path.

Since :
9.0
Remarks:
The key can be used only when secure type is WIFI_AWARE_SECURITY_TYPE_PSK.
Parameters:
[in]data_pathThe Data Path handle
[in]keyThe passphrase
Returns:
0 on success, otherwise a negative error value
Return values:
WIFI_AWARE_ERROR_NONESuccessful
WIFI_AWARE_ERROR_NOT_SUPPORTEDNot supported
WIFI_AWARE_ERROR_INVALID_PARAMETERInvalid function parameter
WIFI_AWARE_ERROR_NOT_INITIALIZEDNot initialized
WIFI_AWARE_ERROR_INVALID_OPERATIONInvalid operation
See also:
wifi_aware_data_path_create()

Sets a security type for Wi-Fi Aware Data Path.

Since :
9.0
Parameters:
[in]data_pathThe Data Path handle
[in]security_typeThe security type
Returns:
0 on success, otherwise a negative error value
Return values:
WIFI_AWARE_ERROR_NONESuccessful
WIFI_AWARE_ERROR_NOT_SUPPORTEDNot supported
WIFI_AWARE_ERROR_INVALID_PARAMETERInvalid function parameter
WIFI_AWARE_ERROR_NOT_INITIALIZEDNot initialized
See also:
wifi_aware_data_path_create()

Sets a callback function to notify a Data Path termination.

Since :
9.0
Parameters:
[in]data_pathThe Data Path handle
[in]callbackThe callback function
[in]user_dataThe user data passed to the callback function
Returns:
0 on success, otherwise a negative error value
Return values:
WIFI_AWARE_ERROR_NONESuccessful
WIFI_AWARE_ERROR_NOT_SUPPORTEDNot supported
WIFI_AWARE_ERROR_INVALID_PARAMETERInvalid function parameter
WIFI_AWARE_ERROR_NOT_INITIALIZEDNot initialized
See also:
wifi_aware_data_path_unset_terminated_cb()

Unsets the Data Path terminated callback function.

Since :
9.0
Parameters:
[in]data_pathThe Data Path handle
Returns:
0 on success, otherwise a negative error value
Return values:
WIFI_AWARE_ERROR_NONESuccessful
WIFI_AWARE_ERROR_NOT_SUPPORTEDNot supported
WIFI_AWARE_ERROR_INVALID_PARAMETERInvalid function parameter
WIFI_AWARE_ERROR_NOT_INITIALIZEDNot initialized
See also:
wifi_aware_data_path_set_terminated_cb()
int wifi_aware_deinitialize ( void  )

Deinitializes Wi-Fi Aware.

Since :
9.0
Returns:
0 on success, otherwise a negative error value
Return values:
WIFI_AWARE_ERROR_NONESuccessful
WIFI_AWARE_ERROR_NOT_SUPPORTEDNot supported
WIFI_AWARE_ERROR_NOT_INITIALIZEDNot initialized
See also:
wifi_aware_initialize()
int wifi_aware_disable ( wifi_aware_disabled_cb  callback,
void *  user_data 
)

Disables Wi-Fi Aware functions.

Since :
9.0
Privilege Level:
public
Privilege:
http://tizen.org/privilege/network.set
Parameters:
[in]callbackThe result of disable request is asynchronously delivered
[in]user_dataThe user data passed to the callback function
Returns:
0 on success, otherwise a negative error value
Return values:
WIFI_AWARE_ERROR_NONESuccessful
WIFI_AWARE_ERROR_NOT_SUPPORTEDNot supported
WIFI_AWARE_ERROR_PERMISSION_DENIEDPermission denied
WIFI_AWARE_ERROR_NOT_INITIALIZEDNot initialized
WIFI_AWARE_ERROR_INVALID_OPERATIONInvalid operation
WIFI_AWARE_ERROR_OPERATION_FAILEDOperation failed
See also:
wifi_aware_enable()
int wifi_aware_enable ( wifi_aware_enabled_cb  callback,
void *  user_data 
)

Enables Wi-Fi Aware functions.

Since :
9.0
Privilege Level:
public
Privilege:
http://tizen.org/privilege/network.set
Remarks:
If the enable request is successfully done, the application can get the MAC address.
Parameters:
[in]callbackThe result of enable request is asynchronously delivered
[in]user_dataThe user data passed to the callback function
Returns:
0 on success, otherwise a negative error value
Return values:
WIFI_AWARE_ERROR_NONESuccessful
WIFI_AWARE_ERROR_NOT_SUPPORTEDNot supported
WIFI_AWARE_ERROR_PERMISSION_DENIEDPermission denied
WIFI_AWARE_ERROR_NOT_INITIALIZEDNot initialized
WIFI_AWARE_ERROR_ALREADY_ENABLEDAlready enabled
WIFI_AWARE_ERROR_OPERATION_FAILEDOperation failed
WIFI_AWARE_ERROR_OUT_OF_MEMORYOut of memory
See also:
wifi_aware_disable()
int wifi_aware_initialize ( void  )

Initializes Wi-Fi Aware.

Since :
9.0
Returns:
0 on success, otherwise a negative error value
Return values:
WIFI_AWARE_ERROR_NONESuccessful
WIFI_AWARE_ERROR_NOT_SUPPORTEDNot supported
WIFI_AWARE_ERROR_ALREADY_INITIALIZEDAlready initialized
WIFI_AWARE_ERROR_OPERATION_FAILEDOperation failed
WIFI_AWARE_ERROR_OUT_OF_MEMORYOut of memory
See also:
wifi_aware_deinitialize()

Copies a Peer handle.

Since :
9.0
Remarks:
The cloned should be released using wifi_aware_peer_destroy().
Parameters:
[out]clonedThe Peer handle copied from origin
[in]originThe origin Peer handle
Returns:
0 on success, otherwise a negative error value
Return values:
WIFI_AWARE_ERROR_NONESuccessful
WIFI_AWARE_ERROR_NOT_SUPPORTEDNot supported
WIFI_AWARE_ERROR_INVALID_PARAMETERInvalid function parameter
WIFI_AWARE_ERROR_NOT_INITIALIZEDNot initialized
WIFI_AWARE_ERROR_OUT_OF_MEMORYOut of memory
Here is an example of the usage:
    wifi_aware_peer_h cloned_peer;
    int ret = 0;

    ret = wifi_aware_peer_clone(&cloned_peer, src_peer);
    if (ret != WIFI_AWARE_ERROR_NONE) {
        printf("Failed to clone the peer\n");
        return;
    }

    // Do stuff here for cloned peer

    wifi_aware_peer_destroy(cloned_peer);
See also:
wifi_aware_peer_destroy()

Destroys a Peer handle.

Since :
9.0
Parameters:
[in]peerThe Peer handle
Returns:
0 on success, otherwise a negative error value
Return values:
WIFI_AWARE_ERROR_NONESuccessful
WIFI_AWARE_ERROR_NOT_SUPPORTEDNot supported
WIFI_AWARE_ERROR_INVALID_PARAMETERInvalid function parameter
WIFI_AWARE_ERROR_NOT_INITIALIZEDNot initialized
See also:
wifi_aware_peer_clone()
int wifi_aware_peer_get_mac ( wifi_aware_peer_h  peer,
unsigned char **  mac 
)

Gets the MAC address (NAN Management Interface) of Wi-Fi Aware peer.

Since :
9.0
Remarks:
The mac should be freed using free().
Parameters:
[in]peerThe Peer handle
[out]macThe MAC address of the peer
Returns:
0 on success, otherwise a negative error value
Return values:
WIFI_AWARE_ERROR_NONESuccessful
WIFI_AWARE_ERROR_NOT_SUPPORTEDNot supported
WIFI_AWARE_ERROR_INVALID_PARAMETERInvalid function parameter
WIFI_AWARE_ERROR_NOT_INITIALIZEDNot initialized
WIFI_AWARE_ERROR_OUT_OF_MEMORYOut of memory
Here is an example of the usage:
    peer_info *info = (peer_info *)data;
    unsigned char *mac = NULL;
    int ret = 0;

    ret = wifi_aware_peer_get_mac(info->peer, &mac);
    if (ret != WIFI_AWARE_ERROR_NONE) {
        printf("Failed to get mac of the peer\n");
        return;
    }

 // Do stuff here for the mac

    free(mac);

Creates the Wi-Fi Aware Session.

Since :
9.0
Remarks:
The session should be released using wifi_aware_session_destroy().
Parameters:
[in]session_typeThe type of session
[out]sessionThe Wi-Fi Aware Session handle that is newly created on success
Returns:
0 on success, otherwise a negative error value
Return values:
WIFI_AWARE_ERROR_NONESuccessful
WIFI_AWARE_ERROR_NOT_SUPPORTEDNot supported
WIFI_AWARE_ERROR_INVALID_PARAMETERInvalid function parameter
WIFI_AWARE_ERROR_NOT_INITIALIZEDNot initialized
WIFI_AWARE_ERROR_OUT_OF_MEMORYOut of memory
Here is an example of the usage:
    int ret = 0;
    wifi_aware_session_h wifi_aware_session = NULL;

    ret = wifi_aware_session_create(WIFI_AWARE_SESSION_PUBLISH, &wifi_aware_session);
    if (ret != WIFI_AWARE_ERROR_NONE) {
        printf("Failed to create session\n");
        return;
    }

    // Do stuff here for created session

    wifi_aware_session_destroy(wifi_aware_session);
See also:
wifi_aware_session_destroy()

Destroys the Wi-Fi Aware Session.

Since :
9.0
Parameters:
[in]sessionThe Wi-Fi Aware Session handle
Returns:
0 on success, otherwise a negative error value
Return values:
WIFI_AWARE_ERROR_NONESuccessful
WIFI_AWARE_ERROR_NOT_SUPPORTEDNot supported
WIFI_AWARE_ERROR_INVALID_PARAMETERInvalid function parameter
WIFI_AWARE_ERROR_NOT_INITIALIZEDNot initialized
See also:
wifi_aware_session_create()
int wifi_aware_session_publish ( wifi_aware_session_h  session,
wifi_aware_publish_h  publish,
wifi_aware_published_cb  callback,
void *  user_data 
)

Publishes a Wi-Fi Aware service so that neighboring devices can find it.

Since :
9.0
Privilege Level:
public
Privilege:
http://tizen.org/privilege/network.set
Parameters:
[in]sessionThe Wi-Fi Aware Session handle
[in]publishThe Wi-Fi Aware Publish handle
[in]callbackThe callback which gets called when a service is published
[in]user_dataThe user data passed to the callback function
Returns:
0 on success, otherwise a negative error value
Return values:
WIFI_AWARE_ERROR_NONESuccessful
WIFI_AWARE_ERROR_NOT_SUPPORTEDNot supported
WIFI_AWARE_ERROR_PERMISSION_DENIEDPermission denied
WIFI_AWARE_ERROR_INVALID_PARAMETERInvalid function parameter
WIFI_AWARE_ERROR_NOT_INITIALIZEDNot initialized
WIFI_AWARE_ERROR_INVALID_OPERATIONInvalid operation
WIFI_AWARE_ERROR_OPERATION_FAILEDOperation failed
See also:
wifi_aware_session_stop()
int wifi_aware_session_send_message ( wifi_aware_session_h  session,
wifi_aware_peer_h  peer,
const unsigned char *  message,
size_t  len,
wifi_aware_send_message_result_cb  callback,
void *  user_data 
)

Sends the message to a peer.

Since :
9.0
Privilege Level:
public
Privilege:
http://tizen.org/privilege/network.set
Parameters:
[in]sessionThe Wi-Fi Aware Session handle
[in]peerThe peer who gets the message
[in]messageThe message sent to a peer
[in]lenThe length of the message
[in]callbackThe callback function
[in]user_dataThe user data passed to the callback function
Returns:
0 on success, otherwise a negative error value
Return values:
WIFI_AWARE_ERROR_NONESuccessful
WIFI_AWARE_ERROR_NOT_SUPPORTEDNot supported
WIFI_AWARE_ERROR_PERMISSION_DENIEDPermission denied
WIFI_AWARE_ERROR_INVALID_PARAMETERInvalid function parameter
WIFI_AWARE_ERROR_NOT_INITIALIZEDNot initialized
WIFI_AWARE_ERROR_INVALID_OPERATIONInvalid operation
WIFI_AWARE_ERROR_OPERATION_FAILEDOperation failed
WIFI_AWARE_ERROR_OUT_OF_MEMORYOut of memory

Sets a callback function to deliver received message from a peer.

Since :
9.0
Parameters:
[in]sessionThe Wi-Fi Aware Session handle
[in]callbackThe callback function which gets called
[in]user_dataThe user data passed to callback
Returns:
0 on success, otherwise a negative error value
Return values:
WIFI_AWARE_ERROR_NONESuccessful
WIFI_AWARE_ERROR_NOT_SUPPORTEDNot supported
WIFI_AWARE_ERROR_INVALID_PARAMETERInvalid function parameter
WIFI_AWARE_ERROR_NOT_INITIALIZEDNot initialized
See also:
wifi_aware_session_unset_message_received_cb()

Sets a callback function to notify a service is discovered.

Since :
9.0
Parameters:
[in]sessionThe Wi-Fi Aware Session handle
[in]callbackThe callback function to register
[in]user_dataThe user data to be passed to the callback function
Returns:
0 on success, otherwise a negative error value
Return values:
WIFI_AWARE_ERROR_NONESuccessful
WIFI_AWARE_ERROR_NOT_SUPPORTEDNot supported
WIFI_AWARE_ERROR_INVALID_PARAMETERInvalid function parameter
WIFI_AWARE_ERROR_NOT_INITIALIZEDNot initialized
See also:
wifi_aware_session_unset_service_discovered_cb()

Sets a callback function to notify session is terminated.

Since :
9.0
Parameters:
[in]sessionThe Wi-Fi Aware Session
[in]callbackThe callback function to register
[in]user_dataThe user data to be passed to the callback function
Returns:
0 on success, otherwise a negative error value
Return values:
WIFI_AWARE_ERROR_NONESuccessful
WIFI_AWARE_ERROR_NOT_SUPPORTEDNot supported
WIFI_AWARE_ERROR_INVALID_PARAMETERInvalid function parameter
WIFI_AWARE_ERROR_NOT_INITIALIZEDNot initialized
See also:
wifi_aware_session_unset_terminated_cb()

Stops a Wi-Fi Aware session.

Since :
9.0
Privilege Level:
public
Privilege:
http://tizen.org/privilege/network.set
Remarks:
The function of the session, Publish or Subscribe, will be cancelled.
Parameters:
[in]sessionThe Wi-Fi Aware Session handle
Returns:
0 on success, otherwise a negative error value
Return values:
WIFI_AWARE_ERROR_NONESuccessful
WIFI_AWARE_ERROR_NOT_SUPPORTEDNot supported
WIFI_AWARE_ERROR_PERMISSION_DENIEDPermission denied
WIFI_AWARE_ERROR_INVALID_PARAMETERInvalid function parameter
WIFI_AWARE_ERROR_NOT_INITIALIZEDNot initialized
WIFI_AWARE_ERROR_INVALID_OPERATIONInvalid operation
WIFI_AWARE_ERROR_OPERATION_FAILEDOperation failed
See also:
wifi_aware_session_publish()
wifi_aware_session_subscribe()
int wifi_aware_session_subscribe ( wifi_aware_session_h  session,
wifi_aware_subscribe_h  subscribe,
wifi_aware_subscribed_cb  callback,
void *  user_data 
)

Starts to find Wi-Fi Aware services.

Since :
9.0
Privilege Level:
public
Privilege:
http://tizen.org/privilege/network.set
Parameters:
[in]sessionThe Wi-Fi Aware Session handle
[in]subscribeThe Wi-Fi Aware Subscribe handle
[in]callbackThe callback which get called when request is finished
[in]user_dataThe user data passed to the callback function
Returns:
0 on success, otherwise a negative error value
Return values:
WIFI_AWARE_ERROR_NONESuccessful
WIFI_AWARE_ERROR_NOT_SUPPORTEDNot supported
WIFI_AWARE_ERROR_PERMISSION_DENIEDPermission denied
WIFI_AWARE_ERROR_INVALID_PARAMETERInvalid function parameter
WIFI_AWARE_ERROR_NOT_INITIALIZEDNot initialized
WIFI_AWARE_ERROR_INVALID_OPERATIONInvalid operation
WIFI_AWARE_ERROR_OPERATION_FAILEDOperation failed
See also:
wifi_aware_session_stop()

Unsets a callback function for received message.

Since :
9.0
Parameters:
[in]sessionThe Wi-Fi Aware Session handle
Returns:
0 on success, otherwise a negative error value
Return values:
WIFI_AWARE_ERROR_NONESuccessful
WIFI_AWARE_ERROR_NOT_SUPPORTEDNot supported
WIFI_AWARE_ERROR_INVALID_PARAMETERInvalid function parameter
WIFI_AWARE_ERROR_NOT_INITIALIZEDNot initialized
See also:
wifi_aware_session_set_message_received_cb()

Unsets the service discovered callback function.

Since :
9.0
Parameters:
[in]sessionThe Wi-Fi Aware Session handle
Returns:
0 on success, otherwise a negative error value
Return values:
WIFI_AWARE_ERROR_NONESuccessful
WIFI_AWARE_ERROR_NOT_SUPPORTEDNot supported
WIFI_AWARE_ERROR_INVALID_PARAMETERInvalid function parameter
WIFI_AWARE_ERROR_NOT_INITIALIZEDNot initialized
See also:
wifi_aware_session_set_service_discovered_cb()

Unsets the session terminated callback function.

Since :
9.0
Parameters:
[in]sessionThe Wi-Fi Aware Session
Returns:
0 on success, otherwise a negative error value
Return values:
WIFI_AWARE_ERROR_NONESuccessful
WIFI_AWARE_ERROR_NOT_SUPPORTEDNot supported
WIFI_AWARE_ERROR_INVALID_PARAMETERInvalid function parameter
WIFI_AWARE_ERROR_NOT_INITIALIZEDNot initialized
See also:
wifi_aware_session_set_terminated_cb()
int wifi_aware_session_update_publish ( wifi_aware_session_h  session,
wifi_aware_publish_h  publish,
wifi_aware_published_cb  callback,
void *  user_data 
)

Updates the configuration for a Wi-Fi Aware service that has already been published.

Since :
9.0
Privilege Level:
public
Privilege:
http://tizen.org/privilege/network.set
Parameters:
[in]sessionThe Wi-Fi Aware Session handle
[in]publishThe Wi-Fi Aware Publish handle
[in]callbackThe callback which gets called when a service is updated
[in]user_dataThe user data passed to the callback function
Returns:
0 on success, otherwise a negative error value
Return values:
WIFI_AWARE_ERROR_NONESuccessful
WIFI_AWARE_ERROR_NOT_SUPPORTEDNot supported
WIFI_AWARE_ERROR_PERMISSION_DENIEDPermission denied
WIFI_AWARE_ERROR_INVALID_PARAMETERInvalid function parameter
WIFI_AWARE_ERROR_NOT_INITIALIZEDNot initialized
WIFI_AWARE_ERROR_INVALID_OPERATIONInvalid operation
WIFI_AWARE_ERROR_OPERATION_FAILEDOperation failed
See also:
wifi_aware_session_publish()
int wifi_aware_session_update_subscribe ( wifi_aware_session_h  session,
wifi_aware_subscribe_h  subscribe,
wifi_aware_subscribed_cb  callback,
void *  user_data 
)

Updates the configuration for a Wi-Fi Aware service that has already been subscribed.

Since :
9.0
Privilege Level:
public
Privilege:
http://tizen.org/privilege/network.set
Parameters:
[in]sessionThe Wi-Fi Aware Session handle
[in]subscribeThe Wi-Fi Aware Subscribe handle
[in]callbackThe callback which gets called when service is updated
[in]user_dataThe user data passed to the callback function
Returns:
0 on success, otherwise a negative error value
Return values:
WIFI_AWARE_ERROR_NONESuccessful
WIFI_AWARE_ERROR_NOT_SUPPORTEDNot supported
WIFI_AWARE_ERROR_PERMISSION_DENIEDPermission denied
WIFI_AWARE_ERROR_INVALID_PARAMETERInvalid function parameter
WIFI_AWARE_ERROR_NOT_INITIALIZEDNot initialized
WIFI_AWARE_ERROR_INVALID_OPERATIONInvalid operation
WIFI_AWARE_ERROR_OPERATION_FAILEDOperation failed
See also:
wifi_aware_session_subscribe()