maximkulkin / esp-homekit

Apple HomeKit accessory server library for ESP-OPEN-RTOS
MIT License
1.1k stars 169 forks source link

Accessory code #102

Closed ericklil closed 4 years ago

ericklil commented 4 years ago

Thank you for your work!

If I wanted to change the accessory to say a Light with HSV values, Or make this control a fan with speed, direction etc, basically adding characteristics to the accessory. How would one find the setup code for that.

maximkulkin commented 4 years ago

Well, to implement an accessory you need to add apropriate services which in turn have proper characteristics. Setup codes are either hard-coded inside firmware (and printed somewhere on packaging or on the accessory itself), iDevices-HomeKit-Code-768x407

SF278428-002_EN_v3

or you add a screen to accessory and show randomly generate setup code or even QR code.

IMG_0077

IMG_0076

ericklil commented 4 years ago

Thank you for your quick reply, I erred in my question I meant to ask; how to create an accessory other than the sample you provided. i.e a Light with HSV values such as a Neopixel or a Fan with speed, direction and other characteristics or services? Where to find the accessory category code as you mention in yourreadme.md In the sample is the .setupId="1QJ8" random generated?

maximkulkin commented 4 years ago

Well, the main read is Homekit Accessory Protocol Specification (you need to create an Apple Developer account to access it). You can find it on this page: https://developer.apple.com/homekit/

In esp-homekit all services and characteristics for the spec are defined in homekit/characteristics.h. For convenience, service definitions in that header file are provided with list of required and optional characteristics.

Accessory categories can also be found in HAP spec. In esp-homekit they are defined in homekit/types.h.

And finally, yes, setupId is a random hexadecimal 4-char sequence that is used for identifying accessory based on QR code.