Skip to content

Commit

Permalink
gtw360: update reset scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
devbis committed Jul 26, 2024
1 parent c6c6f5a commit 586f766
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
. /lib/functions.sh

sed -i 's/iw dev "$wdev" del/# iw dev "$wdev" del/' /lib/netifd/wireless/mac80211.sh
sed -i 's/nl80211.request(nl80211.const.NL80211_CMD_DEL_INTERFACE/\/\/ nl80211.request(nl80211.const.NL80211_CMD_DEL_INTERFACE/' /usr/share/hostap/common.uc
case "$(board_name)" in
aqara,zhwg11lm |\
xiaomi,dgnwg05lm )
sed -i 's/iw dev "$wdev" del/# iw dev "$wdev" del/' /lib/netifd/wireless/mac80211.sh
sed -i 's/nl80211.request(nl80211.const.NL80211_CMD_DEL_INTERFACE/\/\/ nl80211.request(nl80211.const.NL80211_CMD_DEL_INTERFACE/' /usr/share/hostap/common.uc
;;
esac

exit 0
53 changes: 37 additions & 16 deletions target/linux/imx/base-files/etc/uci-defaults/70_start_ap
Original file line number Diff line number Diff line change
@@ -1,20 +1,41 @@
# multi if version
uci delete wireless.@wifi-device[0].disabled
uci delete wireless.@wifi-device[-1].disabled
uci set wireless.@wifi-iface[-1].network='wwan'
uci set wireless.@wifi-iface[-1].mode='sta'
uci set wireless.@wifi-iface[-1].ssid='$0102030405$'
uci delete wireless.@wifi-iface[-1].encryption
uci commit wireless
. /lib/functions.sh

# create wwan zone as it is the default for scanned networks
uci set network.@device[0].ports='wlan0'
uci set network.wwan='interface'
uci set network.wwan.proto='dhcp'
uci commit network
case "$(board_name)" in
aqara,zhwg11lm |\
xiaomi,dgnwg05lm )
# multi if version
uci delete wireless.@wifi-device[0].disabled
uci delete wireless.@wifi-device[-1].disabled
uci set wireless.@wifi-iface[-1].network='wwan'
uci set wireless.@wifi-iface[-1].mode='sta'
uci set wireless.@wifi-iface[-1].ssid='$0102030405$'
uci delete wireless.@wifi-iface[-1].encryption
uci commit wireless

# and add wwan to wan zone in firewall
uci set firewall.@zone[1].network='wwan wan wan6'
uci commit firewall
# create wwan zone as it is the default for scanned networks
uci set network.@device[0].ports='wlan0'
uci set network.wwan='interface'
uci set network.wwan.proto='dhcp'
uci commit network

# and add wwan to wan zone in firewall
uci set firewall.@zone[1].network='wwan wan wan6'
uci commit firewall
;;
geniatech,gtw360 )
uci delete wireless.@wifi-device[0].disabled
uci commit wireless

# create wwan zone as it is the default for scanned networks
uci set network.@device[0].ports='wlan0'
uci set network.wwan='interface'
uci set network.wwan.proto='dhcp'
uci commit network

# and add wwan to wan zone in firewall
uci set firewall.@zone[1].network='wwan wan wan6'
uci commit firewall
;;
esac

exit 0
60 changes: 55 additions & 5 deletions target/linux/imx/base-files/etc/uci-defaults/71_button_actions
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
. /lib/functions.sh

touch /usr/bin/reset_wifi_config
chmod +x /usr/bin/reset_wifi_config
touch /usr/bin/reset_overlay
chmod +x /usr/bin/reset_overlay

mkdir -p /etc/hotplug.d/button
cat << "EOF" > /etc/hotplug.d/button/00-button
source /lib/functions.sh
Expand Down Expand Up @@ -27,7 +34,10 @@ config_load system
config_foreach do_button button
EOF

cat << "EOF" > /usr/bin/reset_wifi_config
case "$(board_name)" in
aqara,zhwg11lm |\
xiaomi,dgnwg05lm )
cat << "EOF" > /usr/bin/reset_wifi_config
#!/bin/sh
{
rm -f /etc/config/network
Expand Down Expand Up @@ -60,9 +70,7 @@ cat << "EOF" > /usr/bin/reset_wifi_config
done
}
EOF
chmod +x /usr/bin/reset_wifi_config

cat << "EOF" > /usr/bin/reset_overlay
cat << "EOF" > /usr/bin/reset_overlay
#!/bin/sh
{
rm -rf /overlay/upper/.* /overlay/upper/*
Expand All @@ -81,7 +89,49 @@ cat << "EOF" > /usr/bin/reset_overlay
reboot
}
EOF
chmod +x /usr/bin/reset_overlay
;;
geniatech,gtw360 )
cat << "EOF" > /usr/bin/reset_wifi_config
#!/bin/sh
{
rm -f /etc/config/network
/bin/config_generate generate_static_network
uci set network.@device[0].ports='wlan0'
uci set network.wwan='interface'
uci set network.wwan.proto='dhcp'
uci commit network

rm -f /etc/config/wireless
wifi config
uci delete wireless.@wifi-device[0].disabled
uci commit wireless
ubus call network restart
for i in 1 2 3
do
echo 100 > /sys/class/leds/amber/brightness
sleep 1
echo 0 > /sys/class/leds/amber/brightness
sleep 1
done
}
EOF
cat << "EOF" > /usr/bin/reset_overlay
#!/bin/sh
{
rm -rf /overlay/upper/.* /overlay/upper/*

for i in 1 2 3
do
echo 100 > /sys/class/leds/blue/brightness
sleep 1
echo 0 > /sys/class/leds/green/brightness
sleep 1
done
reboot
}
EOF
;;
esac

uci add system button
uci set system.@button[-1].button="BTN_0"
Expand Down

0 comments on commit 586f766

Please sign in to comment.