mirror of
https://github.com/Doodle3D/doodle3d-firmware.git
synced 2025-01-03 08:13:49 +01:00
Remove openap hack from uci-defaults; minor fixes to bootstrap logging etc; remove debug print statement.
This commit is contained in:
parent
3de992c5b7
commit
1d9801b314
@ -88,9 +88,6 @@ else
|
|||||||
uci set wireless.@wifi-device[0].disabled=0
|
uci set wireless.@wifi-device[0].disabled=0
|
||||||
# TODO: add firewall net
|
# TODO: add firewall net
|
||||||
uci set network.wlan=interface
|
uci set network.wlan=interface
|
||||||
|
|
||||||
#TEMP: quick hack to automatically configure AP mode
|
|
||||||
/usr/share/lua/wifibox/script/d3dapi r=POST p=/network/openap
|
|
||||||
EOM
|
EOM
|
||||||
|
|
||||||
echo "WARNING: WiFiBox network configuration can only be fully prepared when installing on real device"
|
echo "WARNING: WiFiBox network configuration can only be fully prepared when installing on real device"
|
||||||
|
37
src/main.lua
37
src/main.lua
@ -12,15 +12,15 @@ local ResponseClass = require('rest.response')
|
|||||||
local postData = nil
|
local postData = nil
|
||||||
|
|
||||||
|
|
||||||
-- expects list with tables containing 'ssid' key as values and returns index key if found or nil if not found
|
|
||||||
local function findSsidInList(list, name)
|
|
||||||
for k,v in ipairs(list) do
|
|
||||||
if v.ssid == name then return k end
|
|
||||||
end
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
local function setupAutoWifiMode()
|
local function setupAutoWifiMode()
|
||||||
|
-- expects list with tables containing 'ssid' key as values and returns index key if found or nil if not found
|
||||||
|
local function findSsidInList(list, name)
|
||||||
|
for k,v in ipairs(list) do
|
||||||
|
if v.ssid == name then return k end
|
||||||
|
end
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
local wifiState = wifi.getDeviceState()
|
local wifiState = wifi.getDeviceState()
|
||||||
local netName, netMode = wifiState.ssid, wifiState.mode
|
local netName, netMode = wifiState.ssid, wifiState.mode
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ local function setupAutoWifiMode()
|
|||||||
log:info("known networks: " .. table.concat(knownNet, ", "))
|
log:info("known networks: " .. table.concat(knownNet, ", "))
|
||||||
|
|
||||||
-- if the currently active network is client mode and is also visible, do nothing since it will connect automatically further along the boot process
|
-- if the currently active network is client mode and is also visible, do nothing since it will connect automatically further along the boot process
|
||||||
if netMode == 'sta' and findSsidInList(scanList, netName) then
|
if netMode == 'sta' and netName ~= nil and netName ~= "" and findSsidInList(scanList, netName) then
|
||||||
return true, "autowifi: no action - existing configuration found for currently wifi visible network (" .. netName .. ")"
|
return true, "autowifi: no action - existing configuration found for currently wifi visible network (" .. netName .. ")"
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -60,7 +60,6 @@ local function setupAutoWifiMode()
|
|||||||
end
|
end
|
||||||
|
|
||||||
if connectWith then
|
if connectWith then
|
||||||
print("connectWith: " .. connectWith) --TEMP
|
|
||||||
local rv,msg = netconf.associateSsid(connectWith)
|
local rv,msg = netconf.associateSsid(connectWith)
|
||||||
if rv then
|
if rv then
|
||||||
return true, "autowifi: associated -- client mode with ssid '" .. connectWith .. "'"
|
return true, "autowifi: associated -- client mode with ssid '" .. connectWith .. "'"
|
||||||
@ -163,15 +162,6 @@ end
|
|||||||
local function main(environment)
|
local function main(environment)
|
||||||
local rq = RequestClass.new(environment, postData, confDefaults.DEBUG_API)
|
local rq = RequestClass.new(environment, postData, confDefaults.DEBUG_API)
|
||||||
|
|
||||||
-- log:info("received request of type " .. rq:getRequestMethod() .. " for " .. (rq:getRequestedApiModule() or "<unknown>")
|
|
||||||
-- .. "/" .. (rq:getRealApiFunctionName() or "<unknown>") .. " with arguments: " .. util.dump(rq:getAll()))
|
|
||||||
log:info("received request of type " .. rq:getRequestMethod() .. " for " .. (rq:getRequestedApiModule() or "<unknown>")
|
|
||||||
.. "/" .. (rq:getRealApiFunctionName() or "<unknown>"))
|
|
||||||
if rq:getRequestMethod() ~= 'CMDLINE' then
|
|
||||||
log:info("remote IP/port: " .. rq:getRemoteHost() .. "/" .. rq:getRemotePort())
|
|
||||||
log:debug("user agent: " .. rq:getUserAgent())
|
|
||||||
end
|
|
||||||
|
|
||||||
if rq:getRequestMethod() == 'CMDLINE' and rq:get('autowifi') ~= nil then
|
if rq:getRequestMethod() == 'CMDLINE' and rq:get('autowifi') ~= nil then
|
||||||
log:info("running in autowifi mode")
|
log:info("running in autowifi mode")
|
||||||
local rv,msg = setupAutoWifiMode()
|
local rv,msg = setupAutoWifiMode()
|
||||||
@ -182,6 +172,15 @@ end
|
|||||||
log:error("autowifi setup failed (" .. msg .. ")")
|
log:error("autowifi setup failed (" .. msg .. ")")
|
||||||
end
|
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>")
|
||||||
|
-- .. "/" .. (rq:getRealApiFunctionName() or "<unknown>") .. " with arguments: " .. util.dump(rq:getAll()))
|
||||||
|
log:info("received request of type " .. rq:getRequestMethod() .. " for " .. (rq:getRequestedApiModule() or "<unknown>")
|
||||||
|
.. "/" .. (rq:getRealApiFunctionName() or "<unknown>"))
|
||||||
|
if rq:getRequestMethod() ~= 'CMDLINE' then
|
||||||
|
log:info("remote IP/port: " .. rq:getRemoteHost() .. "/" .. rq:getRemotePort())
|
||||||
|
log:debug("user agent: " .. rq:getUserAgent())
|
||||||
|
end
|
||||||
|
|
||||||
local response, err = rq:handle()
|
local response, err = rq:handle()
|
||||||
|
|
||||||
if err ~= nil then log:error(err) end
|
if err ~= nil then log:error(err) end
|
||||||
|
Loading…
Reference in New Issue
Block a user