Modified SpanService to accept list of required and optional SpanCharacteristics

Started adding lists to the first few Services in Service.h.  This is a longer-term project to enable HomeSpan to validate a configuration and check that all Services have all required Characteristics and that any optional Characteristics defined are indeed permitted.
This commit is contained in:
Gregg 2020-10-04 09:58:40 -05:00
parent 855d5e9735
commit 82215e8d90
3 changed files with 6 additions and 5 deletions

View File

@ -960,7 +960,7 @@ int SpanAccessory::sprintfAttributes(char *cBuf){
// SpanService // // SpanService //
/////////////////////////////// ///////////////////////////////
SpanService::SpanService(const char *type, const char *hapName){ SpanService::SpanService(const char *type, const char *hapName, char *requiredChars, char *optionalChars){
this->type=type; this->type=type;
this->hapName=hapName; this->hapName=hapName;

View File

@ -127,7 +127,8 @@ struct SpanService{
boolean primary=false; // optional property indicating service is primary boolean primary=false; // optional property indicating service is primary
vector<SpanCharacteristic *> Characteristics; // vector of pointers to all Characteristics in this Service vector<SpanCharacteristic *> Characteristics; // vector of pointers to all Characteristics in this Service
SpanService(const char *type, const char *hapName); SpanService(const char *type, const char *hapName,
char *requiredChars="", char *optionalChars="");
SpanService *setPrimary(); // sets the Service Type to be primary and returns pointer to self SpanService *setPrimary(); // sets the Service Type to be primary and returns pointer to self
SpanService *setHidden(); // sets the Service Type to be hidden and returns pointer to self SpanService *setHidden(); // sets the Service Type to be hidden and returns pointer to self

View File

@ -5,11 +5,11 @@
namespace Service { namespace Service {
struct AccessoryInformation : SpanService { AccessoryInformation() : SpanService{"3E","AccessoryInformation"}{} }; struct AccessoryInformation : SpanService { AccessoryInformation() : SpanService{"3E","AccessoryInformation","52,14,20,21,23,30","53"}{} };
struct AirPurifier : SpanService { AirPurifier() : SpanService{"BB","AirPurifier"}{} }; struct AirPurifier : SpanService { AirPurifier() : SpanService{"BB","AirPurifier","B0,A9,A8","23,29,B6,A7"}{} };
struct AirQualitySensor : SpanService { AirQualitySensor() : SpanService{"8D","AirQualitySensor"}{} }; struct AirQualitySensor : SpanService { AirQualitySensor() : SpanService{"8D","AirQualitySensor","95","23,C3,C4,C5,C6,C7,C8,75,77,7A,79"}{} };
struct BatteryService : SpanService { BatteryService() : SpanService{"96","BatteryService"}{} }; struct BatteryService : SpanService { BatteryService() : SpanService{"96","BatteryService"}{} };