summaryrefslogtreecommitdiffhomepage
path: root/IWlib.hsc
diff options
context:
space:
mode:
Diffstat (limited to 'IWlib.hsc')
-rw-r--r--IWlib.hsc5
1 files changed, 3 insertions, 2 deletions
diff --git a/IWlib.hsc b/IWlib.hsc
index afd6bf0..f0bc655 100644
--- a/IWlib.hsc
+++ b/IWlib.hsc
@@ -69,7 +69,8 @@ getWirelessInfo iface =
qualv <- (#peek struct iw_param, value) qual :: IO CInt
let qualm = (#ptr struct iw_range, max_qual) rng
mv <- (#peek struct iw_param, value) qualm :: IO CInt
- return $ fromIntegral qualv / fromIntegral (max 1 mv)
+ let mxv = if mv > 0 then fromIntegral mv else 1
+ return $ fromIntegral qualv / mxv
else return (-1)
let qv = round (100 * (q :: Double))
- return $ WirelessInfo { wiEssid = essid, wiQuality = qv }
+ return $ WirelessInfo { wiEssid = essid, wiQuality = min 100 qv }