Z-Wave Protocol Controller Reference
zwave_command_class_central_scene.c File Reference
#include "zwave_command_class_central_scene.h"
#include "zwave_command_classes_utils.h"
#include "zwave_command_class_agi.h"
#include <stdbool.h>
#include "zwave_command_class_central_scene_types.h"
#include "attribute_store_defined_attribute_types.h"
#include "ZW_classcmd.h"
#include "zwave_command_class_indices.h"
#include "zwave_command_handler.h"
#include "zwave_controller_connection_info.h"
#include "zwave_controller_utils.h"
#include "zpc_attribute_store_network_helper.h"
#include "zwave_unid.h"
#include "attribute_store.h"
#include "attribute_store_helper.h"
#include "attribute_resolver.h"
#include "attribute_timeouts.h"
#include "dotdot_mqtt_generated_commands.h"
#include "sl_log.h"
Include dependency graph for zwave_command_class_central_scene.c:

Classes

struct  central_scene_state
 Full state of a Central Scene supporting node. More...
 

Macros

#define LOG_TAG   "zwave_command_class_central_scene"
 
#define ATTRIBUTE(type)   ATTRIBUTE_COMMAND_CLASS_CENTRAL_SCENE_##type
 
#define V1_KEY_ATTRIBUTES   3
 
#define V2_KEY_ATTRIBUTES   7
 
#define V3_KEY_ATTRIBUTES   7
 
#define SLOW_REFRESH_DEFAULT_VALUE   false
 
#define NO_SCENE_ACTIVE   0
 
#define DEFAULT_SCENE_HELD_DOWN_TIMEOUT_VALUE   (5 * CLOCK_SECOND)
 
#define SLOW_REFRESH_SCENE_TIMEOUT_VALUE   (60 * CLOCK_SECOND)
 
#define SUPPORTED_REPORT_SUPPORTED_SCENES_INDEX   2
 
#define SUPPORTED_REPORT_SLOW_REFRESH_SUPPORT_INDEX   3
 
#define SUPPORTED_REPORT_BITMASKS_INDEX   4
 
#define SUPPORTED_REPORT_SLOW_REFRESH_MASK   1 << 7
 
#define SUPPORTED_REPORT_NUMBER_OF_BITMASK_MASK   3 << 1
 
#define SUPPORTED_REPORT_IDENTICAL_MASK   1
 
#define NOTIFICATION_SEQ_NUMBER_INDEX   2
 
#define NOTIFICATION_KEY_ATTRIBUTE_INDEX   3
 
#define NOTIFICATION_SCENE_NUMBER_INDEX   4
 
#define NOTIFICATION_SLOW_REFRESH_MASK   (1 << 7)
 
#define NOTIFICATION_KEY_ATTRIBUTE_MASK   0x7
 
#define CONFIGURATION_REPORT_SLOW_REFRESH_SUPPORT_INDEX   2
 
#define CONFIGURATION_REPORT_SLOW_REFRESH_MASK   (1 << 7)
 

Typedefs

typedef struct central_scene_state central_scene_state_t
 Full state of a Central Scene supporting node. More...
 

Functions

static uint8_t get_byte_highest_bit (uint8_t byte)
 Finds the highest bit set in a byte Bits will be denote as 8..1 with 8 the MSB and 1 the LSB. More...
 
static central_scene_key_attribute_t get_default_max_key_attribute (attribute_store_node_t endpoint_node)
 Computes what default max key attribute a node can support based on its version. More...
 
static central_scene_key_attribute_t get_supported_attributes (attribute_store_node_t endpoint_node)
 Reads from the attribute store the maximum Key attribute used by a node. More...
 
static central_scene_key_attribute_t calculate_max_supported_attributes (const uint8_t *frame, central_scene_scene_t scene_bitmasks, uint8_t number_of_bitmasks_bytes)
 Calcuates from a received frame maximum Key attribute used by a node. More...
 
static void get_state (attribute_store_node_t endpoint_node, central_scene_state_t *state)
 Reads the state (last active scene) of a supporting node. More...
 
static void set_state (attribute_store_node_t endpoint_node, const central_scene_state_t *state)
 Save the state (last active scene) of a supporting node in the attribute store. More...
 
static central_scene_scene_t get_active_scene (attribute_store_node_t endpoint_node, central_scene_scene_t received_scene, central_scene_key_attribute_t received_key_attribute)
 Maps the received scene notification / key attribute to a unique active scene. More...
 
static void return_scene_to_idle (attribute_store_node_t endpoint_node)
 Sets back the current scene to IDLE. More...
 
static sl_status_t zwave_command_class_central_scene_handle_notification_command (const zwave_controller_connection_info_t *info, const uint8_t *frame, uint16_t frame_length)
 Handle incoming Central Scene Notification Commands. More...
 
static sl_status_t zwave_command_class_central_scene_handle_supported_report_command (const zwave_controller_connection_info_t *info, const uint8_t *frame, uint16_t frame_length)
 Handle incoming Central Scene Supported Report Commands. More...
 
static sl_status_t zwave_command_class_central_scene_handle_configuration_report_command (const zwave_controller_connection_info_t *info, const uint8_t *frame, uint16_t frame_length)
 Handle incoming Central Scene Configuration Report Commands. More...
 
static sl_status_t zwave_command_class_central_scene_control_handler (const zwave_controller_connection_info_t *info, const uint8_t *frame, uint16_t frame_length)
 Dispatches incoming Central Scene Commands to individual command handlers. More...
 
static sl_status_t zwave_command_class_central_scene_supported_get (attribute_store_node_t node, uint8_t *frame, uint16_t *frame_length)
 Generates a Central Scene Supported Get Command. More...
 
static sl_status_t zwave_command_class_central_scene_configuration_get (attribute_store_node_t node, uint8_t *frame, uint16_t *frame_length)
 Generates a Central Scene Configuration Get Command. More...
 
static sl_status_t zwave_command_class_central_scene_configuration_set (attribute_store_node_t node, uint8_t *frame, uint16_t *frame_length)
 Generates a Central Scene Configuration Set Command. More...
 
static void zwave_command_class_central_scene_on_version_attribute_update (attribute_store_node_t updated_node, attribute_store_change_t change)
 Attribute callback function listening for Central Scene version attribute updates. More...
 
sl_status_t zwave_command_class_central_scene_init ()
 This function initialize the Central Scene Command Class handler. More...
 

Variables

static const attribute_store_type_t attribute_list []
 

Macro Definition Documentation

◆ ATTRIBUTE

#define ATTRIBUTE (   type)    ATTRIBUTE_COMMAND_CLASS_CENTRAL_SCENE_##type

◆ CONFIGURATION_REPORT_SLOW_REFRESH_MASK

#define CONFIGURATION_REPORT_SLOW_REFRESH_MASK   (1 << 7)

◆ CONFIGURATION_REPORT_SLOW_REFRESH_SUPPORT_INDEX

#define CONFIGURATION_REPORT_SLOW_REFRESH_SUPPORT_INDEX   2

◆ DEFAULT_SCENE_HELD_DOWN_TIMEOUT_VALUE

#define DEFAULT_SCENE_HELD_DOWN_TIMEOUT_VALUE   (5 * CLOCK_SECOND)

◆ LOG_TAG

#define LOG_TAG   "zwave_command_class_central_scene"

◆ NO_SCENE_ACTIVE

#define NO_SCENE_ACTIVE   0

◆ NOTIFICATION_KEY_ATTRIBUTE_INDEX

#define NOTIFICATION_KEY_ATTRIBUTE_INDEX   3

◆ NOTIFICATION_KEY_ATTRIBUTE_MASK

#define NOTIFICATION_KEY_ATTRIBUTE_MASK   0x7

◆ NOTIFICATION_SCENE_NUMBER_INDEX

#define NOTIFICATION_SCENE_NUMBER_INDEX   4

◆ NOTIFICATION_SEQ_NUMBER_INDEX

#define NOTIFICATION_SEQ_NUMBER_INDEX   2

◆ NOTIFICATION_SLOW_REFRESH_MASK

#define NOTIFICATION_SLOW_REFRESH_MASK   (1 << 7)

◆ SLOW_REFRESH_DEFAULT_VALUE

#define SLOW_REFRESH_DEFAULT_VALUE   false

◆ SLOW_REFRESH_SCENE_TIMEOUT_VALUE

#define SLOW_REFRESH_SCENE_TIMEOUT_VALUE   (60 * CLOCK_SECOND)

◆ SUPPORTED_REPORT_BITMASKS_INDEX

#define SUPPORTED_REPORT_BITMASKS_INDEX   4

