Fix: Do NOT Send when Updating KO Failed on Value Conversion

This commit is contained in:
Cornelius Köpp 2024-11-01 20:44:51 +01:00
parent 483d868dac
commit b8f914c358
2 changed files with 26 additions and 4 deletions

View File

@ -226,8 +226,11 @@ GroupObjectUpdatedHandler GroupObject::callback()
void GroupObject::value(const KNXValue& value, const Dpt& type)
{
valueNoSend(value, type);
if (_valueNoSend(value, type))
{
// write on successful conversion/setting value only
objectWritten();
}
}
@ -281,12 +284,20 @@ void GroupObject::valueNoSend(const KNXValue& value)
#endif
void GroupObject::valueNoSend(const KNXValue& value, const Dpt& type)
{
// ignore actual updating TODO check replacing valueNoSend with _valueNoSend
_valueNoSend(value, type);
}
bool GroupObject::_valueNoSend(const KNXValue& value, const Dpt& type)
{
const bool encodingDone = KNX_Encode_Value(value, _data, _dataLength, type);
// initialize on succesful conversion only
if (encodingDone && _commFlagEx.uninitialized)
commFlag(Ok);
return encodingDone;
}
bool GroupObject::valueNoSendCompare(const KNXValue& value, const Dpt& type)
@ -294,8 +305,7 @@ bool GroupObject::valueNoSendCompare(const KNXValue& value, const Dpt& type)
if (_commFlagEx.uninitialized)
{
// always set first value
this->valueNoSend(value, type);
return true;
return _valueNoSend(value, type);
}
else
{

View File

@ -284,4 +284,16 @@ class GroupObject
GroupObjectUpdatedHandler _updateHandler;
Dpt _datapointType;
#endif
/**
* 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.
*/
bool _valueNoSend(const KNXValue& value, const Dpt& type);
};