devicetree
This module allows to access the ReadyAgent tree.
The list of all variables and their meaning is partially device-dependent, and is given in a separate document.
devicetree
devicetree.get(path) | Retrieves a variable value from the ReadyAgent variable tree. |
devicetree.init() | Initialize the module. |
devicetree.register(regvars, callback, passivevars) | Registers to receive a notification when one or multiple variables change. |
devicetree.set(path, value) | Sets a variable value into the ReadyAgent variable tree. |
devicetree.unregister(userid) | Cancels registration to receive a notification when a variable changes. |
devicetree
devicetree.get(path)
nil
followed by a list of paths to each child.
path
:
is a string defining the path of the variable to retrieve.
path
leaf node.
path
is a non-leaf node.
`devicetree.get("config.monitoring.activate")` may return `true`.
`devicetree.get("config.monitoring")` may return
`nil, {"config.monitoring.activate", "config.monitoring.debug"}`.
devicetree.init()
devicetree.register(regvars, callback, passivevars)
regvars
changes. It receives as parameter a table of
variable-name / variable-value pairs; these variables are all the variables
listed in regvars
which have changed, plus every variables listed in
passivevars
, whether their values changed or not.
Please note that the callback can be called with table param
containing niltoken#niltoken value(s) to indicate variable(s) deletion.
Variables listed in regvars
and passivevars
can be either FQVN names,
or a path which denotes every individual variable below this path.
regvars
:
list of variables which must be monitored for change.
callback
:
the function triggered everytime a regvars
variable changes.
The callback is called with a table containing all the changes.
Callback signature: callback([table] varmap).
passivevars
:
optional variables to always pass to callback
,
whether they changed or not.
devicetree.set(path, value)
Example: to activate the monitoring, you could send:
devicetree.set ("config.monitoring.activate", true).
path
:
defining the path of the variable to set.
value
:
is the value of the variable (can be a table, in which case
it will actually set a whole sub tree (several variables at once)).
devicetree.unregister(userid)
userid
:
is the id returned by previous devicetree.register
call to be cancelled.