◆ SUPPORTED_REPORT_IDENTICAL_MASK

#define SUPPORTED_REPORT_IDENTICAL_MASK   1

◆ SUPPORTED_REPORT_NUMBER_OF_BITMASK_MASK

#define SUPPORTED_REPORT_NUMBER_OF_BITMASK_MASK   3 << 1

◆ SUPPORTED_REPORT_SLOW_REFRESH_MASK

#define SUPPORTED_REPORT_SLOW_REFRESH_MASK   1 << 7

◆ SUPPORTED_REPORT_SLOW_REFRESH_SUPPORT_INDEX

#define SUPPORTED_REPORT_SLOW_REFRESH_SUPPORT_INDEX   3

◆ SUPPORTED_REPORT_SUPPORTED_SCENES_INDEX

#define SUPPORTED_REPORT_SUPPORTED_SCENES_INDEX   2

◆ V1_KEY_ATTRIBUTES

#define V1_KEY_ATTRIBUTES   3

◆ V2_KEY_ATTRIBUTES

#define V2_KEY_ATTRIBUTES   7

◆ V3_KEY_ATTRIBUTES

#define V3_KEY_ATTRIBUTES   7

Typedef Documentation

◆ central_scene_state_t

Full state of a Central Scene supporting node.

Function Documentation

◆ calculate_max_supported_attributes()

static central_scene_key_attribute_t calculate_max_supported_attributes ( const uint8_t *  frame,
central_scene_scene_t  scene_bitmasks,
uint8_t  number_of_bitmasks_bytes 
)
static

Calcuates from a received frame maximum Key attribute used by a node.

Parameters
framePointer pointing at the frame bitmask masks of the Supported Report
scene_bitmasksHow many scenes bitmasks are included in the frame
number_of_bitmasks_bytesHow many bitmask byte are included per scene in the frame.
Returns
Calculated maximum possible key attribute.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_active_scene()

static central_scene_scene_t get_active_scene ( attribute_store_node_t  endpoint_node,
central_scene_scene_t  received_scene,
central_scene_key_attribute_t  received_key_attribute 
)
static

Maps the received scene notification / key attribute to a unique active scene.

Parameters
endpoint_nodeEndpoint ID node for the endpoint supporting Central Scene
received_sceneScene value received in the Central Scene Notification
received_key_attributeKey attribute value received in the Central Scene Notification
Returns
central_scene_scene_t Unique active scene number.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_byte_highest_bit()

static uint8_t get_byte_highest_bit ( uint8_t  byte)
static

Finds the highest bit set in a byte Bits will be denote as 8..1 with 8 the MSB and 1 the LSB.

Parameters
bytethe byte to inspect
Returns
Number of the highest bit set.
Here is the caller graph for this function:

◆ get_default_max_key_attribute()

static central_scene_key_attribute_t get_default_max_key_attribute ( attribute_store_node_t  endpoint_node)
static

Computes what default max key attribute a node can support based on its version.

Parameters
endpoint_nodeEndpoint ID node for the endpoint supporting Central Scene
Returns
central_scene_key_attribute_t value of the maximum possible key attribute.
Here is the caller graph for this function:

◆ get_state()

static void get_state ( attribute_store_node_t  endpoint_node,
central_scene_state_t state 
)
static

Reads the state (last active scene) of a supporting node.

Parameters
endpoint_nodeEndpoint ID node for the endpoint supporting Central Scene
[out]statePointer to a state struct that will be filled with the values retrieved from the attribute store.
Here is the caller graph for this function:

◆ get_supported_attributes()

static central_scene_key_attribute_t get_supported_attributes ( attribute_store_node_t  endpoint_node)
static

Reads from the attribute store the maximum Key attribute used by a node.

Parameters
endpoint_nodeEndpoint ID node for the endpoint supporting Central Scene
Here is the caller graph for this function:

◆ return_scene_to_idle()

static void return_scene_to_idle ( attribute_store_node_t  endpoint_node)
static

Sets back the current scene to IDLE.

Parameters
endpoint_nodeEndpoint ID node for the endpoint supporting Central Scene
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_state()

static void set_state ( attribute_store_node_t  endpoint_node,
const central_scene_state_t state 
)
static

Save the state (last active scene) of a supporting node in the attribute store.

Parameters
endpoint_nodeEndpoint ID node for the endpoint supporting Central Scene
statePointer to a state struct that will be used to save values in the attribute store.
Here is the caller graph for this function:

