Skip to content

Shaopus/esp32-homekit-led

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

esp-homekit 在 ESP32 上移植

esp-homekitApple HomeKit 配件服务器库,可以在 esp8266esp32 上使用,以下是 esp-homekit 是基于 esp-idfesp32 上的移植步骤。

组件

步骤

  • components上下载以上组件,并重命名文件夹

    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文件

    CFLAGS += -DHOMEKIT_SHORT_APPLE_UUIDS
    
    include ./components/component_conf.mk
  • 修改 main 文件下的 component.mk

    COMPONENT_DEPENDS := homekit
  • 修改led demo,详细见目录下的 led.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, "HaPK"),
                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);
    }
    
    ...

参考