Z-Wave Protocol Controller Reference
zwave_tx_groups Class Reference

#include <zwave_tx_groups_internal.hpp>

Collaboration diagram for zwave_tx_groups:

Public Member Functions

 zwave_tx_groups ()
 Class constructor. More...
 
 ~zwave_tx_groups ()
 Class destructor. More...
 
sl_status_t add_node_to_group (zwave_node_id_t node_id, zwave_multicast_group_id_t group_id)
 Forces to add a NodeID to a group. More...
 
sl_status_t assign_group (const zwave_nodemask_t nodes, zwave_multicast_group_id_t *group_id)
 Assigns/returns a Group ID to the list of NodeIDs. More...
 
sl_status_t get_nodes (zwave_nodemask_t nodes, zwave_multicast_group_id_t group_id)
 Returns the list of NodeIDs part of a group. More...
 
sl_status_t lock_group (zwave_multicast_group_id_t group_id)
 Instructs the Z-Wave TX Group not to alter the list of NodeIDs part of a group, until the group is unlocked again. More...
 
sl_status_t unlock_group (zwave_multicast_group_id_t group_id)
 Instructs the Z-Wave TX Group that the list of NodeIDs part of a group can be modified. More...
 
bool is_group_locked (zwave_multicast_group_id_t group_id)
 Verifies if a group is locked. More...
 
void log (zwave_multicast_group_id_t group_id)
 Logs the content / state of the group using sl_log. More...
 

Private Member Functions

void increment_next_group_id ()
 Increments the next_group_id_to_reuse private variable and makes sure to roll around when we reached MAXIMUM_ZWAVE_TX_GROUP_ID. More...
 
zwave_multicast_group_id_t get_next_group_to_reuse ()
 Uses the next_group_id_to_reuse to re-use a already used group that is not currently locked. More...
 
sl_status_t analyze_group_suitability (const zwave_nodemask_t nodes, const zwave_nodemask_t group_nodes, uint16_t *common_nodes) const
 Tells how suitable is a group reuse for a node list. More...
 
bool is_node_list_empty (const zwave_nodemask_t nodes) const
 Verify if a node list is empty. More...
 
zwave_multicast_group_id_t get_most_similar_subgroup (const zwave_nodemask_t nodes) const
 Finds the best group to use or reuse for a given node list. More...
 
sl_status_t get_group_data (zwave_tx_group_t *group_data, zwave_multicast_group_id_t group_id) const
 Returns the group data for a group. More...
 
sl_status_t create_or_update_group (const zwave_tx_group_t &new_group)
 Adds this group into the group list. If the Group ID is already in use update the existing group. More...
 

Private Attributes

std::set< zwave_tx_group_t, zwave_tx_group_comparegroups
 
zwave_multicast_group_id_t next_group_id_to_reuse = 1
 

Constructor & Destructor Documentation

◆ zwave_tx_groups()

zwave_tx_groups::zwave_tx_groups ( )

Class constructor.

◆ ~zwave_tx_groups()

zwave_tx_groups::~zwave_tx_groups ( )

Class destructor.

Member Function Documentation

◆ add_node_to_group()

sl_status_t zwave_tx_groups::add_node_to_group ( zwave_node_id_t  node_id,
zwave_multicast_group_id_t  group_id 
)

Forces to add a NodeID to a group.

This should be used only to restore groups, at initialization time.

Parameters
node_idNodeID to be added to the GroupID
group_idthe Group ID to add the NodeID.
Returns
SL_STATUS_OK if the group was updated or created with the NodeID. SL_STATUS_FAIL otherwize

◆ analyze_group_suitability()

sl_status_t zwave_tx_groups::analyze_group_suitability ( const zwave_nodemask_t  nodes,
const zwave_nodemask_t  group_nodes,
uint16_t *  common_nodes 
) const
private

Tells how suitable is a group reuse for a node list.

Parameters
[in]nodesList of nodes to fit into a group.
[in]group_nodesList of nodes already present in a group
[out]common_nodesThe number of common nodes in both lists.
Returns
SL_STATUS_NOT_AVAILABLE : This group must not be used for this node list. SL_STATUS_ALREADY_EXISTS: Group node list and node list are identical, so no need for any group modification SL_STATUS_OK: The group can be expanded to fit the node list.

◆ assign_group()

sl_status_t zwave_tx_groups::assign_group ( const zwave_nodemask_t  nodes,
zwave_multicast_group_id_t group_id 
)

Assigns/returns a Group ID to the list of NodeIDs.

The following checks are performed:

  1. Are the nodes all included with the same protocol
  2. Do the nodes share the same highest granted class (S0/Non-secure are accepted)
