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                 
有帮助吗?

解决方案

After some research and reference to some other questions, I was able to solve my issue via the open source API given at: managedwifi.codeplex.com

Simply download the api, then add it to your project via add->csproj.

Use 'public int RSSI' that is given in the WlanClient class.

Cheers

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top