Giter Club home page Giter Club logo

esp8266-homekit-led's Introduction

esp-homekit 在 ESP8266 的移植

中文版本

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

组件

步骤

  • 下载这些库到 compnents,并重命名文件夹

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

    PROJECT_NAME = esp8266-homekit-led
    
    CFLAGS += -DHOMEKIT_SHORT_APPLE_UUIDS
    
    include $(IDF_PATH)/make/project.mk
  • 修改 main 文件下的 component.mk

    COMPONENT_DEPENDS := homekit
  • 把项目的 wifi.h.sample 移到 main 文件夹下,然后修改为 wifi.h,最后写入自己的 WiFiSSID 和 密码

    #define WIFI_SSID "mywifi"
    #define WIFI_PASSWORD "mypassword"
  • 修改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, "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 中使能 MDNSIPV6

    # mDNs
    CONFIG_ENABLE_MDNS=y
    
    # IPV6
    CONFIG_LWIP_IPV6=y

声明

该项目参考 esp32-homekit-led 中的 makefile 和 项目目录

Although already forbidden by the sources and subsequent licensing, it is not allowed to use or distribute this software for a commercial purpose.

HomeKit Accessory Protocol (HAP) is Apple’s proprietary protocol that enables third-party accessories in the home (e.g., lights, thermostats and door locks) and Apple products to communicate with each other. HAP supports two transports, IP and Bluetooth LE. The information provided in the HomeKit Accessory Protocol Specification (Non-Commercial Version) describes how to implement HAP in an accessory that you create for non-commercial use and that will not be distributed or sold.
The HomeKit Accessory Protocol Specification (Non-Commercial Version) can be downloaded from the HomeKit Apple Developer page.
Copyright © 2019 Apple Inc. All rights reserved.

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.

Components

Steps

  • 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

Statement:

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.

HomeKit Accessory Protocol (HAP) is Apple’s proprietary protocol that enables third-party accessories in the home (e.g., lights, thermostats and door locks) and Apple products to communicate with each other. HAP supports two transports, IP and Bluetooth LE. The information provided in the HomeKit Accessory Protocol Specification (Non-Commercial Version) describes how to implement HAP in an accessory that you create for non-commercial use and that will not be distributed or sold.
The HomeKit Accessory Protocol Specification (Non-Commercial Version) can be downloaded from the HomeKit Apple Developer page.
Copyright © 2019 Apple Inc. All rights reserved.

esp8266-homekit-led's People

Contributors

shaopus avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.