Skip to content

Commit

Permalink
Fix: Do NOT Send when Updating KO Failed on Value Conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
cornelius-koepp committed Nov 1, 2024
1 parent 483d868 commit b8f914c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/knx/group_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,11 @@ GroupObjectUpdatedHandler GroupObject::callback()

void GroupObject::value(const KNXValue& value, const Dpt& type)
{
valueNoSend(value, type);
objectWritten();
if (_valueNoSend(value, type))
{
// write on successful conversion/setting value only
objectWritten();
}
}


Expand Down Expand Up @@ -281,21 +284,28 @@ 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)
{
if (_commFlagEx.uninitialized)
{
// always set first value
this->valueNoSend(value, type);
return true;
return _valueNoSend(value, type);
}
else
{
Expand Down
12 changes: 12 additions & 0 deletions src/knx/group_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

};

0 comments on commit b8f914c

Please sign in to comment.