From 9ee6e11ca5dc8426b70fa6331dedd32e6a2b14a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cornelius=20K=C3=B6pp?= Date: Sat, 2 Nov 2024 23:31:08 +0100 Subject: [PATCH] (Prepare for devel) Fix: Do NOT Send when Updating KO Failed on Value Conversion --- src/knx/group_object/group_object.h | 30 +++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/src/knx/group_object/group_object.h b/src/knx/group_object/group_object.h index 7acce23..b460c09 100644 --- a/src/knx/group_object/group_object.h +++ b/src/knx/group_object/group_object.h @@ -478,14 +478,29 @@ namespace Knx ComFlag _commFlag : 7; uint8_t* _data = 0; uint8_t _dataLength = 0; + + /** + * set the current value of the group object and show success. + * @param value the value the group object is set to + * @param type the datapoint type used for the conversion. + * + * The parameters must fit the group object. Otherwise it will stay unchanged. + * + * @returns true if the value of the group object was updated after successful conversion. + */ + template bool _valueNoSend(const DPT& value); + }; bool operator==(const GroupObject& lhs, const GroupObject& rhs); template void GroupObject::value(const DPT& value) { - valueNoSend(value); - objectWritten(); + if (_valueNoSend(value)) + { + // write on successful conversion/setting value only + objectWritten(); + } } template DPT GroupObject::value() @@ -508,6 +523,12 @@ namespace Knx } template void GroupObject::valueNoSend(const DPT& value) + { + // ignore actual updating TODO check replacing valueNoSend with _valueNoSend + _valueNoSend(value); + } + + template bool GroupObject::_valueNoSend(const KNXValue& value) { if (value.size() != sizeCode()) return; @@ -518,6 +539,8 @@ namespace Knx // initialize on succesful conversion only if (encodingDone && _uninitialized) commFlag(Ok); + + return encodingDone; } template bool GroupObject::valueNoSendCompare(const DPT& value) @@ -528,8 +551,7 @@ namespace Knx if (_uninitialized) { // always set first value - this->valueNoSend(value); - return true; + return _valueNoSend(value); } else {