2016-04-05 14:24:29 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
[ "${ACTION}" = "released" ] || exit 0
|
|
|
|
|
|
|
|
. /lib/functions.sh
|
|
|
|
|
|
|
|
logger "$BUTTON pressed for $SEEN seconds"
|
|
|
|
if [ "$SEEN" -lt 1 ]
|
|
|
|
then
|
|
|
|
#see https://github.com/Doodle3D/doodle3d-firmware/blob/master/src/network/wlanconfig.lua#L188 for reference
|
2016-04-05 17:22:37 +02:00
|
|
|
#check if network on top is in STA mode
|
2016-04-05 16:44:58 +02:00
|
|
|
if [ $(uci get wireless.@wifi-iface[0].mode) == "sta" ];
|
2016-04-05 14:24:29 +02:00
|
|
|
then
|
2016-04-05 16:44:58 +02:00
|
|
|
logger "switching to AP"
|
|
|
|
#configure dhcp
|
|
|
|
uci delete network.wlan
|
|
|
|
uci set network.wlan=interface
|
|
|
|
uci set network.wlan.netmask=$(uci get wifibox.general.network_ap_netmask)
|
|
|
|
uci set network.wlan.proto=static
|
|
|
|
uci set network.wlan.ipaddr=$(uci get wifibox.general.network_ap_address)
|
|
|
|
|
|
|
|
uci set dhcp.wlan=dhcp
|
|
|
|
uci set dhcp.wlan.start=100
|
|
|
|
uci set dhcp.wlan.leasetime=12h
|
|
|
|
uci set dhcp.wlan.limit=150
|
|
|
|
uci set dhcp.wlan.interface=wlan
|
|
|
|
|
2016-04-05 14:24:29 +02:00
|
|
|
uci set wireless.@wifi-iface[0].disabled=1 #disable current config
|
|
|
|
uci set wireless.@wifi-iface[1].disabled=0 #enable last used network
|
|
|
|
uci reorder wireless.@wifi-iface[0]=2 #reorder networks so last used config goes to the top again
|
2016-04-05 16:44:58 +02:00
|
|
|
uci commit #commit changes
|
|
|
|
/etc/init.d/network reload #reload network module so changes become effective
|
2016-04-05 17:22:37 +02:00
|
|
|
echo "4|" > /tmp/networkstatus.txt
|
2016-04-05 16:44:58 +02:00
|
|
|
else
|
|
|
|
logger "switching to STA $(uci get wireless.@wifi-iface[0].mode)"
|
|
|
|
uci set wireless.@wifi-iface[0].disabled=1 #disable current config
|
|
|
|
uci set wireless.@wifi-iface[1].disabled=0 #enable last used network
|
|
|
|
uci reorder wireless.@wifi-iface[0]=2 #reorder networks so last used config goes to the top again
|
|
|
|
|
|
|
|
uci delete network.wlan
|
|
|
|
uci set network.wlan=interface
|
|
|
|
uci set network.wlan.proto=dhcp
|
|
|
|
uci delete dhcp.wlan
|
|
|
|
uci commit #commit changes
|
2016-04-05 14:24:29 +02:00
|
|
|
/etc/init.d/network reload #reload network module so changes become effective
|
2016-04-05 17:22:37 +02:00
|
|
|
echo "2|" > /tmp/networkstatus.txt
|
2016-04-05 14:24:29 +02:00
|
|
|
fi
|
|
|
|
fi
|