diff options
author | Leandro A. F. Pereira <leandro@hardinfo.org> | 2008-05-24 18:12:26 +0000 |
---|---|---|
committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2008-05-24 18:12:26 +0000 |
commit | 86dbf99b5f054bef60d0fc8bea8043c1d354e470 (patch) | |
tree | 9d23eeb744e09185946a1ebe828aa24a4a0135f7 /hardinfo2 | |
parent | 20f9ea7fb5ba3ea1129e0a4f3371a319c701dce5 (diff) |
Display txpower in mW and dBm.
Diffstat (limited to 'hardinfo2')
-rw-r--r-- | hardinfo2/arch/linux/common/net.h | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/hardinfo2/arch/linux/common/net.h b/hardinfo2/arch/linux/common/net.h index af621db8..bf29a5cc 100644 --- a/hardinfo2/arch/linux/common/net.h +++ b/hardinfo2/arch/linux/common/net.h @@ -372,12 +372,19 @@ static void scan_net_interfaces_24(void) gchar *txpower; if (ni.wi_has_txpower) { - if (ni.wi_txpower.flags & IW_TXPOW_MWATT) - txpower = g_strdup_printf("%d mW", ni.wi_txpower.value); - else - txpower = g_strdup_printf("%d dBm", ni.wi_txpower.value); + gint mw, dbm; + + if (ni.wi_txpower.flags & IW_TXPOW_MWATT) { + mw = ni.wi_txpower.value; + dbm = (int) ceil(10.0 * log10((double) ni.wi_txpower.value)); + } else { + dbm = ni.wi_txpower.value; + mw = (int) floor(pow(10.0, ((double) dbm / 10.0))); + } + + txpower = g_strdup_printf("%ddBm (%dmW)", dbm, mw); } else { - txpower = g_strdup("Radio Off"); + txpower = g_strdup("Unknown"); } detailed = h_strdup_cprintf("\n[Wireless Properties]\n" |