diff --git a/examples/01-SimpleLightBulb/01-SimpleLightBulb.ino b/examples/01-SimpleLightBulb/01-SimpleLightBulb.ino index 8f1a706..6487c48 100644 --- a/examples/01-SimpleLightBulb/01-SimpleLightBulb.ino +++ b/examples/01-SimpleLightBulb/01-SimpleLightBulb.ino @@ -1,7 +1,7 @@ /********************************************************************************* * MIT License * - * Copyright (c) 2020 Gregg E. Berman + * Copyright (c) 2020-2022 Gregg E. Berman * * https://github.com/HomeSpan/HomeSpan * @@ -98,14 +98,7 @@ void setup() { // Your HomeSpan code should be placed within the // new Characteristic::Model("120-Volt Lamp"); // Model of the Accessory (arbitrary text string, and can be the same for every Accessory) // new Characteristic::FirmwareRevision("0.9"); // Firmware of the Accessory (arbitrary text string, and can be the same for every Accessory) - // *NOTE* HAP requires that the AccessoryInformation Service always be instantiated BEFORE any other Services, which is why we created it first. - - // HAP also requires every Accessory (with the exception of those in Bridges, as we will see later) to implement the HAP Protocol Information Service. - // This Service supports a single required Characteristic that defines the version number of HAP used by the device. - // HAP Release R2 requires this version to be set to "1.1.0" - - new Service::HAPProtocolInformation(); // Create the HAP Protcol Information Service - new Characteristic::Version("1.1.0"); // Set the Version Characteristicto "1.1.0" as required by HAP + // *NOTE* HAP requires that the Accessory Information Service always be instantiated BEFORE any other Services, which is why we created it first. // Now that the required "informational" Services have been defined, we can finally create our Light Bulb Service diff --git a/examples/02-TwoSimpleLightBulbs/02-TwoSimpleLightBulbs.ino b/examples/02-TwoSimpleLightBulbs/02-TwoSimpleLightBulbs.ino index 99588a6..cf07904 100644 --- a/examples/02-TwoSimpleLightBulbs/02-TwoSimpleLightBulbs.ino +++ b/examples/02-TwoSimpleLightBulbs/02-TwoSimpleLightBulbs.ino @@ -1,7 +1,7 @@ /********************************************************************************* * MIT License * - * Copyright (c) 2020 Gregg E. Berman + * Copyright (c) 2020-2022 Gregg E. Berman * * https://github.com/HomeSpan/HomeSpan * @@ -52,9 +52,6 @@ void setup() { new Service::AccessoryInformation(); // HAP requires every Accessory to implement an AccessoryInformation Service, with the required Identify Characteristic new Characteristic::Identify(); // Create the required Identify - - new Service::HAPProtocolInformation(); // Create the HAP Protcol Information Service - new Characteristic::Version("1.1.0"); // Set the Version Characteristicto "1.1.0" as required by HAP new Service::LightBulb(); // Create the Light Bulb Service new Characteristic::On(); // This Service requires the "On" Characterstic to turn the light on and off @@ -65,9 +62,6 @@ void setup() { new Service::AccessoryInformation(); // HAP requires every Accessory to implement an AccessoryInformation Service, with the required Identify Characteristic new Characteristic::Identify(); // Create the required Identify - - new Service::HAPProtocolInformation(); // Create the HAP Protcol Information Service - new Characteristic::Version("1.1.0"); // Set the Version Characteristicto "1.1.0" as required by HAP new Service::LightBulb(); // Create the Light Bulb Service new Characteristic::On(); // This Service requires the "On" Characterstic to turn the light on and off diff --git a/examples/03-CeilingFanWithLight/03-CeilingFanWithLight.ino b/examples/03-CeilingFanWithLight/03-CeilingFanWithLight.ino index 200da33..dbeb060 100644 --- a/examples/03-CeilingFanWithLight/03-CeilingFanWithLight.ino +++ b/examples/03-CeilingFanWithLight/03-CeilingFanWithLight.ino @@ -1,7 +1,7 @@ /********************************************************************************* * MIT License * - * Copyright (c) 2020 Gregg E. Berman + * Copyright (c) 2020-2022 Gregg E. Berman * * https://github.com/HomeSpan/HomeSpan * @@ -50,9 +50,6 @@ void setup() { new Service::AccessoryInformation(); // HAP requires every Accessory to implement an AccessoryInformation Service, with the required Identify Characteristic new Characteristic::Identify(); // Create the required Identify - - new Service::HAPProtocolInformation(); // Create the HAP Protcol Information Service - new Characteristic::Version("1.1.0"); // Set the Version Characteristicto "1.1.0" as required by HAP new Service::LightBulb(); // Create the Light Bulb Service new Characteristic::On(); // This Service requires the "On" Characterstic to turn the light on and off diff --git a/examples/04-AdvancedCeilingFan/04-AdvancedCeilingFan.ino b/examples/04-AdvancedCeilingFan/04-AdvancedCeilingFan.ino index 87c76b7..560cbd1 100644 --- a/examples/04-AdvancedCeilingFan/04-AdvancedCeilingFan.ino +++ b/examples/04-AdvancedCeilingFan/04-AdvancedCeilingFan.ino @@ -1,7 +1,7 @@ /********************************************************************************* * MIT License * - * Copyright (c) 2020 Gregg E. Berman + * Copyright (c) 2020-2022 Gregg E. Berman * * https://github.com/HomeSpan/HomeSpan * @@ -50,10 +50,7 @@ void setup() { new SpanAccessory(); new Service::AccessoryInformation(); - new Characteristic::Identify(); - - new Service::HAPProtocolInformation(); - new Characteristic::Version("1.1.0"); + new Characteristic::Identify(); new Service::LightBulb(); new Characteristic::On(true); // NEW: Providing an argument sets its initial value. In this case it means the LightBulb will be turned on at start-up diff --git a/examples/05-WorkingLED/05-WorkingLED.ino b/examples/05-WorkingLED/05-WorkingLED.ino index 4316c6b..71a68b1 100644 --- a/examples/05-WorkingLED/05-WorkingLED.ino +++ b/examples/05-WorkingLED/05-WorkingLED.ino @@ -1,7 +1,7 @@ /********************************************************************************* * MIT License * - * Copyright (c) 2020 Gregg E. Berman + * Copyright (c) 2020-2022 Gregg E. Berman * * https://github.com/HomeSpan/HomeSpan * @@ -74,10 +74,7 @@ void setup() { new SpanAccessory(); new Service::AccessoryInformation(); - new Characteristic::Identify(); - - new Service::HAPProtocolInformation(); - new Characteristic::Version("1.1.0"); + new Characteristic::Identify(); // In Example 2 we instantiated a LightBulb Service and its "On" Characteristic here. We are now going to replace these two lines (by commenting them out)... @@ -97,10 +94,7 @@ void setup() { new SpanAccessory(); new Service::AccessoryInformation(); - new Characteristic::Identify(); - - new Service::HAPProtocolInformation(); - new Characteristic::Version("1.1.0"); + new Characteristic::Identify(); // new Service::LightBulb(); // Same as above, this line is deleted... // new Characteristic::On(); // This line is also deleted... diff --git a/examples/06-DimmableLED/06-DimmableLED.ino b/examples/06-DimmableLED/06-DimmableLED.ino index 71d255a..f81ea0f 100644 --- a/examples/06-DimmableLED/06-DimmableLED.ino +++ b/examples/06-DimmableLED/06-DimmableLED.ino @@ -1,7 +1,7 @@ /********************************************************************************* * MIT License * - * Copyright (c) 2020 Gregg E. Berman + * Copyright (c) 2020-2022 Gregg E. Berman * * https://github.com/HomeSpan/HomeSpan * @@ -64,20 +64,14 @@ void setup() { new SpanAccessory(); new Service::AccessoryInformation(); - new Characteristic::Identify(); - - new Service::HAPProtocolInformation(); - new Characteristic::Version("1.1.0"); + new Characteristic::Identify(); new DEV_LED(16); // create an on/off LED attached to pin 16 (same as in Example 5) new SpanAccessory(); new Service::AccessoryInformation(); - new Characteristic::Identify(); - - new Service::HAPProtocolInformation(); - new Characteristic::Version("1.1.0"); + new Characteristic::Identify(); new DEV_DimmableLED(17); // NEW! create a dimmable (PWM-driven) LED attached to pin 17. See new code at end of DEV_LED.h diff --git a/examples/07-AccessoryNames/07-AccessoryNames.ino b/examples/07-AccessoryNames/07-AccessoryNames.ino index c99c967..d1d7320 100644 --- a/examples/07-AccessoryNames/07-AccessoryNames.ino +++ b/examples/07-AccessoryNames/07-AccessoryNames.ino @@ -1,7 +1,7 @@ /********************************************************************************* * MIT License * - * Copyright (c) 2020 Gregg E. Berman + * Copyright (c) 2020-2022 Gregg E. Berman * * https://github.com/HomeSpan/HomeSpan * @@ -65,21 +65,15 @@ void setup() { new Service::AccessoryInformation(); new Characteristic::Identify(); - new Characteristic::Name("Simply LED"); // This use of Name() will be ignored by the Home App. The default name for the Accessory will continue to be shown as "HomeSpan LED" - - new Service::HAPProtocolInformation(); - new Characteristic::Version("1.1.0"); + new Characteristic::Name("Simple LED"); // This use of Name() will be ignored by the Home App. The default name for the Accessory will continue to be shown as "HomeSpan LED" - new DEV_LED(16); // create an on/off LED attached to pin 16 (same as in Example 5) + new DEV_LED(16); new SpanAccessory(); new Service::AccessoryInformation(); new Characteristic::Identify(); - new Characteristic::Name("Dimmable LED"); // This DOES change the default name for the Accessory from "HomeSpan LED 2" to "Dimmable LED" - - new Service::HAPProtocolInformation(); - new Characteristic::Version("1.1.0"); + new Characteristic::Name("Dimmable LED"); // This DOES change the default name for the Accessory from "HomeSpan LED 2" to "Dimmable LED" new DEV_DimmableLED(17); diff --git a/examples/07-IdentifyRoutines/07-IdentifyRoutines.ino b/examples/07-IdentifyRoutines/07-IdentifyRoutines.ino deleted file mode 100644 index 62d9f5c..0000000 --- a/examples/07-IdentifyRoutines/07-IdentifyRoutines.ino +++ /dev/null @@ -1,115 +0,0 @@ -/********************************************************************************* - * MIT License - * - * Copyright (c) 2020 Gregg E. Berman - * - * https://github.com/HomeSpan/HomeSpan - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - ********************************************************************************/ - -//////////////////////////////////////////////////////////// -// // -// HomeSpan: A HomeKit implementation for the ESP32 // -// ------------------------------------------------ // -// // -// Example 7: Transforming AccessoryInformation into a // -// derived Service that implements the // -// Identify Characteristic // -// // -//////////////////////////////////////////////////////////// - -#include "HomeSpan.h" -#include "DEV_LED.h" -#include "DEV_Identify.h" // NEW! This is where we store all code for the DEV_Identify Service - -void setup() { - - // In Example 5 we saw how to create a derived Service to encapsulate all the functionality needed to implement DEV_LED - // in it's own DEV_LED.h file. Then, in Example 6 we extended that further by implementing DEV_DimmableLED. In this - // example we do the same for the AccessoryInformation Service. Note how AccessoryInformation, and all of its - // Characteristics, need to be defined for every Accessory. By deriving a new Service that implements a multi-argument - // constructor we can avoid having to separately create each required Characteristic every time. Creating a derived Service - // also allows us to implement device-specific code for the Identify Characteristic. We will call this derived Service - // DEV_Identify, and store its code in "DEV_Identify.h" which has already been included above. - - // As usual, all previous comments have been deleted and only new changes from the previous example are shown. - - // NOTE: To see how this works in practice, you'll need to unpair your device and re-pair it once the new code is loaded. - // This will allow oyu to activate the identify routines. - - Serial.begin(115200); - - homeSpan.begin(Category::Lighting,"HomeSpan LEDs"); - - new SpanAccessory(); - - // Rather than instantiate the AccessoryInformation Service and all of it's required Characteristics, - // we'll delete these line (comment them out)... - - // new Service::AccessoryInformation(); - // new Characteristic::Name("On/Off LED"); - // new Characteristic::Manufacturer("HomeSpan"); - // new Characteristic::SerialNumber("123-ABC"); - // new Characteristic::Model("20mA LED"); - // new Characteristic::FirmwareRevision("0.9"); - // new Characteristic::Identify(); - - // ...and replace them with this single line that implements everything above. See DEV_Identify.h for - // details on how this is defined. Note there is an extra argument at the end we set to 3. - // This optional argument will be used to run the identify routine (see code for details) - - new DEV_Identify("On/Off LED","HomeSpan","123-ABC","20mA LED","0.9",3); // NEW! This implements all the Characteristics above - - new Service::HAPProtocolInformation(); - new Characteristic::Version("1.1.0"); - - new DEV_LED(16); // create an on/off LED attached to pin 16 (same as in Example 5) - - new SpanAccessory(); - - // Same as above, we can replace all of this... - - // new Service::AccessoryInformation(); - // new Characteristic::Name("Dimmable LED"); - // new Characteristic::Manufacturer("HomeSpan"); - // new Characteristic::SerialNumber("123-ABC"); - // new Characteristic::Model("20mA LED"); - // new Characteristic::FirmwareRevision("0.9"); - // new Characteristic::Identify(); - - // ...with this (note we set last argument to 5 this time - see code for what this does) - - new DEV_Identify("Dimmable LED","HomeSpan","123-ABC","20mA LED","0.9",5); // NEW! This implements all the Characteristics above - - new Service::HAPProtocolInformation(); - new Characteristic::Version("1.1.0"); - - new DEV_DimmableLED(17); // create a dimmable (PWM-driven) LED attached to pin 17 - -} // end of setup() - -////////////////////////////////////// - -void loop(){ - - homeSpan.poll(); - -} // end of loop() diff --git a/examples/07-IdentifyRoutines/DEV_Identify.h b/examples/07-IdentifyRoutines/DEV_Identify.h deleted file mode 100644 index 01e591b..0000000 --- a/examples/07-IdentifyRoutines/DEV_Identify.h +++ /dev/null @@ -1,65 +0,0 @@ - -////////////////////////////////// -// DEVICE-SPECIFIC SERVICES // -////////////////////////////////// - -// Here we define the DEV_Identify Service as derived class of AccessoryInformation - -struct DEV_Identify : Service::AccessoryInformation { - - int nBlinks; // number of times to blink built-in LED in identify routine - SpanCharacteristic *identify; // reference to the Identify Characteristic - - // Next we define the constructor using all the arguments needed to implement the required Characteristics - // of AccessoryInformation, plus one extra argument at the end called "nBlinks" we will use to specify how many - // times HomeSpan should blink the built-in LED when HomeKit calls this device's Identify routine during pairing. - - DEV_Identify(const char *name, const char *manu, const char *sn, const char *model, const char *version, int nBlinks) : Service::AccessoryInformation(){ - - new Characteristic::Name(name); // create all the required Characteristics with values set based on above arguments - new Characteristic::Manufacturer(manu); - new Characteristic::SerialNumber(sn); - new Characteristic::Model(model); - new Characteristic::FirmwareRevision(version); - identify=new Characteristic::Identify(); // store a reference to the Identify Characteristic for use below - - this->nBlinks=nBlinks; // store the number of times to blink the LED - - pinMode(homeSpan.getStatusPin(),OUTPUT); // make sure LED is set for output - } - - // How HomeKit Identifies Devices: - // - // When HomeKit first pairs with a new device it "calls" that device's identify routine for every defined Accessory. - // To do so, HomeKit requests the Identify Characteristic for each defined AccessoryInformation Service to be set to "true". - // The Identify Characteristic is write-only, so no value is ever stored, even though HomeKit is requesting its value - // be updated. We can therefore use the same update() method as if the Identify Characteristic was the same as any - // other boolean Characteristic. - - // There are many ways to implement some form of identification. For an LED, you could blink it one or more times. - // For a LightBulb, you can flash it on and off. For window shade, you could raise and lower it. - // Most commerical devices don't do anything. Because HomeSpan can be used to control many different types of - // device, below we implement a very generic routine that simply blinks the Status LED the number of times specified above. - // In principle, this code could call a user-defined routine that is different for each physcially-attached device (light, shade, fan, etc), - // but in practice this is overkill. - - // Note that the blink routine below starts by turning off the Status LED and then leaves it on once it has blinked - // the specified number of times. This is because when HomeSpan starts up if confirms to user that it has connected - // to the WiFi network by turning on the Status LED. Thus we want to leave it on when blinking is completed. - - // Also note we use the homeSpan.getStatusPin() method to find the pin number associated with the Status LED - - boolean update(){ - - for(int i=0;iledPin=ledPin; - pinMode(ledPin,OUTPUT); - - } // end constructor - - boolean update(){ // update() method - - digitalWrite(ledPin,power->getNewVal()); - - return(true); // return true - - } // update -}; - -////////////////////////////////// - -struct DEV_DimmableLED : Service::LightBulb { // Dimmable LED - - LedPin *ledPin; // reference to Led Pin - SpanCharacteristic *power; // reference to the On Characteristic - SpanCharacteristic *level; // reference to the Brightness Characteristic - - DEV_DimmableLED(int pin) : Service::LightBulb(){ // constructor() method - - power=new Characteristic::On(); - - level=new Characteristic::Brightness(50); // Brightness Characteristic with an initial value of 50% - level->setRange(5,100,1); // sets the range of the Brightness to be from a min of 5%, to a max of 100%, in steps of 1% - - this->ledPin=new LedPin(pin); // configures a PWM LED for output to the specified pin - - } // end constructor - - boolean update(){ // update() method - - ledPin->set(power->getNewVal()*level->getNewVal()); - - return(true); // return true - - } // update -}; - -////////////////////////////////// diff --git a/examples/08-Bridges/08-Bridges.ino b/examples/08-Bridges/08-Bridges.ino index b01a4dd..4469daa 100644 --- a/examples/08-Bridges/08-Bridges.ino +++ b/examples/08-Bridges/08-Bridges.ino @@ -1,7 +1,7 @@ /********************************************************************************* * MIT License * - * Copyright (c) 2020 Gregg E. Berman + * Copyright (c) 2020-2022 Gregg E. Berman * * https://github.com/HomeSpan/HomeSpan * @@ -31,33 +31,29 @@ // ------------------------------------------------ // // // // Example 8: HomeKit Bridges and Bridge Accessories // -// ** the preferred method for HomeSpan ** // // // //////////////////////////////////////////////////////////// #include "HomeSpan.h" #include "DEV_LED.h" -#include "DEV_Identify.h" void setup() { - // Though we've seen in prior examples that one device can support multiple Accessories, HomeKit provides a more - // general multi-Accessory framework that is somewhat more robust and easier to use: HomeKit Bridges. - // A Bridge is a device that includes multiple Accessories, except that the FIRST defined Accessory contains - // nothing but the AccessoryInformation Service and the HAPProtcolInformation Service. When such a device is paired - // to HomeKit, it is automatically recognized as a Bridge. All of the other Accessories defined in the device are - // associated with this Bridge. If you unpair the Bridge from HomeKit, all associated Accessories are automatically - // removed. - // - // Adding, editing, and deleting the other Accessories occurs in the same manner as before, but because the device - // is paired as a Bridge, changes to the other Accessories is less likely to require you to un-pair and re-pair - // the device. HomeKit seems to be able to better process changes when they are done within a Bridge framework. - // - // One added bonus is that the HAPProtcolInformation Service only needs to be defined for the Bridge Accessory, and - // does not need to be repeated for other Accessories. - // - // Example 8 is functionally identical to Example 7, except that instead of defining two Accessories (one for the on/off - // LED and one for the dimmable LED), we define three Accessories, where the first acts as the Bridge. + // If the only Service defined in the FIRST Accessory of a mult-Accessory device is the required Accessory Information Service, + // the device is said to be configured as a "Bridge". Historically there may have been a number of functional differences between bridge + // devices and non-bridge devices, but since iOS 15, it's not obvious there are any differences in functionality, with two exceptions: + + // 1. Recall from Example 7 that the use of Characteristic::Name() to change the default name of an Accessory Tile + // does not work for the first Accessory defined. The Home App always displays the default name of the first Accessory Tile + // as the name of the device specified in homeSpan.begin(). However, this is not an issue when implementing a device + // as a Bridge, since the first Accessory is nothing but the Bridge itself - having the default name match the name + // of the device in this case makes much more sense. More importantly, you can now use Characteristic::Name() to change the + // default name of BOTH the LED Accessory Tiles. + + // 2. Devices configured as a Bridge appear in the Home App under the main settings page that displays all Hubs and Bridges. + + // The sketch below is functionally identical to Example 7, except that instead of defining two Accessories (one for the Simple On/Off + // LED and one for the Dimmable LED), we define three Accessories, where the first acts as the Bridge. // As usual, all previous comments have been deleted and only new changes from the previous example are shown. @@ -65,40 +61,28 @@ void setup() { Serial.begin(115200); - homeSpan.begin(Category::Bridges,"HomeSpan Bridge"); // CHANGED! Note that we replaced Category::Lighting with Bridges (this changes the icon when pairing) + // Below we replace Category::Lighting with Category::Bridges. This changes the icon of the device shown when pairing + // with the Home App. It does NOT change any of the icons for an Accessory Tile (these are determined by the types of + // Services implemented in each Accessory - see Example 9). Note you can choose any Category you like - for instance, + // we could have continued to use Category::Lighting, even though we are configuring the device as a Bridge. - // We begin by creating a Bridge Accessory, which look just like any other Accessory, - // except that is only contains DEV_Identify (which is derived from AccessoryInformation) - // and HAPProtcolInformation (required). Note that HomeKit will still call the identify - // update() routine upon pairing, so we specify the number of blinks to be 3. + homeSpan.begin(Category::Bridges,"HomeSpan Bridge"); - new SpanAccessory(); - new DEV_Identify("Bridge #1","HomeSpan","123-ABC","HS Bridge","0.9",3); - new Service::HAPProtocolInformation(); - new Characteristic::Version("1.1.0"); + new SpanAccessory(); // This first Accessory is the new "Bridge" Accessory. It contains no functional Services, just the Accessory Information Service + new Service::AccessoryInformation(); + new Characteristic::Identify(); + + new SpanAccessory(); // This second Accessory is the same as the first Accessory in Example 7, with the exception that Characteristic::Name() now does something + new Service::AccessoryInformation(); + new Characteristic::Identify(); + new Characteristic::Name("Simple LED"); // Note that unlike in Example 7, this use of Name() is properly implented by the Home App since it is not the first Accessory (the Bridge above is the first) + new DEV_LED(16); - // Now we simply repeat the definitions of the previous LED Accessories, as per Example 7, with two exceptions: - // 1) We no longer need to include the HAPProtocolInformation Service. - // 2) We will set the number of blinks to zero, so that only the bridge accessory will cause the Built-In - // LED to blink. This becomes especially important if you had 20 Accessories defined and needed to wait a - // minute or more for all the blinking to finish while pairing. - - new SpanAccessory(); - new DEV_Identify("On/Off LED","HomeSpan","123-ABC","20mA LED","0.9",0); // CHANGED! The number of blinks is now set to zero - - // new Service::HAPProtocolInformation(); - DELETED - NO LONGER NEEDED - // new Characteristic::Version("1.1.0"); - DELETED - NO LONGER NEEDED - - new DEV_LED(16); // create an on/off LED attached to pin 16 - - new SpanAccessory(); - - new DEV_Identify("Dimmable LED","HomeSpan","123-ABC","20mA LED","0.9",0); // CHANGED! The number of blinks is now set to zero - - // new Service::HAPProtocolInformation(); - DELETED - NO LONGER NEEDED - // new Characteristic::Version("1.1.0"); - DELETED - NO LONGER NEEDED - - new DEV_DimmableLED(17); // create a dimmable (PWM-driven) LED attached to pin 17 + new SpanAccessory(); // This third Accessory is the same as the second Accessory in Example 7 + new Service::AccessoryInformation(); + new Characteristic::Identify(); + new Characteristic::Name("Dimmable LED"); + new DEV_DimmableLED(17); } // end of setup() diff --git a/examples/08-Bridges/DEV_Identify.h b/examples/08-Bridges/DEV_Identify.h deleted file mode 100644 index b8d21d6..0000000 --- a/examples/08-Bridges/DEV_Identify.h +++ /dev/null @@ -1,38 +0,0 @@ - -////////////////////////////////// -// DEVICE-SPECIFIC SERVICES // -////////////////////////////////// - -struct DEV_Identify : Service::AccessoryInformation { - - int nBlinks; // number of times to blink built-in LED in identify routine - SpanCharacteristic *identify; // reference to the Identify Characteristic - - DEV_Identify(const char *name, const char *manu, const char *sn, const char *model, const char *version, int nBlinks) : Service::AccessoryInformation(){ - - new Characteristic::Name(name); // create all the required Characteristics with values set based on above arguments - new Characteristic::Manufacturer(manu); - new Characteristic::SerialNumber(sn); - new Characteristic::Model(model); - new Characteristic::FirmwareRevision(version); - identify=new Characteristic::Identify(); // store a reference to the Identify Characteristic for use below - - this->nBlinks=nBlinks; // store the number of times to blink the LED - - pinMode(homeSpan.getStatusPin(),OUTPUT); // make sure LED is set for output - } - - boolean update(){ - - for(int i=0;i