From 7939624bf78cb766b084cc03441544d638d39c57 Mon Sep 17 00:00:00 2001 From: Gregg Date: Fri, 23 Dec 2022 16:51:55 -0600 Subject: [PATCH] Added Service::TelevisionSpeaker Also updated Television Example. Volume buttons on remote now function as expected, though there does not seems to be a mute button --- Other Examples/Television/Television.ino | 6 ++++++ src/Characteristics.h | 2 +- src/HomeSpan.cpp | 2 +- src/Span.h | 8 ++++++++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Other Examples/Television/Television.ino b/Other Examples/Television/Television.ino index fda3581..39a232b 100644 --- a/Other Examples/Television/Television.ino +++ b/Other Examples/Television/Television.ino @@ -189,6 +189,11 @@ void setup() { new Characteristic::CurrentVisibilityState(0); // ...and included in the Selection List... new Characteristic::TargetVisibilityState(0); // ...and a "checked" checkbox is provided on the Settings Screen that can be used to toggle CurrentVisibilityState() + SpanService *speaker = new Service::TelevisionSpeaker(); + new Characteristic::Mute(); + new Characteristic::VolumeSelector(); + new Characteristic::VolumeControlType(3); + (new HomeSpanTV("Test TV")) // Define a Television Service. Must link in InputSources! ->addLink(hdmi1) ->addLink(hdmi2) @@ -200,6 +205,7 @@ void setup() { ->addLink(hdmi8) ->addLink(hdmi9) ->addLink(hdmi10) + ->addLink(speaker) ; } diff --git a/src/Characteristics.h b/src/Characteristics.h index 5bce47c..e5d075f 100644 --- a/src/Characteristics.h +++ b/src/Characteristics.h @@ -192,7 +192,7 @@ struct HapCharacteristics { HAPCHAR( VOCDensity, C8, PR+EV, FLOAT, false ); HAPCHAR( Volume, 119, PW+PR+EV, UINT8, false ); HAPCHAR( VolumeControlType, E9, PR+EV, UINT8, true ); - HAPCHAR( VolumeSelector, EA, PR+EV, UINT8, true ); + HAPCHAR( VolumeSelector, EA, PW, UINT8, true ); HAPCHAR( WaterLevel, B5, PR+EV, FLOAT, false ); }; diff --git a/src/HomeSpan.cpp b/src/HomeSpan.cpp index e5328ee..6d8718c 100644 --- a/src/HomeSpan.cpp +++ b/src/HomeSpan.cpp @@ -911,7 +911,7 @@ void Span::processSerialCommand(const char *c){ aidValues.insert((*acc)->aid); for(auto svc=(*acc)->Services.begin(); svc!=(*acc)->Services.end(); svc++){ - Serial.printf(" \u279f Service %s: IID=%d, %sUUIS=\"%s\"",(*svc)->hapName,(*svc)->iid,(*svc)->isCustom?"Custom-":"",(*svc)->type); + Serial.printf(" \u279f Service %s: IID=%d, %sUUID=\"%s\"",(*svc)->hapName,(*svc)->iid,(*svc)->isCustom?"Custom-":"",(*svc)->type); Serial.printf("\n"); if(!strcmp((*svc)->type,"3E")){ diff --git a/src/Span.h b/src/Span.h index 8bb10da..04747ba 100644 --- a/src/Span.h +++ b/src/Span.h @@ -335,6 +335,14 @@ namespace Service { OPT(PowerModeSelection); }}; + struct TelevisionSpeaker : SpanService { TelevisionSpeaker() : SpanService{"113","TelevisionSpeaker"}{ + REQ(Mute); + OPT(Active); + OPT(Volume); + OPT(VolumeControlType); + OPT(VolumeSelector); + }}; + struct TemperatureSensor : SpanService { TemperatureSensor() : SpanService{"8A","TemperatureSensor"}{ REQ(CurrentTemperature); OPT(Name);