Zigbee Protocol Controller 1.6.0
Attribute Resolver

The role of the attribute resolver is to locate and resolve missing information in the attribute store. More...

Files

file  attribute_resolver_rule.h
 This module defines necessary API for using resolver.
 
file  attribute_resolver_rule_internal.h
 This module offers API for registering and executing rules.
 

Classes

struct  attribute_resolver_config_t
 

Macros

#define MAX_FRAME_LEN   255
 

Typedefs

typedef void(* attribute_resolver_callback_t) (attribute_store_node_t node)
 A callback type for notifying about resolver events. More...
 
typedef sl_status_t(* attribute_resolver_function_t) (attribute_store_node_t node, uint8_t *frame, uint16_t *frame_len)
 Generator function for building PAN frames. More...
 

Functions

sl_status_t attribute_resolver_init (attribute_resolver_config_t resolver_config)
 Initialize the attribute resolver. This function will clear the rulebook and reset the resolver state. More...
 
int attribute_resolver_teardown ()
 Teardown the attribute resolver. More...
 
sl_status_t attribute_resolver_register_rule (attribute_store_type_t node_type, attribute_resolver_function_t set_func, attribute_resolver_function_t get_func)
 Register an attribute rule. More...
 
sl_status_t attribute_resolver_set_attribute_depth (attribute_store_type_t node_type, int depth)
 Set the relative depth of an attribute in the attribute tree. More...
 
void attribute_resolver_pause_node_resolution (attribute_store_node_t node)
 Pause the resolution on a given node. More...
 
void attribute_resolver_resume_node_resolution (attribute_store_node_t node)
 Resume the resolution on a given node. More...
 
void attribute_resolver_set_resolution_listener (attribute_store_node_t node, attribute_resolver_callback_t callback)
 Register a listener to be called when a node and all its children has been resolved. More...
 
void attribute_resolver_clear_resolution_listener (attribute_store_node_t node, attribute_resolver_callback_t callback)
 Clear a node resolve listener. More...
 
void attribute_resolver_set_resolution_give_up_listener (attribute_store_type_t node_type, attribute_resolver_callback_t callback)
 Registers a listener that will be informed if we give up trying to perform a Get resolution on a node. More...
 
void attribute_resolver_set_resolution_resumption_listener (attribute_store_node_t node, attribute_resolver_callback_t callback)
 Sets a listener for unpausing nodes. More...
 
void attribute_resolver_clear_resolution_resumption_listener (attribute_store_node_t node, attribute_resolver_callback_t callback)
 Sets a listener for unpausing nodes. More...
 
sl_status_t attribute_resolver_restart_set_resolution (attribute_store_node_t node)
 Instructs the resolver to try to resolve a set rule that was pending. More...
 
sl_status_t attribute_resolver_restart_get_resolution (attribute_store_node_t node)
 Instructs the resolver to try to resolve a get rule that was pending. More...
 
attribute_resolver_config_t attribute_resolver_get_config ()
 returns the current configuration for the attribute resolver More...
 
bool attribute_resolver_node_or_child_needs_resolution (attribute_store_node_t node)
 Verifies if the provided node, or any of its child needs resolution. More...
 
bool is_node_or_parent_paused (attribute_store_node_t node)
 This function traverses attribute store to check if any parent of the attribute node is paused or not. More...
 
bool is_node_pending_set_resolution (attribute_store_node_t node)
 Returns true if a node is pending a set resolution. i.e. command has been sent and we are waiting for a state update in the attribute store. More...
 
void attribute_resolver_state_log ()
 Log the state of the Attribute Resolver using Unify Logging system. More...
 

Detailed Description

The role of the attribute resolver is to locate and resolve missing information in the attribute store.

The role of the attribute resolver is to try to fetch missing information and align reported and desired values in attributes. It does so by holding a rule set for attributes. Two hooks rules are allowed pr attributes,

Macro Definition Documentation

◆ MAX_FRAME_LEN

#define MAX_FRAME_LEN   255

Maximum size of the buffer that allows to copy rule frames

Typedef Documentation

◆ attribute_resolver_callback_t

