Skip to content
This repository has been archived by the owner on Jun 23, 2023. It is now read-only.

Commit

Permalink
update luci-app-mtwifi:
Browse files Browse the repository at this point in the history
auto channel selection in client mode (apcli)
various small changes
  • Loading branch information
Azexios committed Jan 8, 2023
1 parent e745aa6 commit c9b450e
Show file tree
Hide file tree
Showing 14 changed files with 374 additions and 137 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# MTK Wi-Fi driver for OpenWrt 22.03.2
# MTK Wi-Fi driver for OpenWrt 22.03.3
#### For Xiaomi Mi R3P and devices using:
- MT7615+MT7615
- MT7603+MT7615
Expand Down
6 changes: 3 additions & 3 deletions README_RU.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@

2. Перейти в каталог openwrt, удалить свой .config - запустить make menuconfig, выбрать своё устройство, перейти в раздел - LuCI > Applications - включить <\*> luci-app-mtwifi, далее в Kernel modules > Wireless Drivers > включить <\*> нужный драйвер/драйвера mtk и зайти в их настройки (выбрать нужные параметры или использовать дефолтные), запомнить настройки/сделать скриншоты и аналогично с Network > Wireless > mt_wifi - MT_WIFI Configuration.

3. Скачать конфиг (для сборки OpenWrt с правильным .vermagiс), ниже пример для OpenWrt 22.03.2 и устройств с CPU mt7621:
3. Скачать конфиг (для сборки OpenWrt с правильным .vermagiс), ниже пример для OpenWrt 22.03.3 и устройств с CPU mt7621:

```bash
wget -O .config https://downloads.openwrt.org/releases/22.03.2/targets/ramips/mt7621/config.buildinfo
wget -O .config https://downloads.openwrt.org/releases/22.03.3/targets/ramips/mt7621/config.buildinfo
make defconfig
```

4. Запустить make menuconfig, выбрать своё устройство, в Kernel modules > Wireless Drivers - включить <\*> нужный драйвер/драйвера mtk и зайти в их настройки - выставить настройки полученные на 2 пункте.
В LuCI > Applications - включить <\*> luci-app-mtwifi.
В Network > Wireless - выставить настройки в mt_wifi из 2 пункта.
В Network > WirelessAPD - отключить wpad-basic-wolfssl и выбрать как модуль \<M> hostapd-common.
Не обязательно - открыть profiles.json (для mt7621 и OpenWrt 22.03.2 - https://downloads.openwrt.org/releases/22.03.2/targets/ramips/mt7621/profiles.json), найти своё устройство и посмотреть какие пакеты (device_packages, кроме Wi-Fi драйверов) нужно дополнительно включить в прошивку.
Не обязательно - открыть profiles.json (для mt7621 и OpenWrt 22.03.3 - https://downloads.openwrt.org/releases/22.03.3/targets/ramips/mt7621/profiles.json), найти своё устройство и посмотреть какие пакеты (device_packages, кроме Wi-Fi драйверов) нужно дополнительно включить в прошивку.

5. Выйти, сохранив настройки и собрать прошивку:

Expand Down
1 change: 1 addition & 0 deletions package/mt/drivers/mt_wifi/files/mt7603.dat
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Default
# ApCliAuto=0
AccessControlList0=
AccessControlList1=
AccessControlList10=
Expand Down
1 change: 1 addition & 0 deletions package/mt/drivers/mt_wifi/files/mt7612.dat
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Default
# ApCliAuto=0
AccessControlList0=
AccessControlList1=
AccessControlList2=
Expand Down
1 change: 1 addition & 0 deletions package/mt/drivers/mt_wifi/files/mt7615.2G.dat
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Default
# ApCliAuto=0
AccessControlList0=
AccessControlList1=
AccessControlList10=
Expand Down
1 change: 1 addition & 0 deletions package/mt/drivers/mt_wifi/files/mt7615.5G.dat
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Default
# ApCliAuto=0
AccessControlList0=
AccessControlList1=
AccessControlList10=
Expand Down
93 changes: 70 additions & 23 deletions package/mt/luci-app-mtwifi/luasrc/controller/mtkwifi.lua
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ function index()
entry({"admin", "network", "wifi", "apcli_cfg"}, call("apcli_cfg")).leaf = true
entry({"admin", "network", "wifi", "apcli_disconnect"}, call("apcli_disconnect")).leaf = true
entry({"admin", "network", "wifi", "apcli_connect"}, call("apcli_connect")).leaf = true
entry({"admin", "network", "wifi", "apcli_connect_ch0"}, call("apcli_connect_ch0")).leaf = true
entry({"admin", "network", "wifi", "apcli_scan"}, call("apcli_scan")).leaf = true;
end

Expand Down Expand Up @@ -384,8 +385,8 @@ function vif_enable(dev, iface)

if iface == "ra0" or iface == "rai0" then
if cfgs.EAPifname == "br-lan" then
mt_lan = mtkwifi.read_pipe("uci show network.cfg030f15.ports | grep -q "..iface.." && echo 1")
if mt_lan ~= "1\n" then
local mt_lan = mtkwifi.read_pipe("uci show network.cfg030f15.ports | grep -q "..iface.." && echo -n 1")
if mt_lan ~= "1" then
os.execute("uci add_list network.cfg030f15.ports='"..iface.."'; uci commit network; logger -t MTK-Wi-Fi Add "..iface.." to br-lan; service network reload")
end
end
Expand Down Expand Up @@ -720,15 +721,15 @@ function vif_cfg(dev, vif)
__security_cfg(cfgs, vif_idx)

if vifname == "ra0" or vifname == "rai0" then
mt_lan = mtkwifi.read_pipe("uci show network.cfg030f15.ports | grep -q "..vifname.." && echo 1")
local mt_lan = mtkwifi.read_pipe("uci show network.cfg030f15.ports | grep -q "..vifname.." && echo -n 1")
if http.formvalue("__lan") == "1" then
cfgs.EAPifname = "br-lan"
if mt_lan ~= "1\n" then
if mt_lan ~= "1" then
os.execute("uci add_list network.cfg030f15.ports='"..vifname.."'; uci commit network; logger -t MTK-Wi-Fi Add "..vifname.." to br-lan; service network reload")
end
else
cfgs.EAPifname = ""
if mt_lan == "1\n" then
if mt_lan == "1" then
os.execute("uci del_list network.cfg030f15.ports='"..vifname.."'; uci commit network; logger -t MTK-Wi-Fi Remove "..vifname.." from br-lan; service network reload")
end
end
Expand All @@ -737,10 +738,10 @@ function vif_cfg(dev, vif)
-- mtkwifi.debug(devname, profile)
mtkwifi.save_profile(cfgs, profile)

if http.formvalue("__apply") then
__mtkwifi_reload(devname)
luci.http.redirect(luci.dispatcher.build_url("admin", "network", "wifi"))
end
-- if http.formvalue("__apply") then
-- __mtkwifi_reload(devname)
-- luci.http.redirect(luci.dispatcher.build_url("admin", "network", "wifi"))
-- end
return luci.http.redirect(to_url)
end

Expand Down Expand Up @@ -790,17 +791,10 @@ function apcli_cfg(dev, vif)
cfgs[k] = v or ""
end
end

if cfgs.Channel == "0" then -- Auto Channel Select
cfgs.AutoChannelSelect = "3"
else
cfgs.AutoChannelSelect = "0"
cfgs.ACSCheckTime = "0"
end

cfgs.ApCliSsid = ''..mtkwifi.__handleSpecialChars(http.formvalue("ApCliSsid"))
local __authmode = http.formvalue("ApCliAuthMode")

if __authmode == "WPA3PSK" or __authmode == "OWE" then
cfgs.ApCliPMFMFPC= "1"
cfgs.ApCliPMFMFPR= "1"
Expand Down Expand Up @@ -832,12 +826,27 @@ function apcli_cfg(dev, vif)
cfgs.ApCliEncrypType = http.formvalue("_wpa_ApCliEncrypType")
end

if cfgs.Channel == "0" then
if vifname == "apcli0" then
cfgs.Channel = "1"
else
cfgs.Channel = "36"
end
end

cfgs.ApCliEnable = "1"
cfgs.AutoChannelSelect = "0"
cfgs.ACSCheckTime = "0"

mtkwifi.save_profile(cfgs, profiles[devname])

if http.formvalue("__apply") then
apcli_connect(dev, vif)
if http.formvalue("__apcli_auto") == "1" then
os.execute("grep -q 'ApCliAuto=1' /etc/wireless/mt7615/"..devname..".dat || sed -i 's/ApCliAuto=0/ApCliAuto=1/' /etc/wireless/mt7615/"..devname..".dat")
else
os.execute("grep -q 'ApCliAuto=0' /etc/wireless/mt7615/"..devname..".dat || sed -i 's/ApCliAuto=1/ApCliAuto=0/' /etc/wireless/mt7615/"..devname..".dat")
end
luci.http.redirect(luci.dispatcher.build_url("admin", "network", "wifi"))

luci.http.redirect(luci.dispatcher.build_url("admin", "network", "wifi", "apcli_cfg_view", dev, vif))
end

function apcli_connect(dev, vif)
Expand All @@ -854,7 +863,10 @@ function apcli_connect(dev, vif)
assert(profiles[devname])

local cfgs = mtkwifi.load_profile(profiles[devname])
local apcli_auto = mtkwifi.read_pipe("grep -q 'ApCliAuto=1' /etc/wireless/mt7615/"..devname..".dat && echo -n 1")

cfgs.ApCliEnable = "1"

mtkwifi.save_profile(cfgs, profiles[devname])
os.execute("ifconfig "..vifname.." up")
os.execute("iwpriv "..vifname.." set ApCliEnable=0")
Expand All @@ -873,9 +885,37 @@ function apcli_connect(dev, vif)
os.execute("iwpriv "..vifname.." set ApCliWPAPSK="..cfgs.ApCliWPAPSK)
end
os.execute("iwpriv "..vifname.." set ApCliSsid=\""..cfgs.ApCliSsid.."\"")
os.execute("iwpriv "..vifname.." set ApCliEnable=1")

if apcli_auto == "1" then
os.execute("iwpriv "..vifname.." set ApCliAutoConnect=3")
else
os.execute("iwpriv "..vifname.." set ApCliEnable=1")
end
__mtkwifi_save_apcli(devname)
os.execute("sleep 5")
end

function apcli_connect_ch0(dev, vif)
local devname,vifname = dev, vif
local profiles = mtkwifi.search_dev_and_profile()
assert(profiles[devname])

local cfgs = mtkwifi.load_profile(profiles[devname])

cfgs.ApCliEnable = "1"

if cfgs.Channel == "0" then
if vifname == "apcli0" then
cfgs.Channel = "1"
else
cfgs.Channel = "36"
end
cfgs.AutoChannelSelect = "0"
cfgs.ACSCheckTime = "0"
end

mtkwifi.save_profile(cfgs, profiles[devname])
os.execute("ifconfig "..vifname.." up")
__mtkwifi_reload(devname)
end

function apcli_disconnect(dev, vif)
Expand All @@ -884,6 +924,7 @@ function apcli_disconnect(dev, vif)
-- 2. mt7615e.1.apclix0 # multi-card
-- 3. mt7615e.1.2G.apclix0 # multi-card & multi-profile
local devname,vifname = dev, vif
local apcli_auto = mtkwifi.read_pipe("grep -q 'ApCliAuto=1' /etc/wireless/mt7615/"..devname..".dat && echo -n 1")
-- mtkwifi.debug("devname=", dev, "vifname", vif)
-- mtkwifi.debug(devname)
-- mtkwifi.debug(vifname)
Expand All @@ -893,7 +934,13 @@ function apcli_disconnect(dev, vif)
local cfgs = mtkwifi.load_profile(profiles[devname])
cfgs.ApCliEnable = "0"
mtkwifi.save_profile(cfgs, profiles[devname])
os.execute("iwpriv "..vifname.." set ApCliAutoConnect=0")
os.execute("iwpriv "..vifname.." set ApCliEnable=0")
os.execute("ifconfig "..vifname.." down")
__mtkwifi_save_apcli(devname)

if apcli_auto == "1" then
__mtkwifi_reload(devname)
else
__mtkwifi_save_apcli(devname)
end
end
Loading

0 comments on commit c9b450e

Please sign in to comment.