Wifi 质量百分比

发布于 2024-12-05 18:05:53 字数 205 浏览 2 评论 0原文

我想知道如何根据 2 个值确定 Wifi 质量:

Signal strength measured in dBm: e.g.: -51 dBm
Signal To Noise Ratio e.g. 70/70

我从系统中获取这些值,但想在我的用户界面中显示 wifi 质量图标,因此我应该使用某种方式将这些值转换为百分比的公式。

I was wondering how I can determine the Wifi-quality based on 2 values:

Signal strength measured in dBm: e.g.: -51 dBm
Signal To Noise Ratio e.g. 70/70

I get these values from my system, but want to show a wifi-quality icon in my User Interface, so I should convert those values into a percentage using some kind of formula.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

想你只要分分秒秒 2024-12-12 18:05:53

好的,所以我现在想通了。对于那些遇到同样问题的人,这就是我所做的。

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 {
    /* Assume signal is a "quality" percentage */
    val = CLAMP (val, 0, 100);
  }
  g_assert (val >= 0);
  return (guint32) val;
}

ok, so I figured it out for now. For those of you having the same issue, here's what I do.

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 {
    /* Assume signal is a "quality" percentage */
    val = CLAMP (val, 0, 100);
  }
  g_assert (val >= 0);
  return (guint32) val;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文