mirror of
https://github.com/Doodle3D/doodle3d-firmware.git
synced 2025-01-03 16:23:49 +01:00
Access point can now be made on start up and the activated network config is always moved to the top so it's picked on startup
This commit is contained in:
parent
880e090cfe
commit
524d41e39b
@ -53,6 +53,7 @@ local function setupAutoWifiMode()
|
|||||||
-- try to find a known network which is also visible (ordered by known network definitions)
|
-- try to find a known network which is also visible (ordered by known network definitions)
|
||||||
local connectWith = nil
|
local connectWith = nil
|
||||||
for _,kn in ipairs(knownSsids) do
|
for _,kn in ipairs(knownSsids) do
|
||||||
|
if kn.mode == 'ap' and kn.ssid == apSsid then break end
|
||||||
if findSsidInList(scanList, kn.ssid) then
|
if findSsidInList(scanList, kn.ssid) then
|
||||||
connectWith = kn.ssid
|
connectWith = kn.ssid
|
||||||
break
|
break
|
||||||
|
@ -34,6 +34,7 @@ local function bothBits(dlist, itemname) dlist[itemname] = 'b' end
|
|||||||
function M.init(wifiInstance, reloadSilent)
|
function M.init(wifiInstance, reloadSilent)
|
||||||
wifi = wifiInstance
|
wifi = wifiInstance
|
||||||
silent = reloadSilent or false
|
silent = reloadSilent or false
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -289,7 +290,8 @@ function M.associateSsid(ssid, passphrase, recreate)
|
|||||||
-- try to associate with the network
|
-- try to associate with the network
|
||||||
wifi.activateConfig(ssid)
|
wifi.activateConfig(ssid)
|
||||||
--M.switchConfiguration{ wifiiface="add", apnet="rm", staticaddr="rm", dhcppool="rm", wwwredir="rm", dnsredir="rm", wwwcaptive="rm", wireless="reload" }
|
--M.switchConfiguration{ wifiiface="add", apnet="rm", staticaddr="rm", dhcppool="rm", wwwredir="rm", dnsredir="rm", wwwcaptive="rm", wireless="reload" }
|
||||||
M.switchConfiguration{ wifiiface="add", apnet="rm", staticaddr="rm", dhcppool="rm", wwwredir="rm", dnsredir="rm", wireless="reload" }
|
--M.switchConfiguration{ wifiiface="add", apnet="rm", staticaddr="rm", dhcppool="rm", wwwredir="rm", dnsredir="rm", wireless="reload" }
|
||||||
|
M.switchConfiguration{ wifiiface="add", staticaddr="rm", dhcppool="rm", wwwredir="rm", dnsredir="rm", wireless="reload" }
|
||||||
|
|
||||||
-- check if we are actually associated
|
-- check if we are actually associated
|
||||||
local status = wifi.getDeviceState()
|
local status = wifi.getDeviceState()
|
||||||
|
@ -121,6 +121,7 @@ end
|
|||||||
-- @param ssid return data for given SSID or for all networks if SSID not given
|
-- @param ssid return data for given SSID or for all networks if SSID not given
|
||||||
-- @return data for all or requested network; false+error on failure or nil when requested network not found
|
-- @return data for all or requested network; false+error on failure or nil when requested network not found
|
||||||
function M.getScanInfo(ssid)
|
function M.getScanInfo(ssid)
|
||||||
|
|
||||||
local iw = iwinfo[deviceApi]
|
local iw = iwinfo[deviceApi]
|
||||||
local sr = iw.scanlist(deviceName)
|
local sr = iw.scanlist(deviceName)
|
||||||
local si, se
|
local si, se
|
||||||
@ -167,11 +168,35 @@ end
|
|||||||
--- Activate wireless section for given SSID and disable all others
|
--- Activate wireless section for given SSID and disable all others
|
||||||
-- @param ssid SSID of config to enable, or nil to disable all network configs
|
-- @param ssid SSID of config to enable, or nil to disable all network configs
|
||||||
function M.activateConfig(ssid)
|
function M.activateConfig(ssid)
|
||||||
uci:foreach('wireless', 'wifi-iface', function(s)
|
|
||||||
|
--local utils = require('util.utils')
|
||||||
|
--local log = require('util.logger')
|
||||||
|
--log:info("wlanconfig:activateConfig: "..utils.dump(ssid))
|
||||||
|
|
||||||
|
-- make sure only one is enabled
|
||||||
|
uci:foreach('wireless', 'wifi-iface', function(s)
|
||||||
local disabled = s.ssid ~= ssid and '1' or '0'
|
local disabled = s.ssid ~= ssid and '1' or '0'
|
||||||
|
--log:info(" "..utils.dump(s.ssid).." disable: "..utils.dump(disabled))
|
||||||
uci:set('wireless', s['.name'], 'disabled', disabled)
|
uci:set('wireless', s['.name'], 'disabled', disabled)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
uci:commit('wireless')
|
uci:commit('wireless')
|
||||||
|
|
||||||
|
-- make sure the wifi-device radio0 is on top
|
||||||
|
uci:reorder('wireless', 'radio0', 0)
|
||||||
|
|
||||||
|
uci:commit('wireless')
|
||||||
|
|
||||||
|
-- put it on top of the wireless configuration so it's the first option when the devices starts
|
||||||
|
uci:foreach('wireless', 'wifi-iface', function(s)
|
||||||
|
if s.ssid == ssid then
|
||||||
|
uci:reorder('wireless', s['.name'], 1)
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
uci:commit('wireless')
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Create a new UCI network from the given iwinfo data
|
--- Create a new UCI network from the given iwinfo data
|
||||||
|
@ -110,7 +110,7 @@ function M.associate_POST(request, response)
|
|||||||
end
|
end
|
||||||
response:addPostResponseFunction(associate)
|
response:addPostResponseFunction(associate)
|
||||||
|
|
||||||
local helloA = function()
|
--[[local helloA = function()
|
||||||
local log = require('util.logger')
|
local log = require('util.logger')
|
||||||
log:info("HELLO A")
|
log:info("HELLO A")
|
||||||
end
|
end
|
||||||
@ -120,7 +120,7 @@ function M.associate_POST(request, response)
|
|||||||
local log = require('util.logger')
|
local log = require('util.logger')
|
||||||
log:info("HELLO B")
|
log:info("HELLO B")
|
||||||
end
|
end
|
||||||
response:addPostResponseFunction(helloB)
|
response:addPostResponseFunction(helloB)]]--
|
||||||
|
|
||||||
--[[response:addData("ssid", argSsid)
|
--[[response:addData("ssid", argSsid)
|
||||||
if rv then
|
if rv then
|
||||||
|
@ -80,17 +80,13 @@ function M:addData(k, v)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function M:addPostResponseFunction(fn)
|
function M:addPostResponseFunction(fn)
|
||||||
local utils = require('util.utils')
|
|
||||||
local log = require('util.logger')
|
|
||||||
log:info("Response:addPostResponseFunction: " .. utils.dump(fn))
|
|
||||||
table.insert(self.postResponseQueue, fn)
|
table.insert(self.postResponseQueue, fn)
|
||||||
log:info(" self.postResponseQueue: " .. utils.dump(self.postResponseQueue))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function M:executePostResponseQueue()
|
function M:executePostResponseQueue()
|
||||||
local utils = require('util.utils')
|
--local utils = require('util.utils')
|
||||||
local log = require('util.logger')
|
--local log = require('util.logger')
|
||||||
log:info("Response:executePostResponseQueue: " .. utils.dump(self.postResponseQueue))
|
--log:info("Response:executePostResponseQueue: " .. utils.dump(self.postResponseQueue))
|
||||||
|
|
||||||
for i,fn in ipairs(self.postResponseQueue) do fn() end
|
for i,fn in ipairs(self.postResponseQueue) do fn() end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user