Added check to ensure Custom Characteristic has valid UUID
And also converted ERRORS to WARNINGS when a Characteristic that is not in the REQ or OPT list is specified for a Service. This allows the user to add any Characteristic to any Service without forcing an Error (just a Warning).
This commit is contained in:
parent
61a2be533b
commit
226548defa
|
|
@ -442,9 +442,12 @@ struct SpanCharacteristic{
|
||||||
uvSet(stepValue,0);
|
uvSet(stepValue,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isCustom=strchr(type,'-');
|
int x=0;
|
||||||
|
sscanf(type,"%*8[0-9a-fA-F]-%*4[0-9a-fA-F]-%*4[0-9a-fA-F]-%*4[0-9a-fA-F]-%*12[0-9a-fA-F]%n",&x);
|
||||||
|
|
||||||
|
boolean isCustom=(strlen(type)==36 && x==36);
|
||||||
|
|
||||||
homeSpan.configLog+="(" + uvPrint(value) + ")" + ": IID=" + String(iid) + ", UUID=\"" + String(type) + "\"";
|
homeSpan.configLog+="(" + uvPrint(value) + ")" + ": IID=" + String(iid) + ", " + (isCustom?"Custom-":"") + "UUID=\"" + String(type) + "\"";
|
||||||
if(format!=FORMAT::STRING && format!=FORMAT::BOOL)
|
if(format!=FORMAT::STRING && format!=FORMAT::BOOL)
|
||||||
homeSpan.configLog+= ", Range=[" + String(uvPrint(minValue)) + "," + String(uvPrint(maxValue)) + "]";
|
homeSpan.configLog+= ", Range=[" + String(uvPrint(minValue)) + "," + String(uvPrint(maxValue)) + "]";
|
||||||
|
|
||||||
|
|
@ -462,8 +465,8 @@ struct SpanCharacteristic{
|
||||||
valid=!strcmp(type,homeSpan.Accessories.back()->Services.back()->opt[i]->type);
|
valid=!strcmp(type,homeSpan.Accessories.back()->Services.back()->opt[i]->type);
|
||||||
|
|
||||||
if(!valid){
|
if(!valid){
|
||||||
homeSpan.configLog+=" *** ERROR! Service does not support this Characteristic. ***";
|
homeSpan.configLog+=" *** WARNING! Service does not support this Characteristic. ***";
|
||||||
homeSpan.nFatalErrors++;
|
homeSpan.nWarnings++;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean repeated=false;
|
boolean repeated=false;
|
||||||
|
|
|
||||||
|
|
@ -329,7 +329,6 @@ namespace Service {
|
||||||
struct Television : SpanService { Television() : SpanService{"D8","Television"}{
|
struct Television : SpanService { Television() : SpanService{"D8","Television"}{
|
||||||
REQ(Active);
|
REQ(Active);
|
||||||
OPT(ConfiguredName);
|
OPT(ConfiguredName);
|
||||||
OPT(ConfiguredNameStatic);
|
|
||||||
OPT(ActiveIdentifier);
|
OPT(ActiveIdentifier);
|
||||||
OPT(RemoteKey);
|
OPT(RemoteKey);
|
||||||
OPT(PowerModeSelection);
|
OPT(PowerModeSelection);
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
#include "HomeSpan.h"
|
#include "HomeSpan.h"
|
||||||
|
|
||||||
CUSTOM_CHAR(CustomActive, AB-123-B0, PW+PR+EV, UINT8, 0, 0, 1, false);
|
CUSTOM_CHAR(CustomActive, E863F10A-079E-48FF-8F27-9C2605A29F52, PR+EV, UINT16, 0, 0, 4800, false);
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
|
||||||
|
|
@ -45,19 +45,18 @@ void setup() {
|
||||||
|
|
||||||
new Service::LightBulb();
|
new Service::LightBulb();
|
||||||
new Characteristic::On(0);
|
new Characteristic::On(0);
|
||||||
SpanCharacteristic *active = new Characteristic::CustomActive();
|
new Characteristic::CustomActive(1200);
|
||||||
new Characteristic::Brightness(50);
|
new Characteristic::Brightness(50);
|
||||||
new Characteristic::Name("Light 1");
|
new Characteristic::Name("Light 1");
|
||||||
new Characteristic::ColorTemperature();
|
new Characteristic::ColorTemperature();
|
||||||
new Characteristic::Active();
|
new Characteristic::Active();
|
||||||
new Service::LightBulb();
|
new Service::LightBulb();
|
||||||
new Characteristic::On(0,true);
|
new Characteristic::On(0,true);
|
||||||
(new Characteristic::Brightness(50,true))->setRange(10,100,5);
|
(new Characteristic::Brightness(50,false))->setRange(10,100,5);
|
||||||
new Characteristic::Name("Light 2");
|
new Characteristic::Name("Light 2");
|
||||||
|
|
||||||
new SpanAccessory(); // Begin by creating a new Accessory using SpanAccessory(), which takes no arguments
|
new SpanAccessory(); // Begin by creating a new Accessory using SpanAccessory(), which takes no arguments
|
||||||
|
|
||||||
// active->setRange(0,10,3);
|
|
||||||
new Service::AccessoryInformation(); // HAP requires every Accessory to implement an AccessoryInformation Service, which has 6 required Characteristics
|
new Service::AccessoryInformation(); // HAP requires every Accessory to implement an AccessoryInformation Service, which has 6 required Characteristics
|
||||||
new Characteristic::Name("HomeSpan Test"); // Name of the Accessory, which shows up on the HomeKit "tiles", and should be unique across Accessories
|
new Characteristic::Name("HomeSpan Test"); // Name of the Accessory, which shows up on the HomeKit "tiles", and should be unique across Accessories
|
||||||
new Characteristic::Manufacturer("HomeSpan"); // Manufacturer of the Accessory (arbitrary text string, and can be the same for every Accessory)
|
new Characteristic::Manufacturer("HomeSpan"); // Manufacturer of the Accessory (arbitrary text string, and can be the same for every Accessory)
|
||||||
|
|
@ -73,6 +72,8 @@ void setup() {
|
||||||
new Characteristic::On(0,true);
|
new Characteristic::On(0,true);
|
||||||
(new Characteristic::Brightness(50,true))->setRange(10,100,5);
|
(new Characteristic::Brightness(50,true))->setRange(10,100,5);
|
||||||
new Characteristic::Name("Light 3");
|
new Characteristic::Name("Light 3");
|
||||||
|
new Characteristic::TargetPosition();
|
||||||
|
new Characteristic::OzoneDensity();
|
||||||
|
|
||||||
} // end of setup()
|
} // end of setup()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue