Modified range checks so that "NAN" gets picked up as error for FLOAT Characteristics
This commit is contained in:
parent
ba240ea4d7
commit
b5dcfbbd7d
|
|
@ -912,7 +912,7 @@ void Span::processSerialCommand(const char *c){
|
||||||
if((*chr)->setValidValuesError)
|
if((*chr)->setValidValuesError)
|
||||||
LOG0(" *** WARNING #%d! Attempt to set Custom Valid Values for this Characteristic ignored ***\n",++nWarnings);
|
LOG0(" *** WARNING #%d! Attempt to set Custom Valid Values for this Characteristic ignored ***\n",++nWarnings);
|
||||||
|
|
||||||
if((*chr)->format!=STRING && ((*chr)->uvGet<double>((*chr)->value) < (*chr)->uvGet<double>((*chr)->minValue) || (*chr)->uvGet<double>((*chr)->value) > (*chr)->uvGet<double>((*chr)->maxValue)))
|
if((*chr)->format!=STRING && (!(((*chr)->uvGet<double>((*chr)->value) >= (*chr)->uvGet<double>((*chr)->minValue)) && ((*chr)->uvGet<double>((*chr)->value) <= (*chr)->uvGet<double>((*chr)->maxValue)))))
|
||||||
LOG0(" *** WARNING #%d! Value of %g is out of range [%g,%g] ***\n",++nWarnings,(*chr)->uvGet<double>((*chr)->value),(*chr)->uvGet<double>((*chr)->minValue),(*chr)->uvGet<double>((*chr)->maxValue));
|
LOG0(" *** WARNING #%d! Value of %g is out of range [%g,%g] ***\n",++nWarnings,(*chr)->uvGet<double>((*chr)->value),(*chr)->uvGet<double>((*chr)->minValue),(*chr)->uvGet<double>((*chr)->maxValue));
|
||||||
|
|
||||||
} // Characteristics
|
} // Characteristics
|
||||||
|
|
|
||||||
|
|
@ -740,7 +740,7 @@ class SpanCharacteristic{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(val < uvGet<T>(minValue) || val > uvGet<T>(maxValue)){
|
if(!((val >= uvGet<T>(minValue)) && (val <= uvGet<T>(maxValue)))){
|
||||||
LOG0("\n*** WARNING: Attempt to update Characteristic::%s with setVal(%g) is out of range [%g,%g]. This may cause device to become non-responsive!\n\n",
|
LOG0("\n*** WARNING: Attempt to update Characteristic::%s with setVal(%g) is out of range [%g,%g]. This may cause device to become non-responsive!\n\n",
|
||||||
hapName,(double)val,uvGet<double>(minValue),uvGet<double>(maxValue));
|
hapName,(double)val,uvGet<double>(minValue),uvGet<double>(maxValue));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,8 @@
|
||||||
|
|
||||||
#define MAX_LIGHTS 2
|
#define MAX_LIGHTS 2
|
||||||
|
|
||||||
|
SpanCharacteristic *brightness[2];
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
|
@ -50,11 +52,14 @@ void setup() {
|
||||||
sprintf(c,"Light-%d",i);
|
sprintf(c,"Light-%d",i);
|
||||||
new Characteristic::Name(c);
|
new Characteristic::Name(c);
|
||||||
new Service::LightBulb();
|
new Service::LightBulb();
|
||||||
new Characteristic::On(0,false);
|
new Characteristic::On(0,true);
|
||||||
|
brightness[i]=new Characteristic::Saturation(0,true);
|
||||||
WEBLOG("Configuring %s\n",c);
|
WEBLOG("Configuring %s\n",c);
|
||||||
}
|
}
|
||||||
|
|
||||||
new SpanUserCommand('w', " - get web log test",webLogTest); // simulate getting an HTTPS request for weblog
|
new SpanUserCommand('w', " - get web log test",webLogTest); // simulate getting an HTTPS request for weblog
|
||||||
|
new SpanUserCommand('b', " - change brightness to fraction",[](const char *buf){brightness[0]->setVal(atof(buf+1));}); // simulate getting an HTTPS request for weblog
|
||||||
|
new SpanUserCommand('c', " - change brightness to fraction",[](const char *buf){brightness[1]->setVal(atof(buf+1));}); // simulate getting an HTTPS request for weblog
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue