From 82215e8d9065b5d23e38cdebe5ff43837fa9ec66 Mon Sep 17 00:00:00 2001 From: Gregg Date: Sun, 4 Oct 2020 09:58:40 -0500 Subject: [PATCH] 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. --- src/HomeSpan.cpp | 2 +- src/HomeSpan.h | 3 ++- src/Services.h | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/HomeSpan.cpp b/src/HomeSpan.cpp index a013b9a..2912eab 100644 --- a/src/HomeSpan.cpp +++ b/src/HomeSpan.cpp @@ -960,7 +960,7 @@ int SpanAccessory::sprintfAttributes(char *cBuf){ // 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->hapName=hapName; diff --git a/src/HomeSpan.h b/src/HomeSpan.h index c761b03..4acdf3c 100644 --- a/src/HomeSpan.h +++ b/src/HomeSpan.h @@ -127,7 +127,8 @@ struct SpanService{ boolean primary=false; // optional property indicating service is primary vector 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 *setHidden(); // sets the Service Type to be hidden and returns pointer to self diff --git a/src/Services.h b/src/Services.h index dd6290d..dfb404d 100644 --- a/src/Services.h +++ b/src/Services.h @@ -5,11 +5,11 @@ 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"}{} };