ESP-32 implementation of Apple Homekit Accessory Protocol(HAP). It supports Homekit via Bluetooth and wlan.
-
Setup Espressif development environment. Go through steps 1 to 10 in this guide (v4.2).
-
Make your project directory a git repository:
%> git init %> echo 'build' > .gitignore
-
Install submodules in the project you just created ($IDF_PATH/examples/get-started/hello_world). To do this, isssue:
%> git submodule add https://github.com/slompf18/esp32_hap_wolfssl.git components/esp32_hap_wolfssl %> git submodule add https://github.com/slompf18/esp32_hap.git components/esp32_hap
-
Overwrite the content of 'hello_world_main.c' with the content of 'examples\simple_switch_ble.c' of this repository.
-
Add the following line into CMakeLists.txt to add the esp32_hap component:
set(COMPONENTS esptool_py esp32 esp32_hap main)
-
Enable Bluetooth LE by opening the configuration
idf.py menuconfig
. Then select:- Component config -> Bluetooth: Enable
- Component config -> Bluetooth -> Bluetooth Host: NimBLE - BLE only
- Save and Quit.
-
Connect an led to GND and IO 19 of your ESP32.
-
Flash and monitor the project to the esp.
When starting your project you will have to choose, which stack you want to use. You can choose your stack by calling idf.py menuconfig
and selecting the option under the 'Homekit' menu entry. Here are the different advantages:
- Easy configuration
- Uses less ressources
- Higher range
- cd into the test_runner directory
- idf.py menuconfig
- choose the stack of hap
- enable bluetooth (nimble only)
- disable task watchdog
- build and flash the test app: idf.py -p /dev/tty.SLAB_USBtoUART flash monitor
In order to get more (or less) verbosity, change the following line in CMakeLists.txt: set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG")
- Connect device by USB
- Get your UDID: http://whatsmyudid.com/
- Check your network devices: ifconfig -l
- Start capturing: rvictl -s
- Check your network devices again: ifconfig -l
- Open WireShark
- Start capturing on the new interface (normally rvi0)
- Filter for http
HomeKit uses the service type of '_hap._tcp' on the 'local.' domain, so you can query for HomeKit devices as such:
$ dns-sd -Z _hap._tcp local.
For HomeKit hubs, look for the service type of _homekit._tcp:
$ dns-sd -Z _homekit._tcp local.
- To be able to upload to the EP-WROOM-32 when connected to a breadboard, you may need a 10K (or so) pull-down resistor between RX0 and GND.
- In case you cannot find your device, it may be a problem with your router: https://jlian.co/post/reliable-homekit/