How to report signal strength for Wifi-Direct / Wifi-Direct Legacy connection?

Jason 1 Reputation point
2020-10-30T00:18:58.54+00:00

Using the Microsoft UWP "WifiDirect" c# sample application (win 10), my objective is to report the signal strength of the Wifi-Direct connection on a regular basis.
I added "System.Devices.Aep.SignalStrength" to the list of properties to the DeviceWatcher. I made sure the Updated event on the DeviceWatcher was subscribed to. Based on what I have read, I assumed the Updated event would be called when the property changed. That did not happen. I could not get the Updated event to ever fire.

Sample snippet from MS sample app:

_deviceWatcher = DeviceInformation.CreateWatcher(deviceSelector, new string[]  
                                                                                 {  
                                                                                     "System.Devices.WiFiDirect.InformationElements",  
                                                                                     "System.ItemNameDisplay",  
                                                                                     "System.Devices.Aep.CanPair",  
                                                                                     "System.Devices.Aep.IsPaired",  
                                                                                     "System.Devices.Aep.SignalStrength"  
                                                                                 });  
  
                _deviceWatcher.Added += OnDeviceAdded;  
                _deviceWatcher.Removed += OnDeviceRemoved;  
                _deviceWatcher.Updated += OnDeviceUpdated;  

And:

private async void OnDeviceUpdated(DeviceWatcher deviceWatcher, DeviceInformationUpdate deviceInfoUpdate)  
        {  
            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>  
            {  
                //Do stuff here.....  
            });  
        }  

Bottom line question: how do I report Signal Strength on a regular basis using Wifi-Direct / Wifi-Direct Legacy? I would like this value displayed to the user as the range of the connected device changes.

Here is a reference to the MS sample app mentioned above:
https://learn.microsoft.com/samples/microsoft/windows-universal-samples/wifidirect/

Universal Windows Platform (UWP)
{count} votes

2 answers

Sort by: Most helpful
  1. Roy Li - MSFT 33,166 Reputation points Microsoft Vendor
    2020-11-25T02:12:43.31+00:00

    Hello,

    Welcome to Microsoft Q&A!

    @Jason Sorry for the delay.

    After talking to the team, it is mentioned that the OnUpdated event would not be fired upon a WiFi signal change. This may only be updated based on certain properties of the device that was changed such as device name or type.

    One potential solution that I got from other engineers is that you could create a timer to manually poll for the signal strength at regular intervals. Here is the document that contains detailed ways in which we can implement a WiFi scanner app that scans at regular intervals to update the list of WiFi devices (along with updating the signal strength)

    https://learn.microsoft.com/en-us/archive/msdn-magazine/2016/july/modern-apps-build-a-wi-fi-scanner-in-the-uwp#scanning-repeatedly

    This may be a better approach as the Signal strength can change at a rapid pace so this can control how often you would want the signal value to be updated. In addition, the signal strength can sometimes go to 0 based on if the device timed out or disconnected so polling the signal strength at certain intervals would provide more data into the WiFi devices nearby.

    Thank you.


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. Jason 1 Reputation point
    2020-11-30T17:45:59.18+00:00

    Rather than going through and creating code from the link you sent, I instead went to the WifiScan UWP sample app...
    https://learn.microsoft.com/en-us/samples/microsoft/windows-universal-samples/wifiscan/

    When I run the Scan I see several expected wifi access points show up in the list. I do not see the Wifi Direct Legacy connection. I made sure the PC was connected to the wifi device and transmitting data (just to verify the wifi connection was successfully established).
    The name of SSID property assigned to the WiFiDirectLegacySettings object does not show up in the scan list. I have used this scanning sample app previously and do not recall ever seeing a Wifi Direct (legacy or normal) connection show up.

    If you think there is a difference between the WifiScan UWP sample app and the link you sent, I can walk through the steps in the link. But at first glance, the two approaches seem similar.

    Thanks

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.