-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmy_accessory.c
More file actions
54 lines (45 loc) · 1.66 KB
/
Copy pathmy_accessory.c
File metadata and controls
54 lines (45 loc) · 1.66 KB
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
43
44
45
46
47
48
49
50
51
52
/*
* my_accessory.c
* Define the accessory in C language using the Macro in characteristics.h
*
* Created on: 2020-05-15
* Author: Mixiaoxiao (Wang Bin)
*/
#include <homekit/homekit.h>
#include <homekit/characteristics.h>
//当点击识别时调用次函数
void my_accessory_identify(homekit_value_t _value) {
printf("accessory identify\n");
}
// Switch (HAP section 8.38)
// required: ON
// optional: NAME
// format: bool; HAP section 9.70; write the .setter function to get the switch-event sent from iOS Home APP.
homekit_characteristic_t cha_switch_on = HOMEKIT_CHARACTERISTIC_(ON, false);
// format: string; HAP section 9.62; max length 64
homekit_characteristic_t cha_name = HOMEKIT_CHARACTERISTIC_(NAME, "Switch");
homekit_accessory_t *accessories[] = {
HOMEKIT_ACCESSORY(.id=1, .category=homekit_accessory_category_switch, .services=(homekit_service_t*[]) {
HOMEKIT_SERVICE(ACCESSORY_INFORMATION, .characteristics=(homekit_characteristic_t*[]) {
HOMEKIT_CHARACTERISTIC(NAME, "Switch"),
HOMEKIT_CHARACTERISTIC(MANUFACTURER, "XcuiTech"),
HOMEKIT_CHARACTERISTIC(SERIAL_NUMBER, "202311221620"),
HOMEKIT_CHARACTERISTIC(MODEL, "ESP8266"),
HOMEKIT_CHARACTERISTIC(FIRMWARE_REVISION, "0.0.2"),
HOMEKIT_CHARACTERISTIC(IDENTIFY, my_accessory_identify),
NULL
}),
HOMEKIT_SERVICE(SWITCH, .primary=true, .characteristics=(homekit_characteristic_t*[]){
&cha_switch_on,
&cha_name,
NULL
}),
NULL
}),
NULL
};
homekit_server_config_t config = {
.accessories = accessories,
.password = "187-23-198",
.setupId = "1Q2W",
};