0
0
mirror of https://github.com/Doodle3D/doodle3d-firmware.git synced 2024-12-22 19:13:49 +01:00

Fixed boot wifi connection issues by adding sleep

This commit is contained in:
peteruithoven 2013-10-04 16:29:53 +02:00
parent d083ee70dd
commit 37783f3f06
5 changed files with 36 additions and 26 deletions

View File

@ -143,7 +143,7 @@ local function init(environment)
end end
if dbgText ~= "" then dbgText = " (" .. dbgText .. " debugging enabled)" end if dbgText ~= "" then dbgText = " (" .. dbgText .. " debugging enabled)" end
log:info("===========================")
log:info("Wifibox CGI handler started" .. dbgText) log:info("Wifibox CGI handler started" .. dbgText)
if (environment['REQUEST_METHOD'] == 'POST') then if (environment['REQUEST_METHOD'] == 'POST') then
@ -177,15 +177,16 @@ local function main(environment)
log:info("running in signin mode") log:info("running in signin mode")
local ds = wifi.getDeviceState() local ds = wifi.getDeviceState()
log:info(" ds.mode: "..util.dump(ds.mode))
if ds.mode == "sta" then if ds.mode == "sta" then
local rv,msg = Signin.signin() log:info(" attempting signin")
local success,msg = Signin.signin()
if success then
log:info("Signin successful")
else
log:info("Signin failed: "..util.dump(msg))
end
end end
--[[if rv then
log:info("autowifi setup done (" .. msg .. ")")
else
log:error("autowifi setup failed (" .. msg .. ")")
end]]--
elseif rq:getRequestMethod() ~= 'CMDLINE' or confDefaults.DEBUG_API then elseif rq:getRequestMethod() ~= 'CMDLINE' or confDefaults.DEBUG_API then
-- log:info("received request of type " .. rq:getRequestMethod() .. " for " .. (rq:getRequestedApiModule() or "<unknown>") -- log:info("received request of type " .. rq:getRequestMethod() .. " for " .. (rq:getRequestedApiModule() or "<unknown>")
-- .. "/" .. (rq:getRealApiFunctionName() or "<unknown>") .. " with arguments: " .. util.dump(rq:getAll())) -- .. "/" .. (rq:getRealApiFunctionName() or "<unknown>") .. " with arguments: " .. util.dump(rq:getAll()))

View File

@ -267,6 +267,7 @@ end
-- @tparam boolean recreate If true, a new UCI configuration based on scan data will always be created, otherwise an attempt will be made to use an existing configuration. -- @tparam boolean recreate If true, a new UCI configuration based on scan data will always be created, otherwise an attempt will be made to use an existing configuration.
-- @return True on success or nil+msg on error. -- @return True on success or nil+msg on error.
function M.associateSsid(ssid, passphrase, recreate) function M.associateSsid(ssid, passphrase, recreate)
log:info("netconfig:associateSsid: "..(ssid or "<nil>")..", "..(passphrase or "<nil>")..", "..(recreate or "<nil>"))
-- see if previously configured network for given ssid exists -- see if previously configured network for given ssid exists
local cfg = nil local cfg = nil
for _, net in ipairs(wifi.getConfigs()) do for _, net in ipairs(wifi.getConfigs()) do
@ -291,10 +292,10 @@ function M.associateSsid(ssid, passphrase, recreate)
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" } 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()
if not status.ssid or status.ssid ~= ssid then if not status.ssid or status.ssid ~= ssid then
return nil,"could not associate with network (incorrect passphrase?)" return nil,"could not associate with network (incorrect passphrase?)"
end end

View File

@ -175,35 +175,36 @@ 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)
--log:info("wlanconfig.activateConfig: "..ssid);
--local utils = require('util.utils') -- make sure only one is enabled
--local log = require('util.logger') uci:foreach('wireless', 'wifi-iface', function(s)
--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)) --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 -- make sure the wifi-device radio0 is on top
uci:reorder('wireless', 'radio0', 0) uci:reorder('wireless', 'radio0', 0)
uci:commit('wireless') uci:commit('wireless')
-- put it on top of the wireless configuration so it's the first option when the devices starts -- 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) uci:foreach('wireless', 'wifi-iface', function(s)
if s.ssid == ssid then if s.ssid == ssid then
uci:reorder('wireless', s['.name'], 1) uci:reorder('wireless', s['.name'], 1)
return false return false
end end
end) end)
--[[log:info(" result:");
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))
end)]]--
uci:commit('wireless') 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

View File

@ -78,7 +78,12 @@ function M.status(request, response)
local withRaw = utils.toboolean(request:get("with_raw")) local withRaw = utils.toboolean(request:get("with_raw"))
local ds = wifi.getDeviceState() local ds = wifi.getDeviceState()
response:setSuccess() if ds.ssid == nil then
response:setFail("Not connected")
else
response:setSuccess()
end
response:addData("ssid", ds.ssid or "") response:addData("ssid", ds.ssid or "")
response:addData("bssid", ds.bssid or "") response:addData("bssid", ds.bssid or "")
response:addData("channel", ds.channel or "") response:addData("channel", ds.channel or "")

View File

@ -6,6 +6,8 @@ START=22
LOGGER="logger -s -t autowifi -p 6" LOGGER="logger -s -t autowifi -p 6"
boot() { boot() {
sleep 1
$LOGGER "Invoking Doodle3D WiFi box network auto-initialization..." $LOGGER "Invoking Doodle3D WiFi box network auto-initialization..."
/usr/share/lua/wifibox/script/d3dapi autowifi /usr/share/lua/wifibox/script/d3dapi autowifi