Z-Wave Protocol Controller Reference
zwave_command_class_meter_control.c File Reference
#include "zwave_command_class_meter_control.h"
#include "zwave_command_classes_utils.h"
#include "zwave_command_class_meter_types.h"
#include "attribute_store_defined_attribute_types.h"
#include "zwave_command_class_indices.h"
#include "zwave_controller_connection_info.h"
#include "zwave_controller_utils.h"
#include "zwave_command_handler.h"
#include "zpc_attribute_store_network_helper.h"
#include "zpc_attribute_resolver.h"
#include "attribute_store.h"
#include "attribute_store_helper.h"
#include "attribute_resolver.h"
#include <string.h>
#include "sl_log.h"
Include dependency graph for zwave_command_class_meter_control.c:

Classes

struct  meter_reset_v6_frame
 

Macros

#define LOG_TAG   "zwave_command_class_meter"
 
#define ATTRIBUTE(type)   ATTRIBUTE_COMMAND_CLASS_METER_##type
 
#define SCALE_BITMASK_MAX_LENTGH   4
 
#define METER_REPORT_VALUE_INDEX   4
 

Typedefs

typedef struct meter_reset_v6_frame meter_reset_v6_frame_t
 

Functions

static void undefine_meter_values (attribute_store_node_t node)
 Checks if an attribute is a Meter value, and undefines its Reported/ Desired values if it is. More...
 
static sl_status_t zwave_command_class_meter_reset (attribute_store_node_t value_node, uint8_t *frame, uint16_t *frame_length)
 Prepares a Meter Reset Command. More...
 
static sl_status_t zwave_command_class_meter_get (attribute_store_node_t node, uint8_t *frame, uint16_t *frame_length)
 Prepares a Meter Get Command. More...
 
static sl_status_t zwave_command_class_meter_supported_get (attribute_store_node_t node, uint8_t *frame, uint16_t *frame_length)
 Frame resolution function for meter capabilities. Will send a Supported Get to v2 or newer nodes, and a Meter Get to v1 nodes. More...
 
static void on_meter_reset_send_data_complete (attribute_store_node_t node, resolver_rule_type_t rule_type, zpc_resolver_event_t event)
 Decides what to do after we've sent a Meter Reset Command. More...
 
static void zwave_command_class_meter_on_version_attribute_update (attribute_store_node_t updated_node, attribute_store_change_t change)
 Attribute callback function listening for Meter version attribute updates. More...
 
static void zwave_command_class_meter_on_supported_scales_attribute_update (attribute_store_node_t supported_scales_node, attribute_store_change_t change)
 Attribute callback function listening for Supported scales attribute updates. More...
 
static void zwave_command_class_meter_on_supported_rate_types_attribute_update (attribute_store_node_t supported_rate_types_node, attribute_store_change_t change)
 Attribute callback function listening for Supported Rate types attribute updates. More...
 
static void zwave_command_class_meter_on_rate_types_attribute_created (attribute_store_node_t rate_type_node, attribute_store_change_t change)
 Attribute callback function listening for Rate type attribute creations. More...
 
static sl_status_t zwave_command_class_meter_handle_report_command (const zwave_controller_connection_info_t *info, const uint8_t *frame, uint16_t frame_length)
 Process an incoming Meter Report Command. More...
 
static sl_status_t zwave_command_class_meter_handle_supported_report_command (const zwave_controller_connection_info_t *info, const uint8_t *frame, uint16_t frame_length)
 Process an incoming Meter Supported Report Command. More...
 
static sl_status_t zwave_command_class_meter_control_handler (const zwave_controller_connection_info_t *info, const uint8_t *frame, uint16_t frame_length)
 Dispatches incoming Meter Commands to individual command handlers. More...
 
sl_status_t zwave_command_class_meter_control_init ()
 This function initialize the Meter Command Class control handler. More...
 

Variables

static const attribute_store_type_t default_attributes []
 
static const attribute_store_type_t value_attributes [] = {ATTRIBUTE(VALUE), ATTRIBUTE(PRECISION)}
 
static const attribute_store_type_t rate_type_attributes [] = {ATTRIBUTE(RATE_TYPE)}
 

Macro Definition Documentation

