|
The NetServices SDK Journey Part 2
|
Wow! I have gotten a lot of responses from my first post on the NetServices SDK. (Thanks to Ben for the link.) In fact, I've gotten so much of a response that I need to write part 2 of it. Here it is for your reading pleasure: It my previous post, I detailed what I had to go through in order to figure out what AP the TungstenC was connected to. I got a great email from Catherine Ruggles who worked on the Boingo client. Her question was why I didn't use netIFSetting80211ESSID to query what AP the WiFi radio was connected to. I realized that my previous post didn't even mention that IF setting. Catherine is absolutely correct that if the WiFi radio is already connected to an AP, you can use the netIFSetting80211ESSID setting to find out which one. However, my particular problem was such that I needed to know what AP my device was associated with before the network connection was established. Using netIFSetting80211ESSID is too late for my particular problem. The problem that I was trying to solve was that I needed to be able to force the WiFi radio to connect to an AP that I specified. It took a lot of searching and digging, but eventually I was able to slog through it. Thanks to Catherine's reminder of the netIFSetting80211ESSID setting, I ended up modifying my original function to use netIFSetting80211ESSID. Because of that, it ultimately ended up being a more robust solution than the one that I had originally implemented. To save other people time and headaches, here is how my final implementation works: 1. Initiate a scan of APs in the vicinity. 2. Check the results of the scan to see if the AP we want to force a connection to is in the list. If it isn't then return an error. 3. Check to see if the Network Library is open. 4. If it is open, call NetLibIFSettingGet with netIFSetting80211ESSID to query the SSID of the AP we are connected to. 5. If we are connected, and the SSID doesn't match the SSID of the one we're trying to force a connection to, force the network library to shutdown immediately. 6. Call NetServicesProfileGetOrder and NetServicesProfileRead to find out the SSID of the 'preferred' AP. 7. Move the profile ID of the AP we are trying to force a connection to be the first (0 order) profile with NetServicesProfileSetOrder. 8. Open the network library (NetLibOpen, etc.) and let the SmartConnect do it's thing. 9. After NetLibOpen returns, call NetLibIFSettingGet with netIFSetting80211ESSID again to query the SSID of the AP we actually connected to. 10. If the AP that we connected to isn't the one that we're trying to force a connection with, close the network connection and return an error.
Incidentally, Catherine explained to me that this is approximately how the Boingo client works. So if you use this method, rest assured that you're not the only one! I am always on the lookout for better ways of doing things. If you know of a better way of doing this, let me know.
|
Submitted by bosshogg on Wednesday the 31st 1970f December 1969, at 04:00
|
|
 
|
Recent Entries: |
|
|
|
|
|
|