[OpenNETCF.Net] Get signal strength from AccessPoint

M

mielmonster

Hello,

first thank to all OpenNetCF contributors for your great framework.

I've got a problem with the OpenNETCF.Net assembly.
I would like to get the signal strength of all the accees points known
by my Adapter but I don't how to do it.

here's my code.

do you have an idea ???

thank you a lot

Yannick

private ArrayList GetMeasures()
{
ArrayList res = new ArrayList();
AdapterCollection ac = Networking.GetAdapters();
IEnumerator ie = ac.GetEnumerator();
while (ie.MoveNext())
{
Adapter a = (Adapter)ie.Current;
if (a.IsWireless)
{
AccessPointCollection apc = a.NearbyAccessPoints;
IEnumerator ieap = apc.GetEnumerator();
while (ieap.MoveNext())
{
AccessPoint ap = (AccessPoint)ie.Current;
// here I would like to put the signal strength
// in the arraylist
res.Add(ap.???);
}
}
}
}
 
J

Jon Skeet [C# MVP]

mielmonster said:
first thank to all OpenNetCF contributors for your great framework.

I've got a problem with the OpenNETCF.Net assembly.
I would like to get the signal strength of all the accees points known
by my Adapter but I don't how to do it.

here's my code.

do you have an idea ???

private ArrayList GetMeasures()
{
ArrayList res = new ArrayList();
AdapterCollection ac = Networking.GetAdapters();
IEnumerator ie = ac.GetEnumerator();
while (ie.MoveNext())
{
Adapter a = (Adapter)ie.Current;
if (a.IsWireless)
{
AccessPointCollection apc = a.NearbyAccessPoints;
IEnumerator ieap = apc.GetEnumerator();
while (ieap.MoveNext())
{
AccessPoint ap = (AccessPoint)ie.Current;
// here I would like to put the signal strength
// in the arraylist
res.Add(ap.???);
}
}
}
}

It looks like the AccessPoint class doesn't actually provide the signal
strength (despite the docs hinting at it).

I thought it would be worth introducing you to the joys of foreach,
however. Your code can be written rather more concisely and readably
as:

ArrayList GetMeasures()
{
ArrayList res = new ArrayList();

foreach (Adapter a in Networking.GetAdapters())
{
if (a.IsWireless)
{
foreach (AccessPoint ap in a.NearbyAccessPoints)
{
res.Add(.....); // Problem here!
}
}
}
}
 
M

mielmonster

It looks like the AccessPoint class doesn't actually provide the signal
strength (despite the docs hinting at it).

Ok, so it seems that I'll have to use the RFutils class from Paul Tobey
instead.
I thought it would be worth introducing you to the joys of foreach,
however. Your code can be written rather more concisely and readably
as:

ArrayList GetMeasures()
{
ArrayList res = new ArrayList();

foreach (Adapter a in Networking.GetAdapters())
{
if (a.IsWireless)
{
foreach (AccessPoint ap in a.NearbyAccessPoints)
{
res.Add(.....); // Problem here!
}
}
}
}

yes, you're right !
It's better.

thank you.

Yannick
 
C

Chris Tacke, eMVP

Everything in the RFUtils should be in the OpenNETCF stuff. It's the same
code base.
 
M

mielmonster

well, It seems that the SSID class in the RFUtils provides a method
called rfSignalStrengthDB but the AccessPoint class (SSID renamed in
OpenNetCF) doesn't do that.

I don't know why.

yannick
 
P

Peter Foot [MVP]

The SignalStrength can be retrieved from the Adapter object

ArrayList GetMeasures()
{
ArrayList res = new ArrayList();

foreach (Adapter a in Networking.GetAdapters())
{
if (a.IsWireless)
{
res.Add(a.SignalStrength);
}
}
}

Peter
 
J

Jon Skeet [C# MVP]

Peter Foot said:
The SignalStrength can be retrieved from the Adapter object

ArrayList GetMeasures()
{
ArrayList res = new ArrayList();

foreach (Adapter a in Networking.GetAdapters())
{
if (a.IsWireless)
{
res.Add(a.SignalStrength);
}
}
}

But if there are several access points, that can only give a single
value back instead of one per access point.

The docs for AccessPointCollection suggest it should be possible:

"Class that represents a collection of the SSID values that a given
network adapter can hear over the airwaves. For each SSID, you can get
the signal strength and random other information."

However, each element is an AccessPoint, and an AccessPoint doesn't
have (as far as I can see) a way of getting the associated SSID - only
its name. (If it gave the SSID, then SSID.RFSignalStrengthDB would
presumably be the way forward.)
 
P

Paul G. Tobey [eMVP]

I'm not sure exactly what Neil changed, but, in RFUtils, you got a signal
strength for each SSID that a given adapter knew about. What you need to do
is find the equivalent name that Neil used when cleaning up RFUtils instead
of SSID. If it's AccessPoint, then that's what you'd look at: there should
be an SSID string associated with each one and, for each one, there should
be a corresponding signal strength indication.

Paul T.
 
P

Paul G. Tobey [eMVP]

Hmmm. It appears that the rssi value was commented out of the properties of
AccessPoint. I think that, if you put it back in, it should give you the
information that you want. You need to uncomment the fetch of the value in
the constructor:

// rssi = bssid.Rssi;

and uncomment the property pieces:

// internal int rssi;
//
// /// <summary>
// /// Returns the strength of the RF Ethernet signal
// /// being received by the adapter for the SSID, in dB.
// /// </summary>
// /// <returns>
// /// integer strength in dB; zero, if adapter is not
// /// an RF adapter or an error occurred
// /// </returns>
// public int SignalStrengthInDecibels
// {
// get
// {
// return rssi;
// }
// }

Paul T.

Paul G. Tobey said:
I'm not sure exactly what Neil changed, but, in RFUtils, you got a signal
strength for each SSID that a given adapter knew about. What you need to do
is find the equivalent name that Neil used when cleaning up RFUtils instead
of SSID. If it's AccessPoint, then that's what you'd look at: there should
be an SSID string associated with each one and, for each one, there should
be a corresponding signal strength indication.

Paul T.
 
Top