Correct setVal() logic to properly check for EV permissions, not PW permissions
This commit is contained in:
parent
8a24819955
commit
dcbfbc3e15
|
|
@ -85,6 +85,30 @@ struct HKTV : Service::Television {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct TV_Source : Service::InputSource{
|
||||||
|
|
||||||
|
SpanCharacteristic *currentState = new Characteristic::CurrentVisibilityState(0);
|
||||||
|
SpanCharacteristic *targetState = new Characteristic::TargetVisibilityState(0);
|
||||||
|
|
||||||
|
TV_Source() : Service::InputSource(){
|
||||||
|
new Characteristic::ConfiguredName("HDMI 12");
|
||||||
|
new Characteristic::Identifier(12);
|
||||||
|
new Characteristic::IsConfigured(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean update() override{
|
||||||
|
|
||||||
|
if(targetState->updated()){
|
||||||
|
Serial.printf("New Target State = %d\n",targetState->getNewVal());
|
||||||
|
currentState->setVal(targetState->getNewVal());
|
||||||
|
}
|
||||||
|
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
homeSpan.begin(Category::Television,"HomeSpan Television");
|
homeSpan.begin(Category::Television,"HomeSpan Television");
|
||||||
|
|
@ -162,11 +186,13 @@ void setup() {
|
||||||
new Characteristic::CurrentVisibilityState(0);
|
new Characteristic::CurrentVisibilityState(0);
|
||||||
|
|
||||||
SpanService *hdmi11 = new Service::InputSource();
|
SpanService *hdmi11 = new Service::InputSource();
|
||||||
new Characteristic::ConfiguredNameStatic("HDMI 11");
|
new Characteristic::ConfiguredName("HDMI 11");
|
||||||
new Characteristic::Identifier(11);
|
new Characteristic::Identifier(11);
|
||||||
new Characteristic::IsConfigured(1);
|
new Characteristic::IsConfigured(1);
|
||||||
new Characteristic::TargetVisibilityState(0);
|
new Characteristic::TargetVisibilityState(0);
|
||||||
new Characteristic::CurrentVisibilityState(0);
|
new Characteristic::CurrentVisibilityState(0);
|
||||||
|
|
||||||
|
SpanService *hdmi12 = new TV_Source();
|
||||||
|
|
||||||
(new Service::Television())
|
(new Service::Television())
|
||||||
->addLink(hdmi1)
|
->addLink(hdmi1)
|
||||||
|
|
@ -180,6 +206,7 @@ void setup() {
|
||||||
->addLink(hdmi9)
|
->addLink(hdmi9)
|
||||||
->addLink(hdmi10)
|
->addLink(hdmi10)
|
||||||
->addLink(hdmi11)
|
->addLink(hdmi11)
|
||||||
|
->addLink(hdmi12)
|
||||||
;
|
;
|
||||||
new Characteristic::Active(1);
|
new Characteristic::Active(1);
|
||||||
new Characteristic::ConfiguredName("AdvancedTV");
|
new Characteristic::ConfiguredName("AdvancedTV");
|
||||||
|
|
|
||||||
|
|
@ -486,8 +486,8 @@ struct SpanCharacteristic{
|
||||||
|
|
||||||
template <typename T> void setVal(T val){
|
template <typename T> void setVal(T val){
|
||||||
|
|
||||||
if(format==FORMAT::STRING && perms & PW == 0){
|
if((perms & EV) == 0){
|
||||||
Serial.printf("\n*** WARNING: Attempt to update Characteristic::%s(\"%s\") with setVal() ignored. No WRITE permission on this characteristic\n\n",hapName,value.STRING);
|
Serial.printf("\n*** WARNING: Attempt to update Characteristic::%s with setVal() ignored. No NOTIFICATION permission on this characteristic\n\n",hapName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue