none
WZCSAPI.DLL Usage Problem on WinCE600 RRS feed

  • Question

  • Hi all,

    I want to add a Wi-Fi network to preferred list such as wzctool programmatically. The driver (that is calling the function connectWiFiPreferredNetwork) has been started not loading on startup after wzcsapi.lib has been added to the driver project sources file as one of  targetlibs. What can the problem be?

     

    BOOL connectWiFiPreferredNetwork()
    {
    	WZC_WLAN_CONFIG wzcConfig;
    
    	INTF_ENTRY_EX Intf;
    	WZC_802_11_CONFIG_LIST *pConfigList;
    	
    	DWORD dwStatus = 0;
    	DWORD dwOutFlags = 0;
       
    	memset(&wzcConfig, 0x00, sizeof(WZC_WLAN_CONFIG));
            memset(&Intf, 0x00, sizeof(INTF_ENTRY_EX));
    
    	wzcConfig.Length = sizeof(WZC_WLAN_CONFIG);
            wzcConfig.dwCtlFlags = 0;
    
    	// ssid
            wzcConfig.Ssid.SsidLength = wcslen(WIFI_DEFAULT_SSID);
            for(UINT i=0; i<wzcConfig.Ssid.SsidLength; i++)
               wzcConfig.Ssid.Ssid[i] = (char)WIFI_DEFAULT_SSID[i];
    
            // adhoc? or infrastructure net?
            wzcConfig.InfrastructureMode = Ndis802_11Infrastructure;
           // Authentication
           wzcConfig.AuthenticationMode = Ndis802_11AuthModeShared;
           // Encryption
           wzcConfig.Privacy = Ndis802_11WEPEnabled;
           // Key
           wzcConfig.KeyIndex = 1;
           wzcConfig.KeyLength = wcslen(WIFI_DEFAULT_KEY);
           for(UINT i=0; i<wzcConfig.KeyLength; i++)
    	{
    		wzcConfig.KeyMaterial[i] = (UCHAR)WIFI_DEFAULT_KEY[i];
    	}
        encryptWepKeyMaterial(&wzcConfig);
        wzcConfig.dwCtlFlags |= WZCCTL_WEPK_PRESENT;
    
        Intf.wszGuid = L"AR6K_SD1";
    
        dwStatus = WZCQueryInterfaceEx (NULL, INTF_ALL, &Intf, &dwOutFlags);
        if (dwStatus)
        {
            ERRORMSG(1, (L"WZCQueryInterfaceEx() error dwStatus=0x%x, dwOutFlags=0x%x", dwStatus, dwOutFlags));
            WZCDeleteIntfObjEx(&Intf);
            return FALSE;
        }
    
        pConfigList = (PWZC_802_11_CONFIG_LIST)Intf.rdStSSIDList.pData;
        if(!pConfigList)   // empty [Preferred Networks] list case
        {
            DWORD dwDataLen = sizeof(WZC_802_11_CONFIG_LIST);
            WZC_802_11_CONFIG_LIST *pNewConfigList = (WZC_802_11_CONFIG_LIST *)LocalAlloc(LPTR, dwDataLen);
            pNewConfigList->NumberOfItems = 1;
            pNewConfigList->Index = 0;
            
    		memcpy(pNewConfigList->Config, &wzcConfig, sizeof(WZC_WLAN_CONFIG));
            
    		Intf.rdStSSIDList.pData = (BYTE*)pNewConfigList;
            Intf.rdStSSIDList.dwDataLen = dwDataLen;
        }
    
        dwStatus = WZCSetInterfaceEx (NULL, INTF_PREFLIST, &Intf, &dwOutFlags);
        if (dwStatus)
    	{
            ERRORMSG (1, (L"WZCSetInterfaceEx() error dwStatus=0x%x, dwOutFlags=0x%x", dwStatus, dwOutFlags));
    	}
    
        WZCDeleteIntfObjEx (&Intf);
    
    	return TRUE;
    }
    


     

    Thanks for helps and explanations,

    Yasemin






    Saturday, November 5, 2011 8:19 AM

All replies

  • I think we need a clearer problem statement. You have a *driver* calling that code? Why? Separate the WZC setup code from the driver and see if the driver will identify the preferred SSID. You should return to the build configuration designed for the driver, too. Now you have an application that tries to set a preferred SSID and a driver that presumably works (and can be controlled via the Windows CE user interface). What is the problem?

    Paul T.

    Thursday, November 10, 2011 6:06 PM