mirror of
https://github.com/Doodle3D/doodle3d-firmware.git
synced 2024-12-22 11:03:48 +01:00
Added LUA API call
Added Lua API call to reset the network configuration.
This commit is contained in:
parent
a8bdd5c188
commit
2b097996e0
@ -218,4 +218,18 @@ function M.alive(request, response)
|
|||||||
response:setSuccess("alive")
|
response:setSuccess("alive")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function M.reset(request, response)
|
||||||
|
response:setSuccess("Resetting networks")
|
||||||
|
|
||||||
|
log:info(MOD_ABBR, "Resetting networks")
|
||||||
|
for _, net in ipairs(wifi.getConfigs()) do
|
||||||
|
print(net.ssid)
|
||||||
|
wifi.removeConfig(net.ssid)
|
||||||
|
end
|
||||||
|
|
||||||
|
local ssid = wifi.getSubstitutedSsid(settings.get('network.ap.ssid'))
|
||||||
|
netconf.setupAccessPoint(ssid)
|
||||||
|
netconf.enableAccessPoint(ssid)
|
||||||
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
@ -4,60 +4,9 @@
|
|||||||
|
|
||||||
. /lib/functions.sh
|
. /lib/functions.sh
|
||||||
|
|
||||||
count_networks() {
|
|
||||||
local config="$1"
|
|
||||||
logger $config
|
|
||||||
count=$((count + 1))
|
|
||||||
# run commands for every interface section
|
|
||||||
}
|
|
||||||
find_network() {
|
|
||||||
local config="$1"
|
|
||||||
succes=false
|
|
||||||
#logger $(uci get wireless.$config.ssid)
|
|
||||||
network_name=$(uci get wireless.$config.ssid)
|
|
||||||
if [ ${network_name:0:8} != "Doodle3D" ]
|
|
||||||
then
|
|
||||||
logger "deleting network $network_name"
|
|
||||||
uci delete wireless.$config
|
|
||||||
else
|
|
||||||
$succes=true
|
|
||||||
logger "enabled $network_name"
|
|
||||||
uci set wireless.$config.disabled=0
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
logger "$BUTTON pressed for $SEEN seconds"
|
logger "$BUTTON pressed for $SEEN seconds"
|
||||||
if [ "$SEEN" -gt 4 ]
|
if [ "$SEEN" -gt 4 ]
|
||||||
then
|
then
|
||||||
#count number of networks
|
logger "Resetting Wireless"
|
||||||
config_load wireless
|
/usr/share/lua/wifibox/script/d3dapi p=/network/reset r=GET
|
||||||
config_foreach count_networks wifi-iface
|
|
||||||
logger $count
|
|
||||||
#if number of networks is less than 1 (or 1) do nothing
|
|
||||||
if [ $count -gt 1 ]
|
|
||||||
then
|
|
||||||
logger "switching to AP"
|
|
||||||
config_foreach find_network wifi-iface
|
|
||||||
if [ $succes != false ]
|
|
||||||
then
|
|
||||||
logger "wireless somehow not found"
|
|
||||||
fi
|
|
||||||
#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
|
|
||||||
|
|
||||||
uci commit #commit changes
|
|
||||||
/etc/init.d/network reload #reload network module so changes become effective
|
|
||||||
logger "setting status flag in /tmp/networkstatus.txt"
|
|
||||||
echo "4|" > /tmp/networkstatus.txt
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user