Skip to content

Commit db3a8e6

Browse files
nkljajicNenad Kljajic
authored andcommitted
SiliconLabsGH-20: Fix support for COMMAND_CLASS_METER V1,V2 & V3
Fixes bug where Attribute [0x3208] Value can not get resolved for legacy devices. Size of ZW_METER_GET_V3_FRAME is smaller than size of ZW_METER_GET_V5_FRAME. Legacy device supporting COMMAND_CLASS_METER_V3 and below will ignore received V5 frames, because frame size is larger than expected. Signed-off-by: Nenad Kljajic <nkljajic@control4.com>
1 parent 5ad3615 commit db3a8e6

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

applications/zpc/components/zwave_command_classes/src/zwave_command_class_meter_control.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,13 +205,21 @@ static sl_status_t zwave_command_class_meter_get(attribute_store_node_t node,
205205
attribute_store_node_t scale_node
206206
= attribute_store_get_first_parent_with_type(rate_type_node,
207207
ATTRIBUTE(SCALE));
208+
zwave_cc_version_t supporting_node_version
209+
= zwave_command_class_get_version_from_node(node, COMMAND_CLASS_METER);
210+
208211
meter_scale_t scale = 0;
209212
attribute_store_get_reported(scale_node, &scale, sizeof(scale));
210213

211214
ZW_METER_GET_V5_FRAME *get_frame = (ZW_METER_GET_V5_FRAME *)frame;
212215
get_frame->cmdClass = COMMAND_CLASS_METER_V6;
213216
get_frame->cmd = METER_GET;
214217

218+
if (supporting_node_version == 1) {
219+
*frame_length = sizeof(ZW_METER_GET_FRAME);
220+
return SL_STATUS_OK;
221+
}
222+
215223
// Insert the rate type into the frame:
216224
get_frame->properties1 = (uint8_t)(rate_type << 6);
217225
if (scale < 7) {
@@ -222,6 +230,11 @@ static sl_status_t zwave_command_class_meter_get(attribute_store_node_t node,
222230
get_frame->scale2 = (uint8_t)(scale - 8);
223231
}
224232

233+
if (supporting_node_version <= 3) {
234+
*frame_length = sizeof(ZW_METER_GET_V3_FRAME);
235+
return SL_STATUS_OK;
236+
}
237+
225238
*frame_length = sizeof(ZW_METER_GET_V5_FRAME);
226239
return SL_STATUS_OK;
227240
}
@@ -244,12 +257,10 @@ static sl_status_t zwave_command_class_meter_supported_get(
244257
= zwave_command_class_get_version_from_node(node, COMMAND_CLASS_METER);
245258

246259
if (supporting_node_version == 1) {
247-
ZW_METER_GET_V5_FRAME *get_frame = (ZW_METER_GET_V5_FRAME *)frame;
248-
get_frame->cmdClass = COMMAND_CLASS_METER_V6;
260+
ZW_METER_GET_FRAME *get_frame = (ZW_METER_GET_FRAME *)frame;
261+
get_frame->cmdClass = COMMAND_CLASS_METER;
249262
get_frame->cmd = METER_GET;
250-
get_frame->properties1 = 0;
251-
get_frame->scale2 = 0;
252-
*frame_length = sizeof(ZW_METER_GET_V5_FRAME);
263+
*frame_length = sizeof(ZW_METER_GET_FRAME);
253264
return SL_STATUS_OK;
254265
}
255266

0 commit comments

Comments
 (0)