diff --git a/src/knx/group_object.cpp b/src/knx/group_object.cpp index 6898ba5..432dfd6 100644 --- a/src/knx/group_object.cpp +++ b/src/knx/group_object.cpp @@ -279,3 +279,18 @@ void GroupObject::valueNoSend(const KNXValue& value, const Dpt& type) KNX_Encode_Value(value, _data, _dataLength, type); } + +void GroupObject::valueSendChangedOnly(const KNXValue& value, const Dpt& type) +{ + // save current value + const uint8_t oldLength = _dataLength; + uint8_t* old = new uint8_t[_dataLength]; + memcpy(old, _data, oldLength); + + // update value in com-object, without sending to bus + valueNoSend(value, type); + + // only when raw data differs trigger sending + if (oldLength!=_dataLength || memcmp(old, _data, oldLength)!=0) + objectWritten(); +} \ No newline at end of file diff --git a/src/knx/group_object.h b/src/knx/group_object.h index 88ce274..657446f 100644 --- a/src/knx/group_object.h +++ b/src/knx/group_object.h @@ -166,6 +166,16 @@ class GroupObject * The parameters must fit the group object. Otherwise it will stay unchanged. */ void valueNoSend(const KNXValue& value, const Dpt& type); + + /** + * set the current value of the group object and only when resulting value differes, changes the state of the group object to ::WriteRequest. + * @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. + */ + void valueSendChangedOnly(const KNXValue& value, const Dpt& type); + /** * set the current value of the group object. * @param value the value the group object is set to