|Using WifiManager to connect to a network||Toad||2/1/10 5:21 AM|
I am using a Nexus One with 2.1 SDK. I am having problems with a module in my application connecting programmatically to a network/AP. The code snippet that I am using is:
WifiConfiguration wifiConfig = new WifiConfiguration();
Monitoring the network, I see probe requests transmitting from the device, but I do not see an Authentication/Association request to the access point that I specify in the BSSID. Ultimately, I will perform a scan to determine valid AP BSSIDs, but for testing, I simply want to connect to a test AP which is in close proximity to my Nexus One.
I have set the appropriate permissions in my manifest xml and am not seeing any negative log statements from adb.
Any pointers or suggestions with using WifiManager to perform this action would be very appreciated.
Thank you very much!
|Re: [android-developers] Using WifiManager to connect to a network||Daniel Rolph||2/2/10 12:30 PM|
After digging around a little, I was able to put together the code to programmatically connect to an open network/AP. For some reason, specifying the SSID causes the code not to connect.
wifiConfig.BSSID = "00:0C:41:F5:B0:08";
wifiConfig.priority = 1;
int netId = wifi.addNetwork(wifiConfig);
I am curious about the behavior of the network activity that I am seeing. The N1 is constantly broadcasting Probe Requests. The Access Point is sending out Probe Responses. When I enable the network with the SDK, the N1 sends out a Probe Response with the SSID of the AccessPoint (probably determined from the Probe Response). The N1 then sends out an Association Request to the AP and negotiates the connection. Why can't I initiate an Association Request to the AP prior to receiving the AP Probe Response? Basically, I would like to already have the AP defined in my WifiConfiguration and be sending Association Requests prior to being in range of the AP. Is this possible or am I constrained by the protocol?
|Re: Using WifiManager to connect to a network||Neil||2/3/10 2:11 AM|
I can't help with your protocol question, but the reason why
specifying the SSID isn't working is because it needs to be a quoted
wifiConfig.SSID = "\"test\"";
|Re: [android-developers] Re: Using WifiManager to connect to a network||Daniel Rolph||2/3/10 4:49 AM|
Thanks for the catch on the SSID. Actually, I find that I can only connect when I do not specify the SSID. Documentation on wifi management is a little hard to come by. I am learning the wifi packages and device/driver functionality through trial and error, logging, and network monitoring. I'll eventually get there.