I am trying to use Windows WCN framework to achive the WPS(Wireless Protected Setup) functions in Windows 10. However, I meet some troubles. And I found someone meet the similar question, here is the link
In my program, I successfully detected the infos of the Access Point. Then I need to try to communicate with it by WSC 2.0 protocol. I do it by the following steps:
1、Create an object that implements IWCNConnectNotify, I call it WCNConnectNotify.
2、call IWCNDevice::SetNetworkProfile()
function to set the profile files;
3、call IWCNDevice::SetPassword()
function to set the mode of WPS;
4、call IWCNDevice::Connect()
function to try to communicate with the AP by WSC 2.0 protocol.
However, on the one hand, when I try to use PIN_STA mode( enter the PIN code of AP into the network adapter) to connect with the AP, the IWCNDevice::SetPassword()
function return E_INVALIDARG
, which means that the arguments passed to this function are wrong! But The sample program can run on Win7,
Win8 and Win8.1 successfully. What's more, I print the arguments out in a file and found nothing wrong. The sample code like this:
//pDevice is a pointer of IWCNDevice class, pWcnConnectNotify is a pointer of WcnConnectNotify class.
WCN_PASSWORD_TYPE cfgType = WCN_PASSWORD_TYPE_PIN;
DWORD dwPinLen = 8;
UCHAR ucPin[8];
CopyMemory(ucPin, "12345670", 8);
hr = pDevice->SetPassword(cfgType, dwPinLen, ucPin);
if (hr != S_OK)
{
printf("{%s} SetPassword() Failed! hr = 0x%x\n", __FUNCTION__, hr);
continue;
}
printf("{%s} SetPassword function success, now begin Connect Function.\n", __FUNCTION__);
hr = pDevice->Connect(pWcnConnectNotify);
On the other hand, When I try to use PBC mode, the IWCNDevice::SetPassword()
function return S_OK
successfully( Of course the arguments passed to it is different with the PIN_STA mode), and it can run the IWCNDevice::Connect()
function, but it cannot communicate with the AP
within the presupposed time(I set 10 seconds).
The most confused thing is that the same code can run successfully on Win7, Win8, and Win8.1, but without the Win10. I try to find the sample code of WindowsConnectNow in Win10 but get nothings. If I miss something important? If anyone can do me a favor? I am truly appreciative if anyone can give me a useful suggestion!Thank you very much!