Skip to content

Thing minimum/maximum #87

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

Closed
gigs2go opened this issue Aug 21, 2019 · 1 comment
Closed

Thing minimum/maximum #87

gigs2go opened this issue Aug 21, 2019 · 1 comment

Comments

@gigs2go
Copy link

gigs2go commented Aug 21, 2019

The current default values (in Thing.h) for minimum and maximum are :

  double minimum = 0;
  double maximum = -1;

In order to check a new value is in range, I put (in ESPWebThingAdapter::setThingProperty):

    case NUMBER: {
      ThingPropertyValue value;
      value.number = newValue.as<double>();
      // Added to account for min/max range - just ignores invalid values
      if ( value.number >= property->minimum && value.number <= property->maximum ) {
          property->setValue(value);
      }
      break;
    }

I believe the default values for min/max should be :

  double minimum = -DBL_MAX;
  double maximum = DBL_MAX;

so the above logic will work even if the values are not set explicitly.

@mrstegeman
Copy link
Contributor

It seems like the code which uses the library should be the one validating the value before setting it, since it is also that code which is defining the min/max.

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

No branches or pull requests

2 participants