- function percent_wifi_signal(info)
- local qc = info.quality or 0
- local qm = info.quality_max or 0
-
- if info.bssid and qc > 0 and qm > 0 then
- return math.floor((100 / qm) * qc)
- else
- return 0
- end
- end
-
- function find_wifi_devices()
- local devs = { }
- uci:foreach("wireless", "wifi-device",
- function(s)
- local dev = s['.name']
- local act = 0
- devs[dev] = { active = 0, networks = { } }
-
- uci:foreach("wireless", "wifi-iface",
- function(s)
- if s.device == dev then
- if s.up == "1" then act = act + 1 end
- devs[dev].networks[#devs[dev].networks+1] = {
- active = (s.up == "1"),
- ifname = s.ifname,
- info = sys.wifi.getiwinfo(s.ifname or s.device)
- }
- end
- end)
-
- devs[dev].hwname = guess_wifi_hw(dev)
- devs[dev].active = (act > 0)
- end)
-
- return devs
- end
-
- function find_wifi_frequency(state)
- if state.active then
- return string.format("%d (%.03f GHz)",
- state.networks[1].info.channel,
- state.networks[1].info.frequency / 1000);
- else
- return "n/a"
- end
- end
-
-
- local devices = find_wifi_devices()