RSSI转换为百分比

guint32
nm_ap_utils_level_to_quality (gint val)
{
if (val < 0) {
/* Assume dBm already; rough conversion: best = -40, worst = -100 /
val = abs (CLAMP (val, -100, -40) + 40); /
normalize to 0 /
val = 100 - (int) ((100.0 * (double) val) / 60.0);
} else if (val > 110 && val < 256) {
/
assume old-style WEXT 8-bit unsigned signal level /
val -= 256; /
subtract 256 to convert to dBm /
val = abs (CLAMP (val, -100, -40) + 40); /
normalize to 0 */
val = 100 - (int) ((100.0 * (double) val) / 60.0);
} else {
val = CLAMP (val, 0, 100);
}
g_assert (val >= 0);

return (guint32) val;

}

上一篇:Leetcode 303. 区域和检索 - 数组不可变(中等) 304. 二维区域和检索 - 矩阵不可变(中等) 560. 和为K的子数组(中等) 前缀和数组求窗口和


下一篇:376. 摆动序列