Parameters
nodesNodemask for the list of nodes for which a GroupID is needed.
[out]group_idthe Group ID assigned for the list of nodes.
Returns
SL_STATUS_OK if the group was created/found and returned in the group_id pointer. SL_STATUS_FAIL if the nodes cannot be part of the same group and the group_id variable is not to be used.

◆ create_or_update_group()

sl_status_t zwave_tx_groups::create_or_update_group ( const zwave_tx_group_t new_group)
private

Adds this group into the group list. If the Group ID is already in use update the existing group.

Parameters
new_groupGroup object to add/update in the group list.
Returns
SL_STATUS_OK

◆ get_group_data()

sl_status_t zwave_tx_groups::get_group_data ( zwave_tx_group_t group_data,
zwave_multicast_group_id_t  group_id 
) const
private

Returns the group data for a group.

Parameters
[out]group_dataPointer to return group data.
[in]group_idGroup ID for which the data is to be returned
Returns
SL_STATUS_OK if the data was written out to the group_data SL_STATUS_NOT_FOUND if the Group ID is not part of the group list.

◆ get_most_similar_subgroup()

zwave_multicast_group_id_t zwave_tx_groups::get_most_similar_subgroup ( const zwave_nodemask_t  nodes) const
private

Finds the best group to use or reuse for a given node list.

Parameters
nodesList of nodes to fit into a group.
Returns
The GroupID that is best to reuse for the node list. Returns ZWAVE_TX_INVALID_GROUP if no groups matches, and a brand new group should be created for this list.

◆ get_next_group_to_reuse()

zwave_multicast_group_id_t zwave_tx_groups::get_next_group_to_reuse ( )
private

Uses the next_group_id_to_reuse to re-use a already used group that is not currently locked.

Returns
ZWAVE_TX_INVALID_GROUP if all groups are locked and none can be reused.

◆ get_nodes()

sl_status_t zwave_tx_groups::get_nodes ( zwave_nodemask_t  nodes,
zwave_multicast_group_id_t  group_id 
)

Returns the list of NodeIDs part of a group.

Parameters
[out]nodesNodemask for the list of nodes that are part of a group
group_idThe Group ID for which we want the list of nodes.
Returns
SL_STATUS_OK if the list of nodes was copied to the nodes nodemask. SL_STATUS_NOT_FOUND if the GroupID is empty or does not exist.

◆ increment_next_group_id()

void zwave_tx_groups::increment_next_group_id ( )
private

Increments the next_group_id_to_reuse private variable and makes sure to roll around when we reached MAXIMUM_ZWAVE_TX_GROUP_ID.

◆ is_group_locked()

bool zwave_tx_groups::is_group_locked ( zwave_multicast_group_id_t  group_id)

Verifies if a group is locked.

Parameters
group_idThe multicast group id to verify
Returns
true if the group is locked. false if the group does not exist or is unlocked.

◆ is_node_list_empty()

bool zwave_tx_groups::is_node_list_empty ( const zwave_nodemask_t  nodes) const
private

Verify if a node list is empty.

Parameters
[in]nodesList of nodes to check.
Returns
true if emtpy, false if at least 1 node is in the node mask

◆ lock_group()

sl_status_t zwave_tx_groups::lock_group ( zwave_multicast_group_id_t  group_id)

Instructs the Z-Wave TX Group not to alter the list of NodeIDs part of a group, until the group is unlocked again.

This function should be called when before transmitting the first Multicast message. The unlock function should be called after the last follow up has been sent out.

Parameters
group_idThe multicast group to lock for changes.
Returns
SL_STATUS_OK if the group is locked. SL_STATUS_FAIL if there is an issue with the Group ID.

◆ log()

void zwave_tx_groups::log ( zwave_multicast_group_id_t  group_id)

Logs the content / state of the group using sl_log.

Parameters
group_idThe multicast group to log

◆ unlock_group()

sl_status_t zwave_tx_groups::unlock_group ( zwave_multicast_group_id_t  group_id)

Instructs the Z-Wave TX Group that the list of NodeIDs part of a group can be modified.

This function should be called when before transmitting the first Multicast message. The unlock function should be called after the last follow up has been sent out.

Parameters
group_idThe multicast group to unlock and allow to be updated
Returns
SL_STATUS_OK if the group is unlocked. SL_STATUS_FAIL if there is an error with the Group ID.

Member Data Documentation

◆ groups

std::set<zwave_tx_group_t, zwave_tx_group_compare> zwave_tx_groups::groups
private

◆ next_group_id_to_reuse

zwave_multicast_group_id_t zwave_tx_groups::next_group_id_to_reuse = 1
private

The documentation for this class was generated from the following file: