New macro to define Characteristic enum values.

New enums for ChargingStatus, DoorState, LeakStatus, SecuritySystemState
This commit is contained in:
Francois 2023-11-11 20:59:48 -05:00
parent f96df1ae63
commit e29e82205f
2 changed files with 9 additions and 9 deletions

View File

@ -87,12 +87,3 @@ enum class StatusCode {
InvalidValue=-70410, InvalidValue=-70410,
TBD=-1 // status To-Be-Determined (TBD) once service.update() called - internal use only TBD=-1 // status To-Be-Determined (TBD) once service.update() called - internal use only
}; };
// Based on HomeKit documentation for HMCharacteristicTypeCurrentSecuritySystemState
typedef enum {
Stay=0, // Armed for Stay, or Armed while at Home
Away=1, // Armed for Away
Night=2, // Armed for Night
Disarmed=3, // Disarmed, or Off
Alarm=4 // Alarm is triggered
} HSSecuritySystemState;

View File

@ -406,6 +406,9 @@ namespace Service {
// SPAN CHARACTERISTICS (HAP Chapter 9) // // SPAN CHARACTERISTICS (HAP Chapter 9) //
////////////////////////////////////////// //////////////////////////////////////////
#define CREATE_CHAR_ENUM(HAPCHAR, ...) \
typedef enum { __VA_ARGS__ } HAPCHAR;
// Macro to define Span Characteristic structures based on name of HAP Characteristic, default value, and min/max value (not applicable for STRING or BOOL which default to min=0, max=1) // Macro to define Span Characteristic structures based on name of HAP Characteristic, default value, and min/max value (not applicable for STRING or BOOL which default to min=0, max=1)
#define CREATE_CHAR(TYPE,HAPCHAR,DEFVAL,MINVAL,MAXVAL) \ #define CREATE_CHAR(TYPE,HAPCHAR,DEFVAL,MINVAL,MAXVAL) \
@ -530,6 +533,12 @@ namespace Characteristic {
CREATE_CHAR(uint8_t,VolumeSelector,0,0,1); CREATE_CHAR(uint8_t,VolumeSelector,0,0,1);
CREATE_CHAR(double,WaterLevel,0,0,100); CREATE_CHAR(double,WaterLevel,0,0,100);
// Macros to define enum values for specific characteristic states / values.
CREATE_CHAR_ENUM(ChargingStatus, NotCharging=0, Charging=1, NotChargeable=2);
CREATE_CHAR_ENUM(DoorState, Open=0, Closed=1);
CREATE_CHAR_ENUM(LeakStatus, NoLeak=0, LeakDetected=1);
CREATE_CHAR_ENUM(SecuritySystemState, Stay=0, Away=1, Night=2, Disarmed=3, Alarm=4);
} }
//////////////////////////////////////////////////////// ////////////////////////////////////////////////////////