mirror of
https://github.com/Doodle3D/doodle3d-firmware.git
synced 2024-12-22 11:03:48 +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)
|
||||
local connectWith = nil
|
||||
for _,kn in ipairs(knownSsids) do
|
||||
if kn.mode == 'ap' and kn.ssid == apSsid then break end
|
||||
if findSsidInList(scanList, kn.ssid) then
|
||||
connectWith = kn.ssid
|
||||
break
|
||||
|
@ -34,6 +34,7 @@ local function bothBits(dlist, itemname) dlist[itemname] = 'b' end
|
||||
function M.init(wifiInstance, reloadSilent)
|
||||
wifi = wifiInstance
|
||||
silent = reloadSilent or false
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
@ -289,7 +290,8 @@ function M.associateSsid(ssid, passphrase, recreate)
|
||||
-- try to associate with the network
|
||||
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", 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
|
||||
local status = wifi.getDeviceState()
|
||||
|
@ -121,6 +121,7 @@ end
|
||||
-- @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
|
||||
function M.getScanInfo(ssid)
|
||||
|
||||
local iw = iwinfo[deviceApi]
|
||||
local sr = iw.scanlist(deviceName)
|
||||
local si, se
|
||||
@ -167,11 +168,35 @@ end
|
||||
--- Activate wireless section for given SSID and disable all others
|
||||
-- @param ssid SSID of config to enable, or nil to disable all network configs
|
||||
function M.activateConfig(ssid)
|
||||
|
||||
--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'
|
||||
--log:info(" "..utils.dump(s.ssid).." disable: "..utils.dump(disabled))
|
||||
uci:set('wireless', s['.name'], 'disabled', disabled)
|
||||
end)
|
||||
|
||||
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
|
||||
|
||||
--- Create a new UCI network from the given iwinfo data
|
||||
|
@ -110,7 +110,7 @@ function M.associate_POST(request, response)
|
||||
end
|
||||
response:addPostResponseFunction(associate)
|
||||
|
||||
local helloA = function()
|
||||
--[[local helloA = function()
|
||||
local log = require('util.logger')
|
||||
log:info("HELLO A")
|
||||
end
|
||||
@ -120,7 +120,7 @@ function M.associate_POST(request, response)
|
||||
local log = require('util.logger')
|
||||
log:info("HELLO B")
|
||||
end
|
||||
response:addPostResponseFunction(helloB)
|
||||
response:addPostResponseFunction(helloB)]]--
|
||||
|
||||
--[[response:addData("ssid", argSsid)
|
||||
if rv then
|
||||
|
@ -80,17 +80,13 @@ function M:addData(k, v)
|
||||
end
|
||||
|
||||
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)
|
||||
log:info(" self.postResponseQueue: " .. utils.dump(self.postResponseQueue))
|
||||
end
|
||||
|
||||
function M:executePostResponseQueue()
|
||||
local utils = require('util.utils')
|
||||
local log = require('util.logger')
|
||||
log:info("Response:executePostResponseQueue: " .. utils.dump(self.postResponseQueue))
|
||||
--local utils = require('util.utils')
|
||||
--local log = require('util.logger')
|
||||
--log:info("Response:executePostResponseQueue: " .. utils.dump(self.postResponseQueue))
|
||||
|
||||
for i,fn in ipairs(self.postResponseQueue) do fn() end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user