Using the Wi-Fi Direct functions
This topics shows how to use Wi-Fi Direct functions in desktop apps. Starting on Windows 8 and Windows Server 2012, Wi-Fi Direct functions were added to the Native Wifi API.
The Wi-Fi Direct feature is based on the development of the Wi-Fi Peer-to-Peer Technical Specification v1.1 by the Wi-Fi Alliance (see Wi-Fi Alliance Published Specifications). The goal of the Wi-Fi Peer-to-Peer Technical Specification is to provide a solution for Wi-Fi device-to-device connectivity without the need for either a Wireless Access Point (wireless AP) to setup the connection or the use of the existing Wi-Fi ad hoc (IBSS) mechanism.
The following functions support the Wi-Fi Direct feature.
- WFDCancelOpenSession - Indicates that the app wants to cancel a pending WFDStartOpenSession function that has not completed.
- WFDCloseHandle - Closes a handle to the Wi-Fi Direct service.
- WFDCloseSession - Closes a session after a previously successful call to the WFDStartOpenSession function.
- WFDOpenHandle - Opens a handle to the Wi-Fi Direct service and negotiates a version of the Wi-FI Direct API to use.
- WFDOpenLegacySession - Retrieves and applies a stored profile for a Wi-Fi Direct legacy device.
- WFDStartOpenSession - Starts an on-demand connection to a specific Wi-Fi Direct device, which has been previously paired through the Windows Pairing experience.
- WFDUpdateDeviceVisibility - Updates device visibility for the Wi-Fi Direct device address for a given installed Wi-Fi Direct device node.
- WFD_OPEN_SESSION_COMPLETE_CALLBACK - Defines the callback function that is called by the WFDStartOpenSession function when the WFDStartOpenSession operation completes
For a desktop app, the Wi-Fi Direct feature requires that Wi-FI Direct devices be previously paired by the user with the Windows Pairing experience user interface. Once this pairing is completed, a profile is stored that allows the Wi-Fi Direct functions to be used to start a Wi-Fi Direct session to establish a connection between the Wi-Fi Direct devices.
In order to use Wi-Fi Direct, an app must first obtain a handle to the Wi-Fi Direct service by calling the WFDOpenHandle function. The Wi-Fi Direct (WFD) handle returned by the WFDOpenHandle function is used for subsequent Wi-Fi Direct function calls made to the Wi-Fi Direct service.
The WFDStartOpenSession function starts an asynchronous operation to start an on-demand connection to a specific Wi-Fi Direct device. The target Wi-Fi device must previously have been paired through the Windows Pairing experience. When the asynchronous operation completes, the callback function specified in the pfnCallback parameter is called.
Once an application is done using the Wi-Fi Direct service, the application should call the WFDCloseHandle function to signal to the Wi-Fi Direct service that the application is done using the service. This allows the Wi-Fi Direct service to release resources used by the application.
- Other resources
- About Native Wifi
- About the Native Wifi API
- About the Wi-Fi Direct feature