From 8121146c6b7c2f269b3474d3bec07c49f6205db4 Mon Sep 17 00:00:00 2001 From: Gregg Date: Tue, 9 Mar 2021 20:33:54 -0600 Subject: [PATCH] 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. --- src/HomeSpan.cpp | 7 +++---- src/Span.h | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/HomeSpan.cpp b/src/HomeSpan.cpp index ccea28d..c7f6d77 100644 --- a/src/HomeSpan.cpp +++ b/src/HomeSpan.cpp @@ -501,7 +501,7 @@ void Span::checkConnect(){ Serial.print("\nAuthorization Password: "); Serial.print(otaAuth?"Enabled\n\n":"DISABLED!\n\n"); } 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(chr->value) < chr->uvGet(chr->minValue) || chr->uvGet(chr->value) > chr->uvGet(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", + 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(chr->value),chr->hapName,chr->iid,chr->uvGet(chr->minValue),chr->uvGet(chr->maxValue)); homeSpan.configLog+=c; } @@ -1456,8 +1456,7 @@ void SpanService::validate(){ if(!valid){ homeSpan.configLog+=" !Characteristic " + String(req[i]->hapName); - homeSpan.configLog+=" *** ERROR! Required Characteristic for this Service not found. ***\n"; - homeSpan.nFatalErrors++; + homeSpan.configLog+=" *** WARNING! Required Characteristic for this Service not found. ***\n"; } } } diff --git a/src/Span.h b/src/Span.h index 7069572..f8eb3ce 100644 --- a/src/Span.h +++ b/src/Span.h @@ -365,7 +365,7 @@ namespace Service { struct WindowCovering : SpanService { WindowCovering() : SpanService{"8C","WindowCovering"}{ REQ(TargetPosition); REQ(CurrentPosition); - OPT(PositionState); + REQ(PositionState); OPT(Name); OPT(HoldPosition); OPT(CurrentHorizontalTiltAngle);