New Classes in SDF v. Next

This afternoon I learned of a few APIs that I was completely unaware of (that would have made my life a lot easier on some earlier projects).  3 hours later, We have this fully implemented:

radios.PNG

Usage looks like this:


Radios radios = Radios.GetRadios();

Debug.WriteLine("nBeforern--------");
foreach (IRadio radio in radios)
{
  Debug.WriteLine(string.Format("Name: {0}, Type: {1}, State: {2}", radio.DeviceName, radio.RadioType.ToString(), radio.RadioState.ToString()));

  // toggle all radio states
  radio.RadioState = (radio.RadioState == RadioState.On) ? RadioState.Off : RadioState.On;
}

// give the radios enough time to change state - some (like BT) seem to be slow
Thread.Sleep(1000);

radios.Refresh();

// display again
Debug.WriteLine("rnAfterrn--------");
foreach (IRadio radio in radios)
{
  Debug.WriteLine(string.Format("Name: {0}, Type: {1}, State: {2}", radio.DeviceName, radio.RadioType.ToString(), radio.RadioState.ToString()));
}
Debug.WriteLine("rnn");
Thread.Sleep(100);


The only down side is that they are WinMo 5.0 and later only, so sorry CE devs.

I’m going to add it to the SDF source tree so it will be in the next release (soon, I promise).

2 thoughts on “New Classes in SDF v. Next”

  1. I’m really looking forward for an update…
    By the way I’m having a bad IOControl Exception when trying to access (for the second time) the NearbyAccessPoints collection after an attempt to connect to one of them has failed.
    Is there any "close" statement missing anywhere in your code?

    Like

  2. Will this work for ALL "radioType"s on all devices? So if I had this I could use it to turn the WiFi on/off from within my application to save power?

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s