Z-Wave Protocol Controller Reference
zwave_frame_generator.hpp
Go to the documentation of this file.
1/******************************************************************************
2 * # License
3 * <b>Copyright 2024 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
23#ifndef ZWAVE_FRAME_GENERATOR_HPP
24#define ZWAVE_FRAME_GENERATOR_HPP
25
26#ifdef __cplusplus
27
28// Unify includes
29#include "attribute_store.h"
30#include "sl_status.h"
31
32// Cpp includes
33#include <vector>
34
82class zwave_frame_generator
83{
84 public:
93 struct shifted_value {
97 uint8_t left_shift = 0;
101 attribute_store_node_t node = ATTRIBUTE_STORE_INVALID_NODE;
105 attribute_store_node_value_state_t node_value_state = REPORTED_ATTRIBUTE;
109 uint8_t raw_value = 0;
110 };
111
117 explicit zwave_frame_generator(uint8_t zwave_command_class);
118 ~zwave_frame_generator() = default;
119
133 void initialize_frame(uint8_t zwave_command_id,
134 uint8_t *raw_data,
135 uint16_t data_size);
136
142 void add_raw_byte(uint8_t byte);
143
157 void add_value(attribute_store_node_t node,
158 attribute_store_node_value_state_t node_value_state
159 = REPORTED_ATTRIBUTE);
170 void add_shifted_values(const std::vector<shifted_value> &shifted_values);
180 void add_shifted_values(const shifted_value &shifted_values);
181
189 void validate_frame(uint16_t *frame_length) const;
190
203 sl_status_t generate_no_args_frame(uint8_t zwave_command_id,
204 uint8_t *raw_data,
205 uint16_t *frame_length);
206
207 private:
218 std::vector<uint8_t> helper_get_raw_data(
219 attribute_store_node_t node,
220 attribute_store_node_value_state_t node_value_state) const;
221
222 // Current Z-Wave command class used in the header of all generated commands
223 const uint8_t current_command_class;
224 // Vector wrapper around raw frame data. See initialize_frame()
225 uint8_t *current_zwave_frame;
226 // Current Z-Wave frame size
227 uint16_t current_zwave_frame_size = 0;
228 // Current Z-Wave frame index (we use uint16_t to match Unify API)
229 uint16_t current_zwave_frame_index = 0;
230};
231
232#endif // __cplusplus
233#endif // ZWAVE_FRAME_GENERATOR_HPP
uint32_t sl_status_t
Definition: sl_status.h:139
SL Status Codes.