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

property won't set if it is read only. #156

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

fatmehosseini
Copy link

Hi,
I noticed that read only parameter is not used. If a user put value to a read only property it will be accepted.
Also about integer and number properties if the put property be less than minimum or more than maximum the server wouldn't care and accept the new value for the property.
I made some changes to prevent accept new value in mentioned case.

Thing.h Outdated
@@ -360,6 +360,10 @@ class ThingProperty : public ThingItem {
callback(newValue);
}
}
bool isInRange(ThingDataValue value){
return (this->maximum < this->minimum) //to check if minimum and maximum values are asigned
|| (this->maximum > value.)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why dot in value. ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is isInRange used ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, at first I was going to handle the process of validation the range in a function then decide to do it directly but forget to delete the function. this function is not used and should delete.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should I just create another pull request?

@rzr
Copy link
Collaborator

rzr commented Jun 23, 2023

It looks like commit message and code differ

@rzr
Copy link
Collaborator

rzr commented Jun 23, 2023

@rzr
Copy link
Collaborator

rzr commented Jun 24, 2023

what about read only test ?

@fatmehosseini
Copy link
Author

what about read only test ?
in thing.h file in line 585 and 856 in setProperty() function it will be checked.

@@ -578,7 +582,8 @@ class ThingDevice {

void setProperty(const char *name, const JsonVariant &newValue) {
ThingProperty *property = findProperty(name);

if(property->readOnly)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good!

@rzr
Copy link
Collaborator

rzr commented Jun 28, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants