2 LuCI - Lua Configuration Interface
3 Copyright
2009 Jo-Philipp Wich
<xm@subsignal.org
>
5 Licensed under the Apache License, Version
2.0 (the
"License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
9 http://www.apache.org/licenses/LICENSE-
2.0
17 local sys = require
"luci.sys"
18 local utl = require
"luci.util"
20 function guess_wifi_signal(info)
21 local scale = (
100 / (info.quality_max or
100) * (info.quality or
0))
24 if not info.bssid or info.bssid ==
"00:00:00:00:00:00" then
25 icon = resource ..
"/icons/signal-none.png"
26 elseif scale <
15 then
27 icon = resource ..
"/icons/signal-0.png"
28 elseif scale <
35 then
29 icon = resource ..
"/icons/signal-0-25.png"
30 elseif scale <
55 then
31 icon = resource ..
"/icons/signal-25-50.png"
32 elseif scale <
75 then
33 icon = resource ..
"/icons/signal-50-75.png"
35 icon = resource ..
"/icons/signal-75-100.png"
41 function percent_wifi_signal(info)
42 local qc = info.quality or
0
43 local qm = info.quality_max or
0
45 if info.bssid and qc
> 0 and qm
> 0 then
46 return math.floor((
100 / qm) * qc)
52 function format_wifi_encryption(info)
53 if info.wep == true and not info.wpa_version then
56 return
"<abbr title='Pairwise: %s / Group: %s'>%s - %s</abbr>" % {
57 table.concat(info.pair_ciphers,
", "),
58 table.concat(info.group_ciphers,
", "),
59 (info.wpa ==
3) and
"mixed WPA/WPA2"
60 or (info.wpa ==
2 and
"WPA2" or
"WPA"),
61 table.concat(info.auth_suites,
", ")
64 return
"<em>None</em>"
68 local dev = luci.http.formvalue(
"device")
69 local iw = luci.sys.wifi.getiwinfo(dev)
74 <h2><a id=
"content" name=
"content"><%:Join Network: Wireless Scan%
></a></h2>
77 <fieldset class=
"cbi-section">
78 <table class=
"cbi-section-table" style=
"empty-cells:hide">
80 <% for i, net in ipairs(iw.scanlist) do %
>
81 <tr class=
"cbi-section-table-row cbi-rowstyle-<%=1 + ((i-1) % 2)%>">
82 <td class=
"cbi-value-field" style=
"width:16px; padding:3px">
83 <abbr title=
"Signal: <%=net.signal%> dB / Quality: <%=net.quality%>/<%=net.quality_max%>">
84 <img src=
"<%=guess_wifi_signal(net)%>" /><br />
85 <small><%=percent_wifi_signal(net)%
>%
</small>
88 <td class=
"cbi-value-field" style=
"vertical-align:middle; text-align:left; padding:3px">
89 <big><strong><%=net.ssid and utl.pcdata(net.ssid) or
"<em>hidden</em>"%
></strong></big><br />
90 <strong>Channel:
</strong> <%=net.channel%
> |
91 <strong>Mode:
</strong> <%=net.mode%
> |
92 <strong>BSSID:
</strong> <%=net.bssid%
> |
93 <strong>Encryption:
</strong> <%=format_wifi_encryption(net)%
>
95 <td class=
"cbi-value-field" style=
"width:40px">
96 <form action=
"<%=REQUEST_URI%>" method=
"post">
97 <input type=
"hidden" name=
"device" value=
"<%=utl.pcdata(dev)%>" />
98 <input type=
"hidden" name=
"join" value=
"<%=utl.pcdata(net.ssid)%>" />
99 <input type=
"hidden" name=
"mode" value=
"<%=net.mode%>" />
100 <input type=
"hidden" name=
"bssid" value=
"<%=net.bssid%>" />
101 <input type=
"hidden" name=
"channel" value=
"<%=net.channel%>" />
102 <input type=
"hidden" name=
"wep" value=
"<%=net.wep and 1 or 0%>" />
103 <% if net.wpa then %
>
104 <input type=
"hidden" name=
"wpa_version" value=
"<%=net.wpa%>" />
105 <% for _, v in ipairs(net.auth_suites) do %
><input type=
"hidden" name=
"wpa_suites" value=
"<%=v%>" />
106 <% end; for _, v in ipairs(net.group_ciphers) do %
><input type=
"hidden" name=
"wpa_group" value=
"<%=v%>" />
107 <% end; for _, v in ipairs(net.pair_ciphers) do %
><input type=
"hidden" name=
"wpa_pairwise" value=
"<%=v%>" />
110 <input class=
"cbi-button-apply" type=
"submit" value=
"Join Network" />
119 <div class=
"cbi-page-actions right">
120 <form class=
"inline" action=
"<%=luci.dispatcher.build_url("admin/network/wireless
")%>" method=
"get">
121 <input class=
"cbi-button-reset" type=
"submit" value=
"<%:Back to overview%>" />
123 <form class=
"inline" action=
"<%=REQUEST_URI%>" method=
"get">
124 <input type=
"hidden" name=
"device" value=
"<%=utl.pcdata(dev)%>" />
125 <input class=
"cbi-input-find" type=
"submit" value=
"<%:Repeat scan%>" />