Z-Wave Protocol Controller Reference
zwave_command_classes_utils.h
Go to the documentation of this file.
1/******************************************************************************
2 * # License
3 * <b>Copyright 2021 Silicon Laboratories Inc. www.silabs.com</b>
4 ******************************************************************************
5 * The licensor of this software is Silicon Laboratories Inc. Your use of this
6 * software is governed by the terms of Silicon Labs Master Software License
7 * Agreement (MSLA) available at
8 * www.silabs.com/about-us/legal/master-software-license-agreement. This
9 * software is distributed to you in Source Code format and is governed by the
10 * sections of the MSLA applicable to Source Code.
11 *
12 *****************************************************************************/
13
14#ifndef ZWAVE_COMMAND_CLASSES_UTILS_H
15#define ZWAVE_COMMAND_CLASSES_UTILS_H
16
17// Generic includes
18#include <stdbool.h>
19#include <string.h>
20
21// Unify includes
22#include "sl_status.h"
24#include "zwave_generic_types.h"
25#include "attribute_store.h"
26#include "zwave_utils.h"
27
28// ZPC includes
31
32// Interfaces
33#include "zwave_generic_types.h"
34
35// Contiki timing includes
36#include "clock.h"
37
38// Value to set in a 8-bits reserved field
39#define RESERVED_BYTE 0x00
40
53typedef struct zwave_minimum_frame {
55 uint8_t command;
57
58// Helper macros
59#define FAHRENHEIT_TO_DEGREES(value) ((value - 32.0) * 5 / 9);
60#define DEGREES_TO_FAHRENHEIT(value) (value * 9 / 5.0) + 32;
61
62// Constants
65#define PROBE_BACK_OFF 500
66
67#ifdef __cplusplus
68extern "C" {
69#endif
70
78attribute_store_node_t zwave_command_class_get_endpoint_node(
79 const zwave_controller_connection_info_t *connection_info);
80
88attribute_store_node_t zwave_command_class_get_node_id_node(
89 const zwave_controller_connection_info_t *connection_info);
90
100 attribute_store_node_t node, zwave_command_class_t command_class);
101
109bool has_reports_to_follow(attribute_store_node_t node);
110
118reports_to_follow_t get_reports_to_follow(attribute_store_node_t node);
119
130sl_status_t set_reports_to_follow(attribute_store_node_t node,
131 reports_to_follow_t reports_to_follow);
132
140void set_command_status_value(attribute_store_node_t command_status_node,
143
154 const zwave_controller_connection_info_t *connection_info,
155 const uint16_t report_size,
156 const uint8_t *const report_data);
157
170 zwave_command_class_t command_class, attribute_store_node_t updated_node);
171
181 const zwave_controller_connection_info_t *connection);
182
192int32_t command_class_get_int32_value(uint8_t size,
193 uint8_t precision,
194 const uint8_t *value);
195
204int32_t get_signed_value_from_frame_and_size(const uint8_t *frame,
205 uint8_t size);
206
215uint32_t get_unsigned_value_from_frame_and_size(const uint8_t *frame,
216 uint8_t size);
217
227int16_t zwave_temperature_to_ucl_temperature(int32_t zwave_value,
228 uint8_t zwave_precision,
229 uint8_t zwave_scale);
230
240int32_t ucl_temperature_to_zwave_temperature(int16_t ucl_value,
241 uint8_t zwave_precision,
242 uint8_t zwave_scale);
253 uint8_t time_to_zwave_duration(clock_time_t time);
254
265clock_time_t zwave_duration_to_time(uint8_t zwave_duration);
266
275
284
292bool is_portable_end_node(attribute_store_node_t node);
293
294#ifdef __cplusplus
295}
296#endif
297
300#endif // ZWAVE_COMMAND_CLASSES_UTILS_H
zwave_cc_version_t zwave_command_class_get_version_from_node(attribute_store_node_t node, zwave_command_class_t command_class)
Find the version of the command class by navigating up to the endpoint from a given attribute store n...
Definition: zwave_command_classes_utils.c:73
attribute_store_node_t zwave_command_class_get_node_id_node(const zwave_controller_connection_info_t *connection_info)
Find the Z-Wave NodeID Node attribute based on a const zwave_controller_connection_info_t object.
Definition: zwave_command_classes_utils.c:58
uint32_t get_unsigned_value_from_frame_and_size(const uint8_t *frame, uint8_t size)
Extracts a 1,2 or 4 bytes unsigned value from a frame.
Definition: zwave_command_classes_utils.c:313
int32_t get_signed_value_from_frame_and_size(const uint8_t *frame, uint8_t size)
Extracts a 1,2 or 4 bytes signed value from a frame.
Definition: zwave_command_classes_utils.c:301
reports_to_follow_t get_reports_to_follow(attribute_store_node_t node)
Gets the number of Reports to Follow for a node.
Definition: zwave_command_classes_utils.c:105
bool is_portable_end_node(attribute_store_node_t node)
Verifies if a Node is a Portable End Node. (PS / PEN Role type)
Definition: zwave_command_classes_utils.c:270
uint8_t time_to_zwave_duration(clock_time_t time)
Converts a clock_time_t duration to a Z-Wave Command Class duration byte.
Definition: zwave_command_classes_utils.c:371
sl_status_t zwave_command_class_send_report(const zwave_controller_connection_info_t *connection_info, const uint16_t report_size, const uint8_t *const report_data)
function to send report frames with default tx options.
Definition: zwave_command_classes_utils.c:148
bool is_using_zpc_highest_security_class(const zwave_controller_connection_info_t *connection)
function helper function that determines if a transmission was done using the ZPC's highest security ...
Definition: zwave_command_classes_utils.c:217
void set_command_status_value(attribute_store_node_t command_status_node, command_status_values_t reported, command_status_values_t desired)
Set the desired and reported value of a command_status_t type of node.
Definition: zwave_command_classes_utils.c:133
int16_t zwave_temperature_to_ucl_temperature(int32_t zwave_value, uint8_t zwave_precision, uint8_t zwave_scale)
Convert a value from the Z-Wave world (precision = [0..7] and C° + F) into a UCL (Zigbee) world (prec...
Definition: zwave_command_classes_utils.c:325
bool has_reports_to_follow(attribute_store_node_t node)
Verifies if a node has some Reports to Follow.
Definition: zwave_command_classes_utils.c:94
int32_t command_class_get_int32_value(uint8_t size, uint8_t precision, const uint8_t *value)
Parse a value and pack it into a uint32.
Definition: zwave_command_classes_utils.c:285
bool is_zwave_command_class_filtered_for_root_device(zwave_command_class_t command_class, attribute_store_node_t updated_node)
function helper function to help Command Classes decide if they should create the supporting node att...
Definition: zwave_command_classes_utils.c:174
int32_t ucl_temperature_to_zwave_temperature(int16_t ucl_value, uint8_t zwave_precision, uint8_t zwave_scale)
Convert a value from the UCL world (Zigbee) (precision = 2 and C°) to the ZWave world (precision = [0...
Definition: zwave_command_classes_utils.c:349
struct zwave_minimum_frame zwave_minimum_frame_t
‍Minimal Z-Wave Frame that can be sent (Command Class / Command).
clock_time_t zwave_duration_to_time(uint8_t zwave_duration)
Converts a duration byte encoded for a Z-Wave command class and returns its corresponding value in cl...
Definition: zwave_command_classes_utils.c:384
bool is_actuator_command_class(zwave_command_class_t command_class)
Verifies if a Command Class is an actuator Command Class.
Definition: zwave_command_classes_utils.c:231
sl_status_t set_reports_to_follow(attribute_store_node_t node, reports_to_follow_t reports_to_follow)
Places a ATTRIBUTE_REPORTS_TO_FOLLOW attribute under an attribute if it does not exist and set it to ...
Definition: zwave_command_classes_utils.c:116
zwave_role_type_t get_zwave_node_role_type(zwave_node_id_t node_id)
Provides the Role Type of a node.
Definition: zwave_command_classes_utils.c:251
attribute_store_node_t zwave_command_class_get_endpoint_node(const zwave_controller_connection_info_t *connection_info)
Find the Z-Wave Endpoint ID Node attribute based on a const zwave_controller_connection_info_t object...
Definition: zwave_command_classes_utils.c:42
uint32_t sl_status_t
Definition: sl_status.h:139
uint8_t reports_to_follow_t
Definition: zwave_command_class_generic_types.h:29
command_status_values_t
Definition: zwave_command_class_generic_types.h:36
uint8_t zwave_cc_version_t
‍Version of a Z-Wave Command Class
Definition: zwave_command_class_version_types.h:26
enum zwave_role_type zwave_role_type_t
Z-Wave Plus Role Type.
uint16_t zwave_command_class_t
Definition: zwave_generic_types.h:29
uint16_t zwave_node_id_t
Z-Wave NodeID type.
Definition: zwave_node_id_definitions.h:84
SL Status Codes.
Structure holding information about the source and destination when transmitting and receiving Z-Wave...
Definition: zwave_controller_connection_info.h:87
‍Minimal Z-Wave Frame that can be sent (Command Class / Command).
Definition: zwave_command_classes_utils.h:53
uint8_t command_class
Definition: zwave_command_classes_utils.h:54
uint8_t command
Definition: zwave_command_classes_utils.h:55
const zwave_node_id_t node_id
Various Z-Wave related utilities.