Z-Wave Protocol Controller Reference
zwave_command_class_wake_up.c File Reference
#include "zwave_command_class_wake_up.h"
#include "zwave_command_classes_utils.h"
#include "zwave_command_class_indices.h"
#include "zwave_controller_utils.h"
#include "attribute_store.h"
#include "attribute_store_defined_attribute_types.h"
#include "attribute_store_helper.h"
#include "zpc_attribute_store_network_helper.h"
#include "zwave_network_management.h"
#include "attribute_resolver.h"
#include "attribute_timeouts.h"
#include "zpc_attribute_resolver.h"
#include "zwave_command_handler.h"
#include "zwave_tx_scheme_selector.h"
#include "zwave_tx.h"
#include "zpc_config.h"
#include "sl_status.h"
#include "zwave_utils.h"
#include "zwave_command_class_wake_up_types.h"
#include "ZW_classcmd.h"
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include "sl_log.h"
Include dependency graph for zwave_command_class_wake_up.c:

Macros

#define LOG_TAG   "zwave_command_class_wake_up"
 
#define ATTRIBUTE(type)   ATTRIBUTE_COMMAND_CLASS_WAKE_UP_##type
 
#define WAKE_UP_ON_DEMAND_INDEX   14
 
#define WAKE_UP_ON_DEMAND_BITMASK   1
 Bitmask for the Wake Up On demand capability. More...
 
#define MINIMUM_WAKE_UP_INTERVAL   0
 Minimum possible Wake Up Interval. More...
 
#define MAXIMUM_WAKE_UP_INTERVAL   16777215
 Maximum possible Wake Up Interval. More...
 
#define DEFAULT_WAKE_UP_STEP   1
 Default possible Wake Up Step. More...
 
#define DEFAULT_WAKE_UP_CAPBILITIES_BITMASK   0
 Default capabilities bitmask (nothing is supported) More...
 
#define WAKE_UP_NO_MORE_DISCARD_TIMEOUT   15000
 
#define WAKE_UP_NO_MORE_DELAY   1000
 

Functions

static void send_wake_up_no_more (attribute_store_node_t node_id_node)
 Check if we need and send a Wake Up No more command to a node and puts it in the Tx Queue. More...
 
static bool we_are_the_wake_up_destination (attribute_store_node_t node_id_node)
 Verifies if we are the Wake Up destination of a NodeID. More...
 
static void verify_if_wake_up_setting_needs_resolution (attribute_store_node_t wake_up_setting_node)
 Verifies if either NodeID / Wake Up interval settings are still undefined or mismatched and a resolution is needed. More...
 
static sl_status_t save_reported_interval (attribute_store_node_t parent, attribute_store_type_t type, uint8_t interval_1_msb, uint8_t interval_2, uint8_t interval_3_lsb)
 Takes the 3 bytes of a wake_up_interval_t and saves it in the attribute store. More...
 
static wake_up_interval_t get_maximum_possible_interval (attribute_store_node_t endpoint_node)
 Finds the value that would lead to the largest time between Wake Ups for a node. More...
 
static wake_up_interval_t get_closest_supported_interval (attribute_store_node_t endpoint_node, wake_up_interval_t wished_interval)
 Finds the closest supported value for a Wake Up Interval. More...
 
static void set_default_v2_capabilities (attribute_store_node_t wake_up_capabilities_node)
 Writes down assumed non-advertised capabilities for a v2 node. More...
 
static void set_default_v1_capabilities (attribute_store_node_t wake_up_capabilities_node)
 Writes down assumed non-advertised capabilities for a v1 node. More...
 
static sl_status_t wake_up_capabilities_get (attribute_store_node_t wake_up_capabilities_node, uint8_t *frame, uint16_t *frame_len)
 
static sl_status_t wake_up_interval_get (attribute_store_node_t wake_up_setting_node, uint8_t *frame, uint16_t *frame_len)
 
