Windows.Devices.WiFiDirect.Services Namespace

Provides support for implementing your own Wi-Fi Direct Services.

Wi-Fi Direct is a technology that enables two devices to connect directly to each other using Wi-Fi, without needing to join an existing network through an access point. Wi-Fi Direct Services are the way that one device (a Service Advertiser) offers capabilities to another device (a Service Seeker) over a Wi-Fi Direct connection. A seeker makes use of an advertised service by establishing a session. A given device can advertise multiple services and also seek multiple services. The Seeker and Advertiser roles are defined with respect to how the devices interact in a particular session.

While the Wi-Fi Direct Services specification defines several standard services, this API supports only the Enable service. It does not support Send, Play, Print, or Display functionality.



Represents a Wi-Fi Direct service. This class is used by code on a device that seeks to use a Wi-Fi Direct Service, to establish a Wi-Fi Direct Service session with the service provider.


Represents a Service Advertiser. This class is used by code on a device that advertises Wi-Fi Direct Services, to advertise the service.


Returned when a WiFiDirectServiceAdvertiser.AutoAcceptSessionConnected event is raised.


Contains provisioning information about a Wi-Fi Direct Service.


Returned when a WiFiDirectServiceSession.RemotePortAdded event is raised. Your event handler should use this information to establish new socket connections to the new port.


Represents a Wi-Fi Direct Services (WFDS) session.


Returned when a WiFiDirectService.SessionDeferred event is raised.


Describes a Wi-Fi Direct Service session request.


Returned when a WiFiDirectServiceAdvertiser.SessionRequested event is raised.



Values used for WiFiDirectServiceAdvertiser.AdvertisementStatus.


Values describing how service configuration is performed when a session is being established. Typically, either no input is required, or one device in the session displays a PIN and the other device requires that the PIN be entered.


Values used for the WiFiDirectServiceAdvertiser.ServiceError property.


Defines constants that specify the IP protocol of the new port when a WiFiDirectServiceSession.RemotePortAdded event is raised.


Values used in the WiFiDirectServiceSession.ErrorStatus property.


Values used to describe the status of a Wi-Fi Direct Service Session.


Values used to describe the service status.


Setting the Group Owner (GO)

You might want to be able to exert precise control over which of the members of a Peer to Peer (P2P) group is the Group Owner (GO). Your code should use the WiFiDirectAdvertiser.PreferGroupOwnerMode property to specify that a given advertiser wants to be the GO. However, if two devices have been previously paired via Wi-Fi Direct, then the Wi-Fi direct roles in the saved profile from that pairing override the advertiser's specified preference. In order to guarantee that a given device in a P2P pairing will be the GO, you must first delete any existing pairing data, using methods provided by the Windows.Devices.Enumeration namespace.

Note that a pairing profile pairs two MAC addresses, so unpairing two devices applies to all apps that use Wi-Fi Direct between those two devices. Your app should never assume that a pairing profile exists, or that it has not been changed by another app, even if it has paired with a device in the past. You should get current profile information from the current profile rather than storing profile information and assuming it is still true at a later date. Another app might have changed the pairing profile in the interim.

The following code finds any Wi-Fi Direct pairing profile between the local device and another device, and unpairs the two devices. After this code has successfully unpaired the two devices, subsequent pairing will obey the WiFiDirectAdvertiser.PreferGroupOwnerMode value active at the time of pairing.

using Windows.Devices.Enumeration;

private async void Unpair_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
    if (DiscoveredServices.Items.Count > 0)
        DiscoveredDeviceWrapper service = 

        String[] aepId = service.DeviceInfo.Id.Split('#');
        String deviceSelector = "System.Devices.DeviceInstanceId:=\"SWD\\WiFiDirect\\" + aepId[1] + "\"";

        // Check if device is paired
        DeviceInformationCollection pairedDeviceCollection = 
            await DeviceInformation.FindAllAsync(deviceSelector, null, DeviceInformationKind.DeviceInterface);

        if (pairedDeviceCollection.Count > 0)
                DeviceInformation devInfo = pairedDeviceCollection[0];
                await devInfo.Pairing.UnpairAsync();
                MainPage.Current.NotifyUser("UnpairAsync succeeded", NotifyType.StatusMessage);

            catch (Exception ex)
                MainPage.Current.NotifyUser("UnpairAsync failed: " + ex.Message, NotifyType.ErrorMessage);

See also