Added check to ensure initial value of Characteristic is in allowable Range
Check is not applied to STRING Characteristics. Check is performed at end of each Accessory definition so will account for any changes to min/max as a result of calls to setRange(). If initial value is outside allowable range, a WARNING (not an ERROR) is thrown.
This commit is contained in:
parent
3b40aeec74
commit
ff0dfefc47
|
|
@ -15,7 +15,7 @@ struct DEV_TempSensor : Service::TemperatureSensor { // A standalone Tempera
|
|||
// Though the HAP documentation includes a Characteristic that appears to allow the device to over-ride this setting by specifying a display
|
||||
// of Celsius or Fahrenheit for each Service, it does not appear to work as advertised.
|
||||
|
||||
temp=new Characteristic::CurrentTemperature(30.0); // instantiate the Current Temperature Characteristic
|
||||
temp=new Characteristic::CurrentTemperature(-10.0); // instantiate the Current Temperature Characteristic
|
||||
temp->setRange(-50,100); // expand the range from the HAP default of 0-100 to -50 to 100 to allow for negative temperatures
|
||||
|
||||
Serial.print("Configuring Temperature Sensor"); // initialization message
|
||||
|
|
@ -70,8 +70,6 @@ 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");
|
||||
|
|
|
|||
|
|
@ -1310,6 +1310,17 @@ void SpanAccessory::validate(){
|
|||
foundProtocol=true;
|
||||
else if(aid==1) // this is an Accessory with aid=1, but it has more than just AccessoryInfo and HAPProtocolInformation. So...
|
||||
homeSpan.isBridge=false; // ...this is not a bridge device
|
||||
|
||||
for(int j=0;j<Services[i]->Characteristics.size();j++){ // check that initial values are all in range of mix/max (which may have been modified by setRange)
|
||||
SpanCharacteristic *chr=Services[i]->Characteristics[j];
|
||||
|
||||
if(chr->format!=STRING && (chr->uvGet<double>(chr->value) < chr->uvGet<double>(chr->minValue) || chr->uvGet<double>(chr->value) > chr->uvGet<double>(chr->maxValue))){
|
||||
char c[256];
|
||||
sprintf(c," !Warning: Initial value of %lg for %s-%d is out of range [%llg,%llg]. This may cause device to be non-reponsive!\n",
|
||||
chr->uvGet<double>(chr->value),chr->hapName,chr->iid,chr->uvGet<double>(chr->minValue),chr->uvGet<double>(chr->maxValue));
|
||||
homeSpan.configLog+=c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!foundInfo){
|
||||
|
|
|
|||
Loading…
Reference in New Issue