3

Is there a way to acquire and display the current wireless signal strength of an application's device in C#? I have an application that detects whether there is connectivity via a timer, however I need to know the current signal strength, then display it graphically in a status bar. Below is my current code to detect basic connectivity every few seconds. What can I add to display the strength as well? Thank you. The timer code was given by S.O. user :parapura rajkumar

 private void Form1_Load(object sender, EventArgs e)
    {                                  
        //create an object to hold app settings FIRST

        appsetting apps = new appsetting();
        apps.getsetting();
        netMessage.Clear();  

        //creates a timer for refresh rate on connectivity check

         var timer = new Timer();
         timer.Tick += new EventHandler(timer_Tick);
         timer.Interval = 2000; //2 seconds
         timer.Start();            
    }


    //starts the timer
 void timer_Tick(object sender, EventArgs e)
 {
    //if connection is not detected
    if (System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable() ==f
    false)
    {
        //clear the buffer
        netMessage.Clear();

        //turn RED indicator on and display message
        netConnect.BackColor = Color.Red;
        this.netMessage.Text = ("No Connection");
        noConn = true;//set "No connection" to true
        conn= false;

    }
    else
        //turn GREEN indicator on and display message
        netConnect.BackColor = Color.Lime;
        this.netMessage.Text = ("Connected");
        conn = true;// set connection to "true
        noConn = false;

            //if box is red but connection is established, turn it back to green  


            if (noConn == true && 
            System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable() == 
            true)
            {
                 netConnect.BackColor = Color.Lime;
                 this.netMessage.Text = ("Connected");
                 conn = true;
                 noConn = false;
             }

}              


    //need to display signal strength in a text box with color codes or status bar HERE                 
4

1 回答 1

0

经过一些研究和参考其他一些问题后,我能够通过以下提供的开源 API 解决我的问题:managedwifi.codeplex.com

只需下载 api,然后通过 add->csproj 将其添加到您的项目中。

使用 WlanClient 类中给出的“public int RSSI”。

干杯

于 2012-08-16T18:42:41.910 回答