localzuk Posted January 29, 2010 Posted January 29, 2010 I am trying to write in a 'self fixer' to a program to fix an issue with wireless connectivity over a long time. Namely, it seems that over time, wireless connections always seem to drop. The fix always being disabling and re-enabling the connection. As I know what this fix is, how can I write it into the software to do it itself should it need to? My idea was this: Normal activity of the program fails for whatever reason. In the try/catch block, it would check to see if the device was active, if it wasn't, enable it, run a ping and based on the result of that, try again. However, every reference to doing this I come across is like running into a big Microsoft shaped wall. Does anybody have any ideas as to API calls within Windows XP which I can use to do a simple enable/disable of a named connection? It seems that you can do it in Vista, but the devices I'm working with are embedded systems and therefore, no Vista (not to mention they only have 256Mb RAM).
webman Posted January 29, 2010 Posted January 29, 2010 Does disabling and re-enabling the device from the Device Manager do the same thing? If so, devcon could be the answer: Enable/disable a device from the command line - The solution 1
SYNACK Posted January 29, 2010 Posted January 29, 2010 WlanDisconnect Function (Windows) Native Wifi API Support on Windows XP (Windows) These any help? 1
localzuk Posted January 29, 2010 Author Posted January 29, 2010 Does disabling and re-enabling the device from the Device Manager do the same thing? If so, devcon could be the answer: Enable/disable a device from the command line - The solution It would be ideal, however, from Microsoft 'DevCon is not redistributable. It is provided for use as a debugging and development tool.' WlanDisconnect Function (Windows) Native Wifi API Support on Windows XP (Windows) These any help? Looks interesting. I'll take a peak.
webman Posted January 29, 2010 Posted January 29, 2010 Ah - curses! If you can do an AutoIt script, there's some posts in the forum which might work: Disable/Enable Local Area Connection - AutoIt Forums
localzuk Posted January 29, 2010 Author Posted January 29, 2010 The Native WIFI API has led me to this Managed Wifi API Which looks like it'll be perfect, should it work
localzuk Posted January 29, 2010 Author Posted January 29, 2010 Just an update for anyone else who is interested. I have now achieved my goal by doing the following: 1. The test method runs a ping 2. If the ping succeeds, then the connectivity returns as OK 3. If not, the software looks for a predefined wireless LAN, and joins it (this automatically drops any other wireless LAN's you may be joined to. 4. Waits a while (this is currently done via a crude thread.sleep() call but I will hopefully add a while loop with a WMI call to check it is connected. 5. Pings again. 6. If OK, continues running the program. 7. If fails, then it informs the user and exits. This is done via the ManagedWifi API I mention in my earlier post, and the Ping method in c#
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now