SpanRange Updated
Updated SpanRange to register itself automatically to the most recent Characteristic. This is more consistent with the overall framework and no longer requires user to access the range variable directly.
This commit is contained in:
parent
17184483ba
commit
8a905c4d35
|
|
@ -36,15 +36,10 @@ void setup() {
|
|||
|
||||
new Service::LightBulb();
|
||||
new Characteristic::On();
|
||||
new Characteristic::Name("Light Control"); // Adding a Name Characteristic allows us to name this specific Service (see below)
|
||||
new SpanRange(20,100,5);
|
||||
|
||||
new Service::Fan();
|
||||
new Characteristic::Active();
|
||||
new Characteristic::Name("Fan Control"); // Adding a Name Characteristic allows us to name this specific Service (see below)
|
||||
|
||||
// A Note about Names: HomeKit generally uses the name of the primary Service (first one defined) as the name to display on a Tile. However, you can
|
||||
// set HomeKit (from within the Controller) to display each Service as its own tile. In that case the names of the Light and Fan Tiles with both display
|
||||
// as "My Ceiling Fan." By setting individual names for each Service you can create your own display names when Tiles are shown separately.
|
||||
|
||||
} // end of setup()
|
||||
|
||||
|
|
|
|||
|
|
@ -1443,7 +1443,7 @@ void HAPClient::removeController(uint8_t *id){
|
|||
|
||||
if(nAdminControllers()==0){ // if no more admins, remove all controllers
|
||||
removeControllers();
|
||||
LOG2("That was last Admin Controller! Removing any remaining Regular Controllers and unpairing Accessory\n");
|
||||
LOG1("That was last Admin Controller! Removing any remaining Regular Controllers and unpairing Accessory\n");
|
||||
mdns_service_txt_item_set("_hap","_tcp","sf","1"); // set Status Flag = 1 (Table 6-8)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -802,6 +802,7 @@ SpanCharacteristic::SpanCharacteristic(char *type, uint8_t perms){
|
|||
aid=homeSpan.Accessories.back()->aid;
|
||||
}
|
||||
|
||||
///////////////////////////////
|
||||
|
||||
SpanCharacteristic::SpanCharacteristic(char *type, uint8_t perms, boolean value) : SpanCharacteristic(type, perms) {
|
||||
this->format=BOOL;
|
||||
|
|
@ -1054,4 +1055,23 @@ void SpanCharacteristic::autoOff(int waitTime){
|
|||
(*pb)->waitTime=waitTime;
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
///////////////////////////////
|
||||
// SpanRange //
|
||||
///////////////////////////////
|
||||
|
||||
SpanRange::SpanRange(int min, int max, int step){
|
||||
this->min=min;
|
||||
this->max=max;
|
||||
this->step=step;
|
||||
|
||||
if(homeSpan.Accessories.empty() || homeSpan.Accessories.back()->Services.empty() || homeSpan.Accessories.back()->Services.back()->Characteristics.empty() ){
|
||||
Serial.print("*** FATAL ERROR: Can't create new Range without a defined Characteristic. Program halted!\n\n");
|
||||
while(1);
|
||||
}
|
||||
|
||||
homeSpan.Accessories.back()->Services.back()->Characteristics.back()->range=this;
|
||||
}
|
||||
|
||||
///////////////////////////////
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -186,7 +186,7 @@ struct SpanRange{
|
|||
int max;
|
||||
int step;
|
||||
|
||||
SpanRange(int _min, int _max, int _step) : min{_min}, max{_max}, step{_step} {};
|
||||
SpanRange(int min, int max, int step);
|
||||
};
|
||||
|
||||
///////////////////////////////
|
||||
|
|
|
|||
Loading…
Reference in New Issue