Skip to content

Commit

Permalink
Merge branch 'fix/group-object-setting-invalid-value' into fix/group-…
Browse files Browse the repository at this point in the history
…object-setting-invalid-value--thelsing/master

# Conflicts:
#	src/knx/group_object.h
  • Loading branch information
cornelius-koepp committed Nov 17, 2024
2 parents a5d5b70 + 1cb2d56 commit 73d4a6c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 33 deletions.
24 changes: 10 additions & 14 deletions src/knx/group_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,15 @@ GroupObjectUpdatedHandler GroupObject::callback()
}
#endif

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


Expand Down Expand Up @@ -283,9 +285,9 @@ bool GroupObject::tryValue(KNXValue& value)
}


void GroupObject::value(const KNXValue& value)
bool GroupObject::value(const KNXValue& value)
{
this->value(value, _datapointType);
return this->value(value, _datapointType);
}


Expand All @@ -295,19 +297,13 @@ KNXValue GroupObject::value()
}


void GroupObject::valueNoSend(const KNXValue& value)
bool GroupObject::valueNoSend(const KNXValue& value)
{
valueNoSend(value, _datapointType);
return valueNoSend(value, _datapointType);
}
#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)
bool GroupObject::valueNoSend(const KNXValue& value, const Dpt& type)
{
const bool encodingDone = KNX_Encode_Value(value, _data, _dataLength, type);

Expand All @@ -323,7 +319,7 @@ bool GroupObject::valueNoSendCompare(const KNXValue& value, const Dpt& type)
if (_uninitialized)
{
// always set first value
return _valueNoSend(value, type);
return valueNoSend(value, type);
}
else
{
Expand Down
35 changes: 16 additions & 19 deletions src/knx/group_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,10 @@ class GroupObject
* @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 was converted successfully to the datapoint type and the group object was updated.
*/
void value(const KNXValue& value, const Dpt& type);
bool 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.
Expand All @@ -173,18 +175,20 @@ class GroupObject
*
* The parameters must fit the group object. Otherwise it will stay unchanged.
*
* @returns true if the value of the group object has changed
* @returns true if the value of the group object has changed, false if conversion results in same value as stored in group object or failed.
*/
bool valueCompare(const KNXValue& value, const Dpt& type);

/**
* set the current value of the group object.
* set the current value of the group objectand 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 value was converted successfully to the datapoint type and the group object was updated.
*/
void valueNoSend(const KNXValue& value, const Dpt& type);
bool valueNoSend(const KNXValue& value, const Dpt& type);

/**
* Check if the value (after conversion to dpt) will differ from current value of the group object and update if necessary.
Expand All @@ -194,7 +198,7 @@ class GroupObject
*
* The parameters must fit the group object. Otherwise it will stay unchanged.
*
* @returns true if the value of the group object has changed
* @returns true if the value of the group object has changed, false if conversion results in same value as stored in group object or failed.
*/
bool valueNoSendCompare(const KNXValue& value, const Dpt& type);

Expand All @@ -220,15 +224,19 @@ class GroupObject
* @param value the value the group object is set to
*
* The parameters must fit the group object and dhe datapoint type must be set with dataPointType(). Otherwise it will stay unchanged.
*
* @returns true if the value was converted successfully to the datapoint type and the group object was updated.
*/
void value(const KNXValue& value);
bool value(const KNXValue& value);
/**
* set the current value of the group object.
* @param value the value the group object is set to
*
* The parameters must fit the group object and dhe datapoint type must be set with dataPointType(). Otherwise it will stay unchanged.
* The parameters must fit the group object and the datapoint type must be set with dataPointType(). Otherwise it will stay unchanged.
*
* @returns true if the value was converted successfully to the datapoint type and the group object was updated.
*/
void valueNoSend(const KNXValue& value);
bool valueNoSend(const KNXValue& value);
/**
* set the current value of the group object.
* @param value the value the group object is set to
Expand Down Expand Up @@ -276,15 +284,4 @@ 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 73d4a6c

Please sign in to comment.