mirror of
https://github.com/Doodle3D/doodle3d-firmware.git
synced 2024-12-22 11:03:48 +01:00
Comments on settings system
This commit is contained in:
parent
d75d1402bc
commit
798031f9cd
@ -161,15 +161,19 @@ end]]--
|
|||||||
function M.get(key)
|
function M.get(key)
|
||||||
--log:info("settings:get: "..utils.dump(key))
|
--log:info("settings:get: "..utils.dump(key))
|
||||||
key = replaceDots(key)
|
key = replaceDots(key)
|
||||||
local base = getBaseKeyTable(key)
|
|
||||||
|
|
||||||
|
-- retrieve settings's base settings from conf_defaults.lua
|
||||||
|
local base = getBaseKeyTable(key)
|
||||||
if not base then return nil,ERR_NO_SUCH_KEY end
|
if not base then return nil,ERR_NO_SUCH_KEY end
|
||||||
|
|
||||||
|
-- check which uci section to read.
|
||||||
|
-- By default it will read from the general section, but if a base setting contains a subSection it will check that subSection
|
||||||
local section = UCI_CONFIG_SECTION;
|
local section = UCI_CONFIG_SECTION;
|
||||||
if base.subSection ~= nil then
|
if base.subSection ~= nil then
|
||||||
section = M.get(base.subSection)
|
section = M.get(base.subSection)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- get setting from uci
|
||||||
local uciV,msg = uci:get(UCI_CONFIG_NAME, section, key)
|
local uciV,msg = uci:get(UCI_CONFIG_NAME, section, key)
|
||||||
if not uciV and msg ~= nil then
|
if not uciV and msg ~= nil then
|
||||||
local errorMSG = "Issue reading setting '"..utils.dump(key).."': "..utils.dump(msg);
|
local errorMSG = "Issue reading setting '"..utils.dump(key).."': "..utils.dump(msg);
|
||||||
@ -177,6 +181,7 @@ function M.get(key)
|
|||||||
return nil, errorMSG;
|
return nil, errorMSG;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- convert uci value into proper lua value
|
||||||
local uciV = fromUciValue(uciV, base.type)
|
local uciV = fromUciValue(uciV, base.type)
|
||||||
if uciV ~= nil then
|
if uciV ~= nil then
|
||||||
-- returning value from uci
|
-- returning value from uci
|
||||||
|
Loading…
Reference in New Issue
Block a user