Added ability to change permissions for Characteristics
New methods for Characteristics: setPerms(uint8_t perms); addPerms(uint8_t dPerms); removePerms(uint8_t dPerms); where perms and dPerms = PR|PW|EV...
This commit is contained in:
parent
9de26715f0
commit
3f833beb74
|
|
@ -566,7 +566,38 @@ struct SpanCharacteristic{
|
||||||
}
|
}
|
||||||
|
|
||||||
} // setVal()
|
} // setVal()
|
||||||
|
|
||||||
|
SpanCharacteristic *setPerms(uint8_t perms){
|
||||||
|
this->perms=perms;
|
||||||
|
homeSpan.configLog+=String(" \u2b0c Change Permissions for ") + String(hapName) + " with AID=" + String(aid) + ", IID=" + String(iid) + ":";
|
||||||
|
|
||||||
|
char pNames[][7]={"PR","PW","EV","AA","TW","HD","WR"};
|
||||||
|
char sep=' ';
|
||||||
|
|
||||||
|
for(uint8_t i=0;i<7;i++){
|
||||||
|
if(perms & (1<<i)){
|
||||||
|
homeSpan.configLog+=String(sep) + String(pNames[i]);
|
||||||
|
sep='+';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(perms==0){
|
||||||
|
homeSpan.configLog+=" *** ERROR! Undefined Permissions! ***";
|
||||||
|
homeSpan.nFatalErrors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
homeSpan.configLog+="\n";
|
||||||
|
return(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
SpanCharacteristic *addPerms(uint8_t dPerms){
|
||||||
|
return(setPerms(perms|dPerms));
|
||||||
|
}
|
||||||
|
|
||||||
|
SpanCharacteristic *removePerms(uint8_t dPerms){
|
||||||
|
return(setPerms(perms&(~dPerms)));
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,7 @@ void setup() {
|
||||||
new Characteristic::Name("Light 3");
|
new Characteristic::Name("Light 3");
|
||||||
new Characteristic::TargetPosition();
|
new Characteristic::TargetPosition();
|
||||||
new Characteristic::OzoneDensity();
|
new Characteristic::OzoneDensity();
|
||||||
|
(new Characteristic::OzoneDensity())->addPerms(PW+AA)->removePerms(EV+PR);
|
||||||
|
|
||||||
} // end of setup()
|
} // end of setup()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue