From 9a7b6a5e80b87df50451d7d5a17933f0465ad3c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cornelius=20K=C3=B6pp?= Date: Fri, 1 Nov 2024 19:28:25 +0100 Subject: [PATCH] Fix `valueNoSendCompare`: DPT Conversion Fail Resulted in Setting KO to 0 --- src/knx/group_object.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/knx/group_object.cpp b/src/knx/group_object.cpp index 5a9ad28..d600bdc 100644 --- a/src/knx/group_object.cpp +++ b/src/knx/group_object.cpp @@ -301,7 +301,13 @@ bool GroupObject::valueNoSendCompare(const KNXValue& value, const Dpt& type) // convert new value to given dtp uint8_t newData[_dataLength]; memset(newData, 0, _dataLength); - KNX_Encode_Value(value, newData, _dataLength, type); + const bool encodingDone = KNX_Encode_Value(value, newData, _dataLength, type); + if (!encodingDone) + { + // value conversion to DPT failed + // do NOT update the value of the KO! + return false; + } // check for change in converted value / update value on change only const bool dataChanged = memcmp(_data, newData, _dataLength);