Changed ERROR to WARNING when a required Characteristic is missing

Only throw a non-fatal warning instead of a fatal error if a Service is missing a required Characteristic.  This allows for user flexibility in leaving out required Characteristics for Services that don't seem to need them (contrary to the HAP docs).

Also, changed PositionState Characteristic back to Required (instead of Optional) in WindowCovering Service (as specified by HAP).  If PositionState is not included this will only throw an error instead of a warning as a result of the above change.

To Do: Update Example 13 to properly incorporate PositionState Characteristic.
This commit is contained in:
Gregg 2021-03-09 20:33:54 -06:00
parent da74066c70
commit 8121146c6b
2 changed files with 4 additions and 5 deletions

View File

@ -501,7 +501,7 @@ void Span::checkConnect(){
Serial.print("\nAuthorization Password: "); Serial.print("\nAuthorization Password: ");
Serial.print(otaAuth?"Enabled\n\n":"DISABLED!\n\n"); Serial.print(otaAuth?"Enabled\n\n":"DISABLED!\n\n");
} else { } else {
Serial.print("\n*** Warning: Can't start OTA Server - Partition table used to compile this sketch is not configured for OTA.\n\n"); Serial.print("\n*** WARNING: Can't start OTA Server - Partition table used to compile this sketch is not configured for OTA.\n\n");
} }
} }
@ -1316,7 +1316,7 @@ void SpanAccessory::validate(){
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))){
char c[256]; 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", 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)); chr->uvGet<double>(chr->value),chr->hapName,chr->iid,chr->uvGet<double>(chr->minValue),chr->uvGet<double>(chr->maxValue));
homeSpan.configLog+=c; homeSpan.configLog+=c;
} }
@ -1456,8 +1456,7 @@ void SpanService::validate(){
if(!valid){ if(!valid){
homeSpan.configLog+=" !Characteristic " + String(req[i]->hapName); homeSpan.configLog+=" !Characteristic " + String(req[i]->hapName);
homeSpan.configLog+=" *** ERROR! Required Characteristic for this Service not found. ***\n"; homeSpan.configLog+=" *** WARNING! Required Characteristic for this Service not found. ***\n";
homeSpan.nFatalErrors++;
} }
} }
} }

View File

@ -365,7 +365,7 @@ namespace Service {
struct WindowCovering : SpanService { WindowCovering() : SpanService{"8C","WindowCovering"}{ struct WindowCovering : SpanService { WindowCovering() : SpanService{"8C","WindowCovering"}{
REQ(TargetPosition); REQ(TargetPosition);
REQ(CurrentPosition); REQ(CurrentPosition);
OPT(PositionState); REQ(PositionState);
OPT(Name); OPT(Name);
OPT(HoldPosition); OPT(HoldPosition);
OPT(CurrentHorizontalTiltAngle); OPT(CurrentHorizontalTiltAngle);