use esp-homekit to esp8266 based on ESP8266_RTOS_SDK
Apple HomeKit
配件服务器库,可以在 esp8266
和 esp32
上使用,以下是 esp-homekit 是基于 ESP8266_RTOS_SDK 在 esp8266
上的移植步骤。compnents
,并重命名文件夹shell
1. git clone --recursive https://github.com/maximkulkin/esp-homekit homekit
2. git clone --recursive https://github.com/maximkulkin/esp-http-parser http-parser
3. git clone --recursive https://github.com/maximkulkin/esp-wolfssl wolfssl
makefile
文件shell
PROJECT_NAME = esp8266-homekit-led
CFLAGS += -DHOMEKIT_SHORT_APPLE_UUIDS
include $(IDF_PATH)/make/project.mk
main
文件下的 component.mk
shell
COMPONENT_DEPENDS := homekit
wifi.h.sample
移到 main
文件夹下,然后修改为 wifi.h
,最后写入自己的 WiFi
的 SSID
和 密码c
#define WIFI_SSID "mywifi"
#define WIFI_PASSWORD "mypassword"
led demo
,详细见目录下的 led.c
c
...
#include <homekit/homekit.h>
#include <homekit/characteristics.h>
...
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, "Sample LED"),
HOMEKIT_CHARACTERISTIC(MANUFACTURER, "PYHOME"),
HOMEKIT_CHARACTERISTIC(SERIAL_NUMBER, "025A2BABF19D"),
HOMEKIT_CHARACTERISTIC(MODEL, "MyLED"),
HOMEKIT_CHARACTERISTIC(FIRMWARE_REVISION, "0.1"),
HOMEKIT_CHARACTERISTIC(IDENTIFY, led_identify),
NULL
}),
HOMEKIT_SERVICE(LIGHTBULB, .primary=true, .characteristics=(homekit_characteristic_t*[]){
HOMEKIT_CHARACTERISTIC(NAME, "Sample LED"),
HOMEKIT_CHARACTERISTIC(
ON, false,
.getter=led_on_get,
.setter=led_on_set
),
NULL
}),
NULL
}),
NULL
};
homekit_server_config_t config = {
.accessories = accessories,
.password = "111-11-111",
.setupId="1SP0",
};
void on_wifi_ready() {
homekit_server_init(&config);
}
...
menuconfig
中使能 MDNS
和 IPV6
shell
# mDNs
CONFIG_ENABLE_MDNS=y
# IPV6
CONFIG_LWIP_IPV6=y
makefile
和 项目目录esp-homekit is Apple HomeKit
accessory server library, which can be used on esp8266 and esp32, the following is esp-homekit based on ESP8266_RTOS_SDK migration steps on esp8266.
download these libraries to components and rename folder
1. git clone --recursive https://github.com/maximkulkin/esp-homekit homekit
2. git clone --recursive https://github.com/maximkulkin/esp-http-parser http-parser
3. git clone --recursive https://github.com/maximkulkin/esp-wolfssl wolfssl
modify the makefile
PROJECT_NAME = esp8266-homekit-led
CFLAGS += -DHOMEKIT_SHORT_APPLE_UUIDS
include $(IDF_PATH)/make/project.mk
modify the component.mk
under main
COMPONENT_DEPENDS := homekit
move the project’s wifi.h.sample
to main folder, then modify it to wifi.h
, finally write your WiFi SSID and password
#define WIFI_SSID "mywifi"
#define WIFI_PASSWORD "mypassword"
modify led demo, see the led.c
for details
...
#include <homekit/homekit.h>
#include <homekit/characteristics.h>
...
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, "Sample LED"),
HOMEKIT_CHARACTERISTIC(MANUFACTURER, "PYHOME"),
HOMEKIT_CHARACTERISTIC(SERIAL_NUMBER, "025A2BABF19D"),
HOMEKIT_CHARACTERISTIC(MODEL, "MyLED"),
HOMEKIT_CHARACTERISTIC(FIRMWARE_REVISION, "0.1"),
HOMEKIT_CHARACTERISTIC(IDENTIFY, led_identify),
NULL
}),
HOMEKIT_SERVICE(LIGHTBULB, .primary=true, .characteristics=(homekit_characteristic_t*[]){
HOMEKIT_CHARACTERISTIC(NAME, "Sample LED"),
HOMEKIT_CHARACTERISTIC(
ON, false,
.getter=led_on_get,
.setter=led_on_set
),
NULL
}),
NULL
}),
NULL
};
homekit_server_config_t config = {
.accessories = accessories,
.password = "111-11-111",
.setupId="1SP0",
};
void on_wifi_ready() {
homekit_server_init(&config);
}
...
note! you need to enable MDNS and IPV6 in menuconfig
# mDNs
CONFIG_ENABLE_MDNS=y
# IPV6
CONFIG_LWIP_IPV6=y
This project refers to the makefile and project directory from esp32-homekit-led
Although already forbidden by the sources and subsequent licensing, it is not allowed to use or distribute this software for a commercial purpose.