我是否获得正确的 WiFi 信号 dBm 读数?

问题描述 投票:0回答:1

下面这个函数从系统获取WiFi信号。目前,它在我的表单上显示“0”(表明我认为存在很强的连接)。我在公司网络上的工作场所 HP 上运行此程序的机器。它似乎没有外部 WiFi 按钮等。我得到的“0”是真实值还是我需要在真正的无线设备上测试它?

public static int GetSignalStrengthAsInt()
{
    Int32 returnStrength = 0;
    ManagementObjectSearcher searcher = null;
    try
    {
        searcher = new ManagementObjectSearcher( 
            @"root\WMI", 
            @"select Ndis80211ReceivedSignalStrength 
              from MSNdis_80211_ReceivedSignalStrength 
              where active=true");

        // Call the get in order to populate the collection
        ManagementObjectCollection adapterObjects = searcher.Get();

        // Loop though the management object and pull out the signal strength
        foreach ( ManagementObject mo in adapterObjects )
        {
            returnStrength = Convert.ToInt32( 
                mo["Ndis80211ReceivedSignalStrength"].ToString());
            break;
        }
    }
    catch (Exception)
    {
    }
    finally
    {
        if ( searcher != null )
        {
            searcher.Dispose();
        }
    }
    return returnStrength;            
}

此时返回强度显示在文本框中。

c# wifi
1个回答
0
投票

首先请注意,我不知道您的开发环境。以下是根据经验得出的一般指示:

  • 信号强度通常以 dB 单位或 dBm 给出 单位。

  • dB 用于表示信号/噪声比。信号相当不错的位置是
    至少18~20分贝。

  • dBm 用于接收的纯功率。一般是在范围内 -20dBm(优秀)至 -80dBm(非常差)

0 常见于无法从设备获取信息时。所以我的猜测是你的值是无效的。

© www.soinside.com 2019 - 2024. All rights reserved.