mirror of
https://github.com/Doodle3D/doodle3d-firmware.git
synced 2024-12-22 11:03:48 +01:00
Merge branch 'develop' of github.com:Doodle3D/doodle3d-firmware into develop
This commit is contained in:
commit
9f50ec73b3
@ -370,16 +370,31 @@ function M.associateSsid(ssid, passphrase, recreate, boot)
|
|||||||
--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" }
|
||||||
M.switchConfiguration({ wifiiface="add", staticaddr="rm", dhcppool="rm", wwwredir="rm", dnsredir="rm" },boot)
|
M.switchConfiguration({ wifiiface="add", staticaddr="rm", dhcppool="rm", wwwredir="rm", dnsredir="rm" },boot)
|
||||||
|
|
||||||
-- check if we are actually associated
|
|
||||||
local status = wifi.getDeviceState()
|
|
||||||
if not status.ssid or status.ssid ~= ssid then
|
|
||||||
local msg = "Could not associate with network (incorrect password?)"
|
|
||||||
M.setStatus(M.CONNECTING_FAILED,msg);
|
|
||||||
return nil,msg
|
|
||||||
end
|
|
||||||
|
|
||||||
M.setStatus(M.CONNECTED,"Connected");
|
-- we check if we get a ssid and ip in max 5 seconds
|
||||||
|
-- if not there is probably a issue
|
||||||
|
local attemptInterval = 1
|
||||||
|
local maxAttempts = 5
|
||||||
|
local attempt = 0
|
||||||
|
local nextAttemptTime = os.time()
|
||||||
|
while true do
|
||||||
|
if os.time() > nextAttemptTime then
|
||||||
|
log:debug("associated check "..utils.dump(attempt).."/"..utils.dump(maxAttempts))
|
||||||
|
if wifi.getLocalIP() ~= nil and wifi.getDeviceState().ssid == ssid then
|
||||||
|
break
|
||||||
|
else
|
||||||
|
attempt = attempt+1
|
||||||
|
if attempt >= maxAttempts then
|
||||||
|
-- still no correct ssid; fail
|
||||||
|
local msg = "Could not associate with network (incorrect password?)"
|
||||||
|
M.setStatus(M.CONNECTING_FAILED,msg);
|
||||||
|
return false, msg
|
||||||
|
else
|
||||||
|
nextAttemptTime = os.time() + attemptInterval
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- signin to connect.doodle3d.com
|
-- signin to connect.doodle3d.com
|
||||||
local success, output = signin.signin()
|
local success, output = signin.signin()
|
||||||
@ -388,7 +403,10 @@ function M.associateSsid(ssid, passphrase, recreate, boot)
|
|||||||
else
|
else
|
||||||
log:info("Signing in failed")
|
log:info("Signing in failed")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- report we are connected after signin attempt
|
||||||
|
M.setStatus(M.CONNECTED,"Connected");
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
--- Disassociate wlan device as client from all SSID's.
|
--- Disassociate wlan device as client from all SSID's.
|
||||||
|
@ -174,7 +174,6 @@ function M.removeConfig(ssid)
|
|||||||
if s.ssid == ssid then
|
if s.ssid == ssid then
|
||||||
uci:delete('wireless', s['.name'])
|
uci:delete('wireless', s['.name'])
|
||||||
rv = true
|
rv = true
|
||||||
return false
|
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
uci:commit('wireless')
|
uci:commit('wireless')
|
||||||
@ -229,7 +228,7 @@ function M.createConfigFromScanInfo(info, passphrase, disabled)
|
|||||||
network = M.NET,
|
network = M.NET,
|
||||||
device = 'radio0',
|
device = 'radio0',
|
||||||
ssid = info.ssid,
|
ssid = info.ssid,
|
||||||
bssid = info.bssid,
|
--bssid = info.bssid,
|
||||||
encryption = M.mapEncryptionType(info.encryption),
|
encryption = M.mapEncryptionType(info.encryption),
|
||||||
mode = mode,
|
mode = mode,
|
||||||
}
|
}
|
||||||
@ -237,8 +236,9 @@ function M.createConfigFromScanInfo(info, passphrase, disabled)
|
|||||||
apconfig.disabled = disabled ~= nil and disabled and 1 or 0
|
apconfig.disabled = disabled ~= nil and disabled and 1 or 0
|
||||||
|
|
||||||
uci:foreach('wireless', 'wifi-iface', function(s)
|
uci:foreach('wireless', 'wifi-iface', function(s)
|
||||||
if s.bssid == info.bssid then
|
--if s.bssid == info.bssid then
|
||||||
log:debug("removing old wireless config for net '" .. s.ssid .. "(bssid: " .. s.bssid .. ")'")
|
if s.ssid == info.ssid then
|
||||||
|
log:debug("removing old wireless config for net '" .. s.ssid .. "'")
|
||||||
uci:delete('wireless', s['.name'])
|
uci:delete('wireless', s['.name'])
|
||||||
-- return false --keep looking, just in case multiple entries with this bssid exist
|
-- return false --keep looking, just in case multiple entries with this bssid exist
|
||||||
end
|
end
|
||||||
|
@ -186,7 +186,6 @@ function M.status(request, response)
|
|||||||
rv = M.access(request, response)
|
rv = M.access(request, response)
|
||||||
if(rv == false) then return end
|
if(rv == false) then return end
|
||||||
end
|
end
|
||||||
response:addData('v', 10)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
@ -215,10 +215,6 @@ end
|
|||||||
|
|
||||||
function M.alive(request, response)
|
function M.alive(request, response)
|
||||||
response:setSuccess("alive")
|
response:setSuccess("alive")
|
||||||
|
|
||||||
local ds = wifi.getDeviceState()
|
|
||||||
log:debug(" ssid: "..utils.dump(ds.ssid))
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
Loading…
Reference in New Issue
Block a user