◆ ATTRIBUTE

#define ATTRIBUTE (   type)    ATTRIBUTE_COMMAND_CLASS_METER_##type

◆ LOG_TAG

#define LOG_TAG   "zwave_command_class_meter"

◆ METER_REPORT_VALUE_INDEX

#define METER_REPORT_VALUE_INDEX   4

◆ SCALE_BITMASK_MAX_LENTGH

#define SCALE_BITMASK_MAX_LENTGH   4

Typedef Documentation

◆ meter_reset_v6_frame_t

Function Documentation

◆ on_meter_reset_send_data_complete()

static void on_meter_reset_send_data_complete ( attribute_store_node_t  node,
resolver_rule_type_t  rule_type,
zpc_resolver_event_t  event 
)
static

Decides what to do after we've sent a Meter Reset Command.

Parameters
nodeAttribute Store node that was resolved
rule_typeThe type of rule that was applied (Set/Get)
eventThe outcome of the resolution.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ undefine_meter_values()

static void undefine_meter_values ( attribute_store_node_t  node)
static

Checks if an attribute is a Meter value, and undefines its Reported/ Desired values if it is.

Parameters
nodeAttribute store node to check.
Here is the caller graph for this function:

◆ zwave_command_class_meter_control_handler()

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

Dispatches incoming Meter 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_meter_get()

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

Prepares a Meter Get Command.

Parameters
nodeAttribute Store node 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 call graph for this function:
Here is the caller graph for this function:

◆ zwave_command_class_meter_handle_report_command()

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

Process an incoming Meter Report Command.

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_meter_handle_supported_report_command()

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

Process an incoming Meter Supported Report Command.

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.

Parse the scales before the rate type due to the tree structure

Here is the call graph for this function:
Here is the caller graph for this function:

◆ zwave_command_class_meter_on_rate_types_attribute_created()

static void zwave_command_class_meter_on_rate_types_attribute_created ( attribute_store_node_t  rate_type_node,
attribute_store_change_t  change 
)
static

Attribute callback function listening for Rate type attribute creations.

It will create a value/precision set of attributes under

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

◆ zwave_command_class_meter_on_supported_rate_types_attribute_update()

static void zwave_command_class_meter_on_supported_rate_types_attribute_update ( attribute_store_node_t  supported_rate_types_node,
attribute_store_change_t  change 
)
static

Attribute callback function listening for Supported Rate types attribute updates.

It will create the list of Rate types under each supported Meter Scale.

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

◆ zwave_command_class_meter_on_supported_scales_attribute_update()

static void zwave_command_class_meter_on_supported_scales_attribute_update ( attribute_store_node_t  supported_scales_node,
attribute_store_change_t  change 
)
static

Attribute callback function listening for Supported scales attribute updates.

It will create the list of scales under the supported Meter Type.

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

◆ zwave_command_class_meter_on_version_attribute_update()

static void zwave_command_class_meter_on_version_attribute_update ( attribute_store_node_t  updated_node,
attribute_store_change_t  change 
)
static

Attribute callback function listening for Meter 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_meter_reset()

static sl_status_t zwave_command_class_meter_reset ( attribute_store_node_t  value_node,
uint8_t *  frame,
uint16_t *  frame_length 
)
static

Prepares a Meter Reset Command.

Parameters
value_nodeAttribute Store node 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_meter_supported_get()

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

Frame resolution function for meter capabilities. Will send a Supported Get to v2 or newer nodes, and a Meter Get to v1 nodes.

Parameters
nodeAttribute Store node 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 call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ default_attributes

const attribute_store_type_t default_attributes[]
static
Initial value:
= {ATTRIBUTE(RESET_SUPPORTED),
ATTRIBUTE(SUPPORTED_SCALES),
ATTRIBUTE(SUPPORTED_RATE_TYPES)}
#define ATTRIBUTE(type)
Definition: zwave_command_class_meter_control.c:40

◆ rate_type_attributes

const attribute_store_type_t rate_type_attributes[] = {ATTRIBUTE(RATE_TYPE)}
static

◆ value_attributes

const attribute_store_type_t value_attributes[] = {ATTRIBUTE(VALUE), ATTRIBUTE(PRECISION)}
static