Click here to Skip to main content
15,913,939 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi every one,

I'm working with ManagedWiFi library. My hope is connecting to special network by SSID. All of step to connecting are in code. I found many sample and create a tiny code that:

C#
WlanClient.WlanInterface tempIFace = null;

            WlanClient client = new WlanClient();

            foreach ( WlanClient.WlanInterface wlanIface in client.Interfaces )
            {
                // Lists all available networks
                Wlan.WlanAvailableNetwork[] networks = wlanIface.GetAvailableNetworkList( 0 );
                foreach ( Wlan.WlanAvailableNetwork network in networks )
                {
                    if ( GetStringForSSID( network.dot11Ssid ).Equals( "test" ) )
                    {
                        string profileName = GetStringForSSID( network.dot11Ssid );
                        var macAddress = ConvertToHex( GetStringForSSID( network.dot11Ssid ) );
                        string mac = macAddress;
                        string key = "123456789a";
                        string profileXml = string.Format( "<?xml version=\"1.0\"?><WLANProfile xmlns=\"http://www.microsoft.com/networking/WLAN/profile/v1\"><name>{0}</name><SSIDConfig><SSID><hex>{1}</hex></SSID></SSIDConfig><connectionType>ESS</connectionType><MSM><security><authEncryption><authentication>open</authentication><encryption>WEP</encryption><useOneX>false</useOneX></authEncryption><sharedKey><keyType>networkKey</keyType><protected>false</protected><keyMaterial>{2}</keyMaterial></sharedKey><keyIndex>0</keyIndex></security></MSM></WLANProfile>", profileName, mac, key );
                        tempIFace = wlanIface;
                        tempIFace.SetProfile( Wlan.WlanProfileFlags.AllUser, profileXml, true );
                        tempIFace.Connect( Wlan.WlanConnectionMode.Profile, Wlan.Dot11BssType.Any, GetStringForSSID( network.dot11Ssid ) );
                        MessageBox.Show( GetStringForSSID( network.dot11Ssid ) );
                        break;
                    }  


this code run very fine. but cannot connect to this wifi.

Please tell me what is problem? and how to fix it.
Thanks.
Posted
Updated 2-Sep-13 23:43pm
v2
Comments
[no name] 3-Sep-13 5:50am    
You should be asking this of the people that made your library or read the documentation. We would have no idea what it is or how it works.
Tuyển Đỗ 3-Sep-13 6:38am    
I cannot contact with them because cannot find their contact in website. Documents were not made, too. Thank you. Hope some body can.
[no name] 3-Sep-13 7:27am    
You cannot find what you do not look for. I found it in less than 10 seconds. http://managedwifi.codeplex.com/discussions
Tuyển Đỗ 3-Sep-13 21:22pm    
Thanks for reply, this is my source. I read it and make sample code abow before asking, My sample network is ad-hoc network, I make it like dummy network and cannot connect success to it.
Arun Kumar K S 13-Oct-16 5:42am    
Did you solve this issue. I too facing the same issue. My issue is to encrypt my key before assigning to the xml string. Do you know how encrypt this key before assigning to this tags.

1 solution

check here there is a API
http://managedwifi.codeplex.com/[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900