Log in

View Full Version : Programming a signal strength bar in vb.net compact framework


MoreLikeIt
09-22-2004, 11:05 AM
Hello

Does anyone know howto make a signal strength bar in visual basic .net compact framework. Maybe there some sample code or something.

I would be very thankfull.

greetingz

MoreLikeIt

GSmith
09-24-2004, 01:56 AM
This is a very general request. Do you want sample code for the display or for obtaining the signal strength?

I'd start with something quick, try using System.Windows.Forms.ProgressBar as the display. The code around it depends on what you displaying and whether another program is using the radio and how exactly you get the signal info.

Good luck!

Xymus
09-24-2004, 04:03 AM
I took a look at my www.OpenNETCF.org "poster" and there is a SignalStrenght under Net in their Smart Device Framework v1.2... If you are looking of the signal strenght for a wifi connection, I'd guess this should do the trick.

Xymus
09-24-2004, 08:52 AM
I thought it would be fun to write this kind of app, so I did it! It is in c#, but only the syntax is different of vb.net so you should understant easily. PM me with your email if you want the source code.

I had to use the Smart Device Framework v1.1 since v1.2 seems to have problems with the AdapterCollection.

private System.Windows.Forms.ProgressBar progressBar1;
private System.Windows.Forms.Timer timer1;
OpenNETCF.Net.AdapterCollection acs;
private System.Windows.Forms.Label label1;
private void Form1_Load(object sender, System.EventArgs e)
{
acs = OpenNETCF.Net.Networking.GetAdapters();

if ( acs.Count > 0 )
{

// -90 db means a bad connection
// -50 -> good
// 0 -> no wireless connection

progressBar1.Minimum = -90;
progressBar1.Maximum = -50;
progressBar1.Value = -90;
progressBar1.Value = acs.Item( 0 ).SignalStrength.Decibels;

// additional infos

label1.Text = "";
if ( acs.Item( 0 ).IsWireless )
label1.Text += "Is wireless\n";
else
label1.Text += "Is wired\n";

label1.Text += "DHCP server: " + acs.Item( 0 ).DhcpServer + "\n";
label1.Text += "Gateway: " + acs.Item( 0 ).Gateway + "\n";
label1.Text += "Current IP: " + acs.Item( 0 ).CurrentIpAddress + "\n";
label1.Text += "Current acces point: " + acs.Item( 0 ).AssociatedAccessPoint + "\n";

timer1.Enabled = true;
}
else
{
MessageBox.Show( "No adapter detected" );
this.Close();
Application.Exit();
}
}

private void timer1_Tick(object sender, System.EventArgs e)
{
progressBar1.Value = acs.Item( 0 ).SignalStrength.Decibels;
}