typedef void(* attribute_resolver_callback_t) (attribute_store_node_t node)

A callback type for notifying about resolver events.

Parameters
nodeThe attribute store node for which something happened.

◆ attribute_resolver_function_t

typedef sl_status_t(* attribute_resolver_function_t) (attribute_store_node_t node, uint8_t *frame, uint16_t *frame_len)

Generator function for building PAN frames.

This function prototype is used by the rules engine to retrieve PAN frames that will resolve a get or set attribute.

Resolution functions are expected to return the following return codes:

  • SL_STATUS_OK : A frame was copied into the frame pointer and should be final to resolve the attribute
  • SL_STATUS_IN_PROGRESS: A frame was copied into the frame pointer, but this attribute will require more frames to be fully resolved.
  • SL_STATUS_ALREADY_EXISTS: The Attribute was solved using some calculation/deductions from the Attribute Store and no frame needs to be transmitted.
  • SL_STATUS_IS_WAITING: The Attribute should not be resolved and should be skipped for now.
  • SL_STATUS_FAIL: (or other codes) No frame was copied due to an error. The attribute should be skipped for now.

Function parameters:

  • attribute_store_node_t node [in]: The attribute store node to resolve. Resolving functions can use this information to retrieve related information from the Attribute Store.
  • uint8_t frame [out]: Frame pointer. The data payload for the resolution must be written at the address pointed by this variable
  • uint16_t *frame_len [out]: Length variable pointer. The length of the payload written at the frame address must be written here.

Function Documentation

◆ attribute_resolver_clear_resolution_listener()

void attribute_resolver_clear_resolution_listener ( attribute_store_node_t  node,
attribute_resolver_callback_t  callback 
)

Clear a node resolve listener.

See attribute_resolver_set_resolution_listener This will clear the callback function registered for the node. If the combination of node and callback is not found, it will do nothing.

Parameters
nodeNode to clear listener for
callbackCallback function to clear from node

◆ attribute_resolver_clear_resolution_resumption_listener()

void attribute_resolver_clear_resolution_resumption_listener ( attribute_store_node_t  node,
attribute_resolver_callback_t  callback 
)

Sets a listener for unpausing nodes.

Listeners to unpausing/resume will get a synchronous callback

Parameters
nodeNode to set a listener for
callbackCallback function to invoke when the node is resumed for resolution.

◆ attribute_resolver_get_config()

attribute_resolver_config_t attribute_resolver_get_config ( )

returns the current configuration for the attribute resolver

Returns
current configuration object

◆ attribute_resolver_init()

sl_status_t attribute_resolver_init ( attribute_resolver_config_t  resolver_config)

Initialize the attribute resolver. This function will clear the rulebook and reset the resolver state.

Parameters
resolver_configAttribute resolver configurations bundle
Returns
sl_status_t

◆ attribute_resolver_node_or_child_needs_resolution()

bool attribute_resolver_node_or_child_needs_resolution ( attribute_store_node_t  node)

Verifies if the provided node, or any of its child needs resolution.

This can be used in order to detect if paused node would be resolved if unpaused.

Parameters
nodeThe node to verify.
Returns
true if a get or set rule is to be applied on the node or a node of its subtree. false otherwise.

◆ attribute_resolver_pause_node_resolution()

void attribute_resolver_pause_node_resolution ( attribute_store_node_t  node)

Pause the resolution on a given node.

Parameters
nodeAttribute node that the resolution is paused.

◆ attribute_resolver_register_rule()

sl_status_t attribute_resolver_register_rule ( attribute_store_type_t  node_type,
attribute_resolver_function_t  set_func,
attribute_resolver_function_t  get_func 
)

Register an attribute rule.

This function registers a new rule into the resolver rule book. Only one rule can exist per attribute type. Some attributes have both a set and get rule, some only have a set rule, some have only a get rule, some have no rules.

Parameters
node_typeAttribute type for which these rules apply.
set_funcGenerator function which will generate the SET command for this attribute type.
get_funcGenerator function which will generate the GET command for this attribute type.
Returns
sl_status_t

