mirror of
https://github.com/Doodle3D/doodle3d-firmware.git
synced 2024-12-22 11:03:48 +01:00
Minor changes to UCI error handling.
This commit is contained in:
parent
8fda75664c
commit
1fe9da5985
@ -51,7 +51,7 @@ function M._global_GET(request, response)
|
||||
else
|
||||
response:addData(k, "could not read key ('" .. m .. "')")
|
||||
response:setError(m)
|
||||
return false;
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -75,7 +75,7 @@ function M._global_POST(request, response)
|
||||
log:info(" m: "..utils.dump(m))
|
||||
elseif r == nil then
|
||||
response:setError(m)
|
||||
return false;
|
||||
return
|
||||
end
|
||||
end
|
||||
response:addData("validation",validation)
|
||||
@ -83,7 +83,7 @@ function M._global_POST(request, response)
|
||||
local substitutedSsid = wifi.getSubstitutedSsid(settings.get('network.ap.ssid'))
|
||||
response:addData("substituted_ssid",substitutedSsid)
|
||||
|
||||
-- we now call signin seperatly trough cgi-bin
|
||||
-- we now call signin seperately trough cgi-bin
|
||||
--[[log:info("API:Network:try signing in")
|
||||
if signin.signin() then
|
||||
log:info("API:Network:signin successfull")
|
||||
@ -101,7 +101,7 @@ function M.all_GET(request, response)
|
||||
end
|
||||
else
|
||||
response:setError(msg)
|
||||
return false;
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
@ -124,7 +124,7 @@ function M.reset_POST(request, response)
|
||||
else
|
||||
response:addData(k, "could not reset key ('" .. m .. "')")
|
||||
response:setError(m)
|
||||
return false;
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -138,7 +138,7 @@ function M.resetall_POST(request, response)
|
||||
|
||||
if(rv == nil) then
|
||||
response:setError(msg)
|
||||
return false
|
||||
return
|
||||
end
|
||||
|
||||
for k,v in pairs(settings.getAll()) do
|
||||
|
@ -156,7 +156,8 @@ end]]--
|
||||
|
||||
--- Returns the value of the requested key if it exists.
|
||||
-- @p key The key to return the associated value for.
|
||||
-- @return The associated value, beware (!) that this may be boolean false for keys of 'bool' type.
|
||||
-- @return The associated value, beware (!) that this may be boolean false for keys of 'bool' type, or nil if the key could not be read because of a UCI error.
|
||||
-- @treturn string Message in case of error.
|
||||
function M.get(key)
|
||||
--log:info("settings:get: "..utils.dump(key))
|
||||
key = replaceDots(key)
|
||||
@ -192,14 +193,15 @@ function M.get(key)
|
||||
end
|
||||
|
||||
--- Returns all configuration keys with their current values.
|
||||
-- @treturn table A table containing a key/value pair for each configuration key.
|
||||
-- @return A table containing a key/value pair for each configuration key, or nil if a UCI error occured.
|
||||
-- @return string Message in case of error.
|
||||
function M.getAll()
|
||||
local result = {}
|
||||
for k,_ in pairs(baseconfig) do
|
||||
if not k:match('^[A-Z_]*$') then --TEMP: skip 'constants', which should be moved anyway
|
||||
local key = replaceUnderscores(k)
|
||||
local v, msg = M.get(key)
|
||||
if not uciV and msg ~= nil then
|
||||
if not v and msg ~= nil then
|
||||
return nil, msg
|
||||
else
|
||||
result[key] = v
|
||||
@ -369,7 +371,7 @@ end
|
||||
|
||||
--- Returns a UCI configuration key from the system section.
|
||||
-- @string key The key for which to return the value, must be non-empty.
|
||||
-- @return Requested value or false if it does not exist or nil on invalid key.
|
||||
-- @return Requested value or false if it does not exist or nil on UCI error.
|
||||
function M.getSystemKey(key)
|
||||
if type(key) ~= 'string' or key:len() == 0 then return nil end
|
||||
local v,msg = uci:get(UCI_CONFIG_NAME, UCI_CONFIG_SYSTEM_SECTION, key)
|
||||
|
Loading…
Reference in New Issue
Block a user