Update ServiceList.md

This commit is contained in:
HomeSpan 2020-11-15 10:45:48 -06:00 committed by GitHub
parent d44146d9fc
commit 8c9c6eebbb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 7 deletions

View File

@ -6,16 +6,18 @@ HomeSpan Services and Characteristics are implemented as C++ Classes with names
HomeSpan Services and Characteristics are instantiated with a C++ `new` command. Services do not take any arguments, whereas Characteristics take a single, optional argument that is used to initialize the value of the Characteristic at startup. If this argument is not specified, HomeSpan will apply a reasonable default value based on the Characteristic's type and allowed range.
A list of all HomeSpan Services is provided in the table below. For each Service the table also indicates which Characteritics are required and which are optional. For example, a HomeSpan light bulb could be configured as such:
A list of all HomeSpan Services is provided in the table below. For each Service the table also indicates which Characteristics are required and which are optional. For example, a dimmable light bulb could be configured as such:
```
new Service::LightBulb(); // instantiates a Light Bulb Service
new Characteristics:On(); // instantiate the required On Characteristic without setting initial value
new Characteristic::Brightness(50); // instantiate an optional Brightness Characteristic and set initial value to 50%
new Characteristic::Name("Living Room Lamp"); // instantiate an optional Name Characteristic for this Service, and set to "Living Room Lamp"
```C++
new Service::LightBulb(); // instantiate a Light Bulb Service
new Characteristics:On(); // instantiate the required On Characteristic without setting initial value
new Characteristic::Brightness(50); // instantiate an optional Brightness Characteristic and set initial value to 50%
new Characteristic::Name("Living Room Lamp"); // instantiate an optional Name Characteristic for this Service, and set to "Living Room Lamp"
```
Upon startup HomeSpan will validate the device configuration to ensure any Service you instantiate includes every required Characteristics, and does include aany Charcteristic that is neither required nor optional. If any errors are found at startup HomeSpan reports them to the Arduino Serial Monitor and halts the program
Please see Section 8 and 9 of [HAP-R2](https://developer.apple.com/support/homekit-accessory-protocol/) for a complete description of all HAP Services and Characteristics. Note that HomeSpan's Service and Characteristic Classes already contain all the required HAP fields, such as the UUID, Format, and Permissions, so you don't need to specify any of these parameters.
Additionally, when first starting up, HomeSpan begins by validating the device's configuration to ensure each Service you instantiate includes all required Characteristics, but does not include any Characteristics that are neither required nor optional. If any errors are found, HomeSpan reports them to the Arduino Serial Monitor and halts the program.
### Service List