Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add function to group object to send a value only if it was changed. #23

Merged
merged 1 commit into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/knx/group_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,4 +310,14 @@ bool GroupObject::valueNoSendCompare(const KNXValue& value, const Dpt& type)

return dataChanged;
}
}

bool GroupObject::valueCompare(const KNXValue& value, const Dpt& type)
{
if (valueNoSendCompare(value, type))
{
objectWritten();
return true;
}
return false;
}
13 changes: 13 additions & 0 deletions src/knx/group_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,19 @@ class GroupObject
* The parameters must fit the group object. Otherwise it will stay unchanged.
*/
void value(const KNXValue& value, const Dpt& type);

/**
* Check if the value (after conversion to dpt) will differ from current value of the group object and changes the state of the group object to ::WriteRequest if different.
* Use this method only, when the value should not be sent if it was not changed, otherwise value(const KNXValue&, const Dpt&) will do the same (without overhead for comparing)
* @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 has changed
*/
bool valueCompare(const KNXValue& value, const Dpt& type);

/**
* set the current value of the group object.
* @param value the value the group object is set to
Expand Down
Loading