Windows.Devices.WiFiDirect.Services Windows.Devices.WiFiDirect.Services Windows.Devices.WiFiDirect.Services Windows.Devices.WiFiDirect.Services 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.


WiFiDirectService WiFiDirectService WiFiDirectService WiFiDirectService WiFiDirectService

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.

WiFiDirectServiceAdvertiser WiFiDirectServiceAdvertiser WiFiDirectServiceAdvertiser WiFiDirectServiceAdvertiser WiFiDirectServiceAdvertiser

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

WiFiDirectServiceAutoAcceptSessionConnectedEventArgs WiFiDirectServiceAutoAcceptSessionConnectedEventArgs WiFiDirectServiceAutoAcceptSessionConnectedEventArgs WiFiDirectServiceAutoAcceptSessionConnectedEventArgs WiFiDirectServiceAutoAcceptSessionConnectedEventArgs

Returned when a WiFiDirectServiceAdvertiser.AutoAcceptSessionConnected event is raised.

WiFiDirectServiceProvisioningInfo WiFiDirectServiceProvisioningInfo WiFiDirectServiceProvisioningInfo WiFiDirectServiceProvisioningInfo WiFiDirectServiceProvisioningInfo

Contains provisioning information about a Wi-Fi Direct Service.

WiFiDirectServiceRemotePortAddedEventArgs WiFiDirectServiceRemotePortAddedEventArgs WiFiDirectServiceRemotePortAddedEventArgs WiFiDirectServiceRemotePortAddedEventArgs WiFiDirectServiceRemotePortAddedEventArgs

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

WiFiDirectServiceSession WiFiDirectServiceSession WiFiDirectServiceSession WiFiDirectServiceSession WiFiDirectServiceSession

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

WiFiDirectServiceSessionDeferredEventArgs WiFiDirectServiceSessionDeferredEventArgs WiFiDirectServiceSessionDeferredEventArgs WiFiDirectServiceSessionDeferredEventArgs WiFiDirectServiceSessionDeferredEventArgs

Returned when a WiFiDirectService.SessionDeferred event is raised.

WiFiDirectServiceSessionRequest WiFiDirectServiceSessionRequest WiFiDirectServiceSessionRequest WiFiDirectServiceSessionRequest WiFiDirectServiceSessionRequest

Describes a Wi-Fi Direct Service session request.

WiFiDirectServiceSessionRequestedEventArgs WiFiDirectServiceSessionRequestedEventArgs WiFiDirectServiceSessionRequestedEventArgs WiFiDirectServiceSessionRequestedEventArgs WiFiDirectServiceSessionRequestedEventArgs

Returned when a WiFiDirectServiceAdvertiser.SessionRequested event is raised.


WiFiDirectServiceAdvertisementStatus WiFiDirectServiceAdvertisementStatus WiFiDirectServiceAdvertisementStatus WiFiDirectServiceAdvertisementStatus WiFiDirectServiceAdvertisementStatus

Values used for WiFiDirectServiceAdvertiser.AdvertisementStatus.

WiFiDirectServiceConfigurationMethod WiFiDirectServiceConfigurationMethod WiFiDirectServiceConfigurationMethod WiFiDirectServiceConfigurationMethod WiFiDirectServiceConfigurationMethod

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.

WiFiDirectServiceError WiFiDirectServiceError WiFiDirectServiceError WiFiDirectServiceError WiFiDirectServiceError

Values used for the WiFiDirectServiceAdvertiser.ServiceError property.

WiFiDirectServiceIPProtocol WiFiDirectServiceIPProtocol WiFiDirectServiceIPProtocol WiFiDirectServiceIPProtocol WiFiDirectServiceIPProtocol

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

WiFiDirectServiceSessionErrorStatus WiFiDirectServiceSessionErrorStatus WiFiDirectServiceSessionErrorStatus WiFiDirectServiceSessionErrorStatus WiFiDirectServiceSessionErrorStatus

Values used in the WiFiDirectServiceSession.ErrorStatus property.

WiFiDirectServiceSessionStatus WiFiDirectServiceSessionStatus WiFiDirectServiceSessionStatus WiFiDirectServiceSessionStatus WiFiDirectServiceSessionStatus

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

WiFiDirectServiceStatus WiFiDirectServiceStatus WiFiDirectServiceStatus WiFiDirectServiceStatus WiFiDirectServiceStatus

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