luci-app-mtwifi: sync upstream source

From: https://github.com/MeIsReallyBa/MT7915_7621-MT_WIFI-Openwrt
This commit is contained in:
AmadeusGhost 2021-10-22 23:05:06 +08:00
parent 974cee715d
commit f4ff087e02
8 changed files with 65 additions and 151 deletions

View File

@ -1,13 +1,14 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-mtwifi
PKG_LICENSE:=GPLv2 PKG_LICENSE:=GPLv2
PKG_MAINTAINER:=Hua Shao <nossiac@163.com> PKG_MAINTAINER:=Hua Shao <nossiac@163.com>
LUCI_TITLE:=LuCI support for mt wifi driver LUCI_TITLE:=LuCI support for mt wifi driver
LUCI_DEPENDS:=@TARGET_ramips +mt_wifi @!PACKAGE_kmod-mt7615d_dbdc LUCI_DEPENDS:=@TARGET_ramips +mt_wifi
LUCI_PKGARCH:=all LUCI_PKGARCH:=all
PKG_VERSION:=1 PKG_VERSION:=1
PKG_RELEASE:=16 PKG_RELEASE:=8
define Package/luci-app-mtwifi/conffiles define Package/luci-app-mtwifi/conffiles
/etc/wireless/mt7615/ /etc/wireless/mt7615/

View File

