Updated "Other Examples" and added SPAN_ACCESSORY() Macro
Need to revisit Television sketch - the latest iOS seemed to have disabled the ability to dynamically set visibility of input sources. Checking/Un-Checking the visibility radio buttons either during pairing, or after pairing on the settings screen, seems to be ignored by the Home App (the same input sources are shown in the selector regardless of any changes made). However, dynamically changing the name of an input source seems to work fine.
This commit is contained in:
parent
2277b2506f
commit
0507f26b13
|
|
@ -97,19 +97,7 @@ void setup() {
|
|||
|
||||
homeSpan.begin(Category::Sensors,"Eve Air Pressure");
|
||||
|
||||
new SpanAccessory();
|
||||
|
||||
new Service::AccessoryInformation();
|
||||
new Characteristic::Name("Air Pressure");
|
||||
new Characteristic::Manufacturer("HomeSpan");
|
||||
new Characteristic::SerialNumber("123-ABC");
|
||||
new Characteristic::Model("Simulated Sensor");
|
||||
new Characteristic::FirmwareRevision("1.0");
|
||||
new Characteristic::Identify();
|
||||
|
||||
new Service::HAPProtocolInformation();
|
||||
new Characteristic::Version("1.1.0");
|
||||
|
||||
SPAN_ACCESSORY();
|
||||
new PressureSensor();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -182,55 +182,15 @@ void setup() {
|
|||
|
||||
homeSpan.begin(Category::Lighting,"Pixel LEDS" DEVICE_SUFFIX);
|
||||
|
||||
new SpanAccessory(); // create Bridge
|
||||
new Service::AccessoryInformation();
|
||||
new Characteristic::Name("Pixel LEDS" DEVICE_SUFFIX);
|
||||
new Characteristic::Manufacturer("HomeSpan");
|
||||
new Characteristic::SerialNumber("123-ABC");
|
||||
new Characteristic::Model("Neo/Dot Pixels");
|
||||
new Characteristic::FirmwareRevision("1.0");
|
||||
new Characteristic::Identify();
|
||||
|
||||
new Service::HAPProtocolInformation();
|
||||
new Characteristic::Version("1.1.0");
|
||||
|
||||
/////////
|
||||
|
||||
new SpanAccessory();
|
||||
new Service::AccessoryInformation();
|
||||
new Characteristic::Name("Neo RGB");
|
||||
new Characteristic::Manufacturer("HomeSpan");
|
||||
new Characteristic::SerialNumber("123-ABC");
|
||||
new Characteristic::Model("8-LED Strand");
|
||||
new Characteristic::FirmwareRevision("1.0");
|
||||
new Characteristic::Identify();
|
||||
SPAN_ACCESSORY(); // create Bridge (note this sketch uses the SPAN_ACCESSORY() macro, introduced in v1.5.1 --- see the HomeSpan API Reference for details on this convenience macro)
|
||||
|
||||
SPAN_ACCESSORY("Neo RGB");
|
||||
new NeoPixel_RGB(NEOPIXEL_RGB_PIN,8); // create 8-LED NeoPixel RGB Strand with full color control
|
||||
|
||||
/////////
|
||||
|
||||
new SpanAccessory();
|
||||
new Service::AccessoryInformation();
|
||||
new Characteristic::Name("Neo RGBW");
|
||||
new Characteristic::Manufacturer("HomeSpan");
|
||||
new Characteristic::SerialNumber("123-ABC");
|
||||
new Characteristic::Model("60-LED Strand");
|
||||
new Characteristic::FirmwareRevision("1.0");
|
||||
new Characteristic::Identify();
|
||||
|
||||
SPAN_ACCESSORY("Neo RGBW");
|
||||
new NeoPixel_RGBW(NEOPIXEL_RGBW_PIN,60); // create 60-LED NeoPixel RGBW Strand with simulated color temperature control
|
||||
|
||||
/////////
|
||||
|
||||
new SpanAccessory();
|
||||
new Service::AccessoryInformation();
|
||||
new Characteristic::Name("Dot RGB");
|
||||
new Characteristic::Manufacturer("HomeSpan");
|
||||
new Characteristic::SerialNumber("123-ABC");
|
||||
new Characteristic::Model("30-LED Strand");
|
||||
new Characteristic::FirmwareRevision("1.0");
|
||||
new Characteristic::Identify();
|
||||
|
||||
SPAN_ACCESSORY("Dot RGB");
|
||||
new DotStar_RGB(DOTSTAR_DATA_PIN,DOTSTAR_CLOCK_PIN,30); // create 30-LED DotStar RGB Strand displaying a spectrum of colors and using the current-limiting feature of DotStars to create flicker-free dimming
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,29 @@
|
|||
/* HomeSpan Remote Control Example */
|
||||
/*********************************************************************************
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2020-2022 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.
|
||||
*
|
||||
********************************************************************************/
|
||||
|
||||
#include "HomeSpan.h" // include the HomeSpan library
|
||||
#include "extras/RFControl.h" // include RF Control Library
|
||||
|
|
|
|||
|
|
@ -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<nBlinks;i++){
|
||||
digitalWrite(homeSpan.getStatusPin(),LOW);
|
||||
delay(250);
|
||||
digitalWrite(homeSpan.getStatusPin(),HIGH);
|
||||
delay(250);
|
||||
}
|
||||
|
||||
return(true); // return true
|
||||
|
||||
} // update
|
||||
|
||||
};
|
||||
|
|
@ -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,7 +31,6 @@
|
|||
// is controlled by a Servo connected to the ESP32.
|
||||
|
||||
#include "HomeSpan.h"
|
||||
#include "DEV_Identify.h"
|
||||
#include "DEV_DoorsWindows.h"
|
||||
|
||||
void setup() {
|
||||
|
|
@ -41,12 +40,13 @@ void setup() {
|
|||
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 Service::AccessoryInformation();
|
||||
new Characteristic::Identify();
|
||||
|
||||
new SpanAccessory();
|
||||
new DEV_Identify("Window Shade","HomeSpan","123-ABC","Shade","0.9",0);
|
||||
new Service::AccessoryInformation();
|
||||
new Characteristic::Identify();
|
||||
new Characteristic::Name("Window Shade");
|
||||
new DEV_WindowShade(18); // Create a motorized Window Shade with a Servo attached to Pin 18 that controls the Horizontal Tilt of the Shade
|
||||
|
||||
} // end of setup()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,29 @@
|
|||
/* HomeSpan Table Lamp Example */
|
||||
/*********************************************************************************
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2020-2022 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.
|
||||
*
|
||||
********************************************************************************/
|
||||
|
||||
#include "HomeSpan.h" // include the HomeSpan library
|
||||
|
||||
|
|
@ -33,16 +58,8 @@ void setup() {
|
|||
|
||||
new SpanAccessory(); // Table Lamp Accessory
|
||||
|
||||
new Service::AccessoryInformation(); // HAP requires every Accessory to implement an AccessoryInformation Service, with 6 *required* Characteristics
|
||||
new Characteristic::Name("My Table Lamp"); // Name of the Accessory, which shows up on the HomeKit "tiles", and should be unique across Accessories
|
||||
new Characteristic::Manufacturer("HomeSpan"); // Manufacturer of the Accessory (arbitrary text string, and can be the same for every Accessory)
|
||||
new Characteristic::SerialNumber("123-ABC"); // Serial Number of the Accessory (arbitrary text string, and can be the same for every Accessory)
|
||||
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)
|
||||
new Characteristic::Identify(); // Provides a hook that allows a HomeKit Client to identify the device
|
||||
|
||||
new Service::HAPProtocolInformation(); // HAP requires every Accessory (except those in a bridge) to implement a Protcol Information Service
|
||||
new Characteristic::Version("1.1.0"); // Set the Version Characteristic to "1.1.0," which is required by HAP
|
||||
new Service::AccessoryInformation(); // HAP requires every Accessory to implement an AccessoryInformation Service
|
||||
new Characteristic::Identify(); // HAP requires the Accessory Information Service to include the Identify Characteristic
|
||||
|
||||
new TableLamp(17); // instantiate the TableLamp Service (defined below) with lampPin set to 17
|
||||
|
||||
|
|
|
|||
|
|
@ -125,17 +125,7 @@ void setup() {
|
|||
|
||||
homeSpan.begin(Category::Television,"HomeSpan Television");
|
||||
|
||||
new SpanAccessory();
|
||||
new Service::AccessoryInformation();
|
||||
new Characteristic::Name("HomeSpan TV");
|
||||
new Characteristic::Manufacturer("HomeSpan");
|
||||
new Characteristic::SerialNumber("123-ABC");
|
||||
new Characteristic::Model("HomeSpan");
|
||||
new Characteristic::FirmwareRevision("0.1");
|
||||
new Characteristic::Identify();
|
||||
|
||||
new Service::HAPProtocolInformation();
|
||||
new Characteristic::Version("1.1.0");
|
||||
SPAN_ACCESSORY();
|
||||
|
||||
// Below we define 10 different InputSource Services using different combinations
|
||||
// of Characteristics to demonstrate how they interact and appear to the user in the Home App
|
||||
|
|
|
|||
|
|
@ -536,6 +536,11 @@ namespace Characteristic {
|
|||
#define CUSTOM_SERV(NAME,UUID) \
|
||||
namespace Service { struct NAME : SpanService { NAME() : SpanService{#UUID,#NAME,true}{} }; }
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
// MACROS TO ADD A NEW ACCESSORT WITH OPTIONAL NAME //
|
||||
////////////////////////////////////////////////////////
|
||||
|
||||
#define SPAN_ACCESSORY(...) new SpanAccessory(); new Service::AccessoryInformation(); new Characteristic::Identify(); __VA_OPT__(new Characteristic::Name(__VA_ARGS__));
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue