From f4ff087e029d2cbff5a7c8700e07267a6120544c Mon Sep 17 00:00:00 2001 From: AmadeusGhost <42570690+AmadeusGhost@users.noreply.github.com> Date: Fri, 22 Oct 2021 23:05:06 +0800 Subject: [PATCH] luci-app-mtwifi: sync upstream source From: https://github.com/MeIsReallyBa/MT7915_7621-MT_WIFI-Openwrt --- package/lean/mt/luci-app-mtwifi/Makefile | 5 +- .../luasrc/controller/mtkwifi.lua | 46 ++----------- .../luasrc/view/admin_mtk/mtk_wifi_apcli.htm | 39 ++--------- .../view/admin_mtk/mtk_wifi_dev_cfg.htm | 10 +-- .../view/admin_mtk/mtk_wifi_overview.htm | 69 ++++++++----------- .../view/admin_mtk/mtk_wifi_vif_cfg.htm | 8 +-- .../lean/mt/luci-app-mtwifi/root/sbin/mtkwifi | 14 +--- .../root/usr/lib/lua/mtkwifi.lua | 25 +++---- 8 files changed, 65 insertions(+), 151 deletions(-) diff --git a/package/lean/mt/luci-app-mtwifi/Makefile b/package/lean/mt/luci-app-mtwifi/Makefile index 6bc95cd68..1b5e22c04 100644 --- a/package/lean/mt/luci-app-mtwifi/Makefile +++ b/package/lean/mt/luci-app-mtwifi/Makefile @@ -1,13 +1,14 @@ include $(TOPDIR)/rules.mk +PKG_NAME:=luci-app-mtwifi PKG_LICENSE:=GPLv2 PKG_MAINTAINER:=Hua Shao 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 PKG_VERSION:=1 -PKG_RELEASE:=16 +PKG_RELEASE:=8 define Package/luci-app-mtwifi/conffiles /etc/wireless/mt7615/ diff --git a/package/lean/mt/luci-app-mtwifi/luasrc/controller/mtkwifi.lua b/package/lean/mt/luci-app-mtwifi/luasrc/controller/mtkwifi.lua index 4499fc563..013feea8e 100644 --- a/package/lean/mt/luci-app-mtwifi/luasrc/controller/mtkwifi.lua +++ b/package/lean/mt/luci-app-mtwifi/luasrc/controller/mtkwifi.lua @@ -1,9 +1,9 @@ -- This module is a demo to configure MTK' proprietary WiFi driver. -- 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"). -- And you will get your hands dirty. --- +-- -- Hua Shao module("luci.controller.mtkwifi", package.seeall) @@ -110,12 +110,6 @@ function dev_cfg(devname) cfgs.VHT_Sec80_Channel = http.formvalue("VHT_Sec80_Channel") or "" 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") if mimo == "0" then cfgs.ETxBfEnCond=1 @@ -223,7 +217,7 @@ function vif_del(dev, vif) local devs = mtkwifi.get_all_devs() local idx = devs[devname]["vifs"][vifname].vifidx -- or tonumber(string.match(vifname, "%d+")) + 1 mtkwifi.debug("idx="..idx, devname, vifname) - local profile = devs[devname].profile + local profile = devs[devname].profile assert(profile) if idx and tonumber(idx) >= 0 then local cfgs = mtkwifi.load_profile(profile) @@ -499,13 +493,13 @@ function initialize_multiBssParameters(cfgs,vif_idx) return cfgs end -function vif_cfg(dev, vif) +function vif_cfg(dev, vif) local devname, vifname = dev, vif if not devname then devname = vif end mtkwifi.debug("devname="..devname) mtkwifi.debug("vifname="..(vifname or "")) local devs = mtkwifi.get_all_devs() - local profile = devs[devname].profile + local profile = devs[devname].profile assert(profile) local cfgs = mtkwifi.load_profile(profile) @@ -767,19 +761,8 @@ function apcli_connect(dev, vif) local cfgs = mtkwifi.load_profile(profiles[devname]) cfgs.ApCliEnable = "1" 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("ifconfig "..vifname.." up") os.execute("iwpriv "..vifname.." set Channel="..cfgs.Channel) os.execute("iwpriv "..vifname.." set ApCliAuthMode="..cfgs.ApCliAuthMode) os.execute("iwpriv "..vifname.." set ApCliEncrypType="..cfgs.ApCliEncrypType) @@ -791,9 +774,6 @@ function apcli_connect(dev, vif) or cfgs.ApCliAuthMode == "WPA1PSKWPA2PSK" then os.execute("iwpriv "..vifname.." set ApCliWPAPSK="..cfgs.ApCliWPAPSK) 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 ApCliEnable=1") 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() mtkwifi.debug(profiles[devname]) assert(profiles[devname]) - local cfgs = mtkwifi.load_profile(profiles[devname]) - cfgs.ApCliEnable = "1" + cfgs.ApCliEnable = "0" mtkwifi.save_profile(cfgs, profiles[devname]) - 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") - luci.http.redirect(luci.dispatcher.build_url("admin", "network", "wifi")) end diff --git a/package/lean/mt/luci-app-mtwifi/luasrc/view/admin_mtk/mtk_wifi_apcli.htm b/package/lean/mt/luci-app-mtwifi/luasrc/view/admin_mtk/mtk_wifi_apcli.htm index 3828e0ddc..c25a1977f 100644 --- a/package/lean/mt/luci-app-mtwifi/luasrc/view/admin_mtk/mtk_wifi_apcli.htm +++ b/package/lean/mt/luci-app-mtwifi/luasrc/view/admin_mtk/mtk_wifi_apcli.htm @@ -3,7 +3,7 @@ <% if dev.apcli then %> - <% if dev.apcli.state == "up" then %> - - - - <% if dev.apcli.state == "up" then %> - - <% else %> - - <% end %> - - 接口: <%=dev.apcli.devname%> | 类型: STA | 状态: <%=dev.apcli.status%> -
- <% if dev.apcli.status == "Connected" then %> - BSSID::<%=dev.apcli.bssid%> | - SSID::<%=dev.apcli.ssid%> - <% else %> - Wireless is disabled or not associated - <% end %> - - - '" /> + + + + <% if dev.apcli.state == "up" then %> + + <% else %> + + <% end %> + + 接口: <%=dev.apcli.devname%> | 类型: 中继 | 状态: <%=dev.apcli.status%> +
+ <% if dev.apcli.status == "已连接" then %> + BSSID::<%=dev.apcli.bssid%> | + 上级SSID::<%=dev.apcli.ssid%> + <% else %> + 无线中继未连接 + <% end %> + + - <% if dev.apcli.status == "Connected" then %> - - <% else %> - - <% end %> + - '" /> - - - <% end %> + + + '" /> + + <% end %> diff --git a/package/lean/mt/luci-app-mtwifi/luasrc/view/admin_mtk/mtk_wifi_vif_cfg.htm b/package/lean/mt/luci-app-mtwifi/luasrc/view/admin_mtk/mtk_wifi_vif_cfg.htm index 597c4a396..8ec032b47 100644 --- a/package/lean/mt/luci-app-mtwifi/luasrc/view/admin_mtk/mtk_wifi_vif_cfg.htm +++ b/package/lean/mt/luci-app-mtwifi/luasrc/view/admin_mtk/mtk_wifi_vif_cfg.htm @@ -3,7 +3,7 @@