Open orineman opened 1 year ago
I also saw this problem. After you fixed it, do you get the GO and GC connected?
I believe so. I worked more with the C# sample. So see also #1399.
Best way of testing is to make sure the devices aren't already paired and get the C# sample working first.
Life will be better if you make this change to Scenario2_Connector.cpp at approx. line 78.
deviceWatcher = DeviceInformation::CreateWatcher(deviceSelector, { L"System.Devices.WiFiDirect.InformationElements", L"System.Devices.Aep.CanPair", L"System.Devices.Aep.IsPaired" });
It will make it correctly report the pairing status for the device you are connecting to and stop it from trying to pair when already paired (which fails).
co_await clientSocket.ConnectAsync(remoteHostName, ServerPortString);
is throwing an exception for me at the moment, but it does make the WiFi Direct connection, but I haven't run this code for a couple of months.
I let all the GO settings default and add "Push button" configuration methods on both sides. I suggest trying this first.
Note that the Advertiser only advertises for a couple of minutes and the Connector only looks for a few seconds. Once it says the enumeration is complete, you won't see any more devices until you stop/restart the watcher.
You are better off doing this:
WiFiDirectDevice wiFiDevice = WiFiDirectDevice(nullptr);
hstring selector = wiFiDevice.GetDeviceSelector(WiFiDirectDeviceSelectorType::AssociationEndpoint);
co_await resume_background();
DeviceInformationCollection devices = co_await DeviceInformation::FindAllAsync(
selector,
{
L"System.Devices.Aep.CanPair",
L"System.Devices.Aep.IsPaired",
L"System.Devices.WiFiDirect.InformationElements"
}
);
co_await winrt::resume_foreground(_queue);
every 30 seconds or so while you aren't suspended.
@orineman After look at your reply and the link you mentioned, I realize that only GC needs to do DeviceInformationCustomPairing::PairAsync(...), then both side can get a valid IP address and ping each other. But the problem is that how to use WiFiDirectConfigurationMethod::DisplayPin and ProvidePin? PushButton is kind of unsafe. I don't see WiFiDirectConnectionParameters::PairingRequested call back handler get called at any situation. I mentioned this problem in issue #1406
Which sample are you reporting a bug in?
WifiDirect/cppwinrt
Describe the bug
Listener fails to accept connection from an unpaired device.
To Reproduce Steps to reproduce the behavior:
Run the sample, start a listener using default settings, try to connect to it from an unpaired device.
Expected behavior
It should work the same as the C# sample and successfully connect.
Configuration
Any.
Additional context
The '}' currently at line 235 should be at line 182 in Scenario1_Advertiser.cpp. I.e. immediately before the following user notification:
rootPage.NotifyUser(L"Connecting to " + deviceName + L"...", NotifyType::StatusMessage);
See also Scenario1_Advertiser.xaml.cs in th C# sample which has identical flow.