◆ zwave_command_class_central_scene_configuration_get()

static sl_status_t zwave_command_class_central_scene_configuration_get ( attribute_store_node_t  node,
uint8_t *  frame,
uint16_t *  frame_length 
)
static

Generates a Central Scene Configuration Get Command.

Parameters
nodeAttribute Store node that the resolver tries to resolve.
framePointer at which frame data can be written.
frame_lengthPointer at which the frame data length can be written.
Returns
sl_status_t following the attribute_resolver_function_t return codes.
Here is the caller graph for this function:

◆ zwave_command_class_central_scene_configuration_set()

static sl_status_t zwave_command_class_central_scene_configuration_set ( attribute_store_node_t  node,
uint8_t *  frame,
uint16_t *  frame_length 
)
static

Generates a Central Scene Configuration Set Command.

Parameters
nodeAttribute Store node that the resolver tries to resolve.
framePointer at which frame data can be written.
frame_lengthPointer at which the frame data length can be written.
Returns
sl_status_t following the attribute_resolver_function_t return codes.
Here is the caller graph for this function:

◆ zwave_command_class_central_scene_control_handler()

static sl_status_t zwave_command_class_central_scene_control_handler ( const zwave_controller_connection_info_t info,
const uint8_t *  frame,
uint16_t  frame_length 
)
static

Dispatches incoming Central Scene Commands to individual command handlers.

Parameters
infozwave_controller_connection_info_t object.
framePointer to frame data
frame_lengthNumber of bytes contained in the frame
Returns
sl_status_t following the frame handling return codes.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zwave_command_class_central_scene_handle_configuration_report_command()

static sl_status_t zwave_command_class_central_scene_handle_configuration_report_command ( const zwave_controller_connection_info_t info,
const uint8_t *  frame,
uint16_t  frame_length 
)
static

Handle incoming Central Scene Configuration Report Commands.

Parameters
infozwave_controller_connection_info_t object.
framePointer to frame data
frame_lengthNumber of bytes contained in the frame
Returns
sl_status_t following the frame handling return codes.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zwave_command_class_central_scene_handle_notification_command()

static sl_status_t zwave_command_class_central_scene_handle_notification_command ( const zwave_controller_connection_info_t info,
const uint8_t *  frame,
uint16_t  frame_length 
)
static

Handle incoming Central Scene Notification Commands.

Parameters
infozwave_controller_connection_info_t object.
framePointer to frame data
frame_lengthNumber of bytes contained in the frame
Returns
sl_status_t following the frame handling return codes.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zwave_command_class_central_scene_handle_supported_report_command()

static sl_status_t zwave_command_class_central_scene_handle_supported_report_command ( const zwave_controller_connection_info_t info,
const uint8_t *  frame,
uint16_t  frame_length 
)
static

Handle incoming Central Scene Supported Report Commands.

Parameters
infozwave_controller_connection_info_t object.
framePointer to frame data
frame_lengthNumber of bytes contained in the frame
Returns
sl_status_t following the frame handling return codes.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zwave_command_class_central_scene_on_version_attribute_update()

static void zwave_command_class_central_scene_on_version_attribute_update ( attribute_store_node_t  updated_node,
attribute_store_change_t  change 
)
static

Attribute callback function listening for Central Scene version attribute updates.

Parameters
updated_nodeAttribute Store node that was modified.
changeType of change applied to the node.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zwave_command_class_central_scene_supported_get()

static sl_status_t zwave_command_class_central_scene_supported_get ( attribute_store_node_t  node,
uint8_t *  frame,
uint16_t *  frame_length 
)
static

Generates a Central Scene Supported Get Command.

Parameters
nodeAttribute Store node that the resolver tries to resolve.
framePointer at which frame data can be written.
frame_lengthPointer at which the frame data length can be written.
Returns
sl_status_t following the attribute_resolver_function_t return codes.
Here is the caller graph for this function:

Variable Documentation

◆ attribute_list

const attribute_store_type_t attribute_list[]
static
Initial value:
= {ATTRIBUTE(NUMBER_OF_SCENES),
ATTRIBUTE(MAX_KEY_ATTRIBUTE),
ATTRIBUTE(SLOW_REFRESH),
ATTRIBUTE(ACTIVE_SCENE)}
#define ATTRIBUTE(type)
Definition: zwave_command_class_central_scene.c:45