static sl_status_t wake_up_interval_set (attribute_store_node_t wake_up_setting_node, uint8_t *frame, uint16_t *frame_len)
 
static sl_status_t handle_wake_up_notification (const zwave_controller_connection_info_t *connection)
 
static sl_status_t handle_wake_up_interval_report (const zwave_controller_connection_info_t *connection, const uint8_t *frame_data, uint16_t frame_length)
 
static sl_status_t handle_wake_up_interval_capabilities_report (const zwave_controller_connection_info_t *connection, const uint8_t *frame_data, uint16_t frame_length)
 
static void configure_wake_up_interval (attribute_store_node_t wake_up_capabilities_node)
 Configures the Wake Up Interval setting for a node. More...
 
static void on_wake_up_setting_send_data_complete (attribute_store_node_t wake_up_setting_node, resolver_rule_type_t rule_type, zpc_resolver_event_t event)
 
static void on_version_attribute_update (attribute_store_node_t updated_node, attribute_store_change_t change)
 
static void on_capabilities_attribute_update (attribute_store_node_t updated_node, attribute_store_change_t change)
 Verifies if we are resolving capabilities, and if yes, set a resolutio listener to set the Wake Up Interval. More...
 
static void on_desired_wake_up_setting_update (attribute_store_node_t updated_node, attribute_store_change_t change)
 Verifies if either NodeID / Wake Up interval settings have changed and need resolution in this case, we will mismatch the Setting attribute to get a resolution. More...
 
static sl_status_t wake_up_control_handler (const zwave_controller_connection_info_t *connection, const uint8_t *frame_data, uint16_t frame_length)
 
bool zwave_command_class_wake_up_supports_wake_up_on_demand (attribute_store_node_t node_id_node)
 Verifies if a Node supports the Wake Up on demand functionality. More...
 
sl_status_t zwave_command_class_wake_up_init ()
 Initializes the Wake Up Command Class handler. More...
 

Variables

static const attribute_store_type_t setting_node_type [] = {ATTRIBUTE(SETTING)}
 
static const attribute_store_type_t capabilities_node_type [] = {ATTRIBUTE(CAPABILITIES)}
 
static const attribute_store_type_t setting_attributes [] = {ATTRIBUTE(INTERVAL), ATTRIBUTE(NODE_ID)}
 
static const attribute_store_type_t capabilities_attributes []
 

Macro Definition Documentation

◆ ATTRIBUTE

#define ATTRIBUTE (   type)    ATTRIBUTE_COMMAND_CLASS_WAKE_UP_##type

◆ DEFAULT_WAKE_UP_CAPBILITIES_BITMASK

#define DEFAULT_WAKE_UP_CAPBILITIES_BITMASK   0

Default capabilities bitmask (nothing is supported)

◆ DEFAULT_WAKE_UP_STEP

#define DEFAULT_WAKE_UP_STEP   1

Default possible Wake Up Step.

◆ LOG_TAG

#define LOG_TAG   "zwave_command_class_wake_up"

◆ MAXIMUM_WAKE_UP_INTERVAL

#define MAXIMUM_WAKE_UP_INTERVAL   16777215

Maximum possible Wake Up Interval.

◆ MINIMUM_WAKE_UP_INTERVAL

#define MINIMUM_WAKE_UP_INTERVAL   0

Minimum possible Wake Up Interval.

◆ WAKE_UP_NO_MORE_DELAY

#define WAKE_UP_NO_MORE_DELAY   1000

◆ WAKE_UP_NO_MORE_DISCARD_TIMEOUT

#define WAKE_UP_NO_MORE_DISCARD_TIMEOUT   15000

Timing to send a Wake Up No More (ms). The node falls asleep after 10s, so no reasons to keep this frame more than e.g 15 seconds in the queue.

◆ WAKE_UP_ON_DEMAND_BITMASK

#define WAKE_UP_ON_DEMAND_BITMASK   1

Bitmask for the Wake Up On demand capability.

◆ WAKE_UP_ON_DEMAND_INDEX

