Added check to throw error is setRange is called twice on same Characteristic

This commit is contained in:
Gregg 2021-03-06 08:30:09 -06:00
parent 7e3d982ee5
commit 3b40aeec74
2 changed files with 8 additions and 1 deletions

View File

@ -70,6 +70,8 @@ struct DEV_AirQualitySensor : Service::AirQualitySensor { // A standalone Ai
airQuality=new Characteristic::AirQuality(1); // instantiate the Air Quality Characteristic and set initial value to 1
o3Density=new Characteristic::OzoneDensity(300.0); // instantiate the Ozone Density Characteristic and set initial value to 300.0
no2Density=new Characteristic::NitrogenDioxideDensity(700.0); // instantiate the Nitrogen Dioxide Density Characteristic and set initial value to 700.0
new SpanRange(300,500,2);
Serial.print("Configuring Air Quality Sensor"); // initialization message
Serial.print("\n");

View File

@ -342,7 +342,12 @@ struct SpanCharacteristic{
template <typename A, typename B, typename S=int> SpanCharacteristic *setRange(A min, B max, S step=0){
char c[256];
homeSpan.configLog+=String("------>Set Range for ") + String(hapName) + "-" + String(iid);
homeSpan.configLog+=String("------>Set Range for ") + String(hapName) + "-" + String(iid);
if(customRange){
sprintf(c," *** ERROR! Range already set for this Characteristic! ***\n");
homeSpan.nFatalErrors++;
} else
if(staticRange){
sprintf(c," *** ERROR! Can't change range for this Characteristic! ***\n");