Tizen Native API
6.5
|
Wi-Fi Direct provides API to manage Wi-Fi Direct.
Required Header
#include <wifi-direct.h>
Overview
This set of functions is used to manage the settings of Wi-Fi Direct. In addition, this set provides functions to connect and disconnect remote devices using Wi-Fi Direct.
Related Features
This API is related with the following features:
- http://tizen.org/feature/network.wifi
- http://tizen.org/feature/network.wifi.direct
- http://tizen.org/feature/network.wifi.direct.display
- http://tizen.org/feature/network.wifi.direct.service_discovery
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 | wifi_direct_initialize (void) |
Initializes Wi-Fi Direct service. | |
int | wifi_direct_deinitialize (void) |
Deinitializes Wi-Fi Direct service. | |
int | wifi_direct_set_device_state_changed_cb (wifi_direct_device_state_changed_cb cb, void *user_data) |
Sets the callback called when the state of device is changed. | |
int | wifi_direct_unset_device_state_changed_cb (void) |
Unsets the callback called when the state of device is changed. | |
int | wifi_direct_set_discovery_state_changed_cb (wifi_direct_discovery_state_chagned_cb cb, void *user_data) |
Sets the callback called when the state of discovery is changed. | |
int | wifi_direct_unset_discovery_state_changed_cb (void) |
Unsets the callback called when the state of discovery is changed. | |
int | wifi_direct_set_peer_found_cb (wifi_direct_peer_found_cb cb, void *user_data) |
Sets the callback called when the peer is found. | |
int | wifi_direct_unset_peer_found_cb (void) |
Unsets the callback called when the peer is found. | |
int | wifi_direct_set_connection_state_changed_cb (wifi_direct_connection_state_changed_cb cb, void *user_data) |
Sets the callback called when the state of connection is changed. | |
int | wifi_direct_unset_connection_state_changed_cb (void) |
Unsets the callback called when the state of connection is changed. | |
int | wifi_direct_set_peer_info_connection_state_changed_cb (wifi_direct_peer_info_connection_state_changed_cb cb, void *user_data) |
Sets the callback called when the state of connection is changed. | |
int | wifi_direct_unset_peer_info_connection_state_changed_cb (void) |
Unsets the callback called when the state of connection is changed. | |
int | wifi_direct_set_client_ip_address_assigned_cb (wifi_direct_client_ip_address_assigned_cb cb, void *user_data) |
Sets the callback called when the IP address of the client is assigned if your device is the group owner. | |
int | wifi_direct_unset_client_ip_address_assigned_cb (void) |
Unsets the callback called when the IP address of the client is assigned if your device is the group owner. | |
int | wifi_direct_set_service_state_changed_cb (wifi_direct_service_state_changed_cb cb, void *user_data) |
Sets the callback called when the state of the service discovery is changed. | |
int | wifi_direct_unset_service_state_changed_cb (void) |
Unsets the callback called when the state of the service discovery is changed. | |
int | wifi_direct_set_state_changed_cb (wifi_direct_state_changed_cb cb, void *user_data) |
Sets the callback called when the state of Wi-Fi Direct is changed. | |
int | wifi_direct_unset_state_changed_cb (void) |
Unsets the callback called when the state of Wi-Fi Direct is changed. | |
int | wifi_direct_activate (void) |
Activates the Wi-Fi Direct service, asynchronously. | |
int | wifi_direct_deactivate (void) |
Deactivates the Wi-Fi Direct service, asynchronously. | |
int | wifi_direct_start_discovery (bool listen_only, int timeout) |
Starts discovery to find all P2P capable devices, asynchronously. | |
int | wifi_direct_start_discovery_specific_channel (bool listen_only, int timeout, wifi_direct_discovery_channel_e channel) |
Starts discovery to find all P2P capable devices with specified channel, asynchronously. | |
int | wifi_direct_start_discovery_specific_freq (bool listen_only, int timeout, int frequency) |
Starts discovery to find all P2P capable devices with specified frequency, asynchronously. | |
int | wifi_direct_cancel_discovery (void) |
Cancels discovery process, asynchronously. | |
int | wifi_direct_foreach_discovered_peers (wifi_direct_discovered_peer_cb callback, void *user_data) |
Gets the information of discovered peers. | |
int | wifi_direct_connect (char *mac_address) |
Connects to a specified peer, asynchronously. | |
int | wifi_direct_cancel_connection (char *mac_address) |
Cancels the connection now in progress. | |
int | wifi_direct_disconnect_all (void) |
Disconnects all connected links to peers, asynchronously. | |
int | wifi_direct_disconnect (char *mac_address) |
Disconnects the specified peer, asynchronously. | |
int | wifi_direct_foreach_connected_peers (wifi_direct_connected_peer_cb callback, void *user_data) |
Gets the information of connected peers. | |
int | wifi_direct_create_group (void) |
Creates a Wi-Fi Direct Group, asynchronously. | |
int | wifi_direct_create_group_with_ssid (const char *ssid) |
Creates a Wi-Fi Direct Group, asynchronously with given SSID name. | |
int | wifi_direct_destroy_group (void) |
Destroys the Wi-Fi Direct Group, asynchronously. | |
int | wifi_direct_is_group_owner (bool *is_group_owner) |
Checks whether this device is the group owner or not. | |
int | wifi_direct_is_autonomous_group (bool *is_autonomous_group) |
Checks whether the current group is the autonomous group or not. | |
int | wifi_direct_set_device_name (const char *device_name) |
Sets the friendly name of a local device. | |
int | wifi_direct_get_device_name (char **device_name) |
Gets the name of a local device. | |
int | wifi_direct_get_ssid (char **ssid) |
Gets SSID (Service Set Identifier) of a local device. | |
int | wifi_direct_get_network_interface_name (char **name) |
Gets the name of network interface (for example: eth0, pdp0). | |
int | wifi_direct_get_ip_address (char **ip_address) |
Gets IP address of a local device. | |
int | wifi_direct_get_subnet_mask (char **subnet_mask) |
Gets the Subnet Mask. | |
int | wifi_direct_get_gateway_address (char **gateway_address) |
Gets the Gateway address. | |
int | wifi_direct_get_mac_address (char **mac_address) |
Gets MAC address of a local device. | |
int | wifi_direct_get_state (wifi_direct_state_e *state) |
Gets the state of Wi-Fi Direct service. | |
int | wifi_direct_is_discoverable (bool *discoverable) |
Checks whether this device is discoverable or not by P2P discovery. | |
int | wifi_direct_is_listening_only (bool *listen_only) |
Checks whether the local device is listening only. | |
int | wifi_direct_get_primary_device_type (wifi_direct_primary_device_type_e *type) |
Gets the primary device type of a local device. | |
int | wifi_direct_get_secondary_device_type (wifi_direct_secondary_device_type_e *type) |
Gets the secondary device type of a local device. | |
int | wifi_direct_activate_pushbutton (void) |
Sets the WPS config PBC as preferred method for connection. | |
int | wifi_direct_set_wps_pin (char *pin) |
Sets or updates the WPS PIN number user expects. | |
int | wifi_direct_get_wps_pin (char **pin) |
Gets the WPS PIN number. | |
int | wifi_direct_get_supported_wps_mode (int *wps_mode) |
Gets all the supported WPS (Wi-Fi Protected Setup) types at local device. | |
int | wifi_direct_foreach_supported_wps_types (wifi_direct_supported_wps_type_cb callback, void *user_data) |
Gets the supported WPS (Wi-Fi Protected Setup) types. | |
int | wifi_direct_get_local_wps_type (wifi_direct_wps_type_e *type) |
Gets the WPS (Wi-Fi Protected Setup) type. | |
int | wifi_direct_set_req_wps_type (wifi_direct_wps_type_e type) |
Sets the requested WPS (Wi-Fi Protected Setup) type. | |
int | wifi_direct_get_req_wps_type (wifi_direct_wps_type_e *type) |
Gets the requested WPS (Wi-Fi Protected Setup) type. | |
int | wifi_direct_set_group_owner_intent (int intent) |
Sets the intent of the group owner. | |
int | wifi_direct_set_go_intent_per_type (int type, int intent) |
Sets the intent of the group owner for each connection type. | |
int | wifi_direct_get_group_owner_intent (int *intent) |
Gets the intent of the group owner. | |
int | wifi_direct_get_go_intent_per_type (int type, int *intent) |
Gets the intent of the group owner for each connection type. | |
int | wifi_direct_set_max_clients (int max) |
Sets the max number of clients. | |
int | wifi_direct_get_max_clients (int *max) |
Gets the max number of clients. | |
int | wifi_direct_set_passphrase (const char *passphrase) |
Sets or updates Wi-Fi Protected Access (WPA) password. When creating Wi-Fi Direct Group, this password will be used. | |
int | wifi_direct_get_passphrase (char **passphrase) |
Gets the Wi-Fi Protected Access (WPA) password when creating Wi-Fi Direct Group. | |
int | wifi_direct_get_operating_channel (int *channel) |
Gets the operating channel. | |
int | wifi_direct_set_autoconnection_mode (bool mode) |
Sets the Autoconnection mode. | |
int | wifi_direct_is_autoconnection_mode (bool *mode) |
Gets the Autoconnection mode status. | |
int | wifi_direct_set_autoconnection_peer (char *mac_address) |
Allows a device to connect automatically. | |
int | wifi_direct_set_persistent_group_enabled (bool enabled) |
Enables the persistent group. | |
int | wifi_direct_is_persistent_group_enabled (bool *enabled) |
Checks whether the persistent group is enabled or disabled. | |
int | wifi_direct_foreach_persistent_groups (wifi_direct_persistent_group_cb callback, void *user_data) |
Gets the persistent groups. | |
int | wifi_direct_remove_persistent_group (char *mac_address, const char *ssid) |
Removes a persistent group. | |
int | wifi_direct_start_service_discovery (char *mac_address, wifi_direct_service_type_e service_type) |
Starts wifi direct service discovery. | |
int | wifi_direct_cancel_service_discovery (char *mac_address, wifi_direct_service_type_e service_type) |
Cancels an ongoing wifi direct service discovery. | |
int | wifi_direct_register_service (wifi_direct_service_type_e service_type, char *info1, char *info2, unsigned int *service_id) |
Registers for a service using Wi-Fi Direct Service Discovery. | |
int | wifi_direct_deregister_service (unsigned int service_id) |
Deregisters for a service used for Wi-Fi Direct Service Discovery. | |
int | wifi_direct_init_miracast (bool enable) |
Initializes OR Deintializes the WiFi Direct Display (MIRACAST) service. | |
int | wifi_direct_get_peer_info (char *mac_address, wifi_direct_discovered_peer_info_s **peer_info) |
Gets the information of a discovered peer. | |
int | wifi_direct_init_display (void) |
Enables Wi-Fi Display (WFD) functionality and initialize the various variables required for WFD. | |
int | wifi_direct_deinit_display (void) |
Disables Wi-Fi Display functionality & disables the support of WFD Information Element (IE). | |
int | wifi_direct_set_display (wifi_direct_display_type_e type, int port, int hdcp) |
Sets the Wi-Fi Display parameters for the WFD IE of local device. | |
int | wifi_direct_set_display_availability (bool availability) |
Sets the Wi-Fi Display Session Availability. | |
int | wifi_direct_get_display (wifi_direct_display_type_e *type, int *port, int *hdcp) |
Gets the Wi-Fi Display parameters for the WFD IE of local device. | |
int | wifi_direct_get_display_availability (bool *availability) |
Gets the Wi-Fi Display Session Availability. | |
int | wifi_direct_get_peer_display_type (char *mac_address, wifi_direct_display_type_e *type) |
Gets the information of a peer's Wi-Fi Display device type. | |
int | wifi_direct_get_peer_display_availability (char *mac_address, bool *availability) |
Gets the information of a peer's Wi-Fi Display session availability. | |
int | wifi_direct_get_peer_display_hdcp (char *mac_address, int *hdcp) |
Gets the information of a peer's Wi-Fi Display HDCP support. | |
int | wifi_direct_get_peer_display_port (char *mac_address, int *port) |
Gets the information of a peer's Wi-Fi Display RTSP control port. | |
int | wifi_direct_get_peer_display_throughput (char *mac_address, int *throughput) |
Gets the information of a peer's Wi-Fi Display max throughput. | |
int | wifi_direct_set_auto_group_removal (bool enable) |
Enables / Disables automatic group removal feature when all peers are disconnected. | |
int | wifi_direct_set_session_timer (int seconds) |
Sets the timer which is used to expire the connection session. | |
int | wifi_direct_get_session_timer (int *seconds) |
Gets the timer which is used to expire the connection session. | |
int | wifi_direct_get_peer_rssi (char *mac_address, int *rssi) |
Gets the information of a peer's RSSI value. | |
int | wifi_direct_add_vsie (wifi_direct_vsie_frames_e frame_id, const char *vsie_str) |
Adds the Wi-Fi Vendor Specific Information Element (VSIE) to specific frame type. | |
int | wifi_direct_get_vsie (wifi_direct_vsie_frames_e frame_id, char **vsie_str) |
Gets the Wi-Fi Vendor Specific Information Elements (VSIE) from specific frame. | |
int | wifi_direct_remove_vsie (wifi_direct_vsie_frames_e frame_id, const char *vsie_str) |
Removes the Wi-Fi Vendor Specific Information Element (VSIE) from specific frame. | |
int | wifi_direct_get_connecting_peer_info (wifi_direct_discovered_peer_info_s **peer_info) |
Gets the information of peer devices which is in the connecting state. | |
int | wifi_direct_get_peer_vsie (char *mac_address, char **vsie) |
Gets the vendor specific information element (VSIE) of a peer. | |
int | wifi_direct_set_wps_config_method (int type) |
Sets the advertizing WPS (Wi-Fi Protected Setup) type. | |
int | wifi_direct_get_wps_config_method (int *type) |
Gets the advertizing WPS (Wi-Fi Protected Setup) type. | |
int | wifi_direct_remove_persistent_device (char *mac_address) |
Removes a persistent device. | |
int | wifi_direct_remove_all_persistent_devices (void) |
Removes all persistent devices. | |
Typedefs | |
typedef void(* | wifi_direct_discovery_state_chagned_cb )(int error_code, wifi_direct_discovery_state_e discovery_state, void *user_data) |
Called when the state of discovery is changed. | |
typedef void(* | wifi_direct_peer_found_cb )(int error_code, wifi_direct_discovery_state_e discovery_state, const char *mac_address, void *user_data) |
Called when the peer is found. | |
typedef void(* | wifi_direct_device_state_changed_cb )(int error_code, wifi_direct_device_state_e device_state, void *user_data) |
Called when the state of device is changed. | |
typedef void(* | wifi_direct_connection_state_changed_cb )(int error_code, wifi_direct_connection_state_e connection_state, const char *mac_address, void *user_data) |
Called when the state of connection is changed. | |
typedef void(* | wifi_direct_peer_info_connection_state_changed_cb )(wifi_direct_error_e error_code, wifi_direct_connection_state_e connection_state, wifi_direct_connection_state_cb_data_s data_s, void *user_data) |
Called when the state of connection is changed. | |
typedef void(* | wifi_direct_client_ip_address_assigned_cb )(const char *mac_address, const char *ip_address, const char *interface_address, void *user_data) |
Called when IP address of client is assigned when your device is the group owner. | |
typedef void(* | wifi_direct_service_state_changed_cb )(int error_code, wifi_direct_service_discovery_state_e service_state, wifi_direct_service_type_e service_type, void *response_data, const char *mac_address, void *user_data) |
Called when the state of Service discovery is changed. | |
typedef void(* | wifi_direct_state_changed_cb )(wifi_direct_state_e state, void *user_data) |
Called when the state of Wi-FI Direct is changed. | |
typedef bool(* | wifi_direct_discovered_peer_cb )(wifi_direct_discovered_peer_info_s *peer, void *user_data) |
Called repeatedly when you get the information of discovered peers. | |
typedef bool(* | wifi_direct_connected_peer_cb )(wifi_direct_connected_peer_info_s *peer, void *user_data) |
Called repeatedly when you get the information of connected peers. | |
typedef bool(* | wifi_direct_supported_wps_type_cb )(wifi_direct_wps_type_e type, void *user_data) |
Called when you get the supported WPS (Wi-Fi Protected Setup) type repeatedly. | |
typedef bool(* | wifi_direct_persistent_group_cb )(const char *mac_address, const char *ssid, void *user_data) |
Called when you get the persistent groups repeatedly. | |
Defines | |
#define | WIFI_DIRECT_MAX_DEVICE_NAME_LEN 32 |
Wi-Fi Direct Device Name maximum length. | |
#define | WIFI_DIRECT_MAC_ADDRESS_LEN 18 |
Wi-Fi Direct MAC Address length. |
Define Documentation
#define WIFI_DIRECT_MAC_ADDRESS_LEN 18 |
Wi-Fi Direct MAC Address length.
- Since :
- 5.0
#define WIFI_DIRECT_MAX_DEVICE_NAME_LEN 32 |
Wi-Fi Direct Device Name maximum length.
- Since :
- 5.0
Typedef Documentation
typedef void(* wifi_direct_client_ip_address_assigned_cb)(const char *mac_address, const char *ip_address, const char *interface_address, void *user_data) |
Called when IP address of client is assigned when your device is the group owner.
The following error codes can be delivered WIFI_DIRECT_ERROR_NONE WIFI_DIRECT_ERROR_OPERATION_FAILED WIFI_DIRECT_ERROR_NOT_PERMITTED
- Since :
- 2.3
- Remarks:
- The mac_address can be used only in the callback. To use outside, make a copy. The ip_address can be used only in the callback. To use outside, make a copy. The interface_address can be used only in the callback. To use outside, make a copy.
- Parameters:
-
[in] mac_address The MAC address of connection peer [in] ip_address The IP address of connection peer [in] interface_address The interface address of connection peer [in] user_data The user data passed from the callback registration function
- Precondition:
- This callback will be invoked in the thread-default main context of the thread from which you registered this callback using wifi_direct_set_client_ip_address_assigned_cb().
typedef bool(* wifi_direct_connected_peer_cb)(wifi_direct_connected_peer_info_s *peer, void *user_data) |
Called repeatedly when you get the information of connected peers.
- Since :
- 2.3
- Remarks:
- peer is valid only in this function.
- Parameters:
-
[in] peer The information of discovered peer [in] user_data The user data passed from foreach function
- Returns:
true
to continue with the next iteration of the loop,false
to break out of the loop
typedef void(* wifi_direct_connection_state_changed_cb)(int error_code, wifi_direct_connection_state_e connection_state, const char *mac_address, void *user_data) |
Called when the state of connection is changed.
The following error codes can be delivered WIFI_DIRECT_ERROR_NONE WIFI_DIRECT_ERROR_OPERATION_FAILED WIFI_DIRECT_ERROR_NOT_PERMITTED WIFI_DIRECT_ERROR_CONNECTION_FAILED
- Since :
- 2.3
- Remarks:
- The mac_address can be used only in the callback. To use outside, make a copy.
- Parameters:
-
[in] error_code The error code [in] connection_state The connection state [in] mac_address The MAC address of the connection peer [in] user_data The user data passed from the callback registration function
- Precondition:
- wifi_direct_create_group(), wifi_direct_destroy_group(), wifi_direct_connect(), wifi_direct_disconnect() or wifi_direct_disconnect_all() will invoke this callback in the thread-default main context of the thread from which you registered this callback using using wifi_direct_set_connection_state_changed_cb().
typedef void(* wifi_direct_device_state_changed_cb)(int error_code, wifi_direct_device_state_e device_state, void *user_data) |
Called when the state of device is changed.
The following error codes can be delivered WIFI_DIRECT_ERROR_NONE WIFI_DIRECT_ERROR_OPERATION_FAILED WIFI_DIRECT_ERROR_NOT_PERMITTED
- Since :
- 2.3
- Parameters:
-
[in] error_code The error code [in] device_state The device state [in] user_data The user data passed from the callback registration function
- Precondition:
- Either wifi_direct_activate() or wifi_direct_deactivate() will invoke this callback in the thread-default main context of the thread from which you registered this callback using wifi_direct_set_device_state_changed_cb().
typedef bool(* wifi_direct_discovered_peer_cb)(wifi_direct_discovered_peer_info_s *peer, void *user_data) |
Called repeatedly when you get the information of discovered peers.
- Since :
- 2.3
- Remarks:
- peer is valid only in this function.
- Parameters:
-
[in] peer The information of the discovered peer [in] user_data The user data passed from foreach function
- Returns:
true
to continue with the next iteration of the loop,false
to break out of the loop
typedef void(* wifi_direct_discovery_state_chagned_cb)(int error_code, wifi_direct_discovery_state_e discovery_state, void *user_data) |
Called when the state of discovery is changed.
The following error codes can be delivered WIFI_DIRECT_ERROR_NONE WIFI_DIRECT_ERROR_OPERATION_FAILED WIFI_DIRECT_ERROR_NOT_PERMITTED
- Since :
- 2.3
- Parameters:
-
[in] error_code The error code [in] discovery_state The discovery state [in] user_data The user data passed from the callback registration function
- Precondition:
- Either wifi_direct_start_discovery() or wifi_direct_cancel_discovery() will invoke this callback in the thread-default main context of the thread from which you registered this callback using wifi_direct_set_discovery_state_changed_cb().
typedef void(* wifi_direct_peer_found_cb)(int error_code, wifi_direct_discovery_state_e discovery_state, const char *mac_address, void *user_data) |
Called when the peer is found.
The following error codes can be delivered WIFI_DIRECT_ERROR_NONE WIFI_DIRECT_ERROR_OPERATION_FAILED WIFI_DIRECT_ERROR_NOT_PERMITTED
- Since :
- 2.3
- Remarks:
- The mac_address can be used only in the callback. To use outside, make a copy.
- Parameters:
-
[in] error_code The error code [in] discovery_state The discovery state [in] mac_address The MAC address of found peer [in] user_data The user data passed from the callback registration function
- Precondition:
- Either wifi_direct_start_discovery() or wifi_direct_cancel_discovery() will invoke this callback in the thread-default main context of the thread from which you registered this callback using wifi_direct_set_peer_found_cb().
typedef void(* wifi_direct_peer_info_connection_state_changed_cb)(wifi_direct_error_e error_code, wifi_direct_connection_state_e connection_state, wifi_direct_connection_state_cb_data_s data_s, void *user_data) |
Called when the state of connection is changed.
The following error codes can be delivered:
WIFI_DIRECT_ERROR_NONE
WIFI_DIRECT_ERROR_OPERATION_FAILED
WIFI_DIRECT_ERROR_NOT_PERMITTED
- Since :
- 5.0
- Parameters:
-
[in] error_code The error code [in] connection_state The connection state [in] data_s The structure for peer data [in] user_data The user data passed from the callback registration function
- Precondition:
- wifi_direct_create_group(), wifi_direct_destroy_group(), wifi_direct_connect(), wifi_direct_disconnect() or wifi_direct_disconnect_all() will invoke this callback if you register this callback using wifi_direct_set_peer_info_connection_state_changed_cb().
typedef bool(* wifi_direct_persistent_group_cb)(const char *mac_address, const char *ssid, void *user_data) |
Called when you get the persistent groups repeatedly.
- Since :
- 2.3
- Remarks:
- The mac_address can be used only in the callback. To use outside, make a copy. The ssid can be used only in the callback. To use outside, make a copy.
- Parameters:
-
[in] mac_address The MAC address of the persistent group owner [in] ssid The SSID (Service Set Identifier) of the persistent group owner [in] user_data The user data passed from the request function
- Returns:
true
to continue with the next iteration of the loop,
false
to break out of the loop
- Precondition:
- wifi_direct_foreach_persistent_groups() will invoke this callback.
typedef void(* wifi_direct_service_state_changed_cb)(int error_code, wifi_direct_service_discovery_state_e service_state, wifi_direct_service_type_e service_type, void *response_data, const char *mac_address, void *user_data) |
Called when the state of Service discovery is changed.
The following error codes can be delivered WIFI_DIRECT_ERROR_NONE WIFI_DIRECT_ERROR_OPERATION_FAILED WIFI_DIRECT_ERROR_NOT_PERMITTED
- Since :
- 2.3
- Remarks:
- The mac_address can be used only in the callback. To use outside, make a copy.
- Parameters:
-
[in] error_code The error code [in] service_state The service discovery state [in] service_type Specifies the types of service [in] response_data Received response [in] mac_address The MAC address of the connection peer [in] user_data User can transfer the user specific data in callback
- Precondition:
- Either wifi_direct_start_service_discovery() or wifi_direct_cancel_service_discovery() will invoke this callback in the thread-default main context of the thread from which you registered this callback using wifi_direct_set_service_state_changed_cb().
typedef void(* wifi_direct_state_changed_cb)(wifi_direct_state_e state, void *user_data) |
Called when the state of Wi-FI Direct is changed.
- Since :
- 3.0
- Parameters:
-
[in] state The Wi-Fi Direct state [in] user_data The user data passed from the callback registration function
- Precondition:
- Changes in Wi-Fi Direct state will invoke this callback if you register this callback using wifi_direct_set_state_changed_cb().
typedef bool(* wifi_direct_supported_wps_type_cb)(wifi_direct_wps_type_e type, void *user_data) |
Called when you get the supported WPS (Wi-Fi Protected Setup) type repeatedly.
- Since :
- 2.3
- Parameters:
-
[in] type The type of WPS [in] user_data The user data passed from the request function
- Returns:
true
to continue with the next iteration of the loop,
false
to break out of the loop
- Precondition:
- wifi_direct_foreach_supported_wps_types() will invoke this callback.
Enumeration Type Documentation
Enumeration for WPS Config Method type.
- Since :
- 5.0
Enumeration for Wi-Fi Direct connection state.
- Since :
- 2.3
- Enumerator:
Enumeration for Wi-Fi Direct device state.
- Since :
- 2.3
Enumeration for Wi-Fi Direct Discovery Channel.
- Since :
- 2.3
Enumeration for Wi-Fi Direct discovery state.
- Since :
- 2.3
Enumeration for Wi-Fi Display device type.
- Since :
- 2.4
enum wifi_direct_error_e |
Enumeration for Wi-Fi Direct error code.
- Since :
- 2.3
- Enumerator:
Enumeration for Wi-Fi Direct primary device type.
- Since :
- 2.3
- Enumerator:
Enumeration for Wi-Fi Direct secondary device type.
- Since :
- 2.3
- Enumerator:
Enumeration for Wi-Fi Direct service Discovery state.
- Since :
- 2.3
Enumeration for Service Discovery type.
- Since :
- 2.3
- See also:
- wifi_direct_service_state_changed_cb()
- wifi_direct_start_service_discovery()
- wifi_direct_cancel_service_discovery()
- wifi_direct_register_service()
- Enumerator:
enum wifi_direct_state_e |
Enumeration for Wi-Fi Direct link status.
- Since :
- 2.3
- Enumerator:
Enumeration for Wi-Fi Frame type.
- Since :
- 4.0
- Enumerator:
Enumeration for Wi-Fi WPS type.
- Since :
- 2.3
enum wifi_display_type_e |
Enumeration for Wi-Fi Display device type.
- Deprecated:
- Deprecated since 5.0. Use wifi_direct_display_type_e instead.
- Since :
- 2.3
Function Documentation
int wifi_direct_activate | ( | void | ) |
Activates the Wi-Fi Direct service, asynchronously.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy WIFI_DIRECT_ERROR_WIFI_USED Wi-Fi is being used WIFI_DIRECT_ERROR_MOBILE_AP_USED Mobile AP is being used
- Precondition:
- Wi-Fi Direct service must be initialized by wifi_direct_initialize().
- Postcondition:
- wifi_direct_device_state_changed_cb() will be invoked.
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int ret; ret = wifi_direct_activate(); // Activate Wi-Fi Direct if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to activate Wi-Fi Direct\n"); return -1; } printf("Wi-Fi Direct Activated\n"); return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct function(); wifi_direct_deactivate(); // deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_activate_pushbutton | ( | void | ) |
Sets the WPS config PBC as preferred method for connection.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate().
- See also:
- wifi_direct_activate()
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int ret; ret = wifi_direct_activate_pushbutton(); // Activate WPS PBC Push Button if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to activate push button\n"); return -1; } printf("Push button Activated successfully\n"); return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_add_vsie | ( | wifi_direct_vsie_frames_e | frame_id, |
const char * | vsie_str | ||
) |
Adds the Wi-Fi Vendor Specific Information Element (VSIE) to specific frame type.
- Since :
- 4.0
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Remarks:
- vsie_str for frame_id will be in effect until Wi-Fi Direct is deactivated.
- Parameters:
-
[in] frame_id frame ID for setting VSIE [in] vsie_str VSIE data
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate().
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int ret; char *vsie = NULL; unsigned int frame_id; printf("Input the frame id\n"); scanf("%2u", &frame_id); printf("Input the vsie\n"); scanf("%100ms", &vsie); ret = wifi_direct_add_vsie(frame_id, vsie); // add vsie if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to add vsie\n"); return -1; } printf("vsie added success"); free(vsie); return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_cancel_connection | ( | char * | mac_address | ) |
Cancels the connection now in progress.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[in] mac_address The MAC address of rejected device
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> bool peer_selected = false; int connection_timeout = 0; int count = 0; // counter to wait for connection int function(char *mac); gboolean connection_timeout_cb(gpointer data) { char *mac = (char *)data; if (count < 3) { count++; return TRUE; } function(mac); // cancel ongoing connection g_free(mac); return FALSE; } void peers_cb(wifi_direct_discovered_peer_info_s* peer, void *user_data) { char *mac; if (peer && !peer_selected) { printf("peer device=%s MAC=%s\n", peer->device_name, peer->mac_address); mac = g_strdup(peer->mac_address); peer_selected = true; wifi_direct_connect(mac); // Connect to the selected peer connection_timeout = g_timeout_add(1000, connection_timeout_cb, mac); // Add 3secs timeout } } int function(char *mac) { int ret; ret = wifi_direct_cancel_connection(mac); // cancel connection if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to cancel the ongoing connection\n"); return -1; } return 0; } void callback_2(int error_code, wifi_direct_connection_state_e state, const char *mac, void *user_data) *{ switch (state) { case WIFI_DIRECT_CONNECTION_IN_PROGRESS: printf("Connection in progress\n"); break; case WIFI_DIRECT_CONNECTON_RSP: printf("Connected\n"); g_source_remove(connection_timeout); break; case WIFI_DIRECT_DISCONNECTION_IND: printf("Disconnection IND\n"); break; case WIFI_DIRECT_DISCONNECTION_RSP; printf("Disconnected\n"); break; } *} void callback_1(int error_code, wifi_direct_discovery_state_e discovery_state, void *user_data) { switch(discovery_state) { case WIFI_DIRECT_DISCOVERY_STARTED: printf("Discovery started\n"); break; case WIFI_DIRECT_ONLY_LISTEN_STARTED: printf("listen started\n"); break; case WIFI_DIRECT_DISCOVERY_FINISHED: printf("Discovery finished\n"); wifi_direct_foreach_discovered_peers(peers_cb, NULL); // Get discovered peer break; case WIFI_DIRECT_DISCOVERY_FOUND: printf("peer devices found\n"); break; case WIFI_DIRECT_DISCOVERY_LOST: printf("Discovery lost\n"); break; default: break; } } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_set_discovery_state_changed_cb(callback_1, NULL); // Register callback 1 wifi_direct_set_connection_state_changed_cb(callback_2, NULL); // Register callback 2 wifi_direct_activate(); // Activate Wi-Fi Direct wifi_direct_start_discovery(TRUE, 15); // Start discovery // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_unset_connection_state_changed_cb(); // Deregister callback 2 wifi_direct_unset_discovery_state_changed_cb(); // Deregister callback 1 wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_cancel_discovery | ( | void | ) |
Cancels discovery process, asynchronously.
This function stops all discovery processes started with wifi_direct_start_discovery() functions.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Discovery must be started by wifi_direct_start_discovery().
- Postcondition:
- wifi_direct_discovery_state_chagned_cb() will be invoked.
- See also:
- wifi_direct_start_discovery()
- wifi_direct_start_discovery_specific_channel()
- wifi_direct_start_discovery_specific_freq()
- wifi_direct_discovery_state_chagned_cb()
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> void callback(int error_code, wifi_direct_discovery_state_e discovery_state, void *user_data) { switch(discovery_state) { case WIFI_DIRECT_DISCOVERY_STARTED: printf("Discovery started\n"); break; case WIFI_DIRECT_ONLY_LISTEN_STARTED: printf("listen started\n"); break; case WIFI_DIRECT_DISCOVERY_FINISHED: printf("Discovery finished\n"); break; case WIFI_DIRECT_DISCOVERY_FOUND: printf("peer devices found\n"); break; case WIFI_DIRECT_DISCOVERY_LOST: printf("Discovery lost\n"); break; default: break; } } int function(void) { int ret; ret = wifi_direct_cancel_discovery(); // Cancel ongoing discovery if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to cancel discovery\n"); return -1; } return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_set_discovery_state_changed_cb(callback, NULL); // Register callback wifi_direct_activate(); // Activate Wi-Fi Direct wifi_direct_start_discovery(TRUE, 15); // Start discovery function(); wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_unset_discovery_state_changed_cb(); // Deregister callback wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_cancel_service_discovery | ( | char * | mac_address, |
wifi_direct_service_type_e | service_type | ||
) |
Cancels an ongoing wifi direct service discovery.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[in] mac_address The MAC address of servicing device. A broadcast
will be sent when MAC is SET to ZERO[in] service_type Describes the type of service
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate().
- See also:
- wifi_direct_activate()
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> void callback(int error_code, wifi_direct_service_discovery_state_e discovery_state, wifi_direct_service_type_e service_type, void *response_data, const char * mac_address, void *user_data) { switch (discovery_state) { case WIFI_DIRECT_SERVICE_DISCOVERY_STARTED: printf("Service discovery started\n"); break; case WIFI_DIRECT_SERVICE_DISCOVERY_FINISHED: printf("Service discovery finished\n"); break; case WIFI_DIRECT_SERVICE_DISCOVERY_FOUND: printf("Service discovery found\n"); break; } } int function(void) { int ret; ret = wifi_direct_cancel_service_discovery(NULL, WIFI_DIRECT_SERVICE_TYPE_ALL); // cancel the ongoing service discovery if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to cancel service discovery\n"); return -1; } return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_set_service_state_changed_cb(callback, NULL); wifi_direct_activate(); // Activate Wi-Fi Direct wifi_direct_start_service_discovery(NULL, WIFI_DIRECT_SERVICE_TYPE_ALL); // start broadcast service discovery function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_unset_service_state_changed_cb(); wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_connect | ( | char * | mac_address | ) |
Connects to a specified peer, asynchronously.
This function connects to specified peer by automatically determining whether to perform group formation, join an existing group, invite, re-invoke a group. The decision is based on the current state of the peers (i.e. GO, STA, not connected) and the availability of persistent data.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[in] mac_address The MAC address of remote device
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_TOO_MANY_CLIENT Too many client WIFI_DIRECT_ERROR_CONNECTION_TIME_OUT Connection timed out WIFI_DIRECT_ERROR_CONNECTION_FAILED Connection failed WIFI_DIRECT_ERROR_AUTH_FAILED Authentication failed
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate().
- Postcondition:
- wifi_direct_connection_state_changed_cb() will be invoked.
- See also:
- wifi_direct_activate()
- wifi_direct_disconnect()
- wifi_direct_disconnect_all()
- wifi_direct_connection_state_changed_cb()
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> bool device_selected = false; void peers_cb(wifi_direct_discovered_peer_info_s* peer, void *user_data) { if (peer && !device_selected) { printf("peer device=%s MAC=%s\n", peer->device_name, peer->mac_address); device_selected = true; function(peer->mac_address); // Connect to the first discovered peer } } int function(const char *mac) { int ret; ret = wifi_direct_connect(mac); // connect to the peer device if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to connect the peer\n"); return -1; } return 0; } void callback_2(int error_code, wifi_direct_connection_state_e state, const char *mac, void *user_data) *{ switch (state) { case WIFI_DIRECT_CONNECTION_IN_PROGRESS: printf("Connection in progress\n"); break; case WIFI_DIRECT_CONNECTION_RSP: printf("Connected\n"); break; case WIFI_DIRECT_DISCONNECTION_IND: printf("Disconnection IND\n"); break; case WIFI_DIRECT_DISCONNECTION_RSP; printf("Disconnected\n"); break; } } void callback_1(int error_code, wifi_direct_discovery_state_e discovery_state, void *user_data) { switch(discovery_state) { case WIFI_DIRECT_DISCOVERY_STARTED: printf("Discovery started\n"); break; case WIFI_DIRECT_ONLY_LISTEN_STARTED: printf("listen started\n"); break; case WIFI_DIRECT_DISCOVERY_FINISHED: printf("Discovery finished\n"); wifi_direct_foreach_discovered_peers(peers_cb, NULL); // Get discovered peer break; case WIFI_DIRECT_DISCOVERY_FOUND: printf("peer devices found\n"); break; case WIFI_DIRECT_DISCOVERY_LOST: printf("Discovery lost\n"); break; default: break; } } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_set_discovery_state_changed_cb(callback_1, NULL); // Register callback 1 wifi_direct_set_connection_state_changed_cb(callback_2, NULL); // Register callback 2 wifi_direct_activate(); // Activate Wi-Fi Direct wifi_direct_start_discovery(TRUE, 15); // Start discovery // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_unset_discovery_state_changed_cb(); // Deregister callback wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_create_group | ( | void | ) |
Creates a Wi-Fi Direct Group, asynchronously.
This function sets up device as the Group Owner and waits for clients to connect. In addition, a soft AP will be created, the WPS registrar and the DHCP server will be started.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy WIFI_DIRECT_ERROR_AUTH_FAILED Authentication failed
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate().
- Postcondition:
- wifi_direct_connection_state_changed_cb() will be invoked with WIFI_DIRECT_GROUP_CREATED.
- See also:
- wifi_direct_activate()
- wifi_direct_destroy_group()
- wifi_direct_connection_state_changed_cb()
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> void callback_1(int error_code, wifi_direct_connection_state_e state, const char *mac, void *user_data) { if (state == WIFI_DIRECT_GROUP_CREATED) { printf("Group created\n"); } } int function(void) { int res; res = wifi_direct_create_group() // create autonomous group if (res != WIFI_DIRECT_ERROR_NONE) { printf("Failed to create group\n"); return -1; } return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_set_connection_state_changed_cb(callback_1, NULL); // Register callback_1 wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_unset_connection_state_changed_cb(); // Deregister callback_1 wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_create_group_with_ssid | ( | const char * | ssid | ) |
Creates a Wi-Fi Direct Group, asynchronously with given SSID name.
This function sets up device as the Group Owner and waits for clients to connect. In addition, a soft AP will be created, the WPS registrar and the DHCP server will be started.
- Since :
- 5.0
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[in] ssid Referred to as a network name, it is a name that identifies a wireless network
- Returns:
- 0 on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameters WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy WIFI_DIRECT_ERROR_AUTH_FAILED Authentication failed
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate().
- Postcondition:
- wifi_direct_connection_state_changed_cb() will be invoked with WIFI_DIRECT_GROUP_CREATED.
int wifi_direct_deactivate | ( | void | ) |
Deactivates the Wi-Fi Direct service, asynchronously.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate().
- Postcondition:
- wifi_direct_device_state_changed_cb() will be invoked.
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int ret; ret = wifi_direct_deactivate(); // Deactivate Wi-Fi Direct if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to deactivate Wi-Fi Direct\n"); return -1; } printf("Wi-Fi Direct Deactivated\n"); return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activated Wi-Fi Direct function(); wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_deinit_display | ( | void | ) |
Disables Wi-Fi Display functionality & disables the support of WFD Information Element (IE).
- Since :
- 2.4
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate() and Wi-Fi Display must be enabled by wifi_direct_init_display().
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int ret; wifi_direct_init_display(); ret = wifi_direct_deinit_display(); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to deinit display\n"); return -1; } printf("deinit display success\n"); return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_deinitialize | ( | void | ) |
Deinitializes Wi-Fi Direct service.
- Since :
- 2.3
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported
- Precondition:
- Wi-Fi Direct service must be initialized by wifi_direct_initialize().
- See also:
- wifi_direct_initialize()
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> void function(void) { int ret; ret = wifi_direct_deinitialize(); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to deinitialize\n"); return; } printf("Deinitialized Successfully\n"); } int main() { wifi_direct_initialize(); // initialize Wi-Fi Direct function(); // deinitialize Wi-Fi Direct return 0; }
int wifi_direct_deregister_service | ( | unsigned int | service_id | ) |
Deregisters for a service used for Wi-Fi Direct Service Discovery.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[in] service_id A Service ID for which service has to be deregistered
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate().
- See also:
- wifi_direct_activate()
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int ret; int input; printf("Enter the service id\n"); scanf("%5d", &input); ret = wifi_direct_deregister_service(input); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to deregister service\n"); return -1; } return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_destroy_group | ( | void | ) |
Destroys the Wi-Fi Direct Group, asynchronously.
This function destroys the Wi-Fi Direct Group owned by a local device. If creating a Group is in progress, this function cancels that creating.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy WIFI_DIRECT_ERROR_AUTH_FAILED Authentication failed
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate().
- Postcondition:
- wifi_direct_connection_state_changed_cb() will be invoked with WIFI_DIRECT_GROUP_DESTROYED.
- See also:
- wifi_direct_activate()
- wifi_direct_create_group()
- wifi_direct_connection_state_changed_cb()
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> void callback_1(int error_code, wifi_direct_connection_state_e state, const char *mac, void *user_data) { if (state == WIFI_DIRECT_GROUP_DESTROYED) { printf("Group destroyed\n"); } } int function(void) { int res; res = wifi_direct_destroy_group() // destroy autonomous group if (res != WIFI_DIRECT_ERROR_NONE) { printf("Failed to destroy group\n"); return -1; } return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_set_connection_state_changed_cb(callback_1, NULL); // Register callback_1 wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_unset_connection_state_changed_cb(); // Deregister callback_1 wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_disconnect | ( | char * | mac_address | ) |
Disconnects the specified peer, asynchronously.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[in] mac_address The MAC address of remote device
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate().
- Postcondition:
- wifi_direct_connection_state_changed_cb() will be invoked.
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> bool callback_2(wifi_direct_connected_peer_info_s* peer, void* user_data) { if (peer) { printf("connected device=%s mac=%s\n", peer->device_name, peer->mac_address); } } void callback_1(int error_code, wifi_direct_connection_state_e state, const char *mac, void *user_data) *{ switch (state) { case WIFI_DIRECT_CONNECTION_IN_PROGRESS: printf("Connection in progress\n"); break; case WIFI_DIRECT_CONNECTON_RSP: printf("Connected\n"); break; case WIFI_DIRECT_DISCONNECTION_IND: printf("Disconnection IND\n"); break; case WIFI_DIRECT_DISCONNECTION_RSP; printf("Disconnected mac=%s\n", mac_address); // disconnect notification break; } *} int function(char *mac) { int res; res = wifi_direct_disconnect(mac); // disconnect the connected peer with input mac if (res != WIFI_DIRECT_ERROR_NONE) { printf("Failed to disconnect all clients\n"); return -1; } return 0; } int main() { char mac[16] = {0,}; wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_set_connection_state_changed_cb(callback_1, NULL); // Register callback_1 wifi_direct_activate(); // Activate Wi-Fi Direct * wifi_direct_foreach_connected_peers(callback_2, NULL); // Register callback_2 printf("Enter the connected peer mac address\n"); read(stdin, mac, 15); function(mac); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_unset_connection_state_changed_cb(); // Deregister callback wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_disconnect_all | ( | void | ) |
Disconnects all connected links to peers, asynchronously.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate().
- Postcondition:
- wifi_direct_connection_state_changed_cb() will be invoked.
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> void callback(int error_code, wifi_direct_connection_state_e state, const char *mac, void *user_data) *{ switch (state) { case WIFI_DIRECT_CONNECTION_IN_PROGRESS: printf("Connection in progress\n"); break; case WIFI_DIRECT_CONNECTON_RSP: printf("Connected\n"); break; case WIFI_DIRECT_DISCONNECTION_IND: printf("Disconnection IND\n"); break; case WIFI_DIRECT_DISCONNECTION_RSP; printf("Disconnected\n"); // disconnect notification break; } *} int function(void) { int res; res = wifi_direct_disconnect_all(); // disconnect all the connected peers if (res != WIFI_DIRECT_ERROR_NONE) { printf("Failed to disconnect all clients\n"); return -1; } return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_set_connection_state_changed_cb(callback, NULL); // Register callback wifi_direct_activate(); // Activate Wi-Fi Direct * function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_unset_connection_state_changed_cb(); // Deregister callback wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_foreach_connected_peers | ( | wifi_direct_connected_peer_cb | callback, |
void * | user_data | ||
) |
Gets the information of connected peers.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[in] callback The callback function to invoke [in] user_data The user data to be passed to the callback function
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate().
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> bool callback_1(wifi_direct_connected_peer_info_s* peer, void* user_data) { if (peer) { printf("connected device=%s mac=%s\n", peer->device_name, peer->mac_address); } } int function(char *mac) { int res; res = wifi_direct_foreach_connected_peers(callback_1, NULL) // Get connected peers if (res != WIFI_DIRECT_ERROR_NONE) { printf("Failed to get connected peers\n"); return -1; } return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_foreach_discovered_peers | ( | wifi_direct_discovered_peer_cb | callback, |
void * | user_data | ||
) |
Gets the information of discovered peers.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[in] callback The callback function to invoke [in] user_data The user data to be passed to the callback function
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate().
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> void function_cb(wifi_direct_discovered_peer_info_s* peer, void *user_data) { if (peer) printf("peer device=%s MAC=%s\n", peer->device_name, peer->mac_address); } int function(void) { int ret; ret = wifi_direct_foreach_discovered_peers(function_cb, NULL); // get discovered peer devices info if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to get discovered peers\n"); return -1; } return 0; } void callback(int error_code, wifi_direct_discovery_state_e discovery_state, void *user_data) { switch(discovery_state) { case WIFI_DIRECT_DISCOVERY_STARTED: printf("Discovery started\n"); break; case WIFI_DIRECT_ONLY_LISTEN_STARTED: printf("listen started\n"); break; case WIFI_DIRECT_DISCOVERY_FINISHED: printf("Discovery finished\n"); function(); break; case WIFI_DIRECT_DISCOVERY_FOUND: printf("peer devices found\n"); break; case WIFI_DIRECT_DISCOVERY_LOST: printf("Discovery lost\n"); break; default: break; } } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_set_discovery_state_changed_cb(callback, NULL); // Register callback wifi_direct_activate(); // Activate Wi-Fi Direct wifi_direct_start_discovery(TRUE, 15); // Start discovery // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_unset_discovery_state_changed_cb(); // Deregister callback wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_foreach_persistent_groups | ( | wifi_direct_persistent_group_cb | callback, |
void * | user_data | ||
) |
Gets the persistent groups.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[in] callback The callback function to invoke [in] user_data The user data to be passed to the callback function
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be initialized by wifi_direct_initialize().
- Postcondition:
- wifi_direct_persistent_group_cb() will be called.
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> bool callback(const char *mac_address, const char *ssid, void *user_data) { if (mac_address) printf("mac = %s\n", mac_address); if (ssid) printf("ssid = %s\n", ssid); return true; } int function(void) { int ret; ret = wifi_direct_foreach_persistent_groups(callback, NULL); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to set callback to get persistent groups\n"); return -1; } return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_foreach_supported_wps_types | ( | wifi_direct_supported_wps_type_cb | callback, |
void * | user_data | ||
) |
Gets the supported WPS (Wi-Fi Protected Setup) types.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[in] callback The callback function to invoke [in] user_data The user data to be passed to the callback function
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be initialized by wifi_direct_initialize().
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> bool callback(wifi_direct_wps_types_e type, void *user_data) { switch (type) { case WIFI_DIRECT_WPS_TYPE_PBC: printf("mode is WPS PBC\n"); break; case WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY: printf("mode is WPS PIN Display\n"); break; case WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD: printf("mode is WPS PIN Keypad\n"); break; } } int function(void) { int ret; ret = wifi_direct_foreach_supported_wps_types(callback, NULL); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to get supported wps types\n"); return -1; } return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_get_connecting_peer_info | ( | wifi_direct_discovered_peer_info_s ** | peer_info | ) |
Gets the information of peer devices which is in the connecting state.
- Since :
- 4.0
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Remarks:
- peer_info must be released with free().
- Parameters:
-
[out] peer_info connecting peer device data
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be connecting state by wifi_direct_connect() or by receiving connection request from p2p peer device.
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> bool device_selected = false; void peers_cb(wifi_direct_discovered_peer_info_s* peer, void *user_data) { if (peer && !device_selected) { printf("peer device=%s MAC=%s\n", peer->device_name, peer->mac_address); device_selected = true; wifi_direct_connect(peer->mac_address); // Connect to the first discovered peer } } int function(void) { int ret; wifi_direct_discovered_peer_info_s *peer = NULL; ret = wifi_direct_get_connecting_peer_info(&peer); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to get connecting peer info\n"); return -1; } printf("peer device name (%s) mac (%s)\n", peer->device_name, peer->mac_address); return 0; } void callback_2(int error_code, wifi_direct_connection_state_e state, const char *mac, void *user_data) *{ switch (state) { case WIFI_DIRECT_CONNECTION_IN_PROGRESS: printf("Connection in progress\n"); function(); // get the connecting peer info break; case WIFI_DIRECT_CONNECTION_RSP: printf("Connected\n"); break; case WIFI_DIRECT_DISCONNECTION_IND: printf("Disconnection IND\n"); break; case WIFI_DIRECT_DISCONNECTION_RSP; printf("Disconnected\n"); break; } *} void callback_1(int error_code, wifi_direct_discovery_state_e discovery_state, void *user_data) { switch(discovery_state) { case WIFI_DIRECT_DISCOVERY_STARTED: printf("Discovery started\n"); break; case WIFI_DIRECT_ONLY_LISTEN_STARTED: printf("listen started\n"); break; case WIFI_DIRECT_DISCOVERY_FINISHED: printf("Discovery finished\n"); wifi_direct_foreach_discovered_peers(peers_cb, NULL); // Get discovered peer break; case WIFI_DIRECT_DISCOVERY_FOUND: printf("peer devices found\n"); break; case WIFI_DIRECT_DISCOVERY_LOST: printf("Discovery lost\n"); break; default: break; } } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_set_discovery_state_changed_cb(callback_1, NULL); // Register callback 1 wifi_direct_set_connection_state_changed_cb(callback_2, NULL); // Register callback 2 wifi_direct_activate(); // Activate Wi-Fi Direct wifi_direct_start_discovery(TRUE, 15); // Start discovery // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_unset_discovery_state_changed_cb(); // Deregister callback wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_get_device_name | ( | char ** | device_name | ) |
Gets the name of a local device.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Remarks:
- device_name must be released with free().
- Parameters:
-
[out] device_name The name of a local device
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be initialized by wifi_direct_initialize().
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int res; char *name; res = wifi_direct_get_device_name(&name); // get device name if (res != WIFI_DIRECT_ERROR_NONE) { printf("Failed to get device name\n"); return -1; } printf("device name = %s\n", name); g_free(name); return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_get_display | ( | wifi_direct_display_type_e * | type, |
int * | port, | ||
int * | hdcp | ||
) |
Gets the Wi-Fi Display parameters for the WFD IE of local device.
- Since :
- 5.0
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[out] type WFD device type: role of WFD device like source or sink [out] port Session management control port number, it will be of 2 bytes (0~65535) [out] hdcp CP support bit: ( 1
= hdcp support is enabled,0
= hdcp support is disabled)
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate() and enable Wi-Fi Display by wifi_direct_init_display().
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int ret; wifi_direct_display_type_e type; int port; int hdcp; ret = wifi_direct_get_display(&type, &port, &hdcp); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to get display property\n"); return -1; } printf("get display param success [type:%d], [port:%d], [hdcp:%d]\n", type, port, hdcp); return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_get_display_availability | ( | bool * | availability | ) |
Gets the Wi-Fi Display Session Availability.
- Since :
- 5.0
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[out] availability Wi-Fi display session availability
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate() and enable Wi-Fi Display by wifi_direct_init_display().
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int ret; int availability; ret = wifi_direct_get_display_availability(&availability); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to get display availability\n"); return -1; } printf("get display availability success [%d]\n", availability); return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_get_gateway_address | ( | char ** | gateway_address | ) |
Gets the Gateway address.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Remarks:
- gateway_address must be released using free().
- Parameters:
-
[out] gateway_address The gateway address
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_OUT_OF_MEMORY Out of memory WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate().
- See also:
- wifi_direct_activate()
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void); bool device_selected = false; void peers_cb(wifi_direct_discovered_peer_info_s* peer, void *user_data) { if (peer && !device_selected) { printf("peer device=%s MAC=%s\n", peer->device_name, peer->mac_address); device_selected = true; wifi_direct_connect(peer->mac_address); // Connect to the first discovered peer } } int function(void) { int ret; char *gateway; char *ip; wifi_direct_get_ip_address(&ip); // get ip address ret = wifi_direct_get_gateway_address(&gateway); // get gateway address if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to get gateway address\n"); return -1; } printf("gateway address=%s\n", gateway); g_free(ip); g_free(gateway); return 0; } void callback_2(int error_code, wifi_direct_connection_state_e state, const char *mac, void *user_data) *{ switch (state) { case WIFI_DIRECT_CONNECTION_IN_PROGRESS: printf("Connection in progress\n"); break; case WIFI_DIRECT_CONNECTON_RSP: printf("Connected\n"); function(); break; case WIFI_DIRECT_DISCONNECTION_IND: printf("Disconnection IND\n"); break; case WIFI_DIRECT_DISCONNECTION_RSP; printf("Disconnected\n"); break; } *} void callback_1(int error_code, wifi_direct_discovery_state_e discovery_state, void *user_data) { switch(discovery_state) { case WIFI_DIRECT_DISCOVERY_STARTED: printf("Discovery started\n"); break; case WIFI_DIRECT_ONLY_LISTEN_STARTED: printf("listen started\n"); break; case WIFI_DIRECT_DISCOVERY_FINISHED: printf("Discovery finished\n"); wifi_direct_foreach_discovered_peers(peers_cb, NULL); break; case WIFI_DIRECT_DISCOVERY_FOUND: printf("peer devices found\n"); break; case WIFI_DIRECT_DISCOVERY_LOST: printf("Discovery lost\n"); break; default: break; } } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_set_discovery_state_changed_cb(callback_1, NULL); // Register callback 1 wifi_direct_set_connection_state_changed_cb(callback_2, NULL); // Register callback 2 wifi_direct_activate(); // Activate Wi-Fi Direct wifi_direct_start_discovery(TRUE, 15); // Start discovery // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_unset_connection_state_changed_cb(); // Deregister callback wifi_direct_unset_discovery_state_changed_cb(); // Deregister callback wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_get_go_intent_per_type | ( | int | type, |
int * | intent | ||
) |
Gets the intent of the group owner for each connection type.
- Since :
- 5.0
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[in] type The type of connection for a peer device [out] intent The intent of the group owner
- Returns:
- 0 on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be initialized by wifi_direct_initialize().
int wifi_direct_get_group_owner_intent | ( | int * | intent | ) |
Gets the intent of the group owner.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[out] intent The intent of the group owner
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be initialized by wifi_direct_initialize().
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int ret; int go_intent; ret = wifi_direct_get_group_owner_intent(&go_intent); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to get go intent\n"); return -1; } printf("Current GO Intent = %d\n", go_intent); return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_get_ip_address | ( | char ** | ip_address | ) |
Gets IP address of a local device.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Remarks:
- ip_address must be released using free().
- Parameters:
-
[out] ip_address The IP address
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_OUT_OF_MEMORY Out of memory WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate().
- See also:
- wifi_direct_activate()
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void); bool device_selected = false; void peers_cb(wifi_direct_discovered_peer_info_s* peer, void *user_data) { if (peer && !device_selected) { printf("peer device=%s MAC=%s\n", peer->device_name, peer->mac_address); device_selected = true; wifi_direct_connect(peer->mac_address); // Connect to the first discovered peer } } int function(void) { int ret; char *ip; ret = wifi_direct_get_ip_address(&ip); // get ip address if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to connect the peer\n"); return -1; } printf("IP address=%s\n", ip); g_free(ip); return 0; } void callback_2(int error_code, wifi_direct_connection_state_e state, const char *mac, void *user_data) *{ switch (state) { case WIFI_DIRECT_CONNECTION_IN_PROGRESS: printf("Connection in progress\n"); break; case WIFI_DIRECT_CONNECTON_RSP: printf("Connected\n"); function(); break; case WIFI_DIRECT_DISCONNECTION_IND: printf("Disconnection IND\n"); break; case WIFI_DIRECT_DISCONNECTION_RSP; printf("Disconnected\n"); break; } *} void callback_1(int error_code, wifi_direct_discovery_state_e discovery_state, void *user_data) { switch(discovery_state) { case WIFI_DIRECT_DISCOVERY_STARTED: printf("Discovery started\n"); break; case WIFI_DIRECT_ONLY_LISTEN_STARTED: printf("listen started\n"); break; case WIFI_DIRECT_DISCOVERY_FINISHED: printf("Discovery finished\n"); wifi_direct_foreach_discovered_peers(peers_cb, NULL); break; case WIFI_DIRECT_DISCOVERY_FOUND: printf("peer devices found\n"); break; case WIFI_DIRECT_DISCOVERY_LOST: printf("Discovery lost\n"); break; default: break; } } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_set_discovery_state_changed_cb(callback_1, NULL); // Register callback 1 wifi_direct_set_connection_state_changed_cb(callback_2, NULL); // Register callback 2 wifi_direct_activate(); // Activate Wi-Fi Direct wifi_direct_start_discovery(TRUE, 15); // Start discovery // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_unset_discovery_state_changed_cb(); // Deregister callback wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_get_local_wps_type | ( | wifi_direct_wps_type_e * | type | ) |
Gets the WPS (Wi-Fi Protected Setup) type.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[out] type The type of WPS
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be initialized by wifi_direct_initialize().
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int ret; int wps_type; ret = wifi_direct_get_local_wps_type(&wps_type); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to get supported wps types\n"); return -1; } switch (wps_type) { case WIFI_DIRECT_WPS_TYPE_PBC: printf("mode is WPS PBC\n"); break; case WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY: printf("mode is WPS PIN Display\n"); break; case WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD: printf("mode is WPS PIN Keypad\n"); break; } return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_get_mac_address | ( | char ** | mac_address | ) |
Gets MAC address of a local device.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Remarks:
- mac_address must be released using free().
- Parameters:
-
[out] mac_address The MAC address
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_OUT_OF_MEMORY Out of memory WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be initialized by wifi_direct_initialize().
- See also:
- wifi_direct_initialize()
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void); bool device_selected = false; void peers_cb(wifi_direct_discovered_peer_info_s* peer, void *user_data) { if (peer && !device_selected) { printf("peer device=%s MAC=%s\n", peer->device_name, peer->mac_address); device_selected = true; wifi_direct_connect(peer->mac_address); // Connect to the first discovered peer } } int function(void) { int ret; char *mac; char *ip; wifi_direct_get_ip_address(&ip); // get ip address ret = wifi_direct_get_mac_address(&mac); // get MAC address if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to get mac address\n"); return -1; } printf("MAC address=%s\n", mac); g_free(ip); g_free(mac); return 0; } void callback_2(int error_code, wifi_direct_connection_state_e state, const char *mac, void *user_data) *{ switch (state) { case WIFI_DIRECT_CONNECTION_IN_PROGRESS: printf("Connection in progress\n"); break; case WIFI_DIRECT_CONNECTON_RSP: printf("Connected\n"); function(); break; case WIFI_DIRECT_DISCONNECTION_IND: printf("Disconnection IND\n"); break; case WIFI_DIRECT_DISCONNECTION_RSP; printf("Disconnected\n"); break; } *} void callback_1(int error_code, wifi_direct_discovery_state_e discovery_state, void *user_data) { switch(discovery_state) { case WIFI_DIRECT_DISCOVERY_STARTED: printf("Discovery started\n"); break; case WIFI_DIRECT_ONLY_LISTEN_STARTED: printf("listen started\n"); break; case WIFI_DIRECT_DISCOVERY_FINISHED: printf("Discovery finished\n"); wifi_direct_foreach_discovered_peers(peers_cb, NULL); break; case WIFI_DIRECT_DISCOVERY_FOUND: printf("peer devices found\n"); break; case WIFI_DIRECT_DISCOVERY_LOST: printf("Discovery lost\n"); break; default: break; } } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_set_discovery_state_changed_cb(callback_1, NULL); // Register callback 1 wifi_direct_set_connection_state_changed_cb(callback_2, NULL); // Register callback 2 wifi_direct_activate(); // Activate Wi-Fi Direct wifi_direct_start_discovery(TRUE, 15); // Start discovery // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_unset_connection_state_changed_cb(); // Deregister callback wifi_direct_unset_discovery_state_changed_cb(); // Deregister callback wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_get_max_clients | ( | int * | max | ) |
Gets the max number of clients.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[in] max The max number of clients
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be initialized by wifi_direct_initialize().
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int ret; int max_client; ret = wifi_direct_get_max_clients(&max_client); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to get max clients\n"); return -1; } printf("max client = %d\n", max_client); return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_get_network_interface_name | ( | char ** | name | ) |
Gets the name of network interface (for example: eth0, pdp0).
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Remarks:
- name must be released using free().
- Parameters:
-
[out] name The name of the network interface
- Returns:
0
on success, otherwise negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_OUT_OF_MEMORY Out of memory WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate().
- See also:
- wifi_direct_activate()
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int res; char *iface_name; res = wifi_direct_get_network_interface_name(&iface_name); // get interface name if (res != WIFI_DIRECT_ERROR_NONE) { printf("Failed to get interface name\n"); return -1; } printf("interface = %s\n", iface_name); g_free(iface_name); return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_get_operating_channel | ( | int * | channel | ) |
Gets the operating channel.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[out] channel The operating channel
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be initialized by wifi_direct_initialize().
- See also:
- wifi_direct_initialize()
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int ret; int channel; ret = wifi_direct_get_operating_channel(&channel); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to get operating channel\n"); return -1; } printf("operating channel = %d\n", channel); return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_get_passphrase | ( | char ** | passphrase | ) |
Gets the Wi-Fi Protected Access (WPA) password when creating Wi-Fi Direct Group.
- Since :
- 2.4
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Remarks:
- passphrase must be released with free().
- Parameters:
-
[out] passphrase Pointer to store wpa password. Application must free this memory
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate().
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int ret; char *key; ret = wifi_direct_get_passphrase(&key); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to get passphrase\n"); return -1; } printf("passphrase = %s\n", key); g_free(key); return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_get_peer_display_availability | ( | char * | mac_address, |
bool * | availability | ||
) |
Gets the information of a peer's Wi-Fi Display session availability.
- Since :
- 2.4
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[in] mac_address MAC Address of the PEER [out] availability The information of a peer's Wi-Fi Display session availability if there's Wi-Fi Direct information, this will be NULL
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate().
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int ret; bool availability; char *mac = NULL; printf("Input the peer mac\n"); scanf("%18ms", &mac); ret = wifi_direct_get_peer_display_availability(mac, &availability); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to get peer display availability\n"); return -1; } printf("peer display availability = %s\n", availability?"yes":"no"); free(mac); return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_get_peer_display_hdcp | ( | char * | mac_address, |
int * | hdcp | ||
) |
Gets the information of a peer's Wi-Fi Display HDCP support.
- Since :
- 2.4
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[in] mac_address MAC Address of the PEER [out] hdcp The information of a peer's Wi-Fi Display HDCP support if there's Wi-Fi Direct information, this will be NULL
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate().
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int ret; int hdcp; char *mac = NULL; printf("Input the peer mac\n"); scanf("%18ms", &mac); ret = wifi_direct_get_peer_display_hdcp(mac, &hdcp); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to get peer display hdcp\n"); return -1; } printf("peer display hdcp = %d\n", hdcp); free(mac); return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_get_peer_display_port | ( | char * | mac_address, |
int * | port | ||
) |
Gets the information of a peer's Wi-Fi Display RTSP control port.
- Since :
- 2.4
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[in] mac_address MAC Address of the PEER [out] port The information of a peer's Wi-Fi Display RTSP control port if there's Wi-Fi Direct information, this will be NULL
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate().
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int ret; int port; char *mac = NULL; printf("Input the peer mac\n"); scanf("%18ms", &mac); ret = wifi_direct_get_peer_display_port(mac, &port); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to get peer display port\n"); return -1; } printf("peer display port = %d\n", port); free(mac); return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_get_peer_display_throughput | ( | char * | mac_address, |
int * | throughput | ||
) |
Gets the information of a peer's Wi-Fi Display max throughput.
- Since :
- 2.4
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[in] mac_address MAC Address of the PEER [out] throughput The information of a peer's Wi-Fi Display max throughput (Mbps) if there's Wi-Fi Direct information, this will be NULL
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate().
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int ret; int tput; char *mac = NULL; printf("Input the peer mac\n"); scanf("%18ms", &mac); ret = wifi_direct_get_peer_display_throughput(mac, &tput); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to get peer display throughput\n"); return -1; } printf("peer display throughput = %d\n", tput); free(mac); return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_get_peer_display_type | ( | char * | mac_address, |
wifi_direct_display_type_e * | type | ||
) |
Gets the information of a peer's Wi-Fi Display device type.
- Since :
- 2.4
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[in] mac_address MAC Address of the PEER [out] type The information of a peer's Wi-Fi Display device type if there's Wi-Fi Direct information, this will be NULL
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate().
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int ret; char *mac = NULL; wifi_direct_display_type_e type; printf("Input the peer mac\n"); scanf("%18ms", &mac); ret = wifi_direct_get_peer_display_type(mac, &type); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to get peer display type\n"); return -1; } printf("peer display type = %d\n", type); free(mac); return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_get_peer_info | ( | char * | mac_address, |
wifi_direct_discovered_peer_info_s ** | peer_info | ||
) |
Gets the information of a discovered peer.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[in] mac_address The MAC address of peer to get [out] peer_info The peer information to be passed
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate().
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int ret; char mac[19] = {0, }; wifi_direct_discovered_peer_info_s *peer_info; printf("Input peer MAC address\n"); read(stdin, mac, 18); ret = wifi_direct_get_peer_info(mac, &peer_info); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to get peer info\n"); return -1; } printf("get peer info success\n"); return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_get_peer_rssi | ( | char * | mac_address, |
int * | rssi | ||
) |
Gets the information of a peer's RSSI value.
- Since :
- 3.0
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[in] mac_address MAC Address of the peer device [out] rssi RSSI value of the peer device
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be initialized by wifi_direct_initialize().
- See also:
- wifi_direct_activate()
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int ret; int rssi; char *mac = NULL; printf("Input the peer mac\n"); scanf("%18ms", &mac); ret = wifi_direct_get_peer_rssi(mac, &rssi); // get peer rssi if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to get peer rssi\n"); return -1; } printf("peer rssi = %d\n", rssi); free(mac); return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_get_peer_vsie | ( | char * | mac_address, |
char ** | vsie | ||
) |
Gets the vendor specific information element (VSIE) of a peer.
- Since :
- 5.0
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Remarks:
- vsie must be released with free().
- Parameters:
-
[in] mac_address MAC Address of the PEER [out] vsie The vendor specific information element (VSIE) of peer if Wi-Fi Direct information is available, else it will be NULL.
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate().
Gets the primary device type of a local device.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[out] type The primary device type
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be initialized by wifi_direct_initialize().
- See also:
- wifi_direct_initialize()
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> char* print_type(wifi_direct_primary_device_type_e type) { if (type == WIFI_DIRECT_PRIMARY_DEVICE_TYPE_COMPUTER) return "Computer"; if (state == WIFI_DIRECT_PRIMARY_DEVICE_TYPE_CAMERA) return "Camera"; if (state == WIFI_DIRECT_PRIMARY_DEVICE_TYPE_STORAGE) return "Storage"; if (state == WIFI_DIRECT_PRIMARY_DEVICE_TYPE_DISPLAY) return "Display"; if (state == WIFI_DIRECT_PRIMARY_DEVICE_TYPE_TELEPHONE) return "Telephone"; // Refer wifi_direct_primary_device_type_e enum for all devices } int function(void) { int ret; int type; ret = wifi_direct_get_primary_device_type(&type); // get primary device type if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to get primary device type\n"); return -1; } printf("primary Device = %s\n", print_type(type)); return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_get_req_wps_type | ( | wifi_direct_wps_type_e * | type | ) |
Gets the requested WPS (Wi-Fi Protected Setup) type.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[out] type The type of WPS
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be initialized by wifi_direct_initialize().
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int ret; int wps_type; ret = wifi_direct_get_req_wps_type(&wps_type); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to get supported wps types\n"); return -1; } switch (wps_type) { case WIFI_DIRECT_WPS_TYPE_PBC: printf("mode is WPS PBC\n"); break; case WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY: printf("mode is WPS PIN Display\n"); break; case WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD: printf("mode is WPS PIN Keypad\n"); break; } return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
Gets the secondary device type of a local device.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[out] type The secondary device type
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be initialized by wifi_direct_initialize().
- See also:
- wifi_direct_initialize()
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> char* print_type(wifi_direct_primary_device_type_e type) { if (type == WIFI_DIRECT_SECONDARY_DEVICE_TYPE_COMPUTER_PC) return "Computer pc"; if (state == WIFI_DIRECT_SECONDARY_DEVICE_TYPE_INPUT_KEYBOARD) return "input Keyboard"; if (state == WIFI_DIRECT_SECONDARY_DEVICE_TYPE_CAMERA_VIDEO) return "Camera Video"; if (state == WIFI_DIRECT_SECONDARY_DEVICE_TYPE_STORAGE_NAS) return "Storage NAS"; if (state == WIFI_DIRECT_SECONDARY_DEVICE_TYPE_DISPLAY_TV) return "Display TV"; // Refer wifi_direct_secondary_device_type_e enum for all devices } int function(void) { int ret; int type; ret = wifi_direct_get_secondary_device_type(&type); // get secondary device type if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to get secondary device type\n"); return -1; } printf("secondary Device = %s\n", print_type(type)); return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_get_session_timer | ( | int * | seconds | ) |
Gets the timer which is used to expire the connection session.
- Since :
- 3.0
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[out] seconds Connection session timer value
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate().
- See also:
- wifi_direct_activate()
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int ret; int session_timeout; ret = wifi_direct_get_session_timer(&session_timeout); // get session timer if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to get session timer\n"); return -1; } printf("session timer = %d\n", session_timeout); return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_get_ssid | ( | char ** | ssid | ) |
Gets SSID (Service Set Identifier) of a local device.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Remarks:
- ssid must be released using free().
- Parameters:
-
[out] ssid The SSID
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_OUT_OF_MEMORY Out of memory WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be initialized by wifi_direct_initialize().
- See also:
- wifi_direct_initialize()
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int res; char *ssid; res = wifi_direct_get_ssid(&ssid); // get SSID if (res != WIFI_DIRECT_ERROR_NONE) { printf("Failed to get ssid name\n"); return -1; } printf("SSID name = %s\n", ssid); g_free(ssid); return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_get_state | ( | wifi_direct_state_e * | state | ) |
Gets the state of Wi-Fi Direct service.
- Since :
- 2.3
- Parameters:
-
[out] state The state of Wi-Fi Direct service
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> char* print_state(wifi_direct_state_e state) { if (state == WIFI_DIRECT_STATE_DEACTIVATED) return "DEACTIVATED"; if (state == WIFI_DIRECT_STATE_ACTIVATING) return "ACTIVATING"; if (state == WIFI_DIRECT_STATE_ACTIVATED) return "ACTIVATED"; if (state == WIFI_DIRECT_STATE_DISCOVERING) return "DISCOVERING"; if (state == WIFI_DIRECT_STATE_CONNECTING) return "CONNECTING"; if (state == WIFI_DIRECT_STATE_DISCONNECTING) return "DISCONNECTING"; if (state == WIFI_DIRECT_STATE_CONNECTED) return "CONNECTED"; if (state == WIFI_DIRECT_STATE_GROUP_OWNER) return "GROUP OWNER"; return "Unknown state"; } int function(void) { int ret; int state; ret = wifi_direct_get_state(&state); // get Wi-Fi Direct state if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to get state\n"); return -1; } printf(Wi-Fi Direct State = %s\n, print_state(state)); return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_get_subnet_mask | ( | char ** | subnet_mask | ) |
Gets the Subnet Mask.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Remarks:
- subnet_mask must be released using free().
- Parameters:
-
[out] subnet_mask The subnet mask
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_OUT_OF_MEMORY Out of memory WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate().
- See also:
- wifi_direct_activate()
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void); bool device_selected = false; void peers_cb(wifi_direct_discovered_peer_info_s* peer, void *user_data) { if (peer && !device_selected) { printf("peer device=%s MAC=%s\n", peer->device_name, peer->mac_address); device_selected = true; wifi_direct_connect(peer->mac_address); // Connect to the first discovered peer } } int function(void) { int ret; char *subnet; char *ip; wifi_direct_get_ip_address(&ip); // get ip address ret = wifi_direct_get_subnet_mask(&subnet); // get subnet mask if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to get subnet mask\n"); return -1; } printf("subnet address=%s\n", subnet); g_free(ip); g_free(subnet); return 0; } void callback_2(int error_code, wifi_direct_connection_state_e state, const char *mac, void *user_data) *{ switch (state) { case WIFI_DIRECT_CONNECTION_IN_PROGRESS: printf("Connection in progress\n"); break; case WIFI_DIRECT_CONNECTON_RSP: printf("Connected\n"); function(); break; case WIFI_DIRECT_DISCONNECTION_IND: printf("Disconnection IND\n"); break; case WIFI_DIRECT_DISCONNECTION_RSP; printf("Disconnected\n"); break; } *} void callback_1(int error_code, wifi_direct_discovery_state_e discovery_state, void *user_data) { switch(discovery_state) { case WIFI_DIRECT_DISCOVERY_STARTED: printf("Discovery started\n"); break; case WIFI_DIRECT_ONLY_LISTEN_STARTED: printf("listen started\n"); break; case WIFI_DIRECT_DISCOVERY_FINISHED: printf("Discovery finished\n"); wifi_direct_foreach_discovered_peers(peers_cb, NULL); break; case WIFI_DIRECT_DISCOVERY_FOUND: printf("peer devices found\n"); break; case WIFI_DIRECT_DISCOVERY_LOST: printf("Discovery lost\n"); break; default: break; } } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_set_discovery_state_changed_cb(callback_1, NULL); // Register callback 1 wifi_direct_set_connection_state_changed_cb(callback_2, NULL); // Register callback 2 wifi_direct_activate(); // Activate Wi-Fi Direct wifi_direct_start_discovery(TRUE, 15); // Start discovery // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_unset_discovery_state_changed_cb(); // Deregister callback wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_get_supported_wps_mode | ( | int * | wps_mode | ) |
Gets all the supported WPS (Wi-Fi Protected Setup) types at local device.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[out] wps_mode Supported WPS mode for local device
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be initialized by wifi_direct_initialize().
- See also:
- wifi_direct_initialize()
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int ret; int wps_mode; ret = wifi_direct_get_supported_wps_mode(&wps_mode); // Get supported WPS mode if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to get supported wps mode\n"); return -1; } switch (wps_mode) { case WIFI_DIRECT_WPS_TYPE_PBC: printf("mode is WPS PBC\n"); break; case WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY: printf("mode is WPS PIN Display\n"); break; case WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD: printf("mode is WPS PIN Keypad\n"); break; } return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_get_vsie | ( | wifi_direct_vsie_frames_e | frame_id, |
char ** | vsie_str | ||
) |
Gets the Wi-Fi Vendor Specific Information Elements (VSIE) from specific frame.
- Since :
- 4.0
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Remarks:
- vsie_str must be released with free().
- Parameters:
-
[in] frame_id frame ID for setting VSIE [out] vsie_str VSIE data
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate() and set VSIE for specific frame by wifi_direct_add_vsie().
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int ret; char *vsie = NULL; unsigned int frame_id; printf("Input the frame id\n"); scanf("%2u", &frame_id); ret = wifi_direct_get_vsie(frame_id, &vsie); // get vsie if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to get vsie\n"); return -1; } printf("vsie = %s\n", vsie); free(vsie); return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_get_wps_config_method | ( | int * | type | ) |
Gets the advertizing WPS (Wi-Fi Protected Setup) type.
- Since :
- 5.0
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[out] type The type of WPS. composition of wifi_direct_config_method_type_e
- Returns:
- 0 on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be initialized by wifi_direct_initialize().
- Wi-Fi Direct service must be activated by wifi_direct_activate().
- See also:
- wifi_direct_initialize()
int wifi_direct_get_wps_pin | ( | char ** | pin | ) |
Gets the WPS PIN number.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Remarks:
- pin must be released with free().
- Parameters:
-
[out] pin Pointer to store pin number. Application must free this memory
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate().
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int ret; char *pin; ret = wifi_direct_get_wps_pin(&pin); // Get the WPS PIN if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to get the WPS PIN\n"); return -1; } printf("WPS PIN : %s\n", pin); g_free(pin); return 0; } void callback(int error_code, wifi_direct_connection_state_e connection_state, const char *mac_address, void *user_data) *{ char *ip; bool owner; int wps_mode; switch (connection_state) { case WIFI_DIRECT_CONNECTION_IN_PROGRESS: printf("Connection in progress\n"); break; case WIFI_DIRECT_CONNECTION_RSP: if (error_code == WIFI_DIRECT_ERROR_NONE) { printf("Peer Device Connected\n"); // device is connected printf("MAC=%s\n", mac_address); // device's MAC address wifi_direct_get_ip_address(&ip); printf("IP=%s\n", ip); //device's IP address wifi_direct_is_group_owner(&owner); printf("Ownership=%s\n", (owner)? "GO":"STA"); // (GO or client role) } else if (error_code == WIFI_DIRECT_ERROR_CONNECTION_TIME_OUT) { printf("Connection timeout occurred\n"); } else if (error_code == WIFI_DIRECT_ERROR_AUTH_FAILED) { printf("Connection authorization Failed\n"); } else printf("Connection failed\n"); break; case WIFI_DIRECT_CONNECTION_WPS_REQ: wifi_direct_get_local_wps_type(&wps_mode); if (wps_mode == WIFI_DIRECT_WPS_TYPE_PBC) { printf("Connection type WPS PBC\n"); // Handle WPS PBC case here } if (wps_mode == WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY) { printf("Connection type WPS PIN DISPLAY\n"); // Handle WPS PIN Display case here // Display WPS PIN here // Since the device received WPS PIN Display connection request // user need to display the WPS PIN which is shared by peer device function(); } if (wps_mode == WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD) { printf("Connection type WPS PIN KEYPAD\n"); // Handle WPS PIN Keypad case here } break; case WIFI_DIRECT_CONNECTION_REQ: printf("Connection request from MAC %s\n", mac_address); // Handle the connection request from peer device here // 1. WPS PBC // 2. WPS PIN Display // 3. WPS PIN Keypad wifi_direct_accept_connection(mac_address); break; case WIFI_DIRECT_DISCONNECTION_IND: if (error_code == WIFI_DIRECT_ERROR_NONE) printf("peer device disconnected MAC %s\n", mac_address); break; case WIFI_DIRECT_DISCONNECTION_RSP: if (error_code == WIFI_DIRECT_ERROR_NONE) printf("peer device disconnection response MAC %s\n", mac_address); break; case WIFI_DIRECT_DISASSOCIATION_IND: if (error_code == WIFI_DIRECT_ERROR_NONE) printf("peer device disassociation MAC %s\n", mac_address); break; case WIFI_DIRECT_GROUP_CREATED: printf("Group Created\n"); break; case WIFI_DIRECT_GROUP_DESTROYED: printf("Group Destroyed\n"); break; default: break; } *} int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_set_connection_state_changed_cb(callback, NULL); // Register callback wifi_direct_activate(); // Activate Wi-Fi Direct function(); wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_set_connection_state_changed_cb(callback, NULL); // Deregister callback wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_init_display | ( | void | ) |
Enables Wi-Fi Display (WFD) functionality and initialize the various variables required for WFD.
Starts listening in only assigned channel. Device will be discoverable only in assigned listen channel.
- Since :
- 2.4
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate()
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int ret; ret = wifi_direct_init_display(); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to init display\n"); return -1; } printf("init display success\n"); return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_init_miracast | ( | bool | enable | ) |
Initializes OR Deintializes the WiFi Direct Display (MIRACAST) service.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[in] enable Enables/Disables Service based on the value TRUE/FALSE
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate().
- See also:
- wifi_direct_activate()
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int ret; ret = wifi_direct_init_miracast(true); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to init miracast\n"); return -1; } printf("init miracast success\n"); return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_initialize | ( | void | ) |
Initializes Wi-Fi Direct service.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported
- See also:
- wifi_direct_deinitialize()
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> void function(void) { int ret; ret = wifi_direct_initialize(); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to initialize\n"); return; } printf("Initialized Successfully\n"); } int main() { function(); // initialize Wi-Fi Direct wifi_direct_deinitialize(); // deinitialize Wi-Fi Direct return 0; }
int wifi_direct_is_autoconnection_mode | ( | bool * | mode | ) |
Gets the Autoconnection mode status.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[out] mode Describes the auto connection mode of framework has set.
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported
- Precondition:
- Wi-Fi Direct service must be initialized by wifi_direct_initialize().
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int ret; bool status; ret = wifi_direct_is_autoconnection_mode(&status); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to get autoconnection mode\n"); return -1; } printf("auto connect mode = %s\n", (status)?"Yes":"No"); return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_is_autonomous_group | ( | bool * | is_autonomous_group | ) |
Checks whether the current group is the autonomous group or not.
If you create a group by wifi_direct_create_group(), then the current group is the autonomous group.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[out] is_autonomous_group Indicates whether the current group is the autonomous group or not
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate().
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int res; bool owner; res = wifi_direct_is_autonomous_group(&owner); // autonomous group if (res != WIFI_DIRECT_ERROR_NONE) { printf("Failed to get ownership role\n"); return -1; } printf("Group = %s\n", (owner)?"Auto":"Non-Auto"); return 0; } void callback_1(int error_code, wifi_direct_connection_state_e state, const char *mac, void *user_data) { if (state == WIFI_DIRECT_GROUP_DESTROYED) { printf("Group destroyed\n"); } if (state == WIFI_DIRECT_GROUP_CREATED) { printf("Group created\n"); function(); } } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_set_connection_state_changed_cb(callback_1, NULL); // Register callback_1 wifi_direct_activate(); // Activate Wi-Fi Direct wifi_direct_create_group(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_unset_connection_state_changed_cb(); // Deregister callback_1 wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_is_discoverable | ( | bool * | discoverable | ) |
Checks whether this device is discoverable or not by P2P discovery.
If you call wifi_direct_start_discovery(), then your device can be discoverable.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[out] discoverable The status of discoverable: ( true
= discoverable,false
= non-discoverable)
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be initialized by wifi_direct_initialize().
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int ret; bool discoverable; ret = wifi_direct_is_discoverable(&discoverable); // check if device is discoverable if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to get discoverable property\n"); return -1; } printf("discoverable=%s\n", discoverable?"Yes":"No"); return 0; } void callback_1(int error_code, wifi_direct_discovery_state_e discovery_state, void *user_data) { switch(discovery_state) { case WIFI_DIRECT_DISCOVERY_STARTED: printf("Discovery started\n"); function(); break; case WIFI_DIRECT_ONLY_LISTEN_STARTED: printf("listen started\n"); function(); break; case WIFI_DIRECT_DISCOVERY_FINISHED: printf("Discovery finished\n"); function(); break; case WIFI_DIRECT_DISCOVERY_FOUND: printf("peer devices found\n"); break; case WIFI_DIRECT_DISCOVERY_LOST: printf("Discovery lost\n"); break; default: break; } } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct wifi_direct_set_discovery_state_changed_cb(callback_1, NULL); // Register callback 1 wifi_direct_start_discovery(TRUE, 15); // Start discovery function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_unset_discovery_state_changed_cb(); // Deregister callback wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_is_group_owner | ( | bool * | is_group_owner | ) |
Checks whether this device is the group owner or not.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[out] is_group_owner Indicates whether this device is the group owner or not
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate().
- See also:
- wifi_direct_activate()
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int res; bool owner; res = wifi_direct_is_group_owner(&owner); // destroy autonomous group if (res != WIFI_DIRECT_ERROR_NONE) { printf("Failed to get ownership role\n"); return -1; } printf("role = %s\n", (owner)?"GO":"STA"); return 0; } void callback_1(int error_code, wifi_direct_connection_state_e state, const char *mac, void *user_data) { if (state == WIFI_DIRECT_GROUP_DESTROYED) { printf("Group destroyed\n"); function(); } if (state == WIFI_DIRECT_GROUP_CREATED) { printf("Group created\n"); function(); } } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_set_connection_state_changed_cb(callback_1, NULL); // Register callback_1 wifi_direct_activate(); // Activate Wi-Fi Direct wifi_direct_create_group(); wifi_direct_destroy_group(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_unset_connection_state_changed_cb(); // Deregister callback_1 wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_is_listening_only | ( | bool * | listen_only | ) |
Checks whether the local device is listening only.
If you call wifi_direct_start_discovery() with listen_only as true
, it does not support specific channel but the initial 802.11.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[out] listen_only The status of listen only:( true
= listen only,false
= cycling between Scan and Listen or not in discovery state)
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate().
- See also:
- wifi_direct_activate()
- wifi_direct_start_discovery()
- wifi_direct_cancel_discovery()
- wifi_direct_is_discoverable()
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int ret; bool listen_only; ret = wifi_direct_is_listening_only(&listen_only); // check if device is listening if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to get discoverable property\n"); return -1; } printf("listening=%s\n", listen_only?"Yes":"No"); return 0; } void callback_1(int error_code, wifi_direct_discovery_state_e discovery_state, void *user_data) { switch(discovery_state) { case WIFI_DIRECT_DISCOVERY_STARTED: printf("Discovery started\n"); break; case WIFI_DIRECT_ONLY_LISTEN_STARTED: printf("listen started\n"); function(); break; case WIFI_DIRECT_DISCOVERY_FINISHED: printf("Discovery finished\n"); function(); break; case WIFI_DIRECT_DISCOVERY_FOUND: printf("peer devices found\n"); break; case WIFI_DIRECT_DISCOVERY_LOST: printf("Discovery lost\n"); break; default: break; } } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct wifi_direct_set_discovery_state_changed_cb(callback_1, NULL); // Register callback 1 wifi_direct_start_discovery(TRUE, 15); // Start discovery function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_unset_discovery_state_changed_cb(); // Deregister callback wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_is_persistent_group_enabled | ( | bool * | enabled | ) |
Checks whether the persistent group is enabled or disabled.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[out] enabled The status of the persistent group: ( true
= enabled,false
= disabled)
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be initialized by wifi_direct_initialize().
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int ret; bool status; ret = wifi_direct_is_persistent_group_enabled(&status); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to get status of persistence group enabled\n"); return -1; } printf("persistence group status = %s\n", status?"Yes":"No"); return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_register_service | ( | wifi_direct_service_type_e | service_type, |
char * | info1, | ||
char * | info2, | ||
unsigned int * | service_id | ||
) |
Registers for a service using Wi-Fi Direct Service Discovery.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[in] service_type Describes the type of service. [in] info1 Describes the information of service. It is service-specific [in] info2 Describes the information of service. It is service-specific [out] service_id A Service ID will be assigned to service getting registered
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate().
- See also:
- wifi_direct_activate()
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> void callback(int error_code, wifi_direct_service_discovery_state_e discovery_state, wifi_direct_service_type_e service_type, void *response_data, const char * mac_address, void *user_data) { switch (discovery_state) { case WIFI_DIRECT_SERVICE_DISCOVERY_STARTED: printf("Service discovery started\n"); break; case WIFI_DIRECT_SERVICE_DISCOVERY_FINISHED: printf("Service discovery finished\n"); break; case WIFI_DIRECT_SERVICE_DISCOVERY_FOUND: printf("Service discovery found\n"); break; } } int function(void) { int ret; int option; char *info1; char *info2; wifi_direct_service_type_e type = WIFI_DIRECT_SERVICE_TYPE_ALL; printf("Input service type\n"); scanf("%1d", &option); printf("1. WIFI_DIRECT_SERVICE_TYPE_ALL\n"); printf("2. WIFI_DIRECT_SERVICE_TYPE_BONJOUR\n"); printf("3. WIFI_DIRECT_SERVICE_TYPE_UPNP\n"); printf("4. WIFI_DIRECT_SERVICE_TYPE_BT_ADDR\n"); printf("5. WIFI_DIRECT_SERVICE_TYPE_CONTACT_INFO\n"); switch (option) { case 1: type = WIFI_DIRECT_SERVICE_TYPE_ALL; break; case 2: type = WIFI_DIRECT_SERVICE_TYPE_BONJOUR; printf("Enter the info 1\n"); scanf("%50ms", &info1); printf("Enter the info 2\n"); scanf("%50ms", &info2); break; case 3: type = WIFI_DIRECT_SERVICE_TYPE_UPNP; printf("Enter the info 1\n"); scanf("%50ms", &info1); printf("Enter the info 2\n"); scanf("%50ms", &info2); break; case 4: type = WIFI_DIRECT_SERVICE_TYPE_BT_ADDR; break; case 5: type = WIFI_DIRECT_SERVICE_TYPE_CONTACT_INFO; printf("Enter the info 1\n"); scanf("%50ms", &info1); break; } ret = wifi_direct_register_service(type, info1, info2, &option); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to start service discovery\n"); return -1; } wifi_direct_start_service_discovery(NULL, type); free(info1); free(info2); return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_set_service_state_changed_cb(callback, NULL); wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_unset_service_state_changed_cb(); wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_remove_all_persistent_devices | ( | void | ) |
Removes all persistent devices.
- Since :
- 5.0
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Returns:
- 0 on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be initialized by wifi_direct_initialize().
- See also:
- wifi_direct_initialize()
int wifi_direct_remove_persistent_device | ( | char * | mac_address | ) |
Removes a persistent device.
- Since :
- 5.0
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[in] mac_address The MAC address of the persistent group owner
- Returns:
- 0 on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be initialized by wifi_direct_initialize().
- See also:
- wifi_direct_initialize()
int wifi_direct_remove_persistent_group | ( | char * | mac_address, |
const char * | ssid | ||
) |
Removes a persistent group.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[in] mac_address The MAC address of the persistent group owner [in] ssid The SSID (Service Set Identifier) of the persistent group owner
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be initialized by wifi_direct_initialize().
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int ret; char *mac = NULL; char *ssid = NULL; printf("Input MAC\n"); scanf("%18ms", &mac); printf("Input SSID\n"); scanf("%33ms", &ssid); ret = wifi_direct_remove_persistent_group(mac, ssid); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to remove persistent group\n"); return -1; } printf("persistent group with MAC (%s) is removed\n", mac); free(mac); free(ssid); return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_remove_vsie | ( | wifi_direct_vsie_frames_e | frame_id, |
const char * | vsie_str | ||
) |
Removes the Wi-Fi Vendor Specific Information Element (VSIE) from specific frame.
- Since :
- 4.0
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Remarks:
- vsie_str for frame_id will be in effect until Wi-Fi Direct is deactivated.
- Parameters:
-
[in] frame_id frame ID for removing VSIE [in] vsie_str VSIE data
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate() and set VSIE for specific frame by wifi_direct_add_vsie().
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int ret; char *vsie = NULL; unsigned int frame_id; printf("Input the frame id\n"); scanf("%2u", &frame_id); printf("Input the vsie\n"); scanf("%100ms", &vsie); ret = wifi_direct_remove_vsie(frame_id, vsie); // remove vsie if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to remove vsie\n"); return -1; } printf("vsie removed success\n"); free(vsie); return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_set_auto_group_removal | ( | bool | enable | ) |
Enables / Disables automatic group removal feature when all peers are disconnected.
- Since :
- 3.0
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[in] enable Enables/Disables Group Removal feature based on the value TRUE/FALSE
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate().
- Postcondition:
- wifi_direct_connection_state_changed_cb() will be invoked with WIFI_DIRECT_GROUP_DESTROYED when there's no connected Group Client if device is Group Owner and this feature is enabled.
- See also:
- wifi_direct_activate()
- wifi_direct_create_group()
- wifi_direct_connection_state_changed_cb()
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int ret; ret = wifi_direct_set_auto_group_removal(true); // Enable auto group removal if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to set auto group removal\n"); return -1; } printf("set auto group removal success\n"); return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_set_autoconnection_mode | ( | bool | mode | ) |
Sets the Autoconnection mode.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[in] mode Describes the mode of connection. In case of TRUE
auto-connection will be taken care by framework
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported
- Precondition:
- Wi-Fi Direct service must be initialized by wifi_direct_initialize().
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int ret; int auto_connect; printf("enable auto connect mode (yes[1] or no[2])\n"); scanf("%1d", &auto_connect); if (auto_connect) ret = wifi_direct_set_autoconnection_mode(true); else ret = wifi_direct_set_autoconnection_mode(false); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to set autoconnection mode\n"); return -1; } printf("Auto connect mode enabled\n"); return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_set_autoconnection_peer | ( | char * | mac_address | ) |
Allows a device to connect automatically.
- Since :
- 2.4
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[in] mac_address Device MAC address to allow autoconnection
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate().
- See also:
- wifi_direct_activate()
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> bool peer_selected = false; int connection_timeout = 0; int count = 0; // counter to wait for connection int function(char *mac); void peers_cb(wifi_direct_discovered_peer_info_s* peer, void *user_data) { char *mac; if (peer && !peer_selected) { printf("peer device=%s MAC=%s\n", peer->device_name, peer->mac_address); peer_selected = true; function(peer->mac_address); wifi_direct_connect(peer->mac_address); // Connect to the selected peer } } int function(char *mac) { int ret; ret = wifi_direct_set_autoconnection_peer(mac); // set autoconnection if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to set autoconnection for peer\n"); return -1; } printf("set auto-connection success\n"); return 0; } void callback_2(int error_code, wifi_direct_connection_state_e state, const char *mac, void *user_data) *{ switch (state) { case WIFI_DIRECT_CONNECTION_IN_PROGRESS: printf("Connection in progress\n"); break; case WIFI_DIRECT_CONNECTON_RSP: printf("Connected\n"); g_source_remove(connection_timeout); break; case WIFI_DIRECT_DISCONNECTION_IND: printf("Disconnection IND\n"); break; case WIFI_DIRECT_DISCONNECTION_RSP; printf("Disconnected\n"); break; } *} void callback_1(int error_code, wifi_direct_discovery_state_e discovery_state, void *user_data) { switch(discovery_state) { case WIFI_DIRECT_DISCOVERY_STARTED: printf("Discovery started\n"); break; case WIFI_DIRECT_ONLY_LISTEN_STARTED: printf("listen started\n"); break; case WIFI_DIRECT_DISCOVERY_FINISHED: printf("Discovery finished\n"); wifi_direct_foreach_discovered_peers(peers_cb, NULL); // Get discovered peer break; case WIFI_DIRECT_DISCOVERY_FOUND: printf("peer devices found\n"); break; case WIFI_DIRECT_DISCOVERY_LOST: printf("Discovery lost\n"); break; default: break; } } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_set_discovery_state_changed_cb(callback_1, NULL); // Register callback 1 wifi_direct_set_connection_state_changed_cb(callback_2, NULL); // Register callback 2 wifi_direct_activate(); // Activate Wi-Fi Direct wifi_direct_start_discovery(TRUE, 15); // Start discovery // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_unset_connection_state_changed_cb(); // Deregister callback 2 wifi_direct_unset_discovery_state_changed_cb(); // Deregister callback 1 wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_set_client_ip_address_assigned_cb | ( | wifi_direct_client_ip_address_assigned_cb | cb, |
void * | user_data | ||
) |
Sets the callback called when the IP address of the client is assigned if your device is the group owner.
- Since :
- 2.3
- Parameters:
-
[in] cb The callback function to invoke [in] user_data The user data to be passed to the callback function
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported
- Precondition:
- Wi-Fi Direct service must be initialized by wifi_direct_initialize().
- See also:
- wifi_direct_initialize()
- wifi_direct_unset_client_ip_address_assigned_cb()
- wifi_direct_client_ip_address_assigned_cb()
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> void callback(const char *mac_address, const char *ip_address, const char *interface_address, void *user_data); *{ printf("IP Assigned to the client device\n"); printf("mac=%s\n", mac_address); printf("ip=%s\n", ip_address); printf("iface=%s\n", interface_address); *} void function(void) { int ret; ret = wifi_direct_set_client_ip_address_assigned_cb(callback, NULL); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to register callback\n"); return; } printf("callback registered Successfully\n"); } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); wifi_direct_deactivate(); // deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_set_connection_state_changed_cb | ( | wifi_direct_connection_state_changed_cb | cb, |
void * | user_data | ||
) |
Sets the callback called when the state of connection is changed.
- Since :
- 2.3
- Parameters:
-
[in] cb The callback function to invoke [in] user_data The user data to be passed to the callback function
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported
- Precondition:
- Wi-Fi Direct service must be initialized by wifi_direct_initialize().
- See also:
- wifi_direct_initialize()
- wifi_direct_unset_connection_state_changed_cb()
- wifi_direct_connection_state_changed_cb()
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> void callback(int error_code, wifi_direct_connection_state_e connection_state, const char *mac_address, void *user_data) *{ char *ip; bool owner; int wps_mode; switch (connection_state) { case WIFI_DIRECT_CONNECTION_IN_PROGRESS: printf("Connection in progress\n"); break; case WIFI_DIRECT_CONNECTION_RSP: if (error_code == WIFI_DIRECT_ERROR_NONE) { printf("Peer Device Connected\n"); // device is connected printf("MAC=%s\n", mac_address); // device's MAC address wifi_direct_get_ip_address(&ip); printf("IP=%s\n", ip); //device's IP address wifi_direct_is_group_owner(&owner); printf("Ownership=%s\n", (owner)? "GO":"STA"); // (GO or client role) } else if (error_code == WIFI_DIRECT_ERROR_CONNECTION_TIME_OUT) { printf("Connection timeout occurred\n"); } else if (error_code == WIFI_DIRECT_ERROR_AUTH_FAILED) { printf("Connection authorization Failed\n"); } else printf("Connection failed\n"); break; case WIFI_DIRECT_CONNECTION_WPS_REQ: wifi_direct_get_local_wps_type(&wps_mode); if (wps_mode == WIFI_DIRECT_WPS_TYPE_PBC) { printf("Connection type WPS PBC\n"); // Handle WPS PBC case here } if (wps_mode == WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY) { printf("Connection type WPS PIN DISPLAY\n"); // Handle WPS PIN Display case here } if (wps_mode == WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD) { printf("Connection type WPS PIN KEYPAD\n"); // Handle WPS PIN Keypad case here } break; case WIFI_DIRECT_CONNECTION_REQ: printf("Connection request from MAC %s\n", mac_address); // Handle the connection request from peer device here // 1. WPS PBC // 2. WPS PIN Display // 3. WPS PIN Keypad wifi_direct_accept_connection(mac_address); break; case WIFI_DIRECT_DISCONNECTION_IND: if (error_code == WIFI_DIRECT_ERROR_NONE) printf("peer device disconnected MAC %s\n", mac_address); break; case WIFI_DIRECT_DISCONNECTION_RSP: if (error_code == WIFI_DIRECT_ERROR_NONE) printf("peer device disconnection response MAC %s\n", mac_address); break; case WIFI_DIRECT_DISASSOCIATION_IND: if (error_code == WIFI_DIRECT_ERROR_NONE) printf("peer device disassociation MAC %s\n", mac_address); break; case WIFI_DIRECT_GROUP_CREATED: printf("Group Created\n"); break; case WIFI_DIRECT_GROUP_DESTROYED: printf("Group Destroyed\n"); break; default: break; } *} void function(void) { int ret; ret = wifi_direct_set_connection_state_changed_cb(callback, NULL); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to register callback\n"); return; } printf("callback registered Successfully\n"); } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_set_device_name | ( | const char * | device_name | ) |
Sets the friendly name of a local device.
This device name is shown to other devices during device discovery.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Remarks:
- The name set is only valid during activated state. After Wi-Fi Direct is deactivated, this name will be same as the phone name.
- Parameters:
-
[in] device_name The name of a local device
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct must be activated by wifi_direct_activate().
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(char *name) { int res; res = wifi_direct_set_device_name(&name); // set device name if (res != WIFI_DIRECT_ERROR_NONE) { printf("Failed to set device name\n"); return -1; } return 0; } int main() { char name[256] = {0, }; wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct printf("Enter the device name\n"); read(stdin, name, 255); function(name); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_set_device_state_changed_cb | ( | wifi_direct_device_state_changed_cb | cb, |
void * | user_data | ||
) |
Sets the callback called when the state of device is changed.
- Since :
- 2.3
- Parameters:
-
[in] cb The callback function to invoke [in] user_data The user data to be passed to the callback function
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported
- Precondition:
- Wi-Fi Direct service must be initialized by wifi_direct_initialize().
- See also:
- wifi_direct_initialize()
- wifi_direct_unset_device_state_changed_cb()
- wifi_direct_device_state_changed_cb()
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> void callback(int error_code, Wifi_direct_device_state_e device_state, void *user_data) { switch (device_state) { case WIFI_DIRECT_DEVICE_STATE_ACTIVATED: printf("device activated\n"); //Do stuff here when Wi-Fi Direct is activated break; case WIFI_DIRECT_DEVICE_STATE_DEACTIVATED: printf("device deactivated\n"); //Do stuff here when Wi-Fi Direct is deactivated break; default: break; } } void function(void) { int ret; ret = wifi_direct_set_device_state_changed_cb(callback, NULL); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to register callback\n"); return; } printf("callback registered Successfully\n"); } int main() { wifi_direct_initialize(); // initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // deinitialize Wi-Fi Direct return 0; }
int wifi_direct_set_discovery_state_changed_cb | ( | wifi_direct_discovery_state_chagned_cb | cb, |
void * | user_data | ||
) |
Sets the callback called when the state of discovery is changed.
- Since :
- 2.3
- Parameters:
-
[in] cb The callback function to invoke [in] user_data The user data to be passed to the callback function
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported
- Precondition:
- Wi-Fi Direct service must be initialized by wifi_direct_initialize().
- See also:
- wifi_direct_initialize()
- wifi_direct_unset_discovery_state_changed_cb()
- wifi_direct_discovery_state_chagned_cb()
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> void callback(int error_code, wifi_direct_discovery_state_e discovery_state, void *user_data) { switch(discovery_state) { case WIFI_DIRECT_DISCOVERY_STARTED: printf("Discovery started\n"); break; case WIFI_DIRECT_ONLY_LISTEN_STARTED: printf("listen started\n"); break; case WIFI_DIRECT_DISCOVERY_FINISHED: printf("Discovery finished\n"); break; case WIFI_DIRECT_DISCOVERY_FOUND: printf("peer devices found\n"); break; case WIFI_DIRECT_DISCOVERY_LOST: printf("Discovery lost\n"); break; default: break; } } void function(void) { int ret; ret = wifi_direct_set_discovery_state_changed_cb(callback, NULL); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to register callback\n"); return; } printf("callback registered Successfully\n"); } int main() { wifi_direct_initialize(); // initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_set_display | ( | wifi_direct_display_type_e | type, |
int | port, | ||
int | hdcp | ||
) |
Sets the Wi-Fi Display parameters for the WFD IE of local device.
- Since :
- 2.4
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[in] type WFD Device Type: define the Role of WFD device like source or sink [in] port Specifies Session Management Control Port number. It should be 2 bytes (0~65535) [in] hdcp CP support bit: ( 1
= enable the hdcp support,0
= disable the hdcp support)
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate() and Wi-Fi Display must be enabled by wifi_direct_init_display().
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int ret; ret = wifi_direct_set_display(WIFI_DIRECT_DISPLAY_SOURCE, 7236, 1); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to set display property\n"); return -1; } printf("set display param success\n"); return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_set_display_availability | ( | bool | availability | ) |
Sets the Wi-Fi Display Session Availability.
- Since :
- 2.4
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[in] availability Wi-Fi Display Session Availability
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate() and enable Wi-Fi Display by wifi_direct_init_display().
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int ret; int availability; printf("Input the Wi-FI Display availability\n"); scanf("%1d", &availability); ret = wifi_direct_set_display_availability(availability); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to set display availability\n"); return -1; } printf("set display availability success\n"); return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_set_go_intent_per_type | ( | int | type, |
int | intent | ||
) |
Sets the intent of the group owner for each connection type.
- Since :
- 5.0
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Remarks:
- The range of intent is 0 - 15. The higher the intent is, the higher the probability to be the group owner is.
- Parameters:
-
[in] type The type of connection for a peer device [in] intent The intent of the group owner
- Returns:
- 0 on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be initialized by wifi_direct_initialize().
int wifi_direct_set_group_owner_intent | ( | int | intent | ) |
Sets the intent of the group owner.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Remarks:
- The range of intent is 0 - 15. The higher the intent is, the higher the probability to be the group owner is.
- Parameters:
-
[in] intent The intent of the group owner
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be initialized by wifi_direct_initialize().
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int ret; int go_intent; printf("Input the GO Intent range(0~15)\n"); scanf("%2d", &go_intent); ret = wifi_direct_set_group_owner_intent(go_intent); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to set go intent\n"); return -1; } return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_set_max_clients | ( | int | max | ) |
Sets the max number of clients.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[in] max The max number of clients
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be initialized by wifi_direct_initialize().
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int ret; int max_client; printf("Input the maximum clients to be connected\n"); scanf("%4d", &max_client); ret = wifi_direct_set_max_clients(max_client); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to set max clients\n"); return -1; } printf("max client set success\n"); return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_set_passphrase | ( | const char * | passphrase | ) |
Sets or updates Wi-Fi Protected Access (WPA) password. When creating Wi-Fi Direct Group, this password will be used.
- Since :
- 2.4
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Remarks:
- A peer can connect to this group as Wi-Fi Infrastructured mode with a passphrase.
- Parameters:
-
[in] passphrase new wpa password to set. Application must set the new password before.
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate().
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int ret; char key[65] = {0, }; printf("Input the passphrase\n"); read(stdin, key, 64); ret = wifi_direct_set_passphrase(key); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to set passphrase\n"); return -1; } printf("passphrase set success\n"); return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_set_peer_found_cb | ( | wifi_direct_peer_found_cb | cb, |
void * | user_data | ||
) |
Sets the callback called when the peer is found.
- Since :
- 2.3
- Parameters:
-
[in] cb The callback function to invoke [in] user_data The user data to be passed to the callback function
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported
- Precondition:
- Wi-Fi Direct service must be initialized by wifi_direct_initialize().
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> void callback(int error_code, wifi_direct_discovery_state_e discovery_state, const char *mac_address, void *user_data) *{ switch (discovery_state) { case WIFI_DIRECT_DISCOVERY_FOUND: printf("Peer found\n"); printf("MAC Address=%s\n", mac_address); // Do stuff here for discovered devices break; default: break; } *} void function(void) { int ret; ret = wifi_direct_set_peer_found_cb(callback, NULL); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to register callback\n"); return; } printf("callback registered Successfully\n"); } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); wifi_direct_deactivate(); // Deactivate Wi-FI Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_set_peer_info_connection_state_changed_cb | ( | wifi_direct_peer_info_connection_state_changed_cb | cb, |
void * | user_data | ||
) |
Sets the callback called when the state of connection is changed.
- Since :
- 5.0
- Parameters:
-
[in] cb The callback function to invoke [in] user_data The user data to be passed to the callback function
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported
- Precondition:
- Wi-Fi Direct service must be initialized by wifi_direct_initialize().
int wifi_direct_set_persistent_group_enabled | ( | bool | enabled | ) |
Enables the persistent group.
If enabled is true, then P2P persistent group will be used while creating a group and establishing a connection.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[in] enabled The status of persistent group: ( true
= enabled,false
= disabled)
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be initialized by wifi_direct_initialize().
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int ret; ret = wifi_direct_set_persistent_group_enabled(true); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to set persistence group enabled\n"); return -1; } printf("persistence group enabled success\n"); return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_set_req_wps_type | ( | wifi_direct_wps_type_e | type | ) |
Sets the requested WPS (Wi-Fi Protected Setup) type.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[in] type The type of WPS
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be initialized by wifi_direct_initialize().
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int ret; int wps_type; int option; printf("Input new WPS mode\n"); printf("1. WPS Type PBC\n"); printf("2. WPS Type PIN Display\n"); printf("3. WPS Type PIN Keypad\n"); scanf("%1d", &option); switch (input) { case 1: wps_type = WIFI_DIRECT_WPS_TYPE_PBC; break; case 2: wps_type = WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY; break; case 3: wps_type = WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD; break; } ret = wifi_direct_set_req_wps_type(wps_type); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to set requested wps types\n"); return -1; } return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_set_service_state_changed_cb | ( | wifi_direct_service_state_changed_cb | cb, |
void * | user_data | ||
) |
Sets the callback called when the state of the service discovery is changed.
- Since :
- 2.3
- Parameters:
-
[in] cb The callback function to invoke [in] user_data The user data to be passed to the callback function
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported
- Precondition:
- Wi-Fi Direct service must be initialized by wifi_direct_initialize().
- See also:
- wifi_direct_initialize()
- wifi_direct_unset_service_state_changed_cb()
- wifi_direct_service_state_changed_cb()
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> void callback(int error_code, wifi_direct_service_discovery_state_e discovery_state, wifi_direct_service_type_e service_type, void *response_data, const char *mac_address, void *user_data); *{ switch (discovery_state) { case WIFI_DIRECT_SERVICE_DISCOVERY_STARTED: printf("Discovery Started\n"); break; case WIFI_DIRECT_SERVICE_DISCOVERY_FINISHED: printf("Discovery finished\n"); break; case WIFI_DIRECT_SERVICE_DISCOVERY_FOUND: printf("Discovery found\n"); if (mac_address != NULL) printf("Peer MAC=%s\n", mac_address); if (response_data != NULL) printf("Peer response=%s\n", (char *)response_data); if (service_type == WIFI_DIRECT_SERVICE_TYPE_ALL) printf("service type all\n"); if (service_type == WIFI_DIRECT_SERVICE_TYPE_BONJOUR) printf("service type bonjour\n"); if (service_type == WIFI_DIRECT_SERVICE_TYPE_UPNP) printf("service type UPNP\n"); if (service_type == WIFI_DIRECT_SERVICE_TYPE_BT_ADDR) printf("service type BT_ADDR\n"); if (service_type == WIFI_DIRECT_SERVICE_TYPE_CONTACT_INFO)\ printf("service type contact info\n"); break; default: break; } *} void function(void) { int ret; ret = wifi_direct_set_service_state_changed_cb(callback, NULL); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to register callback\n"); return; } printf("callback registered Successfully\n"); } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); wifi_direct_deactivate(); // deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_set_session_timer | ( | int | seconds | ) |
Sets the timer which is used to expire the connection session.
- Since :
- 3.0
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[in] seconds Set the connection session timer value in seconds
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate().
- See also:
- wifi_direct_activate()
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int ret; int session_timeout; printf("Input the time for session timer\n"); scanf("%2d", &session_timeout); ret = wifi_direct_set_session_timer(session_timeout); // set session timer if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to set session timer\n"); return -1; } printf("set session timer success\n"); return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_set_state_changed_cb | ( | wifi_direct_state_changed_cb | cb, |
void * | user_data | ||
) |
Sets the callback called when the state of Wi-Fi Direct is changed.
- Since :
- 3.0
- Parameters:
-
[in] cb The callback function to invoke [in] user_data The user data to be passed to the callback function
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation Failed WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported
- See also:
- wifi_direct_unset_state_changed_cb()
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> char* print_link_state(wifi_direct_state_e state) { if (state == WIFI_DIRECT_STATE_DEACTIVATED) return "DEACTIVATED"; if (state == WIFI_DIRECT_STATE_ACTIVATING) return "ACTIVATING"; if (state == WIFI_DIRECT_STATE_ACTIVATED) return "ACTIVATED"; if (state == WIFI_DIRECT_STATE_DISCOVERING) return "DISCOVERING"; if (state == WIFI_DIRECT_STATE_CONNECTING) return "CONNECTING"; if (state == WIFI_DIRECT_STATE_DISCONNECTING) return "DISCONNECTING"; if (state == WIFI_DIRECT_STATE_CONNECTED) return "CONNECTED"; if (state == WIFI_DIRECT_STATE_GROUP_OWNER) return "GROUP OWNER"; return "Unknown state"; } void callback(wifi_direct_state_e state, void *user_data); { printf("State changed [%s]\n", print_link_state(state)); } void function(void) { int ret; ret = wifi_direct_set_state_changed_cb(callback, NULL); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to register callback\n"); return; } printf("callback registered Successfully\n"); } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-Fi Direct function(); wifi_direct_deactivate(); // deactivate Wi-Fi Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_set_wps_config_method | ( | int | type | ) |
Sets the advertizing WPS (Wi-Fi Protected Setup) type.
- Since :
- 5.0
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[in] type The type of WPS. composition of wifi_direct_config_method_type_e for example WIFI_DIRECT_CONFIG_METHOD_PBC|WIFI_DIRECT_CONFIG_METHOD_PIN_DISPLAY Use WIFI_DIRECT_CONFIG_METHOD_DEFAULT to reset to default value
- Returns:
- 0 on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be initialized by wifi_direct_activate().
- See also:
- wifi_direct_initialize()
int wifi_direct_set_wps_pin | ( | char * | pin | ) |
Sets or updates the WPS PIN number user expects.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[in] pin New pin to set. Application must set the new pin number before
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate().
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> int function(void) { int ret; char pin[9] = {0, }; printf("Input 8 digit PIN to set the WPS PIN mode\n"); read(stdin, pin, 8); ret = wifi_direct_set_wps_pin(pin); // Set the WPS PIN for connection if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to set the WPS PIN\n"); return -1; } printf("WPS PIN set success\n"); return 0; } void callback(int error_code, wifi_direct_connection_state_e connection_state, const char *mac_address, void *user_data) *{ char *ip; bool owner; int wps_mode; switch (connection_state) { case WIFI_DIRECT_CONNECTION_IN_PROGRESS: printf("Connection in progress\n"); break; case WIFI_DIRECT_CONNECTION_RSP: if (error_code == WIFI_DIRECT_ERROR_NONE) { printf("Peer Device Connected\n"); // device is connected printf("MAC=%s\n", mac_address); // device's MAC address wifi_direct_get_ip_address(&ip); printf("IP=%s\n", ip); //device's IP address wifi_direct_is_group_owner(&owner); printf("Ownership=%s\n", (owner)? "GO":"STA"); // (GO or client role) } else if (error_code == WIFI_DIRECT_ERROR_CONNECTION_TIME_OUT) { printf("Connection timeout occurred\n"); } else if (error_code == WIFI_DIRECT_ERROR_AUTH_FAILED) { printf("Connection authorization Failed\n"); } else printf("Connection failed\n"); break; case WIFI_DIRECT_CONNECTION_WPS_REQ: wifi_direct_get_local_wps_type(&wps_mode); if (wps_mode == WIFI_DIRECT_WPS_TYPE_PBC) { printf("Connection type WPS PBC\n"); // Handle WPS PBC case here } if (wps_mode == WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY) { printf("Connection type WPS PIN DISPLAY\n"); // Handle WPS PIN Display case here } if (wps_mode == WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD) { printf("Connection type WPS PIN KEYPAD\n"); // Set 8 digit WPS PIN here // Since the device has received the wps mode as PIN Keypad // User need to set the WPS PIN for peer // device connection using PIN method. if (function() == 0) wifi_direct_accept_connection(mac_address); // Accept the requested connection } break; case WIFI_DIRECT_CONNECTION_REQ: printf("Connection request from MAC %s\n", mac_address); // Handle the connection request from peer device here // 1. WPS PBC // 2. WPS PIN Display // 3. WPS PIN Keypad wifi_direct_accept_connection(mac_address); break; case WIFI_DIRECT_DISCONNECTION_IND: if (error_code == WIFI_DIRECT_ERROR_NONE) printf("peer device disconnected MAC %s\n", mac_address); break; case WIFI_DIRECT_DISCONNECTION_RSP: if (error_code == WIFI_DIRECT_ERROR_NONE) printf("peer device disconnection response MAC %s\n", mac_address); break; case WIFI_DIRECT_DISASSOCIATION_IND: if (error_code == WIFI_DIRECT_ERROR_NONE) printf("peer device disassociation MAC %s\n", mac_address); break; case WIFI_DIRECT_GROUP_CREATED: printf("Group Created\n"); break; case WIFI_DIRECT_GROUP_DESTROYED: printf("Group Destroyed\n"); break; default: break; } *} int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_set_connection_state_changed_cb(callback, NULL); // Register callback wifi_direct_activate(); // Activate Wi-Fi Direct function(); wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_set_connection_state_changed_cb(callback, NULL); // Deregister callback wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_start_discovery | ( | bool | listen_only, |
int | timeout | ||
) |
Starts discovery to find all P2P capable devices, asynchronously.
If application developers call wifi_direct_start_discovery() with listen_only as true
, then skip the initial 802.11 Scan and then enter Listen state instead of cycling between Scan and Listen.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Remarks:
- The function can be called if the Wi-Fi Direct state is one of:
WIFI_DIRECT_STATE_ACTIVATED
WIFI_DIRECT_STATE_DISCOVERING
WIFI_DIRECT_STATE_GROUP_OWNER
The function can be called even if there is another discovery in progress. All started processes will run simultaneously. Each process will receive WIFI_DIRECT_DISCOVERY_FINISHED event in wifi_direct_discovery_state_chagned_cb().
- Parameters:
-
[in] listen_only The status of listen only: ( true
= listen only,false
= cycling between Scan and Listen)[in] timeout Specifies the duration of discovery period, in seconds. If 0
, then there is no limit on how long the discovery takes. The actual limit (and time after which discovery stops) depends on the vendor's hardware and firmware
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate().
- Postcondition:
- wifi_direct_discovery_state_chagned_cb() will be invoked.
- See also:
- wifi_direct_activate()
- wifi_direct_cancel_discovery()
- wifi_direct_discovery_state_chagned_cb()
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> void callback(int error_code, wifi_direct_discovery_state_e discovery_state, void *user_data) { switch(discovery_state) { case WIFI_DIRECT_DISCOVERY_STARTED: printf("Discovery started\n"); break; case WIFI_DIRECT_ONLY_LISTEN_STARTED: printf("listen started\n"); break; case WIFI_DIRECT_DISCOVERY_FINISHED: printf("Discovery finished\n"); break; case WIFI_DIRECT_DISCOVERY_FOUND: printf("peer devices found\n"); break; case WIFI_DIRECT_DISCOVERY_LOST: printf("Discovery lost\n"); break; default: break; } } int function(void) { int ret; ret = wifi_direct_start_discovery(TRUE, 15); // Start discovery with listen only if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to start scan\n"); return -1; } return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_set_discovery_state_changed_cb(callback, NULL); // Register callback wifi_direct_activate(); // Activated Wi-Fi Direct function(); wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_unset_discovery_state_changed_cb(); // Deregister callback wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_start_discovery_specific_channel | ( | bool | listen_only, |
int | timeout, | ||
wifi_direct_discovery_channel_e | channel | ||
) |
Starts discovery to find all P2P capable devices with specified channel, asynchronously.
If you call this function with channel as WIFI_DIRECT_DISCOVERY_FULL_SCAN
it works same as wifi_direct_start_discovery() API. If application developers call this function with channel as WIFI_DIRECT_DISCOVERY_SOCIAL_CHANNEL
, then will search only the devices on the social channels(channel 1 or 6 or 11). If application developers call this function with channel as WIFI_DIRECT_DISCOVERY_CHANNEL1
, then will search only the devices on the channel 1. If application developers call this function with channel as WIFI_DIRECT_DISCOVERY_CHANNEL6
, then will search only the devices on the channel 6. If application developers call this function with channel as WIFI_DIRECT_DISCOVERY_CHANNEL11
, then will search only the devices on the channel 11.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Remarks:
- The function can be called if the Wi-Fi Direct state is one of:
WIFI_DIRECT_STATE_ACTIVATED
WIFI_DIRECT_STATE_DISCOVERING
WIFI_DIRECT_STATE_GROUP_OWNER
The function can be called even if there is another discovery in progress. All started processes will run simultaneously. Each process will receive WIFI_DIRECT_DISCOVERY_FINISHED event in wifi_direct_discovery_state_chagned_cb().
- Parameters:
-
[in] listen_only The status of listen only: ( true
= listen only,false
= cycling between Scan and Listen)[in] timeout Specifies the duration of discovery period, in seconds. If 0
, then there is no limit on how long the discovery takes. The actual limit (and time after which discovery stops) depends on the vendor's hardware and firmware[in] channel Specifies the discovery channel. (Full scan, social channels, channel 1, 6, 11)
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate().
- Postcondition:
- wifi_direct_discovery_state_chagned_cb() will be invoked.
- See also:
- wifi_direct_activate()
- wifi_direct_cancel_discovery()
- wifi_direct_discovery_state_chagned_cb()
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> void callback(int error_code, wifi_direct_discovery_state_e discovery_state, void *user_data) { switch(discovery_state) { case WIFI_DIRECT_DISCOVERY_STARTED: printf("Discovery started\n"); break; case WIFI_DIRECT_ONLY_LISTEN_STARTED: printf("listen started\n"); break; case WIFI_DIRECT_DISCOVERY_FINISHED: printf("Discovery finished\n"); break; case WIFI_DIRECT_DISCOVERY_FOUND: printf("peer devices found\n"); break; case WIFI_DIRECT_DISCOVERY_LOST: printf("Discovery lost\n"); break; default: break; } } int function(void) { int ret; ret = wifi_direct_start_discovery_specific_channel(TRUE, 15, // start discovery with 15sec timeout WIFI_DIRECT_DISCOVERY_FULL_SCAN); // scan all channels if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to start scan\n"); return -1; } return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_set_discovery_state_changed_cb(callback, NULL); // Register callback wifi_direct_activate(); // Activated Wi-Fi Direct function(); wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_unset_discovery_state_changed_cb(); // Deregister callback wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_start_discovery_specific_freq | ( | bool | listen_only, |
int | timeout, | ||
int | frequency | ||
) |
Starts discovery to find all P2P capable devices with specified frequency, asynchronously.
- Since :
- 4.0
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Remarks:
- The function can be called if the Wi-Fi Direct state is one of:
WIFI_DIRECT_STATE_ACTIVATED
WIFI_DIRECT_STATE_DISCOVERING
WIFI_DIRECT_STATE_GROUP_OWNER
The function can be called even if there is another discovery in progress. All started processes will run simultaneously. Each process will receive WIFI_DIRECT_DISCOVERY_FINISHED event in wifi_direct_discovery_state_chagned_cb().
- Parameters:
-
[in] listen_only Indicates mode in which the discovery service will work. If true
, the service will only listen, otherwise it will cycle between scanning and listening[in] timeout Specifies the duration of discovery period, in seconds. If 0
, then there is no limit on how long the discovery takes. The actual limit (and time after which discovery stops) depends on the vendor's hardware and firmware[in] frequency Specifies the discovery frequency in MHz
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate().
- Postcondition:
- wifi_direct_discovery_state_chagned_cb() will be invoked.
- See also:
- wifi_direct_activate()
- wifi_direct_cancel_discovery()
- wifi_direct_discovery_state_chagned_cb()
- wifi_direct_discovered_peer_cb()
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> void callback(int error_code, wifi_direct_discovery_state_e discovery_state, void *user_data) { switch(discovery_state) { case WIFI_DIRECT_DISCOVERY_STARTED: printf("Discovery started\n"); break; case WIFI_DIRECT_ONLY_LISTEN_STARTED: printf("listen started\n"); break; case WIFI_DIRECT_DISCOVERY_FINISHED: printf("Discovery finished\n"); break; case WIFI_DIRECT_DISCOVERY_FOUND: printf("peer devices found\n"); break; case WIFI_DIRECT_DISCOVERY_LOST: printf("Discovery lost\n"); break; default: break; } } int function(void) { int ret; ret = wifi_direct_start_discovery_specific_freq(TRUE, 15, // start discovery with 15sec timeout 2437); // scan for 2437 MHz frequency (Channel 6) if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to start scan\n"); return -1; } return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_set_discovery_state_changed_cb(callback, NULL); // Register callback wifi_direct_activate(); // Activated Wi-Fi Direct function(); wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_unset_discovery_state_changed_cb(); // Deregister callback wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_start_service_discovery | ( | char * | mac_address, |
wifi_direct_service_type_e | service_type | ||
) |
Starts wifi direct service discovery.
- Since :
- 2.3
- Privilege Level:
- public
- Privilege:
- http://tizen.org/privilege/wifidirect
- Parameters:
-
[in] mac_address The MAC address of servicing device. A broadcast
will be sent when MAC is SET to ZERO[in] service_type Describes the type of service
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_INVALID_PARAMETER Invalid parameter WIFI_DIRECT_ERROR_OPERATION_FAILED Operation failed WIFI_DIRECT_ERROR_COMMUNICATION_FAILED Communication failed WIFI_DIRECT_ERROR_PERMISSION_DENIED Permission denied WIFI_DIRECT_ERROR_NOT_PERMITTED Operation not permitted WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_RESOURCE_BUSY Device or resource busy
- Precondition:
- Wi-Fi Direct service must be activated by wifi_direct_activate().
- Postcondition:
- wifi_direct_set_service_state_changed_cb() will be invoked.
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> void callback(int error_code, wifi_direct_service_discovery_state_e discovery_state, wifi_direct_service_type_e service_type, void *response_data, const char * mac_address, void *user_data) { switch (discovery_state) { case WIFI_DIRECT_SERVICE_DISCOVERY_STARTED: printf("Service discovery started\n"); break; case WIFI_DIRECT_SERVICE_DISCOVERY_FINISHED: printf("Service discovery finished\n"); break; case WIFI_DIRECT_SERVICE_DISCOVERY_FOUND: printf("Service discovery found\n"); break; } } int function(void) { int ret; int option; wifi_direct_service_type_e type = WIFI_DIRECT_SERVICE_TYPE_ALL; printf("Input service type\n"); scanf("%1d", &option); printf("1. WIFI_DIRECT_SERVICE_TYPE_ALL\n"); printf("2. WIFI_DIRECT_SERVICE_TYPE_BONJOUR\n"); printf("3. WIFI_DIRECT_SERVICE_TYPE_UPNP\n"); printf("4. WIFI_DIRECT_SERVICE_TYPE_BT_ADDR\n"); printf("5. WIFI_DIRECT_SERVICE_TYPE_CONTACT_INFO\n"); switch (option) { case 1: type = WIFI_DIRECT_SERVICE_TYPE_ALL; break; case 2: type = WIFI_DIRECT_SERVICE_TYPE_BONJOUR; break; case 3: type = WIFI_DIRECT_SERVICE_TYPE_UPNP; break; case 4: type = WIFI_DIRECT_SERVICE_TYPE_BT_ADDR; break; case 5: type = WIFI_DIRECT_SERVICE_TYPE_CONTACT_INFO; break; } ret = wifi_direct_start_service_discovery(NULL, type); // start broadcast service discovery if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to start service discovery\n"); return -1; } return 0; } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct wifi_direct_set_service_state_changed_cb(callback, NULL); wifi_direct_activate(); // Activate Wi-Fi Direct function(); // APP CODE HERE // App must clean up Wi-Fi Direct before exiting wifi_direct_deactivate(); // Deactivate Wi-Fi Direct wifi_direct_unset_service_state_changed_cb(); wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_unset_client_ip_address_assigned_cb | ( | void | ) |
Unsets the callback called when the IP address of the client is assigned if your device is the group owner.
- Since :
- 2.3
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported
- Precondition:
- Wi-Fi Direct service must be initialized by wifi_direct_initialize().
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> void function(void) { int ret; ret = wifi_direct_unset_client_ip_address_assigned_cb(); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to deregister callback\n"); return; } printf("callback deregistered Successfully\n"); } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct function(); wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_unset_connection_state_changed_cb | ( | void | ) |
Unsets the callback called when the state of connection is changed.
- Since :
- 2.3
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported
- Precondition:
- Wi-Fi Direct service must be initialized by wifi_direct_initialize().
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> void function(void) { int ret; ret = wifi_direct_unset_connection_state_changed_cb(); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to deregister callback\n"); return; } printf("callback deregistered Successfully\n"); } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct function(); wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_unset_device_state_changed_cb | ( | void | ) |
Unsets the callback called when the state of device is changed.
- Since :
- 2.3
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported
- Precondition:
- Wi-Fi Direct service must be initialized by wifi_direct_initialize().
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> void function(void) { int ret; ret = wifi_direct_unset_device_state_changed_cb(); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to deregister callback\n"); return; } printf("callback deregistered Successfully\n"); } int main() { wifi_direct_initialize(); // initialize Wi-Fi Direct function(); wifi_direct_deinitialize(); // deinitialize Wi-Fi Direct return 0; }
int wifi_direct_unset_discovery_state_changed_cb | ( | void | ) |
Unsets the callback called when the state of discovery is changed.
- Since :
- 2.3
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported
- Precondition:
- Wi-Fi Direct service must be initialized by wifi_direct_initialize().
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> void function(void) { int ret; ret = wifi_direct_unset_discovery_state_changed_cb(); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to deregister callback\n"); return; } printf("callback deregistered Successfully\n"); } int main() { wifi_direct_initialize(); // initialize Wi-Fi Direct wifi_direct_activate(); // Activate Wi-FI Direct function(); wifi_direct_deactivate(); // Deactivate Wi-FI Direct wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_unset_peer_found_cb | ( | void | ) |
Unsets the callback called when the peer is found.
- Since :
- 2.3
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported
- Precondition:
- Wi-Fi Direct service must be initialized by wifi_direct_initialize().
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> void function(void) { int ret; ret = wifi_direct_unset_peer_found_cb(); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to deregister callback\n"); return; } printf("callback deregistered Successfully\n"); } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct function(); wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
Unsets the callback called when the state of connection is changed.
- Since :
- 5.0
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported
- Precondition:
- Wi-Fi Direct service must be initialized by wifi_direct_initialize().
int wifi_direct_unset_service_state_changed_cb | ( | void | ) |
Unsets the callback called when the state of the service discovery is changed.
- Since :
- 2.3
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_NOT_INITIALIZED Not initialized WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported
- Precondition:
- Wi-Fi Direct service must be initialized by wifi_direct_initialize().
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> void function(void) { int ret; ret = wifi_direct_unset_service_state_changed_cb(); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to deregister callback\n"); return; } printf("callback deregistered Successfully\n"); } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct function(); wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }
int wifi_direct_unset_state_changed_cb | ( | void | ) |
Unsets the callback called when the state of Wi-Fi Direct is changed.
- Since :
- 3.0
- Returns:
0
on success, otherwise a negative error value
- Return values:
-
WIFI_DIRECT_ERROR_NONE Successful WIFI_DIRECT_ERROR_OPERATION_FAILED Operation Failed WIFI_DIRECT_ERROR_NOT_SUPPORTED Not supported
Here is an example of the usage:
#include <stdio.h> #include <wifi_direct.h> void function(void) { int ret; ret = wifi_direct_unset_state_changed_cb(); if (ret != WIFI_DIRECT_ERROR_NONE) { printf("Failed to deregister callback\n"); return; } printf("callback deregistered Successfully\n"); } int main() { wifi_direct_initialize(); // Initialize Wi-Fi Direct function(); wifi_direct_deinitialize(); // Deinitialize Wi-Fi Direct return 0; }