◆ attribute_resolver_restart_get_resolution()

sl_status_t attribute_resolver_restart_get_resolution ( attribute_store_node_t  node)

Instructs the resolver to try to resolve a get rule that was pending.

This function will have no effect if the node is not in the pending gets.

Parameters
nodeNode to resolve again.
Returns
SL_STATUS_OK if the node will be retried. SL_STATUS_NOT_FOUND otherwise

◆ attribute_resolver_restart_set_resolution()

sl_status_t attribute_resolver_restart_set_resolution ( attribute_store_node_t  node)

Instructs the resolver to try to resolve a set rule that was pending.

This function will have no effect if the node is not in the pending sets. It will remove a pending set from its list and try to resolve it again.

Parameters
nodeNode to resolve again.
Returns
SL_STATUS_OK if the node will be retried. SL_STATUS_NOT_FOUND otherwise

◆ attribute_resolver_resume_node_resolution()

void attribute_resolver_resume_node_resolution ( attribute_store_node_t  node)

Resume the resolution on a given node.

Parameters
nodeAttribute node that the resolution is resumed

◆ attribute_resolver_set_attribute_depth()

sl_status_t attribute_resolver_set_attribute_depth ( attribute_store_type_t  node_type,
int  depth 
)

Set the relative depth of an attribute in the attribute tree.

This functions sets the relative depth of an attribute, this is used when the attribute resolver tries to detect if multiple attributes will be resolved by the same set frame. Normally the resolver will assume that all resolved attribute in a frame are siblings (depth=1), however once an a while the a frame will resolve attribute which are on deeper levels, ie cousins and grand cousins. It is assumed that all attributes resolved in a frame are all on the same level, ie all are siblings.

Parameters
node_type
depth
Returns
sl_status_t

◆ attribute_resolver_set_resolution_give_up_listener()

void attribute_resolver_set_resolution_give_up_listener ( attribute_store_type_t  node_type,
attribute_resolver_callback_t  callback 
)

Registers a listener that will be informed if we give up trying to perform a Get resolution on a node.

Parameters
node_typeto be informed about
callbackFunction to invoke when the node resolution has been given up

◆ attribute_resolver_set_resolution_listener()

void attribute_resolver_set_resolution_listener ( attribute_store_node_t  node,
attribute_resolver_callback_t  callback 
)

Register a listener to be called when a node and all its children has been resolved.

This function allows for a callback to be fired when the resolver has completed and resolved a part of the attribute tree. In other words, the node passed as a parameter and all its children.

This feature is used to send Wake Up No More Information for Z-Wave Wake Up nodes. It is also used by the network monitor to identify when the node is no longer interviewed after inclusion.

Parameters
nodeNode to monitor
callbackFunction to invoke when the node resolution is done.

◆ attribute_resolver_set_resolution_resumption_listener()

void attribute_resolver_set_resolution_resumption_listener ( attribute_store_node_t  node,
attribute_resolver_callback_t  callback 
)

Sets a listener for unpausing nodes.

Listeners to unpausing/resume will get a synchronous callback

Parameters
nodeNode to set a listener for
callbackCallback function to invoke when the node is resumed for resolution.

◆ attribute_resolver_state_log()

void attribute_resolver_state_log ( )

Log the state of the Attribute Resolver using Unify Logging system.

◆ attribute_resolver_teardown()

int attribute_resolver_teardown ( )

Teardown the attribute resolver.

This function will terminate the attribute resolver process.

Returns
0 on success, any other value in case of error.

◆ is_node_or_parent_paused()

bool is_node_or_parent_paused ( attribute_store_node_t  node)

This function traverses attribute store to check if any parent of the attribute node is paused or not.

Parameters
nodeAttribute node
Returns
true if the node or any of its parents is paused false if none if the node and none of its parents is paused

◆ is_node_pending_set_resolution()

bool is_node_pending_set_resolution ( attribute_store_node_t  node)

Returns true if a node is pending a set resolution. i.e. command has been sent and we are waiting for a state update in the attribute store.

Parameters
nodeAttribute node
Returns
true if the node is pending set execution false otherwise