diff --git a/examples/4-AdvancedCeilingFan/4-AdvancedCeilingFan.ino b/examples/4-AdvancedCeilingFan/4-AdvancedCeilingFan.ino index 08fddbd..fd12aa5 100644 --- a/examples/4-AdvancedCeilingFan/4-AdvancedCeilingFan.ino +++ b/examples/4-AdvancedCeilingFan/4-AdvancedCeilingFan.ino @@ -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() diff --git a/src/HAP.cpp b/src/HAP.cpp index 27aef41..225ff51 100644 --- a/src/HAP.cpp +++ b/src/HAP.cpp @@ -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) } diff --git a/src/HomeSpan.cpp b/src/HomeSpan.cpp index 8a83488..a0486df 100644 --- a/src/HomeSpan.cpp +++ b/src/HomeSpan.cpp @@ -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; +} + +/////////////////////////////// + + diff --git a/src/HomeSpan.h b/src/HomeSpan.h index d49e112..d960cc3 100644 --- a/src/HomeSpan.h +++ b/src/HomeSpan.h @@ -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); }; ///////////////////////////////