Added HAP Names to all Services and Characteristics in Services.h

This commit is contained in:
Gregg 2020-10-03 21:39:20 -05:00
parent 60c2d5645d
commit 1d6f07a400
4 changed files with 120 additions and 107 deletions

View File

@ -527,13 +527,18 @@ void Span::processSerialCommand(char *c){
break; break;
case 'i':{ case 'i':{
char d[]="------------------------------";
Serial.print("\n*** HomeSpan Info ***\n\n"); Serial.print("\n*** HomeSpan Info ***\n\n");
char cBuf[128]; char cBuf[256];
sprintf(cBuf,"%-30s %s %s %s %s %s %s\n","Service","Type","AID","IID","Update","Loop","Button");
Serial.print(cBuf);
sprintf(cBuf,"%.30s %.4s %.3s %.3s %.6s %.4s %.6s\n",d,d,d,d,d,d,d);
Serial.print(cBuf);
for(int i=0;i<Accessories.size();i++){ // identify all services with over-ridden loop() methods for(int i=0;i<Accessories.size();i++){ // identify all services with over-ridden loop() methods
for(int j=0;j<Accessories[i]->Services.size();j++){ for(int j=0;j<Accessories[i]->Services.size();j++){
SpanService *s=Accessories[i]->Services[j]; SpanService *s=Accessories[i]->Services[j];
sprintf(cBuf,"Service aid=%2d iid=%2d Update: %3s Loop: %3s Button: %3s\n",Accessories[i]->aid,s->iid, sprintf(cBuf,"%-30s %4s %3d %3d %6s %4s %6s\n",s->hapName,s->type,Accessories[i]->aid,s->iid,
(void(*)())(s->*(&SpanService::update))!=(void(*)())(&SpanService::update)?"YES":"NO", (void(*)())(s->*(&SpanService::update))!=(void(*)())(&SpanService::update)?"YES":"NO",
(void(*)())(s->*(&SpanService::loop))!=(void(*)())(&SpanService::loop)?"YES":"NO", (void(*)())(s->*(&SpanService::loop))!=(void(*)())(&SpanService::loop)?"YES":"NO",
(void(*)(int,boolean))(s->*(&SpanService::button))!=(void(*)(int,boolean))(&SpanService::button)?"YES":"NO" (void(*)(int,boolean))(s->*(&SpanService::button))!=(void(*)(int,boolean))(&SpanService::button)?"YES":"NO"
@ -541,7 +546,7 @@ void Span::processSerialCommand(char *c){
Serial.print(cBuf); Serial.print(cBuf);
} }
} }
Serial.print("\n*** End Status ***\n"); Serial.print("\n*** End Info ***\n");
} }
break; break;
@ -938,12 +943,15 @@ int SpanAccessory::sprintfAttributes(char *cBuf){
// SpanService // // SpanService //
/////////////////////////////// ///////////////////////////////
SpanService::SpanService(const char *type){ SpanService::SpanService(const char *type, const char *hapName){
this->type=type; this->type=type;
this->hapName=hapName;
if(homeSpan.Accessories.empty()){ if(homeSpan.Accessories.empty()){
Serial.print("*** FATAL ERROR: Can't create new Service without a defined Accessory. Program halted!\n\n"); Serial.print("*** FATAL ERROR: Can't create new Service '");
Serial.print(hapName);
Serial.print("' without a defined Accessory. Program halted!\n\n");
while(1); while(1);
} }
@ -996,12 +1004,15 @@ int SpanService::sprintfAttributes(char *cBuf){
// SpanCharacteristic // // SpanCharacteristic //
/////////////////////////////// ///////////////////////////////
SpanCharacteristic::SpanCharacteristic(char *type, uint8_t perms){ SpanCharacteristic::SpanCharacteristic(char *type, uint8_t perms, char *hapName){
this->type=type; this->type=type;
this->perms=perms; this->perms=perms;
this->hapName=hapName;
if(homeSpan.Accessories.empty() || homeSpan.Accessories.back()->Services.empty()){ if(homeSpan.Accessories.empty() || homeSpan.Accessories.back()->Services.empty()){
Serial.print("*** FATAL ERROR: Can't create new Characteristic without a defined Service. Program halted!\n\n"); Serial.print("*** FATAL ERROR: Can't create new Characteristic '");
Serial.print(hapName);
Serial.print("' without a defined Service. Program halted!\n\n");
while(1); while(1);
} }
@ -1016,56 +1027,56 @@ SpanCharacteristic::SpanCharacteristic(char *type, uint8_t perms){
/////////////////////////////// ///////////////////////////////
SpanCharacteristic::SpanCharacteristic(char *type, uint8_t perms, boolean value) : SpanCharacteristic(type, perms) { SpanCharacteristic::SpanCharacteristic(char *type, uint8_t perms, boolean value, char *hapName) : SpanCharacteristic(type, perms, hapName) {
this->format=BOOL; this->format=BOOL;
this->value.BOOL=value; this->value.BOOL=value;
} }
/////////////////////////////// ///////////////////////////////
SpanCharacteristic::SpanCharacteristic(char *type, uint8_t perms, int32_t value) : SpanCharacteristic(type, perms) { SpanCharacteristic::SpanCharacteristic(char *type, uint8_t perms, int32_t value, char *hapName) : SpanCharacteristic(type, perms, hapName) {
this->format=INT; this->format=INT;
this->value.INT=value; this->value.INT=value;
} }
/////////////////////////////// ///////////////////////////////
SpanCharacteristic::SpanCharacteristic(char *type, uint8_t perms, uint8_t value) : SpanCharacteristic(type, perms) { SpanCharacteristic::SpanCharacteristic(char *type, uint8_t perms, uint8_t value, char *hapName) : SpanCharacteristic(type, perms, hapName) {
this->format=UINT8; this->format=UINT8;
this->value.UINT8=value; this->value.UINT8=value;
} }
/////////////////////////////// ///////////////////////////////
SpanCharacteristic::SpanCharacteristic(char *type, uint8_t perms, uint16_t value) : SpanCharacteristic(type, perms) { SpanCharacteristic::SpanCharacteristic(char *type, uint8_t perms, uint16_t value, char *hapName) : SpanCharacteristic(type, perms, hapName) {
this->format=UINT16; this->format=UINT16;
this->value.UINT16=value; this->value.UINT16=value;
} }
/////////////////////////////// ///////////////////////////////
SpanCharacteristic::SpanCharacteristic(char *type, uint8_t perms, uint32_t value) : SpanCharacteristic(type, perms) { SpanCharacteristic::SpanCharacteristic(char *type, uint8_t perms, uint32_t value, char *hapName) : SpanCharacteristic(type, perms, hapName) {
this->format=UINT32; this->format=UINT32;
this->value.UINT32=value; this->value.UINT32=value;
} }
/////////////////////////////// ///////////////////////////////
SpanCharacteristic::SpanCharacteristic(char *type, uint8_t perms, uint64_t value) : SpanCharacteristic(type, perms) { SpanCharacteristic::SpanCharacteristic(char *type, uint8_t perms, uint64_t value, char *hapName) : SpanCharacteristic(type, perms, hapName) {
this->format=UINT64; this->format=UINT64;
this->value.UINT64=value; this->value.UINT64=value;
} }
/////////////////////////////// ///////////////////////////////
SpanCharacteristic::SpanCharacteristic(char *type, uint8_t perms, double value) : SpanCharacteristic(type, perms) { SpanCharacteristic::SpanCharacteristic(char *type, uint8_t perms, double value, char *hapName) : SpanCharacteristic(type, perms, hapName) {
this->format=FLOAT; this->format=FLOAT;
this->value.FLOAT=value; this->value.FLOAT=value;
} }
/////////////////////////////// ///////////////////////////////
SpanCharacteristic::SpanCharacteristic(char *type, uint8_t perms, const char* value) : SpanCharacteristic(type, perms) { SpanCharacteristic::SpanCharacteristic(char *type, uint8_t perms, const char* value, char *hapName) : SpanCharacteristic(type, perms, hapName) {
this->format=STRING; this->format=STRING;
this->value.STRING=value; this->value.STRING=value;
} }

View File

@ -120,11 +120,12 @@ struct SpanService{
int iid=0; // Instance ID (HAP Table 6-2) int iid=0; // Instance ID (HAP Table 6-2)
const char *type; // Service Type const char *type; // Service Type
const char *hapName; // HAP Name
boolean hidden=false; // optional property indicating service is hidden boolean hidden=false; // optional property indicating service is hidden
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); SpanService(const char *type, const char *hapName);
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
@ -173,6 +174,7 @@ struct SpanCharacteristic{
int iid=0; // Instance ID (HAP Table 6-3) int iid=0; // Instance ID (HAP Table 6-3)
char *type; // Characteristic Type char *type; // Characteristic Type
const char *hapName; // HAP Name
UVal value; // Characteristic Value UVal value; // Characteristic Value
uint8_t perms; // Characteristic Permissions uint8_t perms; // Characteristic Permissions
FORMAT format; // Characteristic Format FORMAT format; // Characteristic Format
@ -186,15 +188,15 @@ struct SpanCharacteristic{
UVal newValue; // the updated value requested by PUT /characteristic UVal newValue; // the updated value requested by PUT /characteristic
SpanService *service=NULL; // pointer to Service containing this Characteristic SpanService *service=NULL; // pointer to Service containing this Characteristic
SpanCharacteristic(char *type, uint8_t perms); SpanCharacteristic(char *type, uint8_t perms, char *hapName);
SpanCharacteristic(char *type, uint8_t perms, boolean value); SpanCharacteristic(char *type, uint8_t perms, boolean value, char *hapName);
SpanCharacteristic(char *type, uint8_t perms, uint8_t value); SpanCharacteristic(char *type, uint8_t perms, uint8_t value, char *hapName);
SpanCharacteristic(char *type, uint8_t perms, uint16_t value); SpanCharacteristic(char *type, uint8_t perms, uint16_t value, char *hapName);
SpanCharacteristic(char *type, uint8_t perms, uint32_t value); SpanCharacteristic(char *type, uint8_t perms, uint32_t value, char *hapName);
SpanCharacteristic(char *type, uint8_t perms, uint64_t value); SpanCharacteristic(char *type, uint8_t perms, uint64_t value, char *hapName);
SpanCharacteristic(char *type, uint8_t perms, int32_t value); SpanCharacteristic(char *type, uint8_t perms, int32_t value, char *hapName);
SpanCharacteristic(char *type, uint8_t perms, double value); SpanCharacteristic(char *type, uint8_t perms, double value, char *hapName);
SpanCharacteristic(char *type, uint8_t perms, const char* value); SpanCharacteristic(char *type, uint8_t perms, const char* value, char *hapName);
int sprintfAttributes(char *cBuf, int flags); // prints Characteristic JSON records into buf, according to flags mask; return number of characters printed, excluding null terminator int sprintfAttributes(char *cBuf, int flags); // prints Characteristic JSON records into buf, according to flags mask; return number of characters printed, excluding null terminator
StatusCode loadUpdate(char *val, char *ev); // load updated val/ev from PUT /characteristic JSON request. Return intiial HAP status code (checks to see if characteristic is found, is writable, etc.) StatusCode loadUpdate(char *val, char *ev); // load updated val/ev from PUT /characteristic JSON request. Return intiial HAP status code (checks to see if characteristic is found, is writable, etc.)

View File

@ -5,73 +5,73 @@
namespace Service { namespace Service {
struct AccessoryInformation : SpanService { AccessoryInformation() : SpanService{"3E"}{} }; struct AccessoryInformation : SpanService { AccessoryInformation() : SpanService{"3E","AccessoryInformation"}{} };
struct AirPurifier : SpanService { AirPurifier() : SpanService{"BB"}{} }; struct AirPurifier : SpanService { AirPurifier() : SpanService{"BB","AirPurifier"}{} };
struct AirQualitySensor : SpanService { AirQualitySensor() : SpanService{"8D"}{} }; struct AirQualitySensor : SpanService { AirQualitySensor() : SpanService{"8D","AirQualitySensor"}{} };
struct BatteryService : SpanService { BatteryService() : SpanService{"96"}{} }; struct BatteryService : SpanService { BatteryService() : SpanService{"96","BatteryService"}{} };
struct CarbonDioxideSensor : SpanService { CarbonDioxideSensor() : SpanService{"97"}{} }; struct CarbonDioxideSensor : SpanService { CarbonDioxideSensor() : SpanService{"97","CarbonDioxideSensor"}{} };
struct CarbonMonoxideSensor : SpanService { CarbonMonoxideSensor() : SpanService{"7F"}{} }; struct CarbonMonoxideSensor : SpanService { CarbonMonoxideSensor() : SpanService{"7F","CarbonMonoxideSensor"}{} };
struct ContactSensor : SpanService { ContactSensor() : SpanService{"80"}{} }; struct ContactSensor : SpanService { ContactSensor() : SpanService{"80","ContactSensor"}{} };
struct Door : SpanService { Door() : SpanService{"81"}{} }; struct Door : SpanService { Door() : SpanService{"81","Door"}{} };
struct Doorbell : SpanService { Doorbell() : SpanService{"121"}{} }; struct Doorbell : SpanService { Doorbell() : SpanService{"121","Doorbell"}{} };
struct Fan : SpanService { Fan() : SpanService{"B7"}{} }; struct Fan : SpanService { Fan() : SpanService{"B7","Fan"}{} };
struct Faucet : SpanService { Faucet() : SpanService{"D7"}{} }; struct Faucet : SpanService { Faucet() : SpanService{"D7","Faucet"}{} };
struct FilterMaintenance : SpanService { FilterMaintenance() : SpanService{"BA"}{} }; struct FilterMaintenance : SpanService { FilterMaintenance() : SpanService{"BA","FilterMaintenance"}{} };
struct GarageDoorOpener : SpanService { GarageDoorOpener() : SpanService{"41"}{} }; struct GarageDoorOpener : SpanService { GarageDoorOpener() : SpanService{"41","GarageDoorOpener"}{} };
struct HAPProtocolInformation : SpanService { HAPProtocolInformation() : SpanService{"A2"}{} }; struct HAPProtocolInformation : SpanService { HAPProtocolInformation() : SpanService{"A2","HAPProtocolInformation"}{} };
struct HeaterCooler : SpanService { HeaterCooler() : SpanService{"BC"}{} }; struct HeaterCooler : SpanService { HeaterCooler() : SpanService{"BC","HeaterCooler"}{} };
struct HumidifierDehumidifier : SpanService { HumidifierDehumidifier() : SpanService{"BD"}{} }; struct HumidifierDehumidifier : SpanService { HumidifierDehumidifier() : SpanService{"BD","HumidifierDehumidifier"}{} };
struct HumiditySensor : SpanService { HumiditySensor() : SpanService{"82"}{} }; struct HumiditySensor : SpanService { HumiditySensor() : SpanService{"82","HumiditySensor"}{} };
struct IrrigationSystem : SpanService { IrrigationSystem() : SpanService{"CF"}{} }; struct IrrigationSystem : SpanService { IrrigationSystem() : SpanService{"CF","IrrigationSystem"}{} };
struct LeakSensor : SpanService { LeakSensor() : SpanService{"83"}{} }; struct LeakSensor : SpanService { LeakSensor() : SpanService{"83","LeakSensor"}{} };
struct LightBulb : SpanService { LightBulb() : SpanService{"43"}{} }; struct LightBulb : SpanService { LightBulb() : SpanService{"43","LightBulb"}{} };
struct LightSensor : SpanService { LightSensor() : SpanService{"84"}{} }; struct LightSensor : SpanService { LightSensor() : SpanService{"84","LightSensor"}{} };
struct MotionSensor : SpanService { MotionSensor() : SpanService{"85"}{} }; struct MotionSensor : SpanService { MotionSensor() : SpanService{"85","MotionSensor"}{} };
struct OccupancySensor : SpanService { OccupancySensor() : SpanService{"86"}{} }; struct OccupancySensor : SpanService { OccupancySensor() : SpanService{"86","OccupancySensor"}{} };
struct Outlet : SpanService { Outlet() : SpanService{"47"}{} }; struct Outlet : SpanService { Outlet() : SpanService{"47","Outlet"}{} };
struct ServiceLabel : SpanService { ServiceLabel() : SpanService{"47"}{} }; struct ServiceLabel : SpanService { ServiceLabel() : SpanService{"47","ServiceLabel"}{} };
struct Slat : SpanService { Slat() : SpanService{"B9"}{} }; struct Slat : SpanService { Slat() : SpanService{"B9","Slat"}{} };
struct SmokeSensor : SpanService { SmokeSensor() : SpanService{"87"}{} }; struct SmokeSensor : SpanService { SmokeSensor() : SpanService{"87","SmokeSensor"}{} };
struct StatelessProgrammableSwitch : SpanService { StatelessProgrammableSwitch() : SpanService{"89"}{} }; struct StatelessProgrammableSwitch : SpanService { StatelessProgrammableSwitch() : SpanService{"89","StatelessProgrammableSwitch"}{} };
struct Switch : SpanService { Switch() : SpanService{"49"}{} }; struct Switch : SpanService { Switch() : SpanService{"49","Switch"}{} };
struct TemperatureSensor : SpanService { TemperatureSensor() : SpanService{"8A"}{} }; struct TemperatureSensor : SpanService { TemperatureSensor() : SpanService{"8A","TemperatureSensor"}{} };
struct Thermostat : SpanService { Thermostat() : SpanService{"4A"}{} }; struct Thermostat : SpanService { Thermostat() : SpanService{"4A","Thermostat"}{} };
struct Valve : SpanService { Valve() : SpanService{"D0"}{} }; struct Valve : SpanService { Valve() : SpanService{"D0","Valve"}{} };
struct Window : SpanService { Window() : SpanService{"8B"}{} }; struct Window : SpanService { Window() : SpanService{"8B","Window"}{} };
struct WindowCovering : SpanService { WindowCovering() : SpanService{"8C"}{} }; struct WindowCovering : SpanService { WindowCovering() : SpanService{"8C","WindowCovering"}{} };
} }
@ -81,84 +81,84 @@ namespace Service {
namespace Characteristic { namespace Characteristic {
struct Active : SpanCharacteristic { Active(uint8_t value=0) : SpanCharacteristic{"B0",PR+PW+EV,(uint8_t)value}{} }; struct Active : SpanCharacteristic { Active(uint8_t value=0) : SpanCharacteristic{"B0",PR+PW+EV,(uint8_t)value,"Active"}{} };
struct AirQuality : SpanCharacteristic { AirQuality(uint8_t value=0) : SpanCharacteristic{"95",PR+EV,(uint8_t)value}{} }; struct AirQuality : SpanCharacteristic { AirQuality(uint8_t value=0) : SpanCharacteristic{"95",PR+EV,(uint8_t)value,"AirQuality"}{} };
struct Brightness : SpanCharacteristic { Brightness(int value=0) : SpanCharacteristic{"8",PR+PW+EV,(int)value}{} }; struct Brightness : SpanCharacteristic { Brightness(int value=0) : SpanCharacteristic{"8",PR+PW+EV,(int)value,"Brightness"}{} };
struct ColorTemperature : SpanCharacteristic { ColorTemperature(uint32_t value=50) : SpanCharacteristic{"CE",PR+PW+EV,(uint32_t)value}{} }; struct ColorTemperature : SpanCharacteristic { ColorTemperature(uint32_t value=50) : SpanCharacteristic{"CE",PR+PW+EV,(uint32_t)value,"ColorTemperature"}{} };
struct CurrentDoorState : SpanCharacteristic { CurrentDoorState(uint8_t value=1) : SpanCharacteristic{"E",PR+EV,(uint8_t)value}{} }; struct CurrentDoorState : SpanCharacteristic { CurrentDoorState(uint8_t value=1) : SpanCharacteristic{"E",PR+EV,(uint8_t)value,"CurrentDoorState"}{} };
struct CurrentPosition : SpanCharacteristic { CurrentPosition(uint8_t value=0) : SpanCharacteristic{"6D",PR+EV,(uint8_t)value}{} }; struct CurrentPosition : SpanCharacteristic { CurrentPosition(uint8_t value=0) : SpanCharacteristic{"6D",PR+EV,(uint8_t)value,"CurrentPosition"}{} };
struct CurrentTemperature : SpanCharacteristic { CurrentTemperature(double value=0) : SpanCharacteristic{"11",PR+EV,(double)value}{} }; struct CurrentTemperature : SpanCharacteristic { CurrentTemperature(double value=0) : SpanCharacteristic{"11",PR+EV,(double)value,"CurrentTemperature"}{} };
struct FirmwareRevision : SpanCharacteristic { FirmwareRevision(char *value) : SpanCharacteristic{"52",PR,(char *)value}{} }; struct FirmwareRevision : SpanCharacteristic { FirmwareRevision(char *value) : SpanCharacteristic{"52",PR,(char *)value,"FirmwareRevision"}{} };
struct HoldPosition : SpanCharacteristic { HoldPosition(boolean value=false) : SpanCharacteristic{"6F",PW,(boolean)value}{} }; struct HoldPosition : SpanCharacteristic { HoldPosition(boolean value=false) : SpanCharacteristic{"6F",PW,(boolean)value,"HoldPosition"}{} };
struct Hue : SpanCharacteristic { Hue(double value=0) : SpanCharacteristic{"13",PR+PW+EV,(double)value}{} }; struct Hue : SpanCharacteristic { Hue(double value=0) : SpanCharacteristic{"13",PR+PW+EV,(double)value,"Hue"}{} };
struct Identify : SpanCharacteristic { Identify() : SpanCharacteristic{"14",PW,(boolean)false}{} }; struct Identify : SpanCharacteristic { Identify() : SpanCharacteristic{"14",PW,(boolean)false,"Identify"}{} };
struct Manufacturer : SpanCharacteristic { Manufacturer(char *value) : SpanCharacteristic{"20",PR,(char *)value}{} }; struct Manufacturer : SpanCharacteristic { Manufacturer(char *value) : SpanCharacteristic{"20",PR,(char *)value,"Manufacturer"}{} };
struct Model : SpanCharacteristic { Model(char *value) : SpanCharacteristic{"21",PR,(char *)value}{} }; struct Model : SpanCharacteristic { Model(char *value) : SpanCharacteristic{"21",PR,(char *)value,"Model"}{} };
struct Name : SpanCharacteristic { Name(char *value) : SpanCharacteristic{"23",PR,(char *)value}{} }; struct Name : SpanCharacteristic { Name(char *value) : SpanCharacteristic{"23",PR,(char *)value,"Name"}{} };
struct NitrogenDioxideDensity : SpanCharacteristic { NitrogenDioxideDensity(double value=0) : SpanCharacteristic{"C4",PR+EV,(double)value}{} }; struct NitrogenDioxideDensity : SpanCharacteristic { NitrogenDioxideDensity(double value=0) : SpanCharacteristic{"C4",PR+EV,(double)value,"NitrogenDioxideDensity"}{} };
struct ObstructionDetected : SpanCharacteristic { ObstructionDetected(boolean value=false) : SpanCharacteristic{"24",PR+EV,(boolean)value}{} }; struct ObstructionDetected : SpanCharacteristic { ObstructionDetected(boolean value=false) : SpanCharacteristic{"24",PR+EV,(boolean)value,"ObstructionDetected"}{} };
struct On : SpanCharacteristic { On(boolean value=false) : SpanCharacteristic{"25",PR+PW+EV,(boolean)value}{} }; struct On : SpanCharacteristic { On(boolean value=false) : SpanCharacteristic{"25",PR+PW+EV,(boolean)value,"On"}{} };
struct OutletInUse : SpanCharacteristic { OutletInUse(boolean value=false) : SpanCharacteristic{"26",PR+EV,(boolean)value}{} }; struct OutletInUse : SpanCharacteristic { OutletInUse(boolean value=false) : SpanCharacteristic{"26",PR+EV,(boolean)value,"OutletInUse"}{} };
struct OzoneDensity : SpanCharacteristic { OzoneDensity(double value=0) : SpanCharacteristic{"C3",PR+EV,(double)value}{} }; struct OzoneDensity : SpanCharacteristic { OzoneDensity(double value=0) : SpanCharacteristic{"C3",PR+EV,(double)value,"OzoneDensity"}{} };
struct PM10Density : SpanCharacteristic { PM10Density(double value=0) : SpanCharacteristic{"C7",PR+EV,(double)value}{} }; struct PM10Density : SpanCharacteristic { PM10Density(double value=0) : SpanCharacteristic{"C7",PR+EV,(double)value,"PM10Density"}{} };
struct PM25Density : SpanCharacteristic { PM25Density(double value=0) : SpanCharacteristic{"C6",PR+EV,(double)value}{} }; struct PM25Density : SpanCharacteristic { PM25Density(double value=0) : SpanCharacteristic{"C6",PR+EV,(double)value,"PM25Density"}{} };
struct PositionState : SpanCharacteristic { PositionState(uint8_t value=2) : SpanCharacteristic{"72",PR+EV,(uint8_t)value}{} }; struct PositionState : SpanCharacteristic { PositionState(uint8_t value=2) : SpanCharacteristic{"72",PR+EV,(uint8_t)value,"PositionState"}{} };
struct RotationDirection : SpanCharacteristic { RotationDirection(int value=0) : SpanCharacteristic{"28",PR+PW+EV,(int)value}{} }; struct RotationDirection : SpanCharacteristic { RotationDirection(int value=0) : SpanCharacteristic{"28",PR+PW+EV,(int)value,"RotationDirection"}{} };
struct RotationSpeed : SpanCharacteristic { RotationSpeed(double value=0) : SpanCharacteristic{"29",PR+PW+EV,(double)value}{} }; struct RotationSpeed : SpanCharacteristic { RotationSpeed(double value=0) : SpanCharacteristic{"29",PR+PW+EV,(double)value,"RotationSpeed"}{} };
struct Saturation : SpanCharacteristic { Saturation(double value=0) : SpanCharacteristic{"2F",PR+PW+EV,(double)value}{} }; struct Saturation : SpanCharacteristic { Saturation(double value=0) : SpanCharacteristic{"2F",PR+PW+EV,(double)value,"Saturation"}{} };
struct SerialNumber : SpanCharacteristic { SerialNumber(char *value) : SpanCharacteristic{"30",PR,(char *)value}{} }; struct SerialNumber : SpanCharacteristic { SerialNumber(char *value) : SpanCharacteristic{"30",PR,(char *)value,"SerialNumber"}{} };
struct SlatType : SpanCharacteristic { SlatType(uint8_t value=0) : SpanCharacteristic{"C0",PR,(uint8_t)value}{} }; struct SlatType : SpanCharacteristic { SlatType(uint8_t value=0) : SpanCharacteristic{"C0",PR,(uint8_t)value,"SlatType"}{} };
struct SmokeDetected : SpanCharacteristic { SmokeDetected(uint8_t value=0) : SpanCharacteristic{"76",PR+EV,(uint8_t)value}{} }; struct SmokeDetected : SpanCharacteristic { SmokeDetected(uint8_t value=0) : SpanCharacteristic{"76",PR+EV,(uint8_t)value,"SmokeDetected"}{} };
struct StatusActive : SpanCharacteristic { StatusActive(boolean value=true) : SpanCharacteristic{"75",PR+EV,(boolean)value}{} }; struct StatusActive : SpanCharacteristic { StatusActive(boolean value=true) : SpanCharacteristic{"75",PR+EV,(boolean)value,"StatusActive"}{} };
struct StatusFault : SpanCharacteristic { StatusFault(uint8_t value=0) : SpanCharacteristic{"77",PR+EV,(uint8_t)value}{} }; struct StatusFault : SpanCharacteristic { StatusFault(uint8_t value=0) : SpanCharacteristic{"77",PR+EV,(uint8_t)value,"StatusFault"}{} };
struct StatusJammed : SpanCharacteristic { StatusJammed(uint8_t value=0) : SpanCharacteristic{"78",PR+EV,(uint8_t)value}{} }; struct StatusJammed : SpanCharacteristic { StatusJammed(uint8_t value=0) : SpanCharacteristic{"78",PR+EV,(uint8_t)value,"StatusJammed"}{} };
struct StatusLowBattery : SpanCharacteristic { StatusLowBattery(uint8_t value=0) : SpanCharacteristic{"79",PR+EV,(uint8_t)value}{} }; struct StatusLowBattery : SpanCharacteristic { StatusLowBattery(uint8_t value=0) : SpanCharacteristic{"79",PR+EV,(uint8_t)value,"StatusLowBattery"}{} };
struct StatusTampered : SpanCharacteristic { StatusTampered(uint8_t value=0) : SpanCharacteristic{"7A",PR+EV,(uint8_t)value}{} }; struct StatusTampered : SpanCharacteristic { StatusTampered(uint8_t value=0) : SpanCharacteristic{"7A",PR+EV,(uint8_t)value,"StatusTampered"}{} };
struct SulphurDioxideDensity : SpanCharacteristic { SulphurDioxideDensity(double value=0) : SpanCharacteristic{"C5",PR+EV,(double)value}{} }; struct SulphurDioxideDensity : SpanCharacteristic { SulphurDioxideDensity(double value=0) : SpanCharacteristic{"C5",PR+EV,(double)value,"SulphurDioxideDensity"}{} };
struct SwingMode : SpanCharacteristic { SwingMode(uint8_t value=0) : SpanCharacteristic{"B6",PR+PW+EV,(uint8_t)value}{} }; struct SwingMode : SpanCharacteristic { SwingMode(uint8_t value=0) : SpanCharacteristic{"B6",PR+PW+EV,(uint8_t)value,"SwingMode"}{} };
struct TargetDoorState : SpanCharacteristic { TargetDoorState(uint8_t value=1) : SpanCharacteristic{"32",PR+PW+EV,(uint8_t)value}{} }; struct TargetDoorState : SpanCharacteristic { TargetDoorState(uint8_t value=1) : SpanCharacteristic{"32",PR+PW+EV,(uint8_t)value,"TargetDoorState"}{} };
struct TargetPosition : SpanCharacteristic { TargetPosition(uint8_t value=0) : SpanCharacteristic{"7C",PR+PW+EV,(uint8_t)value}{} }; struct TargetPosition : SpanCharacteristic { TargetPosition(uint8_t value=0) : SpanCharacteristic{"7C",PR+PW+EV,(uint8_t)value,"TargetPosition"}{} };
struct TemperatureDisplayUnits : SpanCharacteristic { TemperatureDisplayUnits(uint8_t value=0) : SpanCharacteristic{"36",PR+PW+EV,(uint8_t)value}{} }; struct TemperatureDisplayUnits : SpanCharacteristic { TemperatureDisplayUnits(uint8_t value=0) : SpanCharacteristic{"36",PR+PW+EV,(uint8_t)value,"TemperatureDisplayUnits"}{} };
struct Version : SpanCharacteristic { Version(char *value) : SpanCharacteristic{"37",PR,(char *)value}{} }; struct Version : SpanCharacteristic { Version(char *value) : SpanCharacteristic{"37",PR,(char *)value,"Version"}{} };
struct VOCDensity : SpanCharacteristic { VOCDensity(double value=0) : SpanCharacteristic{"C8",PR+EV,(double)value}{} }; struct VOCDensity : SpanCharacteristic { VOCDensity(double value=0) : SpanCharacteristic{"C8",PR+EV,(double)value,"VOCDensity"}{} };
} }

View File

@ -7,13 +7,13 @@
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
homeSpan.setLogLevel(2);
homeSpan.begin(Category::Lighting,"HomeSpan Benchmark"); homeSpan.begin(Category::Lighting,"HomeSpan Benchmark");
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
new Characteristic::Model("HSL Test"); // Model of the Accessory (arbitrary text string, and can be the same for every Accessory)
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)
@ -23,10 +23,10 @@ void setup() {
new Characteristic::Identify(); // Create the required Identify new Characteristic::Identify(); // Create the required Identify
new Service::HAPProtocolInformation(); // Create the HAP Protcol Information Service new Service::HAPProtocolInformation(); // Create the HAP Protcol Information Service
new Characteristic::Version("1.1.0"); // Set the Version Characteristicto "1.1.0" as required by HAP new Characteristic::Version("1.1.0"); // Set the Version Characteristic to "1.1.0" as required by HAP
new Service::LightBulb(); // Create the Light Bulb Service new Service::LightBulb(); // Create the Light Bulb Service
new Characteristic::On(); // This Service requires the "On" Characterstic to turn the light on and off new Characteristic::On(); // This Service requires the "On" Characteristic to turn the light on and off
} // end of setup() } // end of setup()