Search code examples
c#compact-frameworkwindows-ce

How to verify WiFi password with OpenNetCF SDF


I'm using the OpenNetCF SDF WirelessZeroConfigNetworkInterface class to connect to a WiFi access point. I can connect OK, if I know the password, but how will I know if the password is wrong?

At the moment my best guess is to:

  1. Add the preferred network
  2. Connect to the preferred network's SSID
  3. Poll the currently connected access point for a while. If the current access point is the one I have tried to connect to then great, all is well.

But in this sequence I can't know that the password is wrong until I decide that the connection has failed just by waiting a while. So far as I can tell there's no way to actively know that a connection attempt has failed, much less know that it failed because of a wrong password.

Am I missing something?


Solution

  • No, you're not missing anything. That's the same procedure I use.

    • Attempt to connect to network X
    • Wait for the connection state to change or for 30 seconds, whichever is first (it will change twice for a failed password, usually)
    • Check to see if you're connected to network X
    • If you're not, then you've failed