views:

664

answers:

1

Here is what i wanted to do in a .NET CF 3.5(C#) application

1) Check if the wireless adapter is working/active 2) Add a preferred network with the available SSID, password and other details 3) Establish connection to the preferred network

I tried using OpenNetCF.Net.NetworkInformation class, but tough luck! I'm not able to detect Wireless networks. All the networks includnig wifi and bluetooth are shown as Ethernet.

foreach (var networkInterface in NetworkInterface.GetAllNetworkInterfaces())
{
    if (networkInterface is WirelessNetworkInterface)
        MessageBox.Show("Found a WirelessNetworkInterface");
    else if (networkInterface is WirelessZeroConfigNetworkInterface)
        MessageBox.Show("Found a WirelessZeroConfigNetworkInterface");
    else
        MessageBox.Show("Ethernet??");
}

The problem I'm facing is discussed here http://community.opennetcf.com/forums/t/11099.aspx. But there are no solutions.

Are there any .NET CF APIs that allow me to interact with Wifi?

+3  A: 

You're misunderstanding. It is listing, as the name implies, all network interfaces. Bluetooth and Wifi (and even RNDIS USB connections) are all network interfaces and therefore will be enumerated. Basically, under the hood this is just asking NDIS to tell us all of the interfaces it knows about.

While it is iterating, it does two things. First, it asks WZC if it knows about the interface (i.e. if the interface's driver registered with WZC). If it does, then we know it's a WZC-compliant wireless dvice and we get some more info for it and return a WirelessZeroConfig interface.

We then ask NDIS is the driver for the device reported itself as wireless. If it did, we then get the NDIS info for wireless and return a Wireless interface.

Everything else becomes a generic NetworkInterface.

So how could a wireless device show up as a generic NetworkInterface? Simple. The driver for it didn't register with WZC and also isn't reporting that it's wireless through NDIS. Our code can't detect what the driver doesn't report. This is actually somewhat common with older Cisco cards, which uses a Cico-proprietary interface for the wireless stuff. They are physically a wireless device, but since the software doesn't tell us that it is, and since we're not querying any proprietary APIs, all we can do is return the generic NDIS info for the adapter.

If you have such a device, the only recourse is to talk with the adapter OEM and see if they have an API for it that you can use.

ctacke