Logged in as Guest   Sun, Oct. 21st, 7:33 AM.      
 
 
Web hazelware.luggle.com
 

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:
I'm BACK!!!!!!
Code Monkey
Cool 3D Code Snippet From My Former Life
YouTube: The Revival of the Internet Time Killer
WhereMate Released
Palmasaurus Released As Freeware
VM-Plus Beta
Handspring Undocumented APIs
Posting Malaise
PhoneShield Released!!!

Archive:
October - 2007
August - 2007
July - 2007
June - 2007
May - 2007
April - 2007
December - 2006
November - 2006
September - 2006
August - 2006
July - 2006
March - 2006
February - 2006
January - 2006
December - 2005
November - 2005
October - 2005
September - 2005
August - 2005
July - 2005
June - 2005
May - 2005
April - 2005
February - 2005
January - 2005
December - 2004
November - 2004
October - 2004
September - 2004
August - 2004
July - 2004
June - 2004
May - 2004
April - 2004
March - 2004