Replaced Service definitions with macros CREATE_SERV and END_SERV

This has no effect on the code but the names of the macros can be used as flags for an external script to autogenerate documentation in the form of a list of all services and characteristics supported by HomeSpan
This commit is contained in:
Gregg 2023-02-16 07:23:22 -06:00
parent 0ecaf2ee7f
commit 69af3d59a3
1 changed files with 87 additions and 83 deletions

View File

@ -29,14 +29,18 @@
// SPAN SERVICES (HAP Chapter 8) // // SPAN SERVICES (HAP Chapter 8) //
/////////////////////////////////// ///////////////////////////////////
// Macros to define vectors of required and optional characteristics for each Span Service structure // Macros to define services, along with vectors of required and optional characteristics for each Span Service structure
// The names of the macros are picked up by external scripts to help generate documentation
#define CREATE_SERV(NAME,UUID) struct NAME : SpanService { NAME() : SpanService{#UUID,#NAME}{
#define END_SERV }};
#define REQ(HAPCHAR) req.insert(&hapChars.HAPCHAR) #define REQ(HAPCHAR) req.insert(&hapChars.HAPCHAR)
#define OPT(HAPCHAR) opt.insert(&hapChars.HAPCHAR) #define OPT(HAPCHAR) opt.insert(&hapChars.HAPCHAR)
namespace Service { namespace Service {
struct AccessoryInformation : SpanService { AccessoryInformation() : SpanService{"3E","AccessoryInformation"}{ CREATE_SERV(AccessoryInformation,3E)
REQ(Identify); REQ(Identify);
OPT(FirmwareRevision); OPT(FirmwareRevision);
OPT(Manufacturer); OPT(Manufacturer);
@ -45,9 +49,9 @@ namespace Service {
OPT(SerialNumber); OPT(SerialNumber);
OPT(HardwareRevision); OPT(HardwareRevision);
OPT(AccessoryFlags); OPT(AccessoryFlags);
}}; END_SERV
struct AirPurifier : SpanService { AirPurifier() : SpanService{"BB","AirPurifier"}{ CREATE_SERV(AirPurifier,BB)
REQ(Active); REQ(Active);
REQ(CurrentAirPurifierState); REQ(CurrentAirPurifierState);
REQ(TargetAirPurifierState); REQ(TargetAirPurifierState);
@ -55,9 +59,9 @@ namespace Service {
OPT(RotationSpeed); OPT(RotationSpeed);
OPT(SwingMode); OPT(SwingMode);
OPT(LockPhysicalControls); OPT(LockPhysicalControls);
}}; END_SERV
struct AirQualitySensor : SpanService { AirQualitySensor() : SpanService{"8D","AirQualitySensor"}{ CREATE_SERV(AirQualitySensor,8D)
REQ(AirQuality); REQ(AirQuality);
OPT(Name); OPT(Name);
OPT(OzoneDensity); OPT(OzoneDensity);
@ -70,16 +74,16 @@ namespace Service {
OPT(StatusFault); OPT(StatusFault);
OPT(StatusTampered); OPT(StatusTampered);
OPT(StatusLowBattery); OPT(StatusLowBattery);
}}; END_SERV
struct BatteryService : SpanService { BatteryService() : SpanService{"96","BatteryService"}{ CREATE_SERV(BatteryService,96)
REQ(BatteryLevel); REQ(BatteryLevel);
REQ(ChargingState); REQ(ChargingState);
REQ(StatusLowBattery); REQ(StatusLowBattery);
OPT(Name); OPT(Name);
}}; END_SERV
struct CarbonDioxideSensor : SpanService { CarbonDioxideSensor() : SpanService{"97","CarbonDioxideSensor"}{ CREATE_SERV(CarbonDioxideSensor,97)
REQ(CarbonDioxideDetected); REQ(CarbonDioxideDetected);
OPT(Name); OPT(Name);
OPT(StatusActive); OPT(StatusActive);
@ -88,9 +92,9 @@ namespace Service {
OPT(StatusLowBattery); OPT(StatusLowBattery);
OPT(CarbonDioxideLevel); OPT(CarbonDioxideLevel);
OPT(CarbonDioxidePeakLevel); OPT(CarbonDioxidePeakLevel);
}}; END_SERV
struct CarbonMonoxideSensor : SpanService { CarbonMonoxideSensor() : SpanService{"7F","CarbonMonoxideSensor"}{ CREATE_SERV(CarbonMonoxideSensor,7F)
REQ(CarbonMonoxideDetected); REQ(CarbonMonoxideDetected);
OPT(Name); OPT(Name);
OPT(StatusActive); OPT(StatusActive);
@ -99,34 +103,34 @@ namespace Service {
OPT(StatusLowBattery); OPT(StatusLowBattery);
OPT(CarbonMonoxideLevel); OPT(CarbonMonoxideLevel);
OPT(CarbonMonoxidePeakLevel); OPT(CarbonMonoxidePeakLevel);
}}; END_SERV
struct ContactSensor : SpanService { ContactSensor() : SpanService{"80","ContactSensor"}{ CREATE_SERV(ContactSensor,80)
REQ(ContactSensorState); REQ(ContactSensorState);
OPT(Name); OPT(Name);
OPT(StatusActive); OPT(StatusActive);
OPT(StatusFault); OPT(StatusFault);
OPT(StatusTampered); OPT(StatusTampered);
OPT(StatusLowBattery); OPT(StatusLowBattery);
}}; END_SERV
struct Door : SpanService { Door() : SpanService{"81","Door"}{ CREATE_SERV(Door,81)
REQ(CurrentPosition); REQ(CurrentPosition);
REQ(TargetPosition); REQ(TargetPosition);
REQ(PositionState); REQ(PositionState);
OPT(Name); OPT(Name);
OPT(HoldPosition); OPT(HoldPosition);
OPT(ObstructionDetected); OPT(ObstructionDetected);
}}; END_SERV
struct Doorbell : SpanService { Doorbell() : SpanService{"121","Doorbell"}{ CREATE_SERV(Doorbell,121)
REQ(ProgrammableSwitchEvent); REQ(ProgrammableSwitchEvent);
OPT(Name); OPT(Name);
OPT(Volume); OPT(Volume);
OPT(Brightness); OPT(Brightness);
}}; END_SERV
struct Fan : SpanService { Fan() : SpanService{"B7","Fan"}{ CREATE_SERV(Fan,B7)
REQ(Active); REQ(Active);
OPT(Name); OPT(Name);
OPT(CurrentFanState); OPT(CurrentFanState);
@ -135,35 +139,35 @@ namespace Service {
OPT(RotationSpeed); OPT(RotationSpeed);
OPT(SwingMode); OPT(SwingMode);
OPT(LockPhysicalControls); OPT(LockPhysicalControls);
}}; END_SERV
struct Faucet : SpanService { Faucet() : SpanService{"D7","Faucet"}{ CREATE_SERV(Faucet,D7)
REQ(Active); REQ(Active);
OPT(StatusFault); OPT(StatusFault);
OPT(Name); OPT(Name);
}}; END_SERV
struct FilterMaintenance : SpanService { FilterMaintenance() : SpanService{"BA","FilterMaintenance"}{ CREATE_SERV(FilterMaintenance,BA)
REQ(FilterChangeIndication); REQ(FilterChangeIndication);
OPT(Name); OPT(Name);
OPT(FilterLifeLevel); OPT(FilterLifeLevel);
OPT(ResetFilterIndication); OPT(ResetFilterIndication);
}}; END_SERV
struct GarageDoorOpener : SpanService { GarageDoorOpener() : SpanService{"41","GarageDoorOpener"}{ CREATE_SERV(GarageDoorOpener,41)
REQ(CurrentDoorState); REQ(CurrentDoorState);
REQ(TargetDoorState); REQ(TargetDoorState);
REQ(ObstructionDetected); REQ(ObstructionDetected);
OPT(LockCurrentState); OPT(LockCurrentState);
OPT(LockTargetState); OPT(LockTargetState);
OPT(Name); OPT(Name);
}}; END_SERV
struct HAPProtocolInformation : SpanService { HAPProtocolInformation() : SpanService{"A2","HAPProtocolInformation"}{ CREATE_SERV(HAPProtocolInformation,A2)
REQ(Version); REQ(Version);
}}; END_SERV
struct HeaterCooler : SpanService { HeaterCooler() : SpanService{"BC","HeaterCooler"}{ CREATE_SERV(HeaterCooler,BC)
REQ(Active); REQ(Active);
REQ(CurrentTemperature); REQ(CurrentTemperature);
REQ(CurrentHeaterCoolerState); REQ(CurrentHeaterCoolerState);
@ -175,9 +179,9 @@ namespace Service {
OPT(CoolingThresholdTemperature); OPT(CoolingThresholdTemperature);
OPT(HeatingThresholdTemperature); OPT(HeatingThresholdTemperature);
OPT(LockPhysicalControls); OPT(LockPhysicalControls);
}}; END_SERV
struct HumidifierDehumidifier : SpanService { HumidifierDehumidifier() : SpanService{"BD","HumidifierDehumidifier"}{ CREATE_SERV(HumidifierDehumidifier,BD)
REQ(Active); REQ(Active);
REQ(CurrentRelativeHumidity); REQ(CurrentRelativeHumidity);
REQ(CurrentHumidifierDehumidifierState); REQ(CurrentHumidifierDehumidifierState);
@ -189,167 +193,167 @@ namespace Service {
OPT(SwingMode); OPT(SwingMode);
OPT(WaterLevel); OPT(WaterLevel);
OPT(LockPhysicalControls); OPT(LockPhysicalControls);
}}; END_SERV
struct HumiditySensor : SpanService { HumiditySensor() : SpanService{"82","HumiditySensor"}{ CREATE_SERV(HumiditySensor,82)
REQ(CurrentRelativeHumidity); REQ(CurrentRelativeHumidity);
OPT(Name); OPT(Name);
OPT(StatusActive); OPT(StatusActive);
OPT(StatusFault); OPT(StatusFault);
OPT(StatusTampered); OPT(StatusTampered);
OPT(StatusLowBattery); OPT(StatusLowBattery);
}}; END_SERV
struct InputSource : SpanService { InputSource() : SpanService{"D9","InputSource"}{ CREATE_SERV(InputSource,D9)
OPT(ConfiguredName); OPT(ConfiguredName);
OPT(IsConfigured); OPT(IsConfigured);
REQ(Identifier); REQ(Identifier);
OPT(CurrentVisibilityState); OPT(CurrentVisibilityState);
OPT(TargetVisibilityState); OPT(TargetVisibilityState);
}}; END_SERV
struct IrrigationSystem : SpanService { IrrigationSystem() : SpanService{"CF","IrrigationSystem"}{ CREATE_SERV(IrrigationSystem,CF)
REQ(Active); REQ(Active);
REQ(ProgramMode); REQ(ProgramMode);
REQ(InUse); REQ(InUse);
OPT(RemainingDuration); OPT(RemainingDuration);
OPT(StatusFault); OPT(StatusFault);
}}; END_SERV
struct LeakSensor : SpanService { LeakSensor() : SpanService{"83","LeakSensor"}{ CREATE_SERV(LeakSensor,83)
REQ(LeakDetected); REQ(LeakDetected);
OPT(Name); OPT(Name);
OPT(StatusActive); OPT(StatusActive);
OPT(StatusFault); OPT(StatusFault);
OPT(StatusTampered); OPT(StatusTampered);
OPT(StatusLowBattery); OPT(StatusLowBattery);
}}; END_SERV
struct LightBulb : SpanService { LightBulb() : SpanService{"43","LightBulb"}{ CREATE_SERV(LightBulb,43)
REQ(On); REQ(On);
OPT(Brightness); OPT(Brightness);
OPT(Hue); OPT(Hue);
OPT(Name); OPT(Name);
OPT(Saturation); OPT(Saturation);
OPT(ColorTemperature); OPT(ColorTemperature);
}}; END_SERV
struct LightSensor : SpanService { LightSensor() : SpanService{"84","LightSensor"}{ CREATE_SERV(LightSensor,84)
REQ(CurrentAmbientLightLevel); REQ(CurrentAmbientLightLevel);
OPT(Name); OPT(Name);
OPT(StatusActive); OPT(StatusActive);
OPT(StatusFault); OPT(StatusFault);
OPT(StatusTampered); OPT(StatusTampered);
OPT(StatusLowBattery); OPT(StatusLowBattery);
}}; END_SERV
struct LockMechanism : SpanService { LockMechanism() : SpanService{"45","LockMechanism"}{ CREATE_SERV(LockMechanism,45)
REQ(LockCurrentState); REQ(LockCurrentState);
REQ(LockTargetState); REQ(LockTargetState);
OPT(Name); OPT(Name);
}}; END_SERV
struct Microphone : SpanService { Microphone() : SpanService{"112","Microphone"}{ CREATE_SERV(Microphone,112)
REQ(Mute); REQ(Mute);
OPT(Name); OPT(Name);
OPT(Volume); OPT(Volume);
}}; END_SERV
struct MotionSensor : SpanService { MotionSensor() : SpanService{"85","MotionSensor"}{ CREATE_SERV(MotionSensor,85)
REQ(MotionDetected); REQ(MotionDetected);
OPT(Name); OPT(Name);
OPT(StatusActive); OPT(StatusActive);
OPT(StatusFault); OPT(StatusFault);
OPT(StatusTampered); OPT(StatusTampered);
OPT(StatusLowBattery); OPT(StatusLowBattery);
}}; END_SERV
struct OccupancySensor : SpanService { OccupancySensor() : SpanService{"86","OccupancySensor"}{ CREATE_SERV(OccupancySensor,86)
REQ(OccupancyDetected); REQ(OccupancyDetected);
OPT(Name); OPT(Name);
OPT(StatusActive); OPT(StatusActive);
OPT(StatusFault); OPT(StatusFault);
OPT(StatusTampered); OPT(StatusTampered);
OPT(StatusLowBattery); OPT(StatusLowBattery);
}}; END_SERV
struct Outlet : SpanService { Outlet() : SpanService{"47","Outlet"}{ CREATE_SERV(Outlet,47)
REQ(On); REQ(On);
REQ(OutletInUse); REQ(OutletInUse);
OPT(Name); OPT(Name);
}}; END_SERV
struct SecuritySystem : SpanService { SecuritySystem() : SpanService{"7E","SecuritySystem"}{ CREATE_SERV(SecuritySystem,7E)
REQ(SecuritySystemCurrentState); REQ(SecuritySystemCurrentState);
REQ(SecuritySystemTargetState); REQ(SecuritySystemTargetState);
OPT(Name); OPT(Name);
OPT(SecuritySystemAlarmType); OPT(SecuritySystemAlarmType);
OPT(StatusFault); OPT(StatusFault);
OPT(StatusTampered); OPT(StatusTampered);
}}; END_SERV
struct ServiceLabel : SpanService { ServiceLabel() : SpanService{"CC","ServiceLabel"}{ CREATE_SERV(ServiceLabel,CC)
REQ(ServiceLabelNamespace); REQ(ServiceLabelNamespace);
}}; END_SERV
struct Slat : SpanService { Slat() : SpanService{"B9","Slat"}{ CREATE_SERV(Slat,B9)
REQ(CurrentSlatState); REQ(CurrentSlatState);
REQ(SlatType); REQ(SlatType);
OPT(Name); OPT(Name);
OPT(SwingMode); OPT(SwingMode);
OPT(CurrentTiltAngle); OPT(CurrentTiltAngle);
OPT(TargetTiltAngle); OPT(TargetTiltAngle);
}}; END_SERV
struct SmokeSensor : SpanService { SmokeSensor() : SpanService{"87","SmokeSensor"}{ CREATE_SERV(SmokeSensor,87)
REQ(SmokeDetected); REQ(SmokeDetected);
OPT(Name); OPT(Name);
OPT(StatusActive); OPT(StatusActive);
OPT(StatusFault); OPT(StatusFault);
OPT(StatusTampered); OPT(StatusTampered);
OPT(StatusLowBattery); OPT(StatusLowBattery);
}}; END_SERV
struct Speaker : SpanService { Speaker() : SpanService{"113","Speaker"}{ CREATE_SERV(Speaker,113)
REQ(Mute); REQ(Mute);
OPT(Name); OPT(Name);
OPT(Volume); OPT(Volume);
}}; END_SERV
struct StatelessProgrammableSwitch : SpanService { StatelessProgrammableSwitch() : SpanService{"89","StatelessProgrammableSwitch"}{ CREATE_SERV(StatelessProgrammableSwitch,89)
REQ(ProgrammableSwitchEvent); REQ(ProgrammableSwitchEvent);
OPT(Name); OPT(Name);
OPT(ServiceLabelIndex); OPT(ServiceLabelIndex);
}}; END_SERV
struct Switch : SpanService { Switch() : SpanService{"49","Switch"}{ CREATE_SERV(Switch,49)
REQ(On); REQ(On);
OPT(Name); OPT(Name);
}}; END_SERV
struct Television : SpanService { Television() : SpanService{"D8","Television"}{ CREATE_SERV(Television,D8)
REQ(Active); REQ(Active);
OPT(ConfiguredName); OPT(ConfiguredName);
OPT(ActiveIdentifier); OPT(ActiveIdentifier);
OPT(RemoteKey); OPT(RemoteKey);
OPT(PowerModeSelection); OPT(PowerModeSelection);
}}; END_SERV
struct TelevisionSpeaker : SpanService { TelevisionSpeaker() : SpanService{"113","TelevisionSpeaker"}{ CREATE_SERV(TelevisionSpeaker,113)
REQ(VolumeControlType); REQ(VolumeControlType);
REQ(VolumeSelector); REQ(VolumeSelector);
}}; END_SERV
struct TemperatureSensor : SpanService { TemperatureSensor() : SpanService{"8A","TemperatureSensor"}{ CREATE_SERV(TemperatureSensor,8A)
REQ(CurrentTemperature); REQ(CurrentTemperature);
OPT(Name); OPT(Name);
OPT(StatusActive); OPT(StatusActive);
OPT(StatusFault); OPT(StatusFault);
OPT(StatusTampered); OPT(StatusTampered);
OPT(StatusLowBattery); OPT(StatusLowBattery);
}}; END_SERV
struct Thermostat : SpanService { Thermostat() : SpanService{"4A","Thermostat"}{ CREATE_SERV(Thermostat,4A)
REQ(CurrentHeatingCoolingState); REQ(CurrentHeatingCoolingState);
REQ(TargetHeatingCoolingState); REQ(TargetHeatingCoolingState);
REQ(CurrentTemperature); REQ(CurrentTemperature);
@ -360,9 +364,9 @@ namespace Service {
OPT(HeatingThresholdTemperature); OPT(HeatingThresholdTemperature);
OPT(Name); OPT(Name);
OPT(TargetRelativeHumidity); OPT(TargetRelativeHumidity);
}}; END_SERV
struct Valve : SpanService { Valve() : SpanService{"D0","Valve"}{ CREATE_SERV(Valve,D0)
REQ(Active); REQ(Active);
REQ(InUse); REQ(InUse);
REQ(ValveType); REQ(ValveType);
@ -372,18 +376,18 @@ namespace Service {
OPT(ServiceLabelIndex); OPT(ServiceLabelIndex);
OPT(StatusFault); OPT(StatusFault);
OPT(Name); OPT(Name);
}}; END_SERV
struct Window : SpanService { Window() : SpanService{"8B","Window"}{ CREATE_SERV(Window,8B)
REQ(CurrentPosition); REQ(CurrentPosition);
REQ(TargetPosition); REQ(TargetPosition);
REQ(PositionState); REQ(PositionState);
OPT(Name); OPT(Name);
OPT(HoldPosition); OPT(HoldPosition);
OPT(ObstructionDetected); OPT(ObstructionDetected);
}}; END_SERV
struct WindowCovering : SpanService { WindowCovering() : SpanService{"8C","WindowCovering"}{ CREATE_SERV(WindowCovering,8C)
REQ(TargetPosition); REQ(TargetPosition);
REQ(CurrentPosition); REQ(CurrentPosition);
REQ(PositionState); REQ(PositionState);
@ -394,7 +398,7 @@ namespace Service {
OPT(CurrentVerticalTiltAngle); OPT(CurrentVerticalTiltAngle);
OPT(TargetVerticalTiltAngle); OPT(TargetVerticalTiltAngle);
OPT(ObstructionDetected); OPT(ObstructionDetected);
}}; END_SERV
} }