#define WAKE_UP_ON_DEMAND_INDEX   14

Function Documentation

◆ configure_wake_up_interval()

static void configure_wake_up_interval ( attribute_store_node_t  wake_up_capabilities_node)
static

Configures the Wake Up Interval setting for a node.

Parameters
wake_up_capabilities_nodeThe Attribute Store node for the Wake Up capabilities
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_closest_supported_interval()

static wake_up_interval_t get_closest_supported_interval ( attribute_store_node_t  endpoint_node,
wake_up_interval_t  wished_interval 
)
static

Finds the closest supported value for a Wake Up Interval.

Nodes support between Min and Max allowing certain steps. Not all values are allowed.

Parameters
endpoint_nodeThe Attribute Store node for the Endpoint ID
wished_intervalThe Interval that we wish to set
Returns
wake_up_interval_t value that can be set for the end node.
Here is the caller graph for this function:

◆ get_maximum_possible_interval()

static wake_up_interval_t get_maximum_possible_interval ( attribute_store_node_t  endpoint_node)
static

Finds the value that would lead to the largest time between Wake Ups for a node.

Parameters
endpoint_nodeThe Attribute Store node for the Endpoint ID which which will be read.
Returns
wake_up_interval_t value.
Here is the caller graph for this function:

◆ handle_wake_up_interval_capabilities_report()

static sl_status_t handle_wake_up_interval_capabilities_report ( const zwave_controller_connection_info_t connection,
const uint8_t *  frame_data,
uint16_t  frame_length 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_wake_up_interval_report()

static sl_status_t handle_wake_up_interval_report ( const zwave_controller_connection_info_t connection,
const uint8_t *  frame_data,
uint16_t  frame_length 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_wake_up_notification()

static sl_status_t handle_wake_up_notification ( const zwave_controller_connection_info_t connection)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ on_capabilities_attribute_update()

static void on_capabilities_attribute_update ( attribute_store_node_t  updated_node,
attribute_store_change_t  change 
)
static

Verifies if we are resolving capabilities, and if yes, set a resolutio listener to set the Wake Up Interval.

We register a listener callback on the lowest possible level, so we configure the wake up interval as early as possible.

Parameters
updated_nodeAttribute Store node that was updated (ATTRIBUTE(CAPABILITIES))
changeAttribute Store change.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ on_desired_wake_up_setting_update()

static void on_desired_wake_up_setting_update ( attribute_store_node_t  updated_node,
attribute_store_change_t  change 
)
static

Verifies if either NodeID / Wake Up interval settings have changed and need resolution in this case, we will mismatch the Setting attribute to get a resolution.

Parameters
updated_nodeAttribute Store node that was updated Setting->NodeID or Setting->Interval
changeAttribute Store change.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ on_version_attribute_update()

static void on_version_attribute_update ( attribute_store_node_t  updated_node,
attribute_store_change_t  change 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ on_wake_up_setting_send_data_complete()

static void on_wake_up_setting_send_data_complete ( attribute_store_node_t  wake_up_setting_node,
resolver_rule_type_t  rule_type,
zpc_resolver_event_t  event 
)
static
Here is the caller graph for this function:

◆ save_reported_interval()

static sl_status_t save_reported_interval ( attribute_store_node_t  parent,
attribute_store_type_t  type,
uint8_t  interval_1_msb,
uint8_t  interval_2,
uint8_t  interval_3_lsb 
)
static

Takes the 3 bytes of a wake_up_interval_t and saves it in the attribute store.

Parameters
parentThe Attribute Store node under which the child with the type reported value will be saved.
typeType of the attribute store node to be saved under the parent
interval_1_msbMSB for the wake_up_interval_t. See the Command Class specifications for details.
interval_2Middle byte for the wake_up_interval_t. See the Command Class specifications for details.
interval_3_lsbspecifications for details.
Returns
wake_up_interval_t value.
Here is the caller graph for this function:

◆ send_wake_up_no_more()

static void send_wake_up_no_more ( attribute_store_node_t  node_id_node)
static

Check if we need and send a Wake Up No more command to a node and puts it in the Tx Queue.

Parameters
node_id_nodeThe Attribute Store node for the NODE_ID to send back to sleep.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_default_v1_capabilities()

static void set_default_v1_capabilities ( attribute_store_node_t  wake_up_capabilities_node)
static

Writes down assumed non-advertised capabilities for a v1 node.

V1, there are no range of capabilities, we just write that everything Is supported. It can be overridden by somebody else (e.g. Mapper) if we know of a v1 device that does not support the full range.

Parameters
wake_up_capabilities_nodeThe Attribute Store node for the Wake Up capabilities node.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_default_v2_capabilities()

static void set_default_v2_capabilities ( attribute_store_node_t  wake_up_capabilities_node)
static

Writes down assumed non-advertised capabilities for a v2 node.

V2, the nodes do not advertise if they support the Wake Up On Demand, so we Set that to false.

Parameters
wake_up_capabilities_nodeThe Attribute Store node for the Wake Up capabilities node.
Here is the caller graph for this function:

◆ verify_if_wake_up_setting_needs_resolution()

static void verify_if_wake_up_setting_needs_resolution ( attribute_store_node_t  wake_up_setting_node)
static

Verifies if either NodeID / Wake Up interval settings are still undefined or mismatched and a resolution is needed.

If the wake_up_setting_node needs resolution, the wake_up_setting_node value will be adjusted to either undefined value or NEEDS_ONE_COMMAND / FINAL_STATE value mismatch, to trigger resolution.

Parameters
wake_up_setting_nodeAttribute Store node for the Wake Up Setting.
Here is the caller graph for this function:

◆ wake_up_capabilities_get()

static sl_status_t wake_up_capabilities_get ( attribute_store_node_t  wake_up_capabilities_node,
uint8_t *  frame,
uint16_t *  frame_len 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ wake_up_control_handler()

static sl_status_t wake_up_control_handler ( const zwave_controller_connection_info_t connection,
const uint8_t *  frame_data,
uint16_t  frame_length 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ wake_up_interval_get()

static sl_status_t wake_up_interval_get ( attribute_store_node_t  wake_up_setting_node,
uint8_t *  frame,
uint16_t *  frame_len 
)
static
Here is the caller graph for this function:

◆ wake_up_interval_set()

static sl_status_t wake_up_interval_set ( attribute_store_node_t  wake_up_setting_node,
uint8_t *  frame,
uint16_t *  frame_len 
)
static
Here is the caller graph for this function:

◆ we_are_the_wake_up_destination()

static bool we_are_the_wake_up_destination ( attribute_store_node_t  node_id_node)
static

Verifies if we are the Wake Up destination of a NodeID.

It will search all endpoints for a Wake Up Configuration containing our NodeID.

Parameters
node_id_nodeThe Attribute Store Node of the NodeID for which we want to check if we are the Wake Up Destination
Returns
true if we are the Wake Up Destination, false otherwise
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ capabilities_attributes

const attribute_store_type_t capabilities_attributes[]
static
Initial value:
= {ATTRIBUTE(MINIMUM_INTERVAL),
ATTRIBUTE(MAXIMUM_INTERVAL),
ATTRIBUTE(DEFAULT_INTERVAL),
ATTRIBUTE(INTERVAL_STEP),
ATTRIBUTE(CAPABILITIES_BITMASK)}
#define ATTRIBUTE(type)
Definition: zwave_command_class_wake_up.c:55

◆ capabilities_node_type

const attribute_store_type_t capabilities_node_type[] = {ATTRIBUTE(CAPABILITIES)}
static

◆ setting_attributes

const attribute_store_type_t setting_attributes[] = {ATTRIBUTE(INTERVAL), ATTRIBUTE(NODE_ID)}
static

◆ setting_node_type

const attribute_store_type_t setting_node_type[] = {ATTRIBUTE(SETTING)}
static