Open orineman opened 7 months ago
I suppose I should add that if we believe the System.Devices.Aep.IsPaired property, then the "Unpaired" designation in the "Discovered Devices" list is incorrect.
Whether this turns out to be an OS bug or not, the sample should take account of this problem as anyone shipping product will have to use some kind of workaround for this problem.
So, if you ask for System.Devices.Aep.IsPaired in the list of properties passed to DeviceInformation.CreateWatcher(), then the System.Devices.Aep.IsPaired property is copied to DeviceInformation.IsPaired. Similarly for CanPair.
string deviceSelector = WiFiDirectDevice.GetDeviceSelector(Utils.GetSelectedItemTag<WiFiDirectDeviceSelectorType>(cmbDeviceSelector));
_deviceWatcher = DeviceInformation.CreateWatcher(deviceSelector,
new string[] {
"System.Devices.WiFiDirect.InformationElements",
"System.Devices.Aep.CanPair",
"System.Devices.Aep.IsPaired"
}
);
I'd suggest this modification is made to the sample. It fixes both this issue and the misreporting of the pairing status in the Discovered Devices list.
I've not found any documentation of this 'feature'.
Which sample are you reporting a bug in?
WiFiDirect
Describe the bug
Second connection to a give Windows computer running the sample fails.
To Reproduce Steps to reproduce the behavior:
Expected behavior
The connection should be successfuil.
Screenshots
Configuration
Additional context
The sample relies on DeviceInformationPairing.IsPaired. It is false in this case. If however, you call CreateFromIdAsync() for the device and ask for "System.Devices.Aep.IsPaired", the "System.Devices.Aep.IsPaired" property will be true. Similarly for DeviceInformationPairing.CanPair and "System.Devices.Aep.CanPair". The documentation implies DeviceInformationPairing.IsPaired is derived from "System.Devices.Aep.IsPaired", whatever that means...
It should be noted that this is a problem on the Connector side only. The Advertiser side uses an additional function, IsAepPaired() to determine if pairing is necessary.
There are various ways of making the sample work should this be an OS "feature". Don't try to pair if CanPair is false seems to work. Probably better is to call CreateFromIdAsync() for the device and use the System.Devices.Aep.IsPaired/System.Devices.Aep.CanPair properties, if present. And finally, I suppose the AlreadyPaired error could be ignored!