-
Notifications
You must be signed in to change notification settings - Fork 1
/
my_accessory.c
42 lines (38 loc) · 1.6 KB
/
my_accessory.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <homekit/homekit.h>
#include <homekit/characteristics.h>
void my_accessory_identify(homekit_value_t _value) {
printf("accessory identify\n");
}
homekit_characteristic_t cha_on = HOMEKIT_CHARACTERISTIC_(ON, false);
homekit_characteristic_t cha_name = HOMEKIT_CHARACTERISTIC_(NAME, "RGB Strip");
homekit_characteristic_t cha_bright = HOMEKIT_CHARACTERISTIC_(BRIGHTNESS, 100);
homekit_characteristic_t cha_sat = HOMEKIT_CHARACTERISTIC_(SATURATION, (float) 0);
homekit_characteristic_t cha_hue = HOMEKIT_CHARACTERISTIC_(HUE, (float) 180);
homekit_accessory_t *accessories[] = {
HOMEKIT_ACCESSORY(.id=1, .category=homekit_accessory_category_lightbulb, .services=(homekit_service_t*[]) {
HOMEKIT_SERVICE(ACCESSORY_INFORMATION, .characteristics=(homekit_characteristic_t*[]) {
HOMEKIT_CHARACTERISTIC(NAME, "RGB Strip"),
HOMEKIT_CHARACTERISTIC(MANUFACTURER, "Will Homekit"),
HOMEKIT_CHARACTERISTIC(SERIAL_NUMBER, "130299"),
HOMEKIT_CHARACTERISTIC(MODEL, "ESP8266-12E"),
HOMEKIT_CHARACTERISTIC(FIRMWARE_REVISION, "3.8"),
HOMEKIT_CHARACTERISTIC(IDENTIFY, my_accessory_identify),
NULL
}),
HOMEKIT_SERVICE(LIGHTBULB, .primary=true, .characteristics=(homekit_characteristic_t*[]) {
&cha_on,
&cha_name,
&cha_bright,
&cha_sat,
&cha_hue,
NULL
}),
NULL
}),
NULL
};
homekit_server_config_t accessory_config = {
.accessories = accessories,
.password = "111-11-111",
.setupId="1QJ8"
};