@ -1,9 +1,9 @@
-- This module is a demo to configure MTK' proprietary WiFi driver. -- This module is a demo to configure MTK' proprietary WiFi driver.
-- Basic idea is to bypass uci and edit wireless profile (mt76xx.dat) directly. -- Basic idea is to bypass uci and edit wireless profile (mt76xx.dat) directly.
-- LuCI's WiFi configuration is more logical and elegent, but it's quite tricky to -- LuCI's WiFi configuration is more logical and elegent, but it's quite tricky to
-- translate uci into MTK's WiFi profile (like we did in "uci2dat"). -- translate uci into MTK's WiFi profile (like we did in "uci2dat").
-- And you will get your hands dirty. -- And you will get your hands dirty.
-- --
-- Hua Shao <nossiac@163.com> -- Hua Shao <nossiac@163.com>
module("luci.controller.mtkwifi", package.seeall) module("luci.controller.mtkwifi", package.seeall)
@ -110,12 +110,6 @@ function dev_cfg(devname)
cfgs.VHT_Sec80_Channel = http.formvalue("VHT_Sec80_Channel") or "" cfgs.VHT_Sec80_Channel = http.formvalue("VHT_Sec80_Channel") or ""
end end
if cfgs.ApCliAuthMode == "WEP" then
cfgs.ApCliEncrypType = http.formvalue("__apcli_wep_enctype")
else
cfgs.ApCliEncrypType = http.formvalue("__apcli_wpa_enctype")
end
local mimo = http.formvalue("__mimo") local mimo = http.formvalue("__mimo")
if mimo == "0" then if mimo == "0" then
cfgs.ETxBfEnCond=1 cfgs.ETxBfEnCond=1
@ -223,7 +217,7 @@ function vif_del(dev, vif)
local devs = mtkwifi.get_all_devs() local devs = mtkwifi.get_all_devs()
local idx = devs[devname]["vifs"][vifname].vifidx -- or tonumber(string.match(vifname, "%d+")) + 1 local idx = devs[devname]["vifs"][vifname].vifidx -- or tonumber(string.match(vifname, "%d+")) + 1
mtkwifi.debug("idx="..idx, devname, vifname) mtkwifi.debug("idx="..idx, devname, vifname)
local profile = devs[devname].profile local profile = devs[devname].profile
assert(profile) assert(profile)
if idx and tonumber(idx) >= 0 then if idx and tonumber(idx) >= 0 then
local cfgs = mtkwifi.load_profile(profile) local cfgs = mtkwifi.load_profile(profile)
@ -499,13 +493,13 @@ function initialize_multiBssParameters(cfgs,vif_idx)
return cfgs return cfgs
end end
function vif_cfg(dev, vif) function vif_cfg(dev, vif)
local devname, vifname = dev, vif local devname, vifname = dev, vif
if not devname then devname = vif end if not devname then devname = vif end
mtkwifi.debug("devname="..devname) mtkwifi.debug("devname="..devname)
mtkwifi.debug("vifname="..(vifname or "")) mtkwifi.debug("vifname="..(vifname or ""))
local devs = mtkwifi.get_all_devs() local devs = mtkwifi.get_all_devs()
local profile = devs[devname].profile local profile = devs[devname].profile
assert(profile) assert(profile)
local cfgs = mtkwifi.load_profile(profile) local cfgs = mtkwifi.load_profile(profile)
@ -767,19 +761,8 @@ function apcli_connect(dev, vif)
local cfgs = mtkwifi.load_profile(profiles[devname]) local cfgs = mtkwifi.load_profile(profiles[devname])
cfgs.ApCliEnable = "1" cfgs.ApCliEnable = "1"
mtkwifi.save_profile(cfgs, profiles[devname]) mtkwifi.save_profile(cfgs, profiles[devname])
os.execute("ifconfig "..vifname.." up")
-- local brvifs = mtkwifi.__trim(mtkwifi.read_pipe("uci get network.lan.ifname"))
-- if not string.match(brvifs, vifname) then
-- brvifs = brvifs.." "..vifname
-- nixio.syslog("debug", "add "..vifname.." into lan")
-- os.execute("uci set network.lan.ifname=\""..brvifs.."\"")
-- os.execute("uci commit")
-- os.execute("ubus call network.interface.lan add_device \"{\\\"name\\\":\\\""..vifname.."\\\"}\"")
-- end
os.execute("iwpriv "..vifname.." set MACRepeaterEn="..cfgs.MACRepeaterEn)
os.execute("iwpriv "..vifname.." set ApCliEnable=0") os.execute("iwpriv "..vifname.." set ApCliEnable=0")
os.execute("ifconfig "..vifname.." up")
os.execute("iwpriv "..vifname.." set Channel="..cfgs.Channel) os.execute("iwpriv "..vifname.." set Channel="..cfgs.Channel)
os.execute("iwpriv "..vifname.." set ApCliAuthMode="..cfgs.ApCliAuthMode) os.execute("iwpriv "..vifname.." set ApCliAuthMode="..cfgs.ApCliAuthMode)
os.execute("iwpriv "..vifname.." set ApCliEncrypType="..cfgs.ApCliEncrypType) os.execute("iwpriv "..vifname.." set ApCliEncrypType="..cfgs.ApCliEncrypType)
@ -791,9 +774,6 @@ function apcli_connect(dev, vif)
or cfgs.ApCliAuthMode == "WPA1PSKWPA2PSK" then or cfgs.ApCliAuthMode == "WPA1PSKWPA2PSK" then
os.execute("iwpriv "..vifname.." set ApCliWPAPSK="..cfgs.ApCliWPAPSK) os.execute("iwpriv "..vifname.." set ApCliWPAPSK="..cfgs.ApCliWPAPSK)
end end
if cfgs.ApCliBssid ~= nil then
os.execute("iwpriv "..vifname.." set ApCliBssid="..cfgs.ApCliBssid)
end
os.execute("iwpriv "..vifname.." set ApCliSsid=\""..cfgs.ApCliSsid.."\"") os.execute("iwpriv "..vifname.." set ApCliSsid=\""..cfgs.ApCliSsid.."\"")
os.execute("iwpriv "..vifname.." set ApCliEnable=1") os.execute("iwpriv "..vifname.." set ApCliEnable=1")
luci.http.redirect(luci.dispatcher.build_url("admin", "network", "wifi")) luci.http.redirect(luci.dispatcher.build_url("admin", "network", "wifi"))
@ -811,23 +791,11 @@ function apcli_disconnect(dev, vif)
local profiles = mtkwifi.search_dev_and_profile() local profiles = mtkwifi.search_dev_and_profile()
mtkwifi.debug(profiles[devname]) mtkwifi.debug(profiles[devname])
assert(profiles[devname]) assert(profiles[devname])
local cfgs = mtkwifi.load_profile(profiles[devname]) local cfgs = mtkwifi.load_profile(profiles[devname])
cfgs.ApCliEnable = "1" cfgs.ApCliEnable = "0"
mtkwifi.save_profile(cfgs, profiles[devname]) mtkwifi.save_profile(cfgs, profiles[devname])
os.execute("iwpriv "..vifname.." set ApCliEnable=0") os.execute("iwpriv "..vifname.." set ApCliEnable=0")
-- local brvifs = mtkwifi.__trim(mtkwifi.read_pipe("uci get network.lan.ifname"))
-- if string.match(brvifs, vifname) then
-- brvifs = mtkwifi.__trim(string.gsub(brvifs, vifname, ""))
-- nixio.syslog("debug", "add "..vifname.." into lan")
-- os.execute("uci set network.lan.ifname=\""..brvifs.."\"")
-- os.execute("uci commit")
-- os.execute("ubus call network.interface.lan remove_device \"{\\\"name\\\":\\\""..vifname.."\\\"}\"")
-- end
os.execute("ifconfig "..vifname.." down") os.execute("ifconfig "..vifname.." down")
luci.http.redirect(luci.dispatcher.build_url("admin", "network", "wifi")) luci.http.redirect(luci.dispatcher.build_url("admin", "network", "wifi"))
end end

View File

@ -3,7 +3,7 @@
<!-- <!--
This module is a demo to configure MTK' proprietary WiFi driver. This module is a demo to configure MTK' proprietary WiFi driver.
Basic idea is to bypass uci and edit wireless profile (mt76xx.dat) directly. Basic idea is to bypass uci and edit wireless profile (mt76xx.dat) directly.
LuCI's WiFi configuration is more logical and elegent, but it's quite tricky to LuCI's WiFi configuration is more logical and elegent, but it's quite tricky to
translate uci into MTK's WiFi profile (like we did in "uci2dat"). translate uci into MTK's WiFi profile (like we did in "uci2dat").
Hua Shao <nossiac@163.com> Hua Shao <nossiac@163.com>
@ -39,28 +39,20 @@ local debug = 0
<div id="loading" style="margin-top: 1em; display: none;"> <div id="loading" style="margin-top: 1em; display: none;">
<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:e;" /> <img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:e;" />
&nbsp;&nbsp;&nbsp; Please waiting while the page is loading...... &nbsp;&nbsp;&nbsp; 正在处理,请耐心等待......
</div> </div>
<form method="post" name="cbi" action="<%=luci.dispatcher.build_url("admin", "network", "wifi", "apcli_cfg", devname, vifname)%>" enctype="multipart/form-data" onreset="return cbi_validate_reset(this)" onsubmit="return cbi_validate_form(this, 'Some fields are invalid, cannot save values!')" autocomplete="off"> <form method="post" name="cbi" action="<%=luci.dispatcher.build_url("admin", "network", "wifi", "apcli_cfg", devname, vifname)%>" enctype="multipart/form-data" onreset="return cbi_validate_reset(this)" onsubmit="return cbi_validate_form(this, 'Some fields are invalid, cannot save values!')" autocomplete="off">
<fieldset class="cbi-section" id="vif-cfg-apcli"> <fieldset class="cbi-section" id="vif-cfg-apcli">
<legend> <a name="apcli_scan_section">Wireless Repeater - <%=devname.."@"..vifname%> </a></legend> <legend> <a name="apcli_scan_section">无线中继 - <%=devname.."@"..vifname%> </a></legend>
<pre> Manually setup apcli0 connection:
iwpriv <%=vifname%> set ApCliEnable=0 // disable sta mode first
iwpriv <%=vifname%> set ApCliAuthMode= // root ap authentication mode
iwpriv <%=vifname%> set ApCliEncrypType= // root ap encryption type
iwpriv <%=vifname%> set ApCliWPAPSK= // root ap password
iwpriv <%=vifname%> set ApCliWirelessMode= // root ap wifi mode
iwpriv <%=vifname%> set ApCliSsid= // root ap ssid
iwpriv <%=vifname%> set ApCliEnable=1 // enable sta mode</pre>
<br /> <br />
<p class="left"> <p class="left">
<input id="scan" type="button" class="cbi-button cbi-button-find" onclick="get_ap_list('<%=vifname%>')" value="扫描网络" /> <input id="scan" type="button" class="cbi-button cbi-button-find" onclick="get_ap_list('<%=vifname%>')" value="扫描网络" />
</p> </p>
<div id="loading" style="display:none;"> <div id="loading" style="display:none;">
<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle;" /> <img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle;" />
&nbsp;&nbsp;&nbsp; Please waiting while the page is loading...... &nbsp;&nbsp;&nbsp; 正在处理,请耐心等待......
</div> </div>
<div id="aplist"> <div id="aplist">
</div> </div>
@ -71,33 +63,18 @@ local debug = 0
<tbody> <tbody>
<tr><th class="th1"></th><th></th><th></th></tr> <tr><th class="th1"></th><th></th><th></th></tr>
<tr> <tr>
<td>MAC Repeater Mode</td> <td>上级无线 SSID</td>
<td>
<input type="radio" name="MACRepeaterEn" value="1" <% if cfgs.MACRepeaterEn == "1" then %> checked="checked"<% end %> /> Enable
<input type="radio" name="MACRepeaterEn" value="0" <% if cfgs.MACRepeaterEn ~= "1" then %> checked="checked"<% end %> /> Disable
</td>
<td></td>
</tr>
<tr>
<td>上级无线名称</td>
<td> <td>
<input type="text" name="ApCliSsid" id="ApCliSsid" value="<%=cfgs.ApCliSsid%>"/> <input type="text" name="ApCliSsid" id="ApCliSsid" value="<%=cfgs.ApCliSsid%>"/>
</td> </td>
<td></td> <td></td>
</tr> </tr>
<tr>
<td>BSSID</td>
<td>
<input type="text" name="ApCliBssid" id="ApCliBssid" value="<%=cfgs.ApCliBssid%>"/>
</td>
<td><span style="color:green;">可选</span></td>
</tr>
<tr> <tr>
<td>上级无线信道</td> <td>上级无线信道</td>
<td> <td>
<input type="text" name="Channel" id="Channel" value="<%=dev.Channel%>"/> <input type="text" name="Channel" id="Channel" value="<%=dev.Channel%>"/>
</td> </td>
<td> <span style="color:red;">将会重置当前信道</span></td> <td> <span style="color:red;">将会重置当前信道.</span></td>
</tr> </tr>
<tr> <tr>
<td>上级无线加密模式</td> <td>上级无线加密模式</td>
@ -171,7 +148,6 @@ local debug = 0
<div class="cbi-page-actions" id="apcli_form_buttons"> <div class="cbi-page-actions" id="apcli_form_buttons">
<input class="cbi-button cbi-button-apply" value="重启无线" type="button" onclick='wifi_reload("<%=luci.dispatcher.build_url("admin", "network", "wifi", "reload", devname)%>");' /> <input class="cbi-button cbi-button-apply" value="重启无线" type="button" onclick='wifi_reload("<%=luci.dispatcher.build_url("admin", "network", "wifi", "reload", devname)%>");' />
<input class="cbi-button cbi-button-apply" value="保存设置" type="submit" /> <input class="cbi-button cbi-button-apply" value="保存设置" type="submit" />
<input class="cbi-button cbi-button-apply" value="连接中继" type="button" onclick='wifi_reload("<%=luci.dispatcher.build_url("admin", "network", "wifi", "apcli_connect", dev.devname, dev.apcli.vifname)%>")' />
<input class="cbi-button cbi-button-reset" value="重置设置" type="reset" /> <input class="cbi-button cbi-button-reset" value="重置设置" type="reset" />
</div> </div>
</form> </form>
@ -229,7 +205,7 @@ local debug = 0
|| aplist[i].authmode == "WPAPSK" || aplist[i].authmode == "WPAPSK"
|| aplist[i].authmode == "WPA2PSK" || aplist[i].authmode == "WPA2PSK"
|| aplist[i].authmode == "WPAPSKWPA2PSK") { || aplist[i].authmode == "WPAPSKWPA2PSK") {
td5.innerHTML = '<a href="javascript:choose_rootap(\''+i+'\')" >Choose This</a>'; td5.innerHTML = '<a href="javascript:choose_rootap(\''+i+'\')" >启用</a>';
} else { } else {
td5.innerHTML = 'Security Not Supported'; td5.innerHTML = 'Security Not Supported';
@ -314,7 +290,6 @@ local debug = 0
function choose_rootap(index) { function choose_rootap(index) {
document.getElementById("ApCliSsid").value=decode_ssid(ap_list[index].ssid); document.getElementById("ApCliSsid").value=decode_ssid(ap_list[index].ssid);
document.getElementById("ApCliBssid").value=ap_list[index].bssid;
document.getElementById("Channel").value=ap_list[index].channel; document.getElementById("Channel").value=ap_list[index].channel;
document.getElementById("ApCliAuthMode").value=ap_list[index].authmode; document.getElementById("ApCliAuthMode").value=ap_list[index].authmode;
if (ap_list[index].authmode == "WPA2PSK" if (ap_list[index].authmode == "WPA2PSK"

View File

@ -3,7 +3,7 @@
<!-- <!--
This module is a demo to configure MTK' proprietary WiFi driver. This module is a demo to configure MTK' proprietary WiFi driver.
Basic idea is to bypass uci and edit wireless profile (mt76xx.dat) directly. Basic idea is to bypass uci and edit wireless profile (mt76xx.dat) directly.
LuCI's WiFi configuration is more logical and elegent, but it's quite tricky to LuCI's WiFi configuration is more logical and elegent, but it's quite tricky to
translate uci into MTK's WiFi profile (like we did in "uci2dat"). translate uci into MTK's WiFi profile (like we did in "uci2dat").
Hua Shao <nossiac@163.com> Hua Shao <nossiac@163.com>
@ -37,13 +37,13 @@ local cfgs = mtkwifi.load_profile(dev.profile)
<form method="post" name="cbi" action="<%=luci.dispatcher.build_url("admin", "network", "wifi", "dev_cfg", devname)%>" enctype="multipart/form-data" onreset="return cbi_validate_reset(this)" onsubmit="return cbi_validate_form(this, 'Some fields are invalid, cannot save values!')" autocomplete="false"> <form method="post" name="cbi" action="<%=luci.dispatcher.build_url("admin", "network", "wifi", "dev_cfg", devname)%>" enctype="multipart/form-data" onreset="return cbi_validate_reset(this)" onsubmit="return cbi_validate_form(this, 'Some fields are invalid, cannot save values!')" autocomplete="false">
<fieldset class="cbi-section"> <fieldset class="cbi-section">
<legend> 无线高级设置 - <%=devname%> <legend> 无线高级设置 - <%=devname%>
<% <%
local diff = mtkwifi.diff_profile(dev.profile) local diff = mtkwifi.diff_profile(dev.profile)
if next(diff) ~= nil then if next(diff) ~= nil then
%> %>
<span style="color:red;">(<a href="javascript:location.href='<%=luci.dispatcher.build_url("admin", "network", "wifi", "reload", dev.devname)%>'">reload</a> to apply changes)</span> <span style="color:red;">(<a href="javascript:location.href='<%=luci.dispatcher.build_url("admin", "network", "wifi", "reload", dev.devname)%>'">reload</a> to apply changes)</span>
<% <%
end end
%> %>
</legend> </legend>
@ -744,7 +744,7 @@ if next(diff) ~= nil then
function is_mode_gband(mode) { function is_mode_gband(mode) {
var imode = mode*1; var imode = mode*1;
var gband_mode_list = [0,1,4,6,7,9]; var gband_mode_list = [0,1,4,6,7,9,16];
var i; var i;
for (i = 0; i < gband_mode_list.length; i++){ for (i = 0; i < gband_mode_list.length; i++){
@ -757,7 +757,7 @@ if next(diff) ~= nil then
function is_mode_aband(mode) { function is_mode_aband(mode) {
var imode = mode*1; var imode = mode*1;
var aband_mode_list = [2,8,11,14,15]; var aband_mode_list = [2,8,11,14,15,17];
var i; var i;
for (i = 0; i < aband_mode_list.length; i++){ for (i = 0; i < aband_mode_list.length; i++){

View File

@ -2,7 +2,7 @@
<!-- <!--
This module is a demo to configure MTK' proprietary WiFi driver. This module is a demo to configure MTK' proprietary WiFi driver.
Basic idea is to bypass uci and edit wireless profile (mt76xx.dat) directly. Basic idea is to bypass uci and edit wireless profile (mt76xx.dat) directly.
LuCI's WiFi configuration is more logical and elegent, but it's quite tricky to LuCI's WiFi configuration is more logical and elegent, but it's quite tricky to
translate uci into MTK's WiFi profile (like we did in "uci2dat"). translate uci into MTK's WiFi profile (like we did in "uci2dat").
Hua Shao <nossiac@163.com> Hua Shao <nossiac@163.com>
@ -37,11 +37,6 @@ local devs = mtkwifi.get_all_devs()
<big><strong title="<%=dev.profile%>"> Generic Mediatek <%=dev.devname%></strong></big> <big><strong title="<%=dev.profile%>"> Generic Mediatek <%=dev.devname%></strong></big>
<% <%
local diff = mtkwifi.diff_profile(dev.profile) local diff = mtkwifi.diff_profile(dev.profile)
if next(diff) ~= nil then
%>
<span style="color:red;">* need reload to apply changes</span>
<%
end
%> %>
<br/> <br/>
<span><strong>模式:</strong> <% if dev.ApCliEnable == "1" then %> APCli <% else %> Master AP<% end %> </span> <span><strong>模式:</strong> <% if dev.ApCliEnable == "1" then %> APCli <% else %> Master AP<% end %> </span>
@ -64,7 +59,7 @@ local devs = mtkwifi.get_all_devs()
<img src="/luci-static/resources/icons/signal-none.png" /> <img src="/luci-static/resources/icons/signal-none.png" />
<% end %> <% end %>
</td> </td>
<td class="cbi-value-field" style="vertical-align:middle; text-align:left; padding:3px"><strong>接口:</strong> <%=vif.vifname%> | <strong>无线名称:</strong> <%=vif.__ssid%> | <strong>信道:</strong> <%=vif.__channel or dev.Channel%> <td class="cbi-value-field" style="vertical-align:middle; text-align:left; padding:3px"><strong>接口:</strong> <%=vif.vifname%> | <strong>无线名称:</strong> <%=vif.__ssid%> | <strong>信道:</strong> <%=vif.__channel or dev.Channel%>
<br/> <br/>
<% if vif.state == "up" then %> <% if vif.state == "up" then %>
<strong>BSSID:</strong>:<%=vif.__bssid%> | <strong>无线模式:</strong> <%=dev.WirelessModeList[tonumber(vif.__wirelessmode or dev.WirelessMode)]%> <strong>BSSID:</strong>:<%=vif.__bssid%> | <strong>无线模式:</strong> <%=dev.WirelessModeList[tonumber(vif.__wirelessmode or dev.WirelessMode)]%>
@ -81,11 +76,6 @@ local devs = mtkwifi.get_all_devs()
<input class="cbi-button cbi-button-apply" style="width:100px" title="禁用无线" value="启用" type="button" onclick="location.href='<%=luci.dispatcher.build_url("admin", "network", "wifi", "vif_enable", vif.vifname)%>'" /> <input class="cbi-button cbi-button-apply" style="width:100px" title="禁用无线" value="启用" type="button" onclick="location.href='<%=luci.dispatcher.build_url("admin", "network", "wifi", "vif_enable", vif.vifname)%>'" />
<% end %> <% end %>
<input class="cbi-button cbi-button-edit" style="width:100px" title="修改无线基本设置" value="基本设置" type="button" onclick="location.href='<%=luci.dispatcher.build_url("admin", "network", "wifi", "vif_cfg_view", dev.devname, vif.vifname)%>'" /> <input class="cbi-button cbi-button-edit" style="width:100px" title="修改无线基本设置" value="基本设置" type="button" onclick="location.href='<%=luci.dispatcher.build_url("admin", "network", "wifi", "vif_cfg_view", dev.devname, vif.vifname)%>'" />
<% if dev.apcli then %>
<% if dev.apcli.state == "down" then %>
<input class="cbi-button cbi-button-apply" style="width:100px" title="启用无线" value="启用中继" type="button" onclick="location.href='<%=luci.dispatcher.build_url("admin", "network", "wifi", "vif_enable", dev.apcli.vifname)%>'" />
<% end %>
<% end %>
<input class="cbi-button cbi-button-remove" style="width:100px" title="删除网络" value="移除" type="button" onclick="location.href='<%=luci.dispatcher.build_url("admin", "network", "wifi", "vif_del", dev.devname, vif.vifname)%>'" /> <input class="cbi-button cbi-button-remove" style="width:100px" title="删除网络" value="移除" type="button" onclick="location.href='<%=luci.dispatcher.build_url("admin", "network", "wifi", "vif_del", dev.devname, vif.vifname)%>'" />
</td> </td>
</tr> </tr>
@ -93,38 +83,33 @@ local devs = mtkwifi.get_all_devs()
<!-- /network list --> <!-- /network list -->
<!-- apcli list --> <!-- apcli list -->
<% if dev.apcli then %> <% if dev.apcli then %>
<% if dev.apcli.state == "up" then %> <tr>
<tr> <td></td>
<td></td> <td class="cbi-value-field" style="width:16px; padding:3px">
<td class="cbi-value-field" style="width:16px; padding:3px"> <% if dev.apcli.state == "up" then %>
<% if dev.apcli.state == "up" then %> <img src="/luci-static/resources/icons/signal-75-100.png" />
<img src="/luci-static/resources/icons/signal-75-100.png" /> <% else %>
<% else %> <img src="/luci-static/resources/icons/signal-none.png" />
<img src="/luci-static/resources/icons/signal-none.png" /> <% end %>
<% end %> </td>
</td> <td class="cbi-value-field" style="vertical-align:middle; text-align:left; padding:3px"><strong>接口:</strong> <%=dev.apcli.devname%> | <strong>类型:</strong> 中继 | <strong>状态:</strong> <%=dev.apcli.status%>
<td class="cbi-value-field" style="vertical-align:middle; text-align:left; padding:3px"><strong>接口:</strong> <%=dev.apcli.devname%> | <strong>类型:</strong> STA | <strong>状态:</strong> <%=dev.apcli.status%> <br/>
<br/> <% if dev.apcli.status == "已连接" then %>
<% if dev.apcli.status == "Connected" then %> <strong>BSSID:</strong>:<%=dev.apcli.bssid%> |
<strong>BSSID:</strong>:<%=dev.apcli.bssid%> | <strong>上级SSID:</strong>:<%=dev.apcli.ssid%>
<strong>SSID:</strong>:<%=dev.apcli.ssid%> <% else %>
<% else %> 无线中继未连接
Wireless is disabled or not associated <% end %>
<% end %> </td>
</td> <td style="text-align:right">
<td style="text-align:right">
<input class="cbi-button cbi-button-reset" style="width:100px" title="禁用无线" value="禁用中继" type="button" onclick="location.href='<%=luci.dispatcher.build_url("admin", "network", "wifi", "vif_disable", dev.apcli.vifname)%>'" />
<% if dev.apcli.status == "Connected" then %> <input class="cbi-button cbi-button-reload" style="width:100px" title="连接中继" value="连接中继" type="button" onclick='wifi_reload("<%=luci.dispatcher.build_url("admin", "network", "wifi", "apcli_connect", dev.devname,dev.apcli.vifname)%>")' />
<input class="cbi-button cbi-button-remove" style="width:100px" title="重启无线" value="断开中继" type="button" onclick='wifi_reload("<%=luci.dispatcher.build_url("admin", "network", "wifi", "apcli_disconnect", dev.devname, dev.apcli.vifname)%>")' />
<% else %>
<input class="cbi-button cbi-button-reload" style="width:100px" title="重启无线" value="连接中继" type="button" onclick='wifi_reload("<%=luci.dispatcher.build_url("admin", "network", "wifi", "apcli_connect", dev.devname, dev.apcli.vifname)%>")' />
<% end %>
<input class="cbi-button cbi-button-edit" style="width:100px" title="配置无线设置" value="中继设置" type="button" onclick="location.href='<%=luci.dispatcher.build_url("admin", "network", "wifi", "apcli_cfg_view", dev.devname, dev.apcli.vifname)%>'" /> <input class="cbi-button cbi-button-remove" style="width:100px" title="断开中继" value="断开中继" type="button" onclick='wifi_reload("<%=luci.dispatcher.build_url("admin", "network", "wifi", "apcli_disconnect", dev.devname, dev.apcli.vifname)%>")' />
</td>
</tr> <input class="cbi-button cbi-button-edit" style="width:100px" title="修改中继参数" value="中继设置" type="button" onclick="location.href='<%=luci.dispatcher.build_url("admin", "network", "wifi", "apcli_cfg_view", dev.devname, dev.apcli.vifname)%>'" />
<% end %> </td>
</tr>
<% end %> <% end %>
<!-- /apcli list --> <!-- /apcli list -->
</tbody> </tbody>

View File

@ -3,7 +3,7 @@
<!-- <!--
This module is a demo to configure MTK' proprietary WiFi driver. This module is a demo to configure MTK' proprietary WiFi driver.
Basic idea is to bypass uci and edit wireless profile (mt76xx.dat) directly. Basic idea is to bypass uci and edit wireless profile (mt76xx.dat) directly.
LuCI's WiFi configuration is more logical and elegent, but it's quite tricky to LuCI's WiFi configuration is more logical and elegent, but it's quite tricky to
translate uci into MTK's WiFi profile (like we did in "uci2dat"). translate uci into MTK's WiFi profile (like we did in "uci2dat").
Hua Shao <nossiac@163.com> Hua Shao <nossiac@163.com>
@ -74,7 +74,7 @@ local diff = mtkwifi.diff_profile(dev.profile)
if next(diff) ~= nil then if next(diff) ~= nil then
%> %>
<span style="color:red;">(<a href="javascript:location.href='<%=luci.dispatcher.build_url("admin", "network", "wifi", "reload", dev.devname)%>'">reload</a> to apply changes)</span> <span style="color:red;">(<a href="javascript:location.href='<%=luci.dispatcher.build_url("admin", "network", "wifi", "reload", dev.devname)%>'">reload</a> to apply changes)</span>
<% <%
end end
%> %>
</legend> </legend>
@ -377,8 +377,8 @@ end
</fieldset> </fieldset>
<div class="cbi-page-actions"> <div class="cbi-page-actions">
<input class="cbi-button cbi-button-apply" value="重新加载" type="button" onclick='wifi_reload("<%=luci.dispatcher.build_url("admin", "network", "wifi", "reload", devname)%>");' /> <input class="cbi-button cbi-button-apply" value="重启无线" type="button" onclick='wifi_reload("<%=luci.dispatcher.build_url("admin", "network", "wifi", "reload", devname)%>");' />
<input class="cbi-button cbi-button-apply" value="保存" type="submit" /> <input class="cbi-button cbi-button-apply" value="保存设置" type="submit" />
<input class="cbi-button cbi-button-apply" name="__apply" value="保存&应用" type="submit" /> <input class="cbi-button cbi-button-apply" name="__apply" value="保存&应用" type="submit" />
<input class="cbi-button cbi-button-reset" value="重置" type="reset" /> <input class="cbi-button cbi-button-reset" value="重置" type="reset" />
</div> </div>

View File

@ -21,12 +21,7 @@ function wifi_common_up(devname)
do do
if string.match(vif, "ra%a-%d+") then if string.match(vif, "ra%a-%d+") then
os.execute("ifconfig "..vif.." up") os.execute("ifconfig "..vif.." up")
end os.execute("brctl addif br-lan "..vif.." ")
end
for _,vif in ipairs(string.split(mtkwifi.read_pipe("ls /sys/class/net"), "\n"))
do
if string.match(vif, "apcli%a-%d+") then
os.execute("ifconfig "..vif.." up")
end end
end end
end end
@ -37,13 +32,6 @@ function wifi_common_down(devname)
-- need to find out the vif prefix for this device -- need to find out the vif prefix for this device
for _,vif in ipairs(string.split(mtkwifi.read_pipe("ls /sys/class/net"), "\n")) for _,vif in ipairs(string.split(mtkwifi.read_pipe("ls /sys/class/net"), "\n"))
do
if string.match(vif, "apcli%d+")
or string.match(vif, "apclii%d+") then
os.execute("ifconfig "..vif.." down")
end
end
for _,vif in ipairs(string.split(mtkwifi.read_pipe("ls /sys/class/net"), "\n"))
do do
if string.match(vif, "ra%d+") if string.match(vif, "ra%d+")
or string.match(vif, "rai%d+") or string.match(vif, "rai%d+")

View File

@ -51,7 +51,7 @@ function mtkwifi.__handleSpecialChars(s)
end end
-- if order function given, sort by it by passing the table and keys a, b, -- if order function given, sort by it by passing the table and keys a, b,
-- otherwise just sort the keys -- otherwise just sort the keys
function mtkwifi.__spairs(t, order) function mtkwifi.__spairs(t, order)
-- collect the keys -- collect the keys
local keys = {} local keys = {}
@ -242,6 +242,8 @@ local WirelessModeList = {
-- [13] = "G/GN/A/AN/AC mixed", -- no B mode -- [13] = "G/GN/A/AN/AC mixed", -- no B mode
[14] = "A/AC/AN mixed", [14] = "A/AC/AN mixed",
[15] = "AC/AN mixed", --but no A mode [15] = "AC/AN mixed", --but no A mode
[16] = "AX/B/G/GN mode",
[17] = "AX/AC/AN mixed",
} }
local DevicePropertyMap = { local DevicePropertyMap = {
@ -255,7 +257,7 @@ local DevicePropertyMap = {
{device="MT7612", band={"2", "8", "11", "14", "15"}}, {device="MT7612", band={"2", "8", "11", "14", "15"}},
{device="MT7662", band={"2", "8", "11", "14", "15"}}, {device="MT7662", band={"2", "8", "11", "14", "15"}},
-- Mix -- Mix
{device="MT7615", band={"0", "1", "4", "9", "2", "8", "14", "15"}} {device="MT7615", band={"0", "1", "4", "9", "2", "8", "14", "15","16","17"}}
} }
mtkwifi.CountryRegionList_5G_All = { mtkwifi.CountryRegionList_5G_All = {
@ -429,7 +431,8 @@ function mtkwifi.band(mode)
or i == 4 or i == 4
or i == 6 or i == 6
or i == 7 or i == 7
or i == 9 then or i == 9
or i == 16 then
return "2.4G" return "2.4G"
else else
return "5G" return "5G"
@ -653,10 +656,10 @@ function mtkwifi.__setup_apcli(cfgs, devname, mainidx, subidx)
local flags = tonumber(mtkwifi.read_pipe("cat /sys/class/net/"..apcli_name.."/flags 2>/dev/null")) or 0 local flags = tonumber(mtkwifi.read_pipe("cat /sys/class/net/"..apcli_name.."/flags 2>/dev/null")) or 0
apcli.state = flags%2 == 1 and "up" or "down" apcli.state = flags%2 == 1 and "up" or "down"
if not ssid or ssid == "" then if not ssid or ssid == "" then
apcli.status = "Disconnected" apcli.status = "未连接"
else else
apcli.ssid = ssid apcli.ssid = ssid
apcli.status = "Connected" apcli.status = "已连接"
end end
apcli.devname = apcli_name apcli.devname = apcli_name
apcli.bssid = mtkwifi.read_pipe("cat /sys/class/net/"..apcli_name.."/address 2>/dev/null") or "?" apcli.bssid = mtkwifi.read_pipe("cat /sys/class/net/"..apcli_name.."/address 2>/dev/null") or "?"
@ -825,8 +828,10 @@ end
function mtkwifi.scan_ap(vifname) function mtkwifi.scan_ap(vifname)
os.execute("ifconfig "..vifname.." down")
os.execute("ifconfig "..vifname.." up")
os.execute("iwpriv "..vifname.." set SiteSurvey=0") os.execute("iwpriv "..vifname.." set SiteSurvey=0")
os.execute("sleep 10") -- depends on your env os.execute("sleep 4") -- depends on your env
local scan_result = mtkwifi.read_pipe("iwpriv "..vifname.." get_site_survey 2>/dev/null") local scan_result = mtkwifi.read_pipe("iwpriv "..vifname.." get_site_survey 2>/dev/null")
local aplist = {} local aplist = {}
@ -840,7 +845,6 @@ function mtkwifi.scan_ap(vifname)
xx.Signal = {string.find(line, "Sig%a%al"),4} xx.Signal = {string.find(line, "Sig%a%al"),4}
xx.Mode = {string.find(line, "W-Mode"),5} xx.Mode = {string.find(line, "W-Mode"),5}
xx.ExtCh = {string.find(line, "ExtCH"),6} xx.ExtCh = {string.find(line, "ExtCH"),6}
xx.WPS = {string.find(line, "WPS"),3}
xx.NT = {string.find(line, "NT"),2} xx.NT = {string.find(line, "NT"),2}
end end
@ -851,18 +855,11 @@ function mtkwifi.scan_ap(vifname)
tmp.ssid = mtkwifi.__trim(string.sub(line, xx.SSID[1], xx.SSID[1]+xx.SSID[2])) tmp.ssid = mtkwifi.__trim(string.sub(line, xx.SSID[1], xx.SSID[1]+xx.SSID[2]))
tmp.bssid = string.upper(mtkwifi.__trim(string.sub(line, xx.BSSID[1], xx.BSSID[1]+xx.BSSID[2]))) tmp.bssid = string.upper(mtkwifi.__trim(string.sub(line, xx.BSSID[1], xx.BSSID[1]+xx.BSSID[2])))
tmp.security = mtkwifi.__trim(string.sub(line, xx.Security[1], xx.Security[1]+xx.Security[2])) tmp.security = mtkwifi.__trim(string.sub(line, xx.Security[1], xx.Security[1]+xx.Security[2]))
tmp.security = string.gsub(tmp.security, "WPA1PSKWPA2PSK", "WPAPSKWPA2PSK")
if (string.find(tmp.security, "/") == nil) then
tmp.security = "OPEN" .. "/" .. tmp.security
end
tmp.authmode = mtkwifi.__trim(string.split(tmp.security, "/")[1]) tmp.authmode = mtkwifi.__trim(string.split(tmp.security, "/")[1])
tmp.encrypttype = mtkwifi.__trim(string.split(tmp.security, "/")[2] or "NONE") tmp.encrypttype = mtkwifi.__trim(string.split(tmp.security, "/")[2] or "NONE")
tmp.rssi = mtkwifi.__trim(string.sub(line, xx.Signal[1], xx.Signal[1]+xx.Signal[2])) tmp.rssi = mtkwifi.__trim(string.sub(line, xx.Signal[1], xx.Signal[1]+xx.Signal[2]))
tmp.extch = mtkwifi.__trim(string.sub(line, xx.ExtCh[1], xx.ExtCh[1]+xx.ExtCh[2])) tmp.extch = mtkwifi.__trim(string.sub(line, xx.ExtCh[1], xx.ExtCh[1]+xx.ExtCh[2]))
tmp.mode = mtkwifi.__trim(string.sub(line, xx.Mode[1], xx.Mode[1]+xx.Mode[2])) tmp.mode = mtkwifi.__trim(string.sub(line, xx.Mode[1], xx.Mode[1]+xx.Mode[2]))
if (xx.WPS[1] ~= nil and xx.WPS[2] ~= nil) then
tmp.wps = mtkwifi.__trim(string.sub(line, xx.WPS[1], xx.WPS[1]+xx.WPS[2]))
end
tmp.nt = mtkwifi.__trim(string.sub(line, xx.NT[1], xx.NT[1]+xx.NT[2])) tmp.nt = mtkwifi.__trim(string.sub(line, xx.NT[1], xx.NT[1]+xx.NT[2]))
table.insert(aplist, tmp) table.insert(aplist, tmp)
end end