问题描述
我应该如何将 Wifi 信号强度从质量百分比(通常为 0% 到 100%)转换为 RSSI 值,通常为负 dBm 数(即 -96db
)?
Wifi Signal Strength Percentage to RSSI dBm
Microsoft 在其WLAN_ASSOCIATION_ATTRIBUTES 结构如下:
wlanSignalQuality:
代表网络信号质量的百分比值.WLAN_SIGNAL_QUALITY 是 ULONG 类型.该成员包含一个值介于 0 和 100 之间.值 0 表示实际的 RSSI 信号强度-100 分贝.值为 100 表示实际 RSSI 信号强度为-50 分贝.您可以计算 RSSI 信号强度值wlanSignalQuality 值介于 1 和 99 之间,使用线性插值.
RSSI(或无线电(接收)信号强度指示器")以dB"(分贝)或类似的dBm"(每毫瓦分贝)为单位(请参阅dB vs. dBm),其中较小的负数具有最高的信号强度,或质量.
因此,quality
(百分比)与dBm
的换算如下:
质量 = 2 * (dBm + 100) 其中 dBm:[-100 到 -50]dBm = (质量/2) - 100 其中质量:[0 到 100]
伪代码(以钳位为例):
//dBm 到质量:如果(dBm = -50)质量 = 100;别的质量 = 2 * (dBm + 100);//质量到 dBm:如果(质量 = 100)dBm = -50;别的dBm = (质量/2) - 100;
注意:
仔细检查用于计算的Quality
的定义.还要检查dB
(或dBm
)的范围.限制可能会有所不同.
示例:
中等质量:50% ->-75dBm = (50/2) - 100低质量:-96dBm ->8% = 2 * (-96 + 100)
How should I convert Wifi signal strength from a Quality in percentage, usually 0% to 100% into an RSSI value, usually a negative dBm number (i.e. -96db
)?
Wifi Signal Strength Percentage to RSSI dBm
Microsoft defines Wifi signal quality in their WLAN_ASSOCIATION_ATTRIBUTES structure as follows:
wlanSignalQuality:
RSSI (or "Radio (Received) Signal Strength Indicator") are in units of 'dB' (decibel) or the similar 'dBm' (dB per milliwatt) (See dB vs. dBm) in which the smaller magnitude negative numbers have the highest signal strength, or quality.
Therefore, the conversion between quality
(percentage) and dBm
is as follows:
quality = 2 * (dBm + 100) where dBm: [-100 to -50]
dBm = (quality / 2) - 100 where quality: [0 to 100]
Pseudo Code (with example clamping):
// dBm to Quality:
if(dBm <= -100)
quality = 0;
else if(dBm >= -50)
quality = 100;
else
quality = 2 * (dBm + 100);
// Quality to dBm:
if(quality <= 0)
dBm = -100;
else if(quality >= 100)
dBm = -50;
else
dBm = (quality / 2) - 100;
Note:
Check the definition of Quality
that you are using for your calculations carefully. Also check the range of dB
(or dBm
). The limits may vary.
Examples:
这篇关于如何将 Wifi 信号强度从质量(百分比)转换为 RSSI(dBm)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!