Git Product home page Git Product logo

esp-apple-homekit-adk's Introduction

ESP Apple HomeKit ADK

HomeKit is a framework developed by Apple for communicating with and controlling connected accessories in a user’s home using iOS devices. This project is a port of Apple's Open Source HomeKit ADK for ESP32 and ESP32S2. This can be used by any developer to prototype non-commercial smart home accessories.

You can also check out the ESP HomeKit SDK here which is Espressif's implementation of the HomeKit Specifications.

Note: If you want to use HomeKit for commercial purposes, please check here.

Get Started

Set up Host environment

Set up the host environment and ESP IDF (master branch) as per the steps given here. The commit that was used for testing is: 012b111

Set up MbedTLS

ESP-IDF currently uses MbedTLS 2.16.x, whereas HomeKit ADK requires 2.18. A branch mbedtls-2.16.6-adk is being maintained here which has the required patches from 2.18, on top of 2.16.6. To switch to this, follow these steps:

$ cd $IDF_PATH/components/mbedtls/mbedtls
$ git pull
$ git checkout -b mbedtls-2.16.6-adk origin/mbedtls-2.16.6-adk

Get esp-apple-homekit-adk

Please clone this repository using the below command:

git clone --recursive https://github.com/espressif/esp-apple-homekit-adk.git

Note the --recursive option. This is required to pull in the HomeKit ADK repository into esp-apple-homekit-adk. In case you have already cloned the repository without this option, execute this to the pull in the submodule: git submodule update --init --recursive

Compile and Flash

You can use esp-apple-homekit-adk with any ESP32 or ESP32-S2 board. We have provided a Lightbulb example for reference. Compile and flash as below:

$ cd /path/to/esp-apple-homekit-adk/examples/Lightbulb
$ export ESPPORT=/dev/tty.SLAB_USBtoUART #Set your board's serial port here
$ idf.py set-target <esp32/esp32s2>
$ idf.py menuconfig # Set Example Configuration -> WiFi SSID/Password
$ idf.py flash
$ esptool.py -p $ESPPORT write_flash 0x340000 accessory_setup.bin
$ idf.py monitor

As the device boots up and connects to your Home Wi-Fi network (configured using the menuconfig), you will see some logs like these:

I (2788) wifi station: connected to ap SSID:myssid password:mypassword
1970-01-01'T'00:00:02'Z'	Default	[com.apple.mfi.HomeKit.Core:AccessoryServer] Version information:
libhap: Unknown
  - Version: Internal (May 12 2020 02:42:49) - compatibility version 7
Using platform: ESP32
  - Version: v4.2-dev-1485-g1ad1791df7-dirty (May 12 2020 02:42:38) - compatibility version 7
  - Available features:
    - Key-Value store
    - Accessory setup manager
    - Service discovery
1970-01-01'T'00:00:02'Z'	Default	[com.apple.mfi.HomeKit.Platform:Clock] Using 'gettimeofday'.

Add acccessory in the Home app

Open the Home app on your iPhone/iPad and follow these steps

  • Tap on "Add Accessory".
  • Choose the "I Don't Have a Code or Cannot Scan" option.
  • Tap on "Acme Light Bulb" in the list of Nearby Accessories.
  • Select the "Add Anyway" option for the "Uncertified Accessory" prompt.
  • Enter 11122333 as the Setup code.
  • You should eventually see the "Acme Light Bulb added" message.
  • Give a custom name, assign to a room, create scenes as required and you are done.

Change the Setup Code

The setup code of 11122333 was encoded in the accessory_setup.bin image flashed at 0x340000. This was generated using Apple's tools and ESP IDF's nvs partition generator. Steps as follows:

$ cd /path/to/esp-apple-homekit-adk/homekit_adk
$ make tools
$ cd Tools/
$ ./provision_raspi.sh --category 5 --setup-code 111-22-333 --setup-id ES32 Lightbulb

This will create the setup info and setup id files as below

~# tree Lightbulb
Lightbulb
├── 40.10
└── 40.11

Note: Compiling the ADK Tools and using provision_raspi.sh is out of scope of this project. If you face any issues with that, please report directly to Apple on GitHub.

Now, generate an nvs image as below:

$ cd Lightbulb
$ cp ../../../tools/accessory_setup/accessory_setup.csv .
$ python $IDF_PATH/components/nvs_flash/nvs_partition_generator/nvs_partition_gen.py generate accessory_setup.csv accessory_setup.bin 0x6000

Flash this using the same command given above.

$ esptool.py -p $ESPPORT write_flash 0x340000 accessory_setup.bin

If you want to change the category, setup code or the setup id, change the values while running provision_raspi.sh. The script also generates a QR code that you can directly use for adding the accessory using the Home app.

Resetting HomeKit Pairing

The accessory pairing information is stored in the NVS (Non Volatile Storage) partition. Once paired, the accessory cannot be paired again, without clearing this pairing information first. It can be done as below:

$ esptool.py -p $ESPPORT erase_region 0x10000 0x6000

Resources

esp-apple-homekit-adk's People

Contributors

cleobis avatar izmmisha avatar shahpiyushv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

esp-apple-homekit-adk's Issues

Make it easier to add component to project

Adding the component as submodule in components directory of a project fails, until you add

set(EXTRA_COMPONENT_DIRS ${CMAKE_CURRENT_LIST_DIR}/components/esp-apple-homekit-adk)

to your CMakeLists.txt. I guess its because the CMakeLists.txt of the component is not in the root directory as stated here.

Is this an intended behavior? Otherwise I could fix it.

Stops working after a while

I frequently see the homekit device becoming unresponsive. I managed to capture the precise moment in the terminal:

1970-01-01'T'01:28:47'Z' Debug [com.apple.mfi.HomeKit.Core:IPAccessoryServer] session:0x3ffb9d20:input closed
1970-01-01'T'01:28:47'Z' Debug [com.apple.mfi.HomeKit.Core:IPAccessoryServer] session:0x3ffb9d20:closing
1970-01-01'T'01:28:47'Z' Debug [com.apple.mfi.HomeKit.Core:IPAccessoryServer] session:0x3ffb9d20:closing security context
1970-01-01'T'01:28:47'Z' Debug [com.apple.mfi.HomeKit.Core:IPAccessoryServer] Closing HAP session.
1970-01-01'T'01:28:47'Z' Debug [com.apple.mfi.HomeKit.Core:Session] HAPSessionRelease
1970-01-01'T'01:28:47'Z' Debug [com.apple.mfi.HomeKit.Core:Session] HAPSessionInvalidate
1970-01-01'T'01:28:47'Z' Debug [com.apple.mfi.HomeKit.Core:IPAccessoryServer] session:0x3ffb9d20:closing TCP stream
1970-01-01'T'01:28:47'Z' Debug [com.apple.mfi.HomeKit.Platform:TCPStreamManager] shutdown(51, SHUT_RDWR);
1970-01-01'T'01:28:47'Z' Debug [com.apple.mfi.HomeKit.Platform:TCPStreamManager] close(51);
1970-01-01'T'01:28:47'Z' Debug [com.apple.mfi.HomeKit.Core:IPAccessoryServer] session:0x3ffb9d20:closed
1970-01-01'T'01:28:47'Z' Debug [com.apple.mfi.HomeKit.Core:IPAccessoryServer] session:0x3ffb9d20:releasing session
1970-01-01'T'01:28:47'Z' Debug [com.apple.mfi.HomeKit.Core:IPAccessoryServer] session:0x3ffba078:input closed
1970-01-01'T'01:28:47'Z' Debug [com.apple.mfi.HomeKit.Core:IPAccessoryServer] session:0x3ffba078:closing
1970-01-01'T'01:28:47'Z' Debug [com.apple.mfi.HomeKit.Core:IPAccessoryServer] session:0x3ffba078:closing security context
1970-01-01'T'01:28:47'Z' Debug [com.apple.mfi.HomeKit.Core:IPAccessoryServer] Closing HAP session.

What is happening? Sometimes, it comes back to live on its own later, but not always.

<netinet/tcp.h> No such file or directory

When trying to compile the example sketch I het two errors:

[9/98] ccache C:\ESP\.espressif\tools\xtensa-esp32-elf\esp-2019r2-8.2.0\xtensa-esp32-elf\bin\xtensa-esp32-elf-gcc.exe -DHAP_LOG_LEVEL=1 -DMBEDTLS_CONFIG_FILE=\"mbedtls/esp_config.h\" -Iconfig -IC:/ESP/esp-idf/components/port/include -IC:/ESP/esp-idf/components/homekit_adk/HAP -IC:/ESP/esp-idf/components/homekit_adk/PAL -IC:/ESP/esp-idf/components/homekit_adk/External/Base64 -IC:/ESP/esp-idf/components/homekit_adk/External/JSON -IC:/ESP/esp-idf/components/homekit_adk/External/HTTP -IC:/ESP/esp-idf/components/newlib/platform_include -IC:/ESP/esp-idf/components/freertos/include -IC:/ESP/esp-idf/components/heap/include -IC:/ESP/esp-idf/components/log/include -IC:/ESP/esp-idf/components/soc/esp32/include -IC:/ESP/esp-idf/components/soc/include -IC:/ESP/esp-idf/components/esp_rom/include -IC:/ESP/esp-idf/components/esp_common/include -IC:/ESP/esp-idf/components/xtensa/include -IC:/ESP/esp-idf/components/xtensa/esp32/include -IC:/ESP/esp-idf/components/esp32/include -IC:/ESP/esp-idf/components/driver/include -IC:/ESP/esp-idf/components/esp_ringbuf/include -IC:/ESP/esp-idf/components/esp_event/include -IC:/ESP/esp-idf/components/tcpip_adapter/include -IC:/ESP/esp-idf/components/lwip/include/apps -IC:/ESP/esp-idf/components/lwip/include/apps/sntp -IC:/ESP/esp-idf/components/lwip/lwip/src/include -IC:/ESP/esp-idf/components/lwip/port/esp32/include -IC:/ESP/esp-idf/components/lwip/port/esp32/include/arch -IC:/ESP/esp-idf/components/vfs/include -IC:/ESP/esp-idf/components/esp_wifi/include -IC:/ESP/esp-idf/components/esp_wifi/esp32/include -IC:/ESP/esp-idf/components/esp_eth/include -IC:/ESP/esp-idf/components/efuse/include -IC:/ESP/esp-idf/components/efuse/esp32/include -IC:/ESP/esp-idf/components/app_trace/include -IC:/ESP/esp-idf/components/nvs_flash/include -IC:/ESP/esp-idf/components/spi_flash/include -IC:/ESP/esp-idf/components/mbedtls/port/include -IC:/ESP/esp-idf/components/mbedtls/mbedtls/include -IC:/ESP/esp-idf/components/mdns/include -IC:/ESP/esp-idf/components/console -mlongcalls -Wno-frame-address -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -nostdlib -Wall -Werror=all -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wextra -Wno-unused-parameter -Wno-sign-compare -ggdb -Og -std=gnu99 -Wno-old-style-declaration -D_GNU_SOURCE -DIDF_VER=\"v4.0.1-dirty\" -DGCC_NOT_5_2_0 -DESP_PLATFORM -MD -MT esp-idf/port/CMakeFiles/__idf_port.dir/src/HAPPlatformTCPStreamManager.c.obj -MF esp-idf\port\CMakeFiles\__idf_port.dir\src\HAPPlatformTCPStreamManager.c.obj.d -o esp-idf/port/CMakeFiles/__idf_port.dir/src/HAPPlatformTCPStreamManager.c.obj -c C:/ESP/esp-idf/components/port/src/HAPPlatformTCPStreamManager.c FAILED: esp-idf/port/CMakeFiles/__idf_port.dir/src/HAPPlatformTCPStreamManager.c.obj ccache C:\ESP\.espressif\tools\xtensa-esp32-elf\esp-2019r2-8.2.0\xtensa-esp32-elf\bin\xtensa-esp32-elf-gcc.exe -DHAP_LOG_LEVEL=1 -DMBEDTLS_CONFIG_FILE=\"mbedtls/esp_config.h\" -Iconfig -IC:/ESP/esp-idf/components/port/include -IC:/ESP/esp-idf/components/homekit_adk/HAP -IC:/ESP/esp-idf/components/homekit_adk/PAL -IC:/ESP/esp-idf/components/homekit_adk/External/Base64 -IC:/ESP/esp-idf/components/homekit_adk/External/JSON -IC:/ESP/esp-idf/components/homekit_adk/External/HTTP -IC:/ESP/esp-idf/components/newlib/platform_include -IC:/ESP/esp-idf/components/freertos/include -IC:/ESP/esp-idf/components/heap/include -IC:/ESP/esp-idf/components/log/include -IC:/ESP/esp-idf/components/soc/esp32/include -IC:/ESP/esp-idf/components/soc/include -IC:/ESP/esp-idf/components/esp_rom/include -IC:/ESP/esp-idf/components/esp_common/include -IC:/ESP/esp-idf/components/xtensa/include -IC:/ESP/esp-idf/components/xtensa/esp32/include -IC:/ESP/esp-idf/components/esp32/include -IC:/ESP/esp-idf/components/driver/include -IC:/ESP/esp-idf/components/esp_ringbuf/include -IC:/ESP/esp-idf/components/esp_event/include -IC:/ESP/esp-idf/components/tcpip_adapter/include -IC:/ESP/esp-idf/components/lwip/include/apps -IC:/ESP/esp-idf/components/lwip/include/apps/sntp -IC:/ESP/esp-idf/components/lwip/lwip/src/include -IC:/ESP/esp-idf/components/lwip/port/esp32/include -IC:/ESP/esp-idf/components/lwip/port/esp32/include/arch -IC:/ESP/esp-idf/components/vfs/include -IC:/ESP/esp-idf/components/esp_wifi/include -IC:/ESP/esp-idf/components/esp_wifi/esp32/include -IC:/ESP/esp-idf/components/esp_eth/include -IC:/ESP/esp-idf/components/efuse/include -IC:/ESP/esp-idf/components/efuse/esp32/include -IC:/ESP/esp-idf/components/app_trace/include -IC:/ESP/esp-idf/components/nvs_flash/include -IC:/ESP/esp-idf/components/spi_flash/include -IC:/ESP/esp-idf/components/mbedtls/port/include -IC:/ESP/esp-idf/components/mbedtls/mbedtls/include -IC:/ESP/esp-idf/components/mdns/include -IC:/ESP/esp-idf/components/console -mlongcalls -Wno-frame-address -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -nostdlib -Wall -Werror=all -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wextra -Wno-unused-parameter -Wno-sign-compare -ggdb -Og -std=gnu99 -Wno-old-style-declaration -D_GNU_SOURCE -DIDF_VER=\"v4.0.1-dirty\" -DGCC_NOT_5_2_0 -DESP_PLATFORM -MD -MT esp-idf/port/CMakeFiles/__idf_port.dir/src/HAPPlatformTCPStreamManager.c.obj -MF esp-idf\port\CMakeFiles\__idf_port.dir\src\HAPPlatformTCPStreamManager.c.obj.d -o esp-idf/port/CMakeFiles/__idf_port.dir/src/HAPPlatformTCPStreamManager.c.obj -c C:/ESP/esp-idf/components/port/src/HAPPlatformTCPStreamManager.c C:/ESP/esp-idf/components/port/src/HAPPlatformTCPStreamManager.c:25:10: fatal error: netinet/tcp.h: No such file or directory #include <netinet/tcp.h>

FAILED: esp-idf/port/CMakeFiles/__idf_port.dir/__/homekit_adk/PAL/Crypto/MbedTLS/HAPMbedTLS.c.obj ccache C:\ESP\.espressif\tools\xtensa-esp32-elf\esp-2019r2-8.2.0\xtensa-esp32-elf\bin\xtensa-esp32-elf-gcc.exe -DHAP_LOG_LEVEL=1 -DMBEDTLS_CONFIG_FILE=\"mbedtls/esp_config.h\" -Iconfig -IC:/ESP/esp-idf/components/port/include -IC:/ESP/esp-idf/components/homekit_adk/HAP -IC:/ESP/esp-idf/components/homekit_adk/PAL -IC:/ESP/esp-idf/components/homekit_adk/External/Base64 -IC:/ESP/esp-idf/components/homekit_adk/External/JSON -IC:/ESP/esp-idf/components/homekit_adk/External/HTTP -IC:/ESP/esp-idf/components/newlib/platform_include -IC:/ESP/esp-idf/components/freertos/include -IC:/ESP/esp-idf/components/heap/include -IC:/ESP/esp-idf/components/log/include -IC:/ESP/esp-idf/components/soc/esp32/include -IC:/ESP/esp-idf/components/soc/include -IC:/ESP/esp-idf/components/esp_rom/include -IC:/ESP/esp-idf/components/esp_common/include -IC:/ESP/esp-idf/components/xtensa/include -IC:/ESP/esp-idf/components/xtensa/esp32/include -IC:/ESP/esp-idf/components/esp32/include -IC:/ESP/esp-idf/components/driver/include -IC:/ESP/esp-idf/components/esp_ringbuf/include -IC:/ESP/esp-idf/components/esp_event/include -IC:/ESP/esp-idf/components/tcpip_adapter/include -IC:/ESP/esp-idf/components/lwip/include/apps -IC:/ESP/esp-idf/components/lwip/include/apps/sntp -IC:/ESP/esp-idf/components/lwip/lwip/src/include -IC:/ESP/esp-idf/components/lwip/port/esp32/include -IC:/ESP/esp-idf/components/lwip/port/esp32/include/arch -IC:/ESP/esp-idf/components/vfs/include -IC:/ESP/esp-idf/components/esp_wifi/include -IC:/ESP/esp-idf/components/esp_wifi/esp32/include -IC:/ESP/esp-idf/components/esp_eth/include -IC:/ESP/esp-idf/components/efuse/include -IC:/ESP/esp-idf/components/efuse/esp32/include -IC:/ESP/esp-idf/components/app_trace/include -IC:/ESP/esp-idf/components/nvs_flash/include -IC:/ESP/esp-idf/components/spi_flash/include -IC:/ESP/esp-idf/components/mbedtls/port/include -IC:/ESP/esp-idf/components/mbedtls/mbedtls/include -IC:/ESP/esp-idf/components/mdns/include -IC:/ESP/esp-idf/components/console -mlongcalls -Wno-frame-address -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -nostdlib -Wall -Werror=all -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wextra -Wno-unused-parameter -Wno-sign-compare -ggdb -Og -std=gnu99 -Wno-old-style-declaration -D_GNU_SOURCE -DIDF_VER=\"v4.0.1-dirty\" -DGCC_NOT_5_2_0 -DESP_PLATFORM -MD -MT esp-idf/port/CMakeFiles/__idf_port.dir/__/homekit_adk/PAL/Crypto/MbedTLS/HAPMbedTLS.c.obj -MF esp-idf\port\CMakeFiles\__idf_port.dir\__\homekit_adk\PAL\Crypto\MbedTLS\HAPMbedTLS.c.obj.d -o esp-idf/port/CMakeFiles/__idf_port.dir/__/homekit_adk/PAL/Crypto/MbedTLS/HAPMbedTLS.c.obj -c C:/ESP/esp-idf/components/homekit_adk/PAL/Crypto/MbedTLS/HAPMbedTLS.c C:/ESP/esp-idf/components/homekit_adk/PAL/Crypto/MbedTLS/HAPMbedTLS.c: In function 'HAP_X25519_scalarmult': C:/ESP/esp-idf/components/homekit_adk/PAL/Crypto/MbedTLS/HAPMbedTLS.c:119:19: error: implicit declaration of function 'mbedtls_ecp_read_key'; did you mean 'mbedtls_ecp_gen_key'? [-Werror=implicit-function-declaration] int ret = mbedtls_ecp_read_key(MBEDTLS_ECP_DP_CURVE25519, &our_key, n, X25519_SCALAR_BYTES);

Unfortunatly I have been unable to solve them

Where to generate your own example?

I am working on a way to generate custom homekit items, and I would like to ask how files for Lightbulb directories were created in the first place? What kind of tools were used! thank you very much

Lightbulb example is not working

Following instruction, when monitoring I get this output with an error:

Rebooting...
ets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:6396
ho 0 tail 12 room 4
load:0x40078000,len:14252
load:0x40080400,len:3820
0x40080400: _init at ??:?

entry 0x40080698
I (29) boot: ESP-IDF v4.4-dev-2533-g83956ebba-dirty 2nd stage bootloader
I (29) boot: compile time 12:39:07
I (30) boot: chip revision: 1
I (34) boot_comm: chip revision: 1, min. bootloader chip revision: 0
I (41) boot.esp32: SPI Speed      : 40MHz
I (45) boot.esp32: SPI Mode       : DIO
I (50) boot.esp32: SPI Flash Size : 4MB
I (55) boot: Enabling RNG early entropy source...
I (60) boot: Partition Table:
I (64) boot: ## Label            Usage          Type ST Offset   Length
I (71) boot:  0 sec_cert         unknown          3f 00 0000d000 00003000
I (78) boot:  1 nvs              WiFi data        01 02 00010000 00006000
I (86) boot:  2 otadata          OTA data         01 00 00016000 00002000
I (93) boot:  3 phy_init         RF data          01 01 00018000 00001000
I (101) boot:  4 ota_0            OTA app          00 10 00020000 00190000
I (108) boot:  5 ota_1            OTA app          00 11 001b0000 00190000
I (116) boot:  6 fctry            WiFi data        01 02 00340000 00006000
I (123) boot: End of partition table
I (128) boot_comm: chip revision: 1, min. application chip revision: 0
I (135) esp_image: segment 0: paddr=00020020 vaddr=3f400020 size=297b0h (169904) map
I (205) esp_image: segment 1: paddr=000497d8 vaddr=3ffb0000 size=03adch ( 15068) load
I (211) esp_image: segment 2: paddr=0004d2bc vaddr=40080000 size=02d5ch ( 11612) load
I (216) esp_image: segment 3: paddr=00050020 vaddr=400d0020 size=a3194h (668052) map
I (461) esp_image: segment 4: paddr=000f31bc vaddr=40082d5c size=11a10h ( 72208) load
I (491) esp_image: segment 5: paddr=00104bd4 vaddr=50000000 size=00010h (    16) load
I (501) boot: Loaded app from partition at offset 0x20000
I (501) boot: Disabling RNG early entropy source...
I (513) cpu_start: Pro cpu up.
I (514) cpu_start: Starting app cpu, entry point is 0x400811a4
0x400811a4: call_start_cpu1 at /Users/lorenzofiamingo/esp/esp-idf/components/esp_system/port/cpu_start.c:156

I (500) cpu_start: App cpu up.
I (530) cpu_start: Pro cpu start user code
I (530) cpu_start: cpu freq: 160000000
I (530) cpu_start: Application information:
I (534) cpu_start: Project name:     Lightbulb
I (539) cpu_start: App version:      94ed975
I (544) cpu_start: Compile time:     Aug  9 2021 12:39:01
I (551) cpu_start: ELF file SHA256:  069b5405d849e32c...
I (557) cpu_start: ESP-IDF:          v4.4-dev-2533-g83956ebba-dirty
I (564) heap_init: Initializing. RAM available for dynamic allocation:
I (571) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (577) heap_init: At 3FFC2358 len 0001DCA8 (119 KiB): DRAM
I (583) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (589) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (596) heap_init: At 4009476C len 0000B894 (46 KiB): IRAM
I (603) spi_flash: detected chip: generic
I (607) spi_flash: flash io: dio
I (612) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
1970-01-01'T'00:00:06'Z'        Default [com.apple.mfi.HomeKit.Platform:KeyValueStore] keyValueStore nvs Initialised
1970-01-01'T'00:00:06'Z'        Default [com.apple.mfi.HomeKit.Platform:KeyValueStore] keyValueStore fctry Initialised
I (756) wifi:wifi driver task: 3ffcb984, prio:23, stack:6656, core=0
I (756) system_api: Base MAC address is not set
I (756) system_api: read default base MAC address from EFUSE
I (786) wifi:wifi firmware version: d062fdb
I (786) wifi:wifi certification version: v7.0
I (786) wifi:config NVS flash: enabled
I (786) wifi:config nano formating: disabled
I (786) wifi:Init data frame dynamic rx buffer num: 32
I (796) wifi:Init management frame dynamic rx buffer num: 32
I (796) wifi:Init management short buffer num: 32
I (806) wifi:Init dynamic tx buffer num: 32
I (806) wifi:Init static rx buffer size: 1600
I (806) wifi:Init static rx buffer num: 10
I (816) wifi:Init dynamic rx buffer num: 32
I (816) wifi_init: rx ba win: 6
I (826) wifi_init: tcpip mbox: 32
I (826) wifi_init: udp mbox: 6
I (826) wifi_init: tcp mbox: 6
I (836) wifi_init: tcp tx win: 5744
I (836) wifi_init: tcp rx win: 5744
I (846) wifi_init: tcp mss: 1440
I (846) wifi_init: WiFi IRAM OP enabled
I (846) wifi_init: WiFi RX IRAM OP enabled
1970-01-01'T'00:00:06'Z'        Default [com.apple.mfi.HomeKit.Platform:KeyValueStore] Error (4354). Key 20 not found in KeyStore
1970-01-01'T'00:00:06'Z'        Default [com.apple.mfi.HomeKit.Platform:KeyValueStore] Error (4354). Key 21 not found in KeyStore
I (876) phy_init: phy_version 4670,719f9f6,Feb 18 2021,17:07:07
I (996) wifi:mode : sta (24:6f:28:79:64:e4)
I (996) wifi:enable tsf
I (996) wifi station: wifi_init_sta finished.
1970-01-01'T'00:00:06'Z'        Default [com.apple.mfi.HomeKit.Core:AccessoryServer] Version information:
libhap: Unknown
  - Version: Internal (Aug  9 2021 12:39:26) - compatibility version 7
Using platform: ESP32
  - Version: v4.4-dev-2533-g83956ebba-dirty (Aug  9 2021 12:39:17) - compatibility version 7
  - Available features:
    - Key-Value store
    - Accessory setup manager
    - Service discovery
1970-01-01'T'00:00:06'Z'        Default [com.apple.mfi.HomeKit.Platform:KeyValueStore] Error (4354). Key 00 not found in KeyStore
1970-01-01'T'00:00:06'Z'        Default [com.apple.mfi.HomeKit.Platform:Clock] Using 'clock_gettime' with 'CLOCK_MONOTONIC_RAW'.
1970-01-01'T'00:00:06'Z'        Error   [com.apple.mfi.HomeKit.Platform:Clock] clock_gettime failed: 22.
1970-01-01'T'00:00:06'Z'        Fault   fatal error - HAPPlatformClockGetCurrent @ /Users/lorenzofiamingo/Developer/esp-apple-homekit-adk/port/src/HAPPlatformClock.c:51

abort() was called at PC 0x400d7687 on core 0
0x400d7687: syscall_not_implemented_aborts at /Users/lorenzofiamingo/esp/esp-idf/components/newlib/syscalls.c:34



Backtrace:0x40081a03:0x3ffc7a800x4008850d:0x3ffc7aa0 0x4008efce:0x3ffc7ac0 0x400d7687:0x3ffc7b30 0x4015f41a:0x3ffc7b50 0x400ea7e9:0x3ffc7b70 0x400da130:0x3ffc7b90 0x400ea8fa:0x3ffc7bb0 0x400d9045:0x3ffc7be0 0x400d7c6b:0x3ffc7c20 0x4008b891:0x3ffc7c40 
0x40081a03: panic_abort at /Users/lorenzofiamingo/esp/esp-idf/components/esp_system/panic.c:391

0x4008850d: esp_system_abort at /Users/lorenzofiamingo/esp/esp-idf/components/esp_system/esp_system.c:129

0x4008efce: abort at /Users/lorenzofiamingo/esp/esp-idf/components/newlib/abort.c:46

0x400d7687: syscall_not_implemented_aborts at /Users/lorenzofiamingo/esp/esp-idf/components/newlib/syscalls.c:34

0x4015f41a: exit at /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32-elf/src/newlib/newlib/libc/stdlib/exit.c:64

0x400ea7e9: HAPPlatformAbort at /Users/lorenzofiamingo/Developer/esp-apple-homekit-adk/port/src/HAPPlatformAbort.c:27

0x400da130: HAPFatalErrorInternal at /Users/lorenzofiamingo/Developer/esp-apple-homekit-adk/homekit_adk/PAL/HAPAssert.c:44

0x400ea8fa: HAPPlatformClockGetCurrent at /Users/lorenzofiamingo/Developer/esp-apple-homekit-adk/port/src/HAPPlatformClock.c:51 (discriminator 1)

0x400d9045: HAPPlatformRunLoopRun at /Users/lorenzofiamingo/Developer/esp-apple-homekit-adk/port/src/HAPPlatformRunLoop.c:609 (discriminator 1)

0x400d7c6b: main_task at /Users/lorenzofiamingo/Developer/esp-apple-homekit-adk/examples/Lightbulb/main/app_main.c:336 (discriminator 2)

0x4008b891: vPortTaskWrapper at /Users/lorenzofiamingo/esp/esp-idf/components/freertos/port/xtensa/port.c:159

ESP32-WROOM-32 "Fault assertion failed" message and reboots

I have tried unchanged version of the Lightbulb example, following the building instructions.
It works fine, however I have noticed that it keeps rebooting around 10 minutes after closing the session with the "iOS" device.
I really don't understand what is causing the issue, but I want to help and mention it.
This is a part of the screen log (I hope it is enough):

1970-01-01'T'00:10:41'Z'	Info	[com.apple.mfi.HomeKit.Core:PairingPairVerify] Pair Verify procedure completed (pairing ID 0).
1970-01-01'T'00:10:41'Z'	Debug	[com.apple.mfi.HomeKit.Core:IPAccessoryServer] session:0x3ffb9cd0:<
    0000  48545450 2f312e31 20323030 204f4b0d 0a436f6e 74656e74 2d547970 653a2061    HTTP/1.1 200 OK..Content-Type: a
    0020  70706c69 63617469 6f6e2f70 61697269 6e672b74 6c76380d 0a436f6e 74656e74    pplication/pairing+tlv8..Content
    0040  2d4c656e 6774683a 20330d0a 0d0a0601 04                                     -Length: 3.......
1970-01-01'T'00:10:41'Z'	Debug	[com.apple.mfi.HomeKit.Core:IPAccessoryServer] session:0x3ffb9cd0:input closed
1970-01-01'T'00:10:41'Z'	Debug	[com.apple.mfi.HomeKit.Core:IPAccessoryServer] session:0x3ffb9cd0:closing
1970-01-01'T'00:10:41'Z'	Debug	[com.apple.mfi.HomeKit.Core:IPAccessoryServer] session:0x3ffb9cd0:closing security context
1970-01-01'T'00:10:41'Z'	Debug	[com.apple.mfi.HomeKit.Core:IPAccessoryServer] Closing HAP session.
1970-01-01'T'00:10:41'Z'	Debug	[com.apple.mfi.HomeKit.Core:Session] HAPSessionRelease
1970-01-01'T'00:10:41'Z'	Debug	[com.apple.mfi.HomeKit.Core:Session] HAPSessionInvalidate
1970-01-01'T'00:10:41'Z'	Debug	[com.apple.mfi.HomeKit.Core:IPAccessoryServer] session:0x3ffb9cd0:closing TCP stream
1970-01-01'T'00:10:41'Z'	Debug	[com.apple.mfi.HomeKit.Platform:TCPStreamManager] shutdown(51, SHUT_RDWR);
1970-01-01'T'00:10:41'Z'	Fault	assertion failed - HAPPlatformLogPOSIXError @ /Users/Logic/esp32_test/esp-apple-homekit-adk/port/src/HAPPlatformLog.c:65

abort() was called at PC 0x400d5fa3 on core 0
0x400d5fa3: syscall_not_implemented_aborts at /Users/Logic/esp32_test/esp-idf/components/newlib/syscalls.c:39


Backtrace:0x4008760f:0x3ffc9540 0x40087cad:0x3ffc9560 0x4008e8fe:0x3ffc9580 0x400d5fa3:0x3ffc95f0 0x40163db2:0x3ffc9610 0x400e9a65:0x3ffc9630 0x400d8b74:0x3ffc9650 0x400e9ca6:0x3ffc9670 0x400d87a2:0x3ffc97a0 0x400e320a:0x3ffc97c0 0x400e32bf:0x3ffc9800 0x400e4ba5:0x3ffc9820 0x400e5aa9:0x3ffc9850 0x400d7e51:0x3ffc9870 0x400d721d:0x3ffc9890 0x400d7a20:0x3ffc98b0 0x400d6487:0x3ffc98f0 0x40087cb5:0x3ffc9910
0x4008760f: panic_abort at /Users/Logic/esp32_test/esp-idf/components/esp_system/panic.c:330

0x40087cad: esp_system_abort at /Users/Logic/esp32_test/esp-idf/components/esp_system/system_api.c:100

0x4008e8fe: abort at /Users/Logic/esp32_test/esp-idf/components/newlib/abort.c:46

0x400d5fa3: syscall_not_implemented_aborts at /Users/Logic/esp32_test/esp-idf/components/newlib/syscalls.c:39

0x40163db2: exit at /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32-elf/src/newlib/newlib/libc/stdlib/exit.c:64

0x400e9a65: HAPPlatformAbort at /Users/Logic/esp32_test/esp-apple-homekit-adk/port/src/HAPPlatformAbort.c:27

0x400d8b74: HAPAssertInternal at /Users/Logic/esp32_test/esp-apple-homekit-adk/homekit_adk/PAL/HAPAssert.c:20

0x400e9ca6: HAPPlatformLogPOSIXError at /Users/Logic/esp32_test/esp-apple-homekit-adk/port/src/HAPPlatformLog.c:65 (discriminator 2)

0x400d87a2: HAPPlatformTCPStreamClose at /Users/Logic/esp32_test/esp-apple-homekit-adk/port/src/HAPPlatformTCPStreamManager.c:516

0x400e320a: CloseSession at /Users/Logic/esp32_test/esp-apple-homekit-adk/homekit_adk/HAP/HAPIPAccessoryServer.c:513 (discriminator 1)

0x400e32bf: handle_input_closed at /Users/Logic/esp32_test/esp-apple-homekit-adk/homekit_adk/HAP/HAPIPAccessoryServer.c:3553

0x400e4ba5: ReadInboundData at /Users/Logic/esp32_test/esp-apple-homekit-adk/homekit_adk/HAP/HAPIPAccessoryServer.c:3595

0x400e5aa9: HandleTCPStreamEvent at /Users/Logic/esp32_test/esp-apple-homekit-adk/homekit_adk/HAP/HAPIPAccessoryServer.c:3622

0x400d7e51: HandleTCPStreamFileHandleCallback at /Users/Logic/esp32_test/esp-apple-homekit-adk/port/src/HAPPlatformTCPStreamManager.c:731

0x400d721d: ProcessSelectedFileHandles at /Users/Logic/esp32_test/esp-apple-homekit-adk/port/src/HAPPlatformRunLoop.c:303

0x400d7a20: HAPPlatformRunLoopRun at /Users/Logic/esp32_test/esp-apple-homekit-adk/port/src/HAPPlatformRunLoop.c:640

0x400d6487: main_task at /Users/Logic/esp32_test/esp-apple-homekit-adk/examples/Lightbulb/build/../main/app_main.c:336

0x40087cb5: vPortTaskWrapper at /Users/Logic/esp32_test/esp-idf/components/freertos/xtensa/port.c:143

Question? - where should I put ESP32 code to turn GPIO on/off

I’m unsure where I should put actual esp-idf code to say define GPIO pin for LED & actually set it on or off. Say for example I want to use the ESP32 built in led GPIO 2.would it go in the App.c or in app_main. Just a little help would go along way for new devs.

The example works great from HomeKit perspective. Just need one more step.

Thanks.

mbedtls error

Hi,

I am seeing the below error when I try flashing to ESP32:

Generated /Users/rashmi/esp-apple-homekit-adk/examples/Lightbulb/build/bootloader/bootloader.bin
[661/1035] Building C object esp-idf/port/CMakeFiles/__idf_port.dir/src/HAPPlatformLog.c.obj
/Users/rashmi/esp-apple-homekit-adk/port/src/HAPPlatformLog.c: In function 'HAPPlatformLogPOSIXError':
/Users/rashmi/esp-apple-homekit-adk/port/src/HAPPlatformLog.c:60:13: warning: initialization of 'int' from 'char *' makes integer from pointer without a cast [-Wint-conversion]
int e = strerror_r(errorNumber, errorString, sizeof errorString);
^~~~~~~~~~
[708/1035] Building C object esp-idf/port/CMakeFiles/__idf_port.dir/Users/rashmi/esp-apple-homekit-adk/homekit_adk/PAL/Crypto/MbedTLS/HAPMbedTLS.c.obj
FAILED: esp-idf/port/CMakeFiles/__idf_port.dir/Users/rashmi/esp-apple-homekit-adk/homekit_adk/PAL/Crypto/MbedTLS/HAPMbedTLS.c.obj
/Users/rashmi/.espressif/tools/xtensa-esp32-elf/esp-2020r1-8.2.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc -DHAP_LOG_LEVEL=1 -DMBEDTLS_CONFIG_FILE="mbedtls/esp_config.h" -Iconfig -I/Users/rashmi/esp-apple-homekit-adk/port/include -I/Users/rashmi/esp-apple-homekit-adk/homekit_adk/HAP -I/Users/rashmi/esp-apple-homekit-adk/homekit_adk/PAL -I/Users/rashmi/esp-apple-homekit-adk/homekit_adk/External/Base64 -I/Users/rashmi/esp-apple-homekit-adk/homekit_adk/External/JSON -I/Users/rashmi/esp-apple-homekit-adk/homekit_adk/External/HTTP -I/Users/rashmi/esp-idf/components/newlib/platform_include -I/Users/rashmi/esp-idf/components/freertos/include -I/Users/rashmi/esp-idf/components/freertos/xtensa/include -I/Users/rashmi/esp-idf/components/heap/include -I/Users/rashmi/esp-idf/components/log/include -I/Users/rashmi/esp-idf/components/lwip/include/apps -I/Users/rashmi/esp-idf/components/lwip/include/apps/sntp -I/Users/rashmi/esp-idf/components/lwip/lwip/src/include -I/Users/rashmi/esp-idf/components/lwip/port/esp32/include -I/Users/rashmi/esp-idf/components/lwip/port/esp32/include/arch -I/Users/rashmi/esp-idf/components/soc/src/esp32/. -I/Users/rashmi/esp-idf/components/soc/src/esp32/include -I/Users/rashmi/esp-idf/components/soc/include -I/Users/rashmi/esp-idf/components/esp_rom/include -I/Users/rashmi/esp-idf/components/esp_common/include -I/Users/rashmi/esp-idf/components/esp_system/include -I/Users/rashmi/esp-idf/components/xtensa/include -I/Users/rashmi/esp-idf/components/xtensa/esp32/include -I/Users/rashmi/esp-idf/components/esp32/include -I/Users/rashmi/esp-idf/components/driver/include -I/Users/rashmi/esp-idf/components/driver/esp32/include -I/Users/rashmi/esp-idf/components/esp_ringbuf/include -I/Users/rashmi/esp-idf/components/efuse/include -I/Users/rashmi/esp-idf/components/efuse/esp32/include -I/Users/rashmi/esp-idf/components/espcoredump/include -I/Users/rashmi/esp-idf/components/esp_timer/include -I/Users/rashmi/esp-idf/components/soc/soc/esp32/. -I/Users/rashmi/esp-idf/components/soc/soc/esp32/include -I/Users/rashmi/esp-idf/components/soc/soc/esp32/../include -I/Users/rashmi/esp-idf/components/vfs/include -I/Users/rashmi/esp-idf/components/esp_wifi/include -I/Users/rashmi/esp-idf/components/esp_wifi/esp32/include -I/Users/rashmi/esp-idf/components/esp_event/include -I/Users/rashmi/esp-idf/components/esp_netif/include -I/Users/rashmi/esp-idf/components/esp_eth/include -I/Users/rashmi/esp-idf/components/tcpip_adapter/include -I/Users/rashmi/esp-idf/components/app_trace/include -I/Users/rashmi/esp-idf/components/nvs_flash/include -I/Users/rashmi/esp-idf/components/spi_flash/include -I/Users/rashmi/esp-idf/components/mbedtls/port/include -I/Users/rashmi/esp-idf/components/mbedtls/mbedtls/include -I/Users/rashmi/esp-idf/components/mbedtls/esp_crt_bundle/include -I/Users/rashmi/esp-idf/components/mdns/include -I/Users/rashmi/esp-idf/components/console -mlongcalls -Wno-frame-address -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -Wall -Werror=all -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wextra -Wno-unused-parameter -Wno-sign-compare -ggdb -Og -std=gnu99 -Wno-old-style-declaration -D_GNU_SOURCE -DIDF_VER="v4.2-dev-1660-g7d7521367-dirty" -DESP_PLATFORM -MD -MT esp-idf/port/CMakeFiles/__idf_port.dir/Users/rashmi/esp-apple-homekit-adk/homekit_adk/PAL/Crypto/MbedTLS/HAPMbedTLS.c.obj -MF esp-idf/port/CMakeFiles/__idf_port.dir/Users/rashmi/esp-apple-homekit-adk/homekit_adk/PAL/Crypto/MbedTLS/HAPMbedTLS.c.obj.d -o esp-idf/port/CMakeFiles/__idf_port.dir/Users/rashmi/esp-apple-homekit-adk/homekit_adk/PAL/Crypto/MbedTLS/HAPMbedTLS.c.obj -c /Users/rashmi/esp-apple-homekit-adk/homekit_adk/PAL/Crypto/MbedTLS/HAPMbedTLS.c
/Users/rashmi/esp-apple-homekit-adk/homekit_adk/PAL/Crypto/MbedTLS/HAPMbedTLS.c: In function 'HAP_X25519_scalarmult':
/Users/rashmi/esp-apple-homekit-adk/homekit_adk/PAL/Crypto/MbedTLS/HAPMbedTLS.c:119:19: error: implicit declaration of function 'mbedtls_ecp_read_key'; did you mean 'mbedtls_ecp_gen_key'? [-Werror=implicit-function-declaration]
int ret = mbedtls_ecp_read_key(MBEDTLS_ECP_DP_CURVE25519, &our_key, n, X25519_SCALAR_BYTES);
^~~~~~~~~~~~~~~~~~~~
/Users/rashmi/esp-apple-homekit-adk/homekit_adk/PAL/Crypto/MbedTLS/HAPMbedTLS.c:107:9: note: in definition of macro 'WITH'
X;
^
/Users/rashmi/esp-apple-homekit-adk/homekit_adk/PAL/Crypto/MbedTLS/HAPMbedTLS.c:118:5: note: in expansion of macro 'WITH_ECP_KEYPAIR'
WITH_ECP_KEYPAIR(our_key, {
^~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
[721/1035] Building C object esp-idf/port/CMakeFiles/__idf_port.dir/Users/rashmi/esp-apple-homekit-adk/homekit_adk/HAP/HAPIPAccessory.c.obj
ninja: build stopped: subcommand failed.
ninja failed with exit code 1

Any clue why this is happening? I am following the exact same instructions you have on your page with git checkout -b mbedtls-2.16.6-adk origin/mbedtls-2.16.6-adk

Thanks for your help

this project support esp32s3 ?

i use master branch build failed:

Users/lamdacat/esp/esp-apple-homekit-adk/port/src/HAPPlatformKeyValueStore.c:211:25: error: too few arguments to function 'nvs_entry_find'
  211 |     nvs_iterator_t it = nvs_entry_find(keyValueStore->part_name, name_space, NVS_TYPE_BLOB);
      |                         ^~~~~~~~~~~~~~
ort/src/HAPPlatformRandomNumber.c
/Users/lamdacat/esp/esp-apple-homekit-adk/port/src/HAPPlatformRandomNumber.c: In function 'HAPPlatformRandomNumberFill':
/Users/lamdacat/esp/esp-apple-homekit-adk/port/src/HAPPlatformRandomNumber.c:26:5: error: implicit declaration of function 'esp_fill_random' [-Werror=implicit-function-declaration]
   26 |     esp_fill_random(bytes, numBytes);
      |     ^~~~~~~~~~~~~~~

homekit adk not compiling

I am trying to compile LightBulb Example as per
readme.md.
After executing "idf.py set-target esp32" I am getting following error:

C:\esp\esp-idf\examples\esp-apple-homekit-adk\examples\Lightbulb>idf.py set-target esp32
Adding "set-target"'s dependency "fullclean" to list of commands with default set of options.
Executing action: fullclean
Directory 'c:\esp\esp-idf\examples\esp-apple-homekit-adk\examples\lightbulb\build' doesn't seem to be a CMake build directory. Refusing to automatically delete files in this directory. Delete the directory manually to 'clean' it.

C:\esp\esp-idf\examples\esp-apple-homekit-adk\examples\Lightbulb>idf.py set-target esp32
Adding "set-target"'s dependency "fullclean" to list of commands with default set of options.
Executing action: fullclean
Build directory 'c:\esp\esp-idf\examples\esp-apple-homekit-adk\examples\lightbulb\build' not found. Nothing to clean.
Executing action: set-target
Set Target to: esp32, new sdkconfig created. Existing sdkconfig renamed to sdkconfig.old.
Running cmake in directory c:\esp\esp-idf\examples\esp-apple-homekit-adk\examples\lightbulb\build
Executing "cmake -G Ninja -DPYTHON_DEPS_CHECKED=1 -DESP_PLATFORM=1 --warn-uninitialized -DIDF_TARGET=esp32 -DCCACHE_ENABLE=1 c:\esp\esp-idf\examples\esp-apple-homekit-adk\examples\lightbulb"...
Warn about uninitialized values.
-- Found Git: C:/Program Files/Git/cmd/git.exe (found version "2.29.0.windows.1")
-- ccache will be used for faster recompilation
-- The C compiler identification is GNU 8.2.0
-- The CXX compiler identification is GNU 8.2.0
-- The ASM compiler identification is GNU
-- Found assembler: C:/esp/tools/.espressif/tools/xtensa-esp32-elf/esp-2020r2-8.2.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc.exe
-- Check for working C compiler: C:/esp/tools/.espressif/tools/xtensa-esp32-elf/esp-2020r2-8.2.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc.exe
-- Check for working C compiler: C:/esp/tools/.espressif/tools/xtensa-esp32-elf/esp-2020r2-8.2.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/esp/tools/.espressif/tools/xtensa-esp32-elf/esp-2020r2-8.2.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-g++.exe
-- Check for working CXX compiler: C:/esp/tools/.espressif/tools/xtensa-esp32-elf/esp-2020r2-8.2.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Project version: v4.1-dirty
-- Building ESP-IDF components for target esp32
Loading defaults file C:/esp/esp-idf/examples/esp-apple-homekit-adk/examples/Lightbulb/sdkconfig.defaults...
-- Found PythonInterp: C:/esp/tools/.espressif/python_env/idf4.1_py3.8_env/Scripts/python.exe (found version "3.8.3")
-- Could NOT find Perl (missing: PERL_EXECUTABLE)
-- Adding linker script C:/esp/esp-idf/examples/esp-apple-homekit-adk/examples/Lightbulb/build/esp-idf/esp32/esp32_out.ld
-- Adding linker script C:/esp/esp-idf/components/esp32/ld/esp32.project.ld.in
-- Adding linker script C:/esp/esp-idf/components/esp32/ld/esp32.peripherals.ld
-- Adding linker script C:/esp/esp-idf/components/esp_rom/esp32/ld/esp32.rom.newlib-time.ld
-- Adding linker script C:/esp/esp-idf/components/esp_rom/esp32/ld/esp32.rom.ld
-- Adding linker script C:/esp/esp-idf/components/esp_rom/esp32/ld/esp32.rom.libgcc.ld
-- Adding linker script C:/esp/esp-idf/components/esp_rom/esp32/ld/esp32.rom.newlib-data.ld
-- Adding linker script C:/esp/esp-idf/components/esp_rom/esp32/ld/esp32.rom.syscalls.ld
-- Adding linker script C:/esp/esp-idf/components/esp_rom/esp32/ld/esp32.rom.newlib-funcs.ld
CMake Error at ../../../../tools/cmake/component.cmake:302 (message):
Include directory
'C:/esp/esp-idf/examples/esp-apple-homekit-adk/homekit_adk/HAP' is not a
directory.
Call Stack (most recent call first):
../../../../tools/cmake/component.cmake:470 (__component_add_include_dirs)
../../port/CMakeLists.txt:102 (idf_component_register)

-- Configuring incomplete, errors occurred!
See also "C:/esp/esp-idf/examples/esp-apple-homekit-adk/examples/Lightbulb/build/CMakeFiles/CMakeOutput.log".
cmake failed with exit code 1

FAILED: esp-idf/main/CMakeFiles/__idf_main.dir/app_wifi.c.obj

Hi!
During idf.py build, I'm receiving the following error.

Does anyone know how to fix it?

`[836/921] Building C object esp-idf/main/CMakeFiles/__idf_main.dir/app_wifi.c.obj
FAILED: esp-idf/main/CMakeFiles/__idf_main.dir/app_wifi.c.obj
ccache C:\Users\victo.espressif\tools\xtensa-esp32-elf\esp-2019r2-8.2.0\xtensa-esp32-elf\bin\xtensa-esp32-elf-gcc.exe -DHAVE_CONFIG_H -DMBEDTLS_CONFIG_FILE="mbedtls/esp_config.h" -DUNITY_INCLUDE_CONFIG_H -DWITH_POSIX -Iconfig -I../main -IC:/Users/victo/Desktop/esp-idf/components/newlib/platform_include -IC:/Users/victo/Desktop/esp-idf/components/freertos/include -IC:/Users/victo/Desktop/esp-idf/components/heap/include -IC:/Users/victo/Desktop/esp-idf/components/log/include -IC:/Users/victo/Desktop/esp-idf/components/soc/esp32/include -IC:/Users/victo/Desktop/esp-idf/components/soc/include -IC:/Users/victo/Desktop/esp-idf/components/esp_rom/include -IC:/Users/victo/Desktop/esp-idf/components/esp_common/include -IC:/Users/victo/Desktop/esp-idf/components/xtensa/include -IC:/Users/victo/Desktop/esp-idf/components/xtensa/esp32/include -IC:/Users/victo/Desktop/esp-idf/components/esp32/include -IC:/Users/victo/Desktop/esp-idf/components/driver/include -IC:/Users/victo/Desktop/esp-idf/components/esp_ringbuf/include -IC:/Users/victo/Desktop/esp-idf/components/esp_event/include -IC:/Users/victo/Desktop/esp-idf/components/tcpip_adapter/include -IC:/Users/victo/Desktop/esp-idf/components/lwip/include/apps -IC:/Users/victo/Desktop/esp-idf/components/lwip/include/apps/sntp -IC:/Users/victo/Desktop/esp-idf/components/lwip/lwip/src/include -IC:/Users/victo/Desktop/esp-idf/components/lwip/port/esp32/include -IC:/Users/victo/Desktop/esp-idf/components/lwip/port/esp32/include/arch -IC:/Users/victo/Desktop/esp-idf/components/vfs/include -IC:/Users/victo/Desktop/esp-idf/components/esp_wifi/include -IC:/Users/victo/Desktop/esp-idf/components/esp_wifi/esp32/include -IC:/Users/victo/Desktop/esp-idf/components/esp_eth/include -IC:/Users/victo/Desktop/esp-idf/components/efuse/include -IC:/Users/victo/Desktop/esp-idf/components/efuse/esp32/include -IC:/Users/victo/Desktop/esp-idf/components/app_trace/include -IC:/Users/victo/Desktop/esp-idf/components/mbedtls/port/include -IC:/Users/victo/Desktop/esp-idf/components/mbedtls/mbedtls/include -IC:/Users/victo/Desktop/esp-idf/components/wpa_supplicant/include -IC:/Users/victo/Desktop/esp-idf/components/wpa_supplicant/port/include -IC:/Users/victo/Desktop/esp-idf/components/wpa_supplicant/include/esp_supplicant -IC:/Users/victo/Desktop/esp-idf/components/bootloader_support/include -IC:/Users/victo/Desktop/esp-idf/components/app_update/include -IC:/Users/victo/Desktop/esp-idf/components/spi_flash/include -IC:/Users/victo/Desktop/esp-idf/components/nvs_flash/include -IC:/Users/victo/Desktop/esp-idf/components/pthread/include -IC:/Users/victo/Desktop/esp-idf/components/espcoredump/include -IC:/Users/victo/Desktop/esp-idf/components/asio/asio/asio/include -IC:/Users/victo/Desktop/esp-idf/components/asio/port/include -IC:/Users/victo/Desktop/esp-idf/components/coap/port/include -IC:/Users/victo/Desktop/esp-idf/components/coap/port/include/coap -IC:/Users/victo/Desktop/esp-idf/components/coap/libcoap/include -IC:/Users/victo/Desktop/esp-idf/components/coap/libcoap/include/coap2 -IC:/Users/victo/Desktop/esp-idf/components/console -IC:/Users/victo/Desktop/esp-idf/components/nghttp/port/include -IC:/Users/victo/Desktop/esp-idf/components/nghttp/nghttp2/lib/includes -IC:/Users/victo/Desktop/esp-idf/components/esp-tls -IC:/Users/victo/Desktop/esp-idf/components/esp_adc_cal/include -IC:/Users/victo/Desktop/esp-idf/components/esp_gdbstub/include -IC:/Users/victo/Desktop/esp-idf/components/tcp_transport/include -IC:/Users/victo/Desktop/esp-idf/components/esp_http_client/include -IC:/Users/victo/Desktop/esp-idf/components/esp_http_server/include -IC:/Users/victo/Desktop/esp-idf/components/esp_https_ota/include -IC:/Users/victo/Desktop/esp-idf/components/protobuf-c/protobuf-c -IC:/Users/victo/Desktop/esp-idf/components/protocomm/include/common -IC:/Users/victo/Desktop/esp-idf/components/protocomm/include/security -IC:/Users/victo/Desktop/esp-idf/components/protocomm/include/transports -IC:/Users/victo/Desktop/esp-idf/components/mdns/include -IC:/Users/victo/Desktop/esp-idf/components/esp_local_ctrl/include -IC:/Users/victo/Desktop/esp-idf/components/esp_websocket_client/include -IC:/Users/victo/Desktop/esp-idf/components/expat/expat/expat/lib -IC:/Users/victo/Desktop/esp-idf/components/expat/port/include -IC:/Users/victo/Desktop/esp-idf/components/wear_levelling/include -IC:/Users/victo/Desktop/esp-idf/components/sdmmc/include -IC:/Users/victo/Desktop/esp-idf/components/fatfs/diskio -IC:/Users/victo/Desktop/esp-idf/components/fatfs/vfs -IC:/Users/victo/Desktop/esp-idf/components/fatfs/src -IC:/Users/victo/Desktop/esp-idf/components/freemodbus/common/include -IC:/Users/victo/Desktop/esp-idf/components/idf_test/include -IC:/Users/victo/Desktop/esp-idf/components/jsmn/include -IC:/Users/victo/Desktop/esp-idf/components/json/cJSON -IC:/Users/victo/Desktop/esp-idf/components/libsodium/libsodium/src/libsodium/include -IC:/Users/victo/Desktop/esp-idf/components/libsodium/port_include -IC:/Users/victo/Desktop/esp-idf/components/mqtt/esp-mqtt/include -IC:/Users/victo/Desktop/esp-idf/components/openssl/include -IC:/Users/victo/Desktop/esp-idf/components/spiffs/include -IC:/Users/victo/Desktop/esp-idf/components/ulp/include -IC:/Users/victo/Desktop/esp-idf/components/unity/include -IC:/Users/victo/Desktop/esp-idf/components/unity/unity/src -IC:/Users/victo/Desktop/esp-idf/components/wifi_provisioning/include -IC:/Users/victo/esp/esp-apple-homekit-adk/port/include -IC:/Users/victo/esp/esp-apple-homekit-adk/homekit_adk/HAP -IC:/Users/victo/esp/esp-apple-homekit-adk/homekit_adk/PAL -IC:/Users/victo/esp/esp-apple-homekit-adk/homekit_adk/External/Base64 -IC:/Users/victo/esp/esp-apple-homekit-adk/homekit_adk/External/JSON -IC:/Users/victo/esp/esp-apple-homekit-adk/homekit_adk/External/HTTP -mlongcalls -Wno-frame-address -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -nostdlib -Wall -Werror=all -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wextra -Wno-unused-parameter -Wno-sign-compare -ggdb -Og -std=gnu99 -Wno-old-style-declaration -D_GNU_SOURCE -DIDF_VER="v4.0.1-dirty" -DGCC_NOT_5_2_0 -DESP_PLATFORM -MD -MT esp-idf/main/CMakeFiles/__idf_main.dir/app_wifi.c.obj -MF esp-idf\main\CMakeFiles__idf_main.dir\app_wifi.c.obj.d -o esp-idf/main/CMakeFiles/__idf_main.dir/app_wifi.c.obj -c ../main/app_wifi.c
In file included from C:/Users/victo/Desktop/esp-idf/components/esp_common/include/esp_timer.h:44,
from C:/Users/victo/Desktop/esp-idf/components/freertos/include/freertos/portmacro.h:84,
from C:/Users/victo/Desktop/esp-idf/components/freertos/include/freertos/portable.h:96,
from C:/Users/victo/Desktop/esp-idf/components/freertos/include/freertos/FreeRTOS.h:105,
from ../main/app_wifi.c:10:
../main/app_wifi.c: In function 'app_wifi_init':
../main/app_wifi.c:71:21: error: implicit declaration of function 'esp_netif_init'; did you mean 'esp_wifi_init'? [-Werror=implicit-function-declaration]
ESP_ERROR_CHECK(esp_netif_init());
^~~~~~~~~~~~~~
C:/Users/victo/Desktop/esp-idf/components/esp_common/include/esp_err.h:118:31: note: in definition of macro 'ESP_ERROR_CHECK'
esp_err_t __err_rc = (x);
^
../main/app_wifi.c:73:5: error: implicit declaration of function 'esp_netif_create_default_wifi_sta' [-Werror=implicit-function-declaration]
esp_netif_create_default_wifi_sta();
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../main/app_wifi.c: In function 'app_wifi_connect':
../main/app_wifi.c:82:5: error: unknown type name 'esp_event_handler_instance_t'; did you mean 'esp_event_handler_t'?
esp_event_handler_instance_t instance_any_id;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
esp_event_handler_t
../main/app_wifi.c:83:5: error: unknown type name 'esp_event_handler_instance_t'; did you mean 'esp_event_handler_t'?
esp_event_handler_instance_t instance_got_ip;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
esp_event_handler_t
In file included from C:/Users/victo/Desktop/esp-idf/components/esp_common/include/esp_timer.h:44,
from C:/Users/victo/Desktop/esp-idf/components/freertos/include/freertos/portmacro.h:84,
from C:/Users/victo/Desktop/esp-idf/components/freertos/include/freertos/portable.h:96,
from C:/Users/victo/Desktop/esp-idf/components/freertos/include/freertos/FreeRTOS.h:105,
from ../main/app_wifi.c:10:
../main/app_wifi.c:84:21: error: implicit declaration of function 'esp_event_handler_instance_register'; did you mean 'esp_event_handler_unregister'? [-Werror=implicit-function-declaration]
ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/Users/victo/Desktop/esp-idf/components/esp_common/include/esp_err.h:118:31: note: in definition of macro 'ESP_ERROR_CHECK'
esp_err_t __err_rc = (x);
^
../main/app_wifi.c:129:21: error: implicit declaration of function 'esp_event_handler_instance_unregister'; did you mean 'esp_event_handler_unregister'? [-Werror=implicit-function-declaration]
ESP_ERROR_CHECK(esp_event_handler_instance_unregister(IP_EVENT, IP_EVENT_STA_GOT_IP, instance_got_ip));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/Users/victo/Desktop/esp-idf/components/esp_common/include/esp_err.h:118:31: note: in definition of macro 'ESP_ERROR_CHECK'
esp_err_t __err_rc = (x);
^
cc1.exe: some warnings being treated as errors
[838/921] Building C object esp-idf/port/CMakeFiles/__idf_port.dir/src/HAPPlatformLog.c.obj
C:/Users/victo/esp/esp-apple-homekit-adk/port/src/HAPPlatformLog.c: In function 'HAPPlatformLogPOSIXError':
C:/Users/victo/esp/esp-apple-homekit-adk/port/src/HAPPlatformLog.c:60:13: warning: initialization of 'int' from 'char *' makes integer from pointer without a cast [-Wint-conversion]
int e = strerror_r(errorNumber, errorString, sizeof errorString);
^~~~~~~~~~
[841/921] Performing configure step for 'bootloader'
Warn about uninitialized values.
-- Found Git: C:/Program Files/Git/cmd/git.exe (found version "2.21.0.windows.1")
CMake Warning at C:/Users/victo/Desktop/esp-idf/tools/cmake/git_submodules.cmake:52 (message):
Git submodule components/mbedtls/mbedtls is out of date. Run 'git
submodule update --init --recursive' to fix.
Call Stack (most recent call first):
C:/Users/victo/Desktop/esp-idf/tools/cmake/build.cmake:78 (git_submodule_check)
C:/Users/victo/Desktop/esp-idf/tools/cmake/build.cmake:159 (__build_get_idf_git_revision)
C:/Users/victo/Desktop/esp-idf/tools/cmake/idf.cmake:43 (__build_init)
C:/Users/victo/Desktop/esp-idf/tools/cmake/project.cmake:7 (include)
CMakeLists.txt:20 (include)

-- mconf-idf version mconf-v4.6.0.0-idf-20190628-win32
-- The C compiler identification is GNU 8.2.0
-- The CXX compiler identification is GNU 8.2.0
-- The ASM compiler identification is GNU
-- Found assembler: C:/Users/victo/.espressif/tools/xtensa-esp32-elf/esp-2019r2-8.2.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc.exe
-- Check for working C compiler: C:/Users/victo/.espressif/tools/xtensa-esp32-elf/esp-2019r2-8.2.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc.exe
-- Check for working C compiler: C:/Users/victo/.espressif/tools/xtensa-esp32-elf/esp-2019r2-8.2.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Users/victo/.espressif/tools/xtensa-esp32-elf/esp-2019r2-8.2.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-g++.exe
-- Check for working CXX compiler: C:/Users/victo/.espressif/tools/xtensa-esp32-elf/esp-2019r2-8.2.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Project version: v4.0.1-dirty
-- Building ESP-IDF components for target esp32
-- Adding linker script C:/Users/victo/Desktop/esp-idf/components/esp32/ld/esp32.peripherals.ld
-- Adding linker script C:/Users/victo/Desktop/esp-idf/components/esp_rom/esp32/ld/esp32.rom.ld
-- Adding linker script C:/Users/victo/Desktop/esp-idf/components/esp_rom/esp32/ld/esp32.rom.newlib-funcs.ld
-- Adding linker script C:/Users/victo/Desktop/esp-idf/components/esp_rom/esp32/ld/esp32.rom.libgcc.ld
-- Adding linker script C:/Users/victo/Desktop/esp-idf/components/bootloader/subproject/main/esp32.bootloader.ld
-- Adding linker script C:/Users/victo/Desktop/esp-idf/components/bootloader/subproject/main/esp32.bootloader.rom.ld
-- Components: bootloader bootloader_support efuse esp32 esp_common esp_rom esptool_py log main micro-ecc partition_table soc spi_flash xtensa
-- Component paths: C:/Users/victo/Desktop/esp-idf/components/bootloader C:/Users/victo/Desktop/esp-idf/components/bootloader_support C:/Users/victo/Desktop/esp-idf/components/efuse C:/Users/victo/Desktop/esp-idf/components/esp32 C:/Users/victo/Desktop/esp-idf/components/esp_common C:/Users/victo/Desktop/esp-idf/components/esp_rom C:/Users/victo/Desktop/esp-idf/components/esptool_py C:/Users/victo/Desktop/esp-idf/components/log C:/Users/victo/Desktop/esp-idf/components/bootloader/subproject/main C:/Users/victo/Desktop/esp-idf/components/bootloader/subproject/components/micro-ecc C:/Users/victo/Desktop/esp-idf/components/partition_table C:/Users/victo/Desktop/esp-idf/components/soc C:/Users/victo/Desktop/esp-idf/components/spi_flash C:/Users/victo/Desktop/esp-idf/components/xtensa
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/victo/esp/esp-apple-homekit-adk/examples/Lightbulb/build/bootloader
ninja: build stopped: subcommand failed.
ninja failed with exit code 1`

Error on setup

I'm following all steps from "Get Started" guide, but something is going wrong.

I set up Host environment using the VS Code Extension. After I tried to run this commands but something is not working:

lorenzofiamingo@MacBook-Pro-di-Lorenzo mbedtls % git pull
remote: Enumerating objects: 874, done.
remote: Counting objects: 100% (874/874), done.
remote: Total 1558 (delta 874), reused 874 (delta 874), pack-reused 684
Receiving objects: 100% (1558/1558), 469.90 KiB | 1.59 MiB/s, done.
Resolving deltas: 100% (1235/1235), completed with 377 local objects.
From https://github.com/espressif/mbedtls
 * [new branch]          mbedtls-2.16.9-idf -> origin/mbedtls-2.16.9-idf
You are not currently on a branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

lorenzofiamingo@MacBook-Pro-di-Lorenzo mbedtls % git checkout -b mbedtls-2.16.6-adk origin/mbedtls-2.16.6-adk
error: Your local changes to the following files would be overwritten by checkout:
	.pylintrc
	.travis.yml
	CONTRIBUTING.md
	ChangeLog
	ChangeLog.d/00README.md
	LICENSE
	Makefile
	README.md
	configs/config-ccm-psk-tls1_2.h
	configs/config-mini-tls1_1.h
	configs/config-no-entropy.h
	configs/config-suite-b.h
	configs/config-thread.h
	doxygen/input/doc_encdec.h
	doxygen/input/doc_hashing.h
	doxygen/input/doc_mainpage.h
	doxygen/input/doc_rng.h
	doxygen/input/doc_ssltls.h
	doxygen/input/doc_tcpip.h
	doxygen/input/doc_x509.h
	doxygen/mbedtls.doxyfile
	gpl-2.0.txt
	include/mbedtls/aes.h
	include/mbedtls/aesni.h
	include/mbedtls/arc4.h
	include/mbedtls/aria.h
	include/mbedtls/asn1.h
	include/mbedtls/asn1write.h
	include/mbedtls/base64.h
	include/mbedtls/bignum.h
	include/mbedtls/blowfish.h
	include/mbedtls/bn_mul.h
	include/mbedtls/camellia.h
	include/mbedtls/ccm.h
	include/mbedtls/certs.h
	include/mbedtls/chacha20.h
	include/mbedtls/chachapoly.h
	include/mbedtls/check_config.h
	include/mbedtls/cipher.h
	include/mbedtls/cipher_internal.h
	include/mbedtls/cmac.h
	include/mbedtls/compat-1.3.h
	include/mbedtls/config.h
	include/mbedtls/ctr_drbg.h
	include/mbedtls/debug.h
	include/mbedtls/des.h
	include/mbedtls/dhm.h
	include/mbedtls/ecdh.h
	include/mbedtls/ecdsa.h
	include/mbedtls/ecjpake.h
	include/mbedtls/ecp.h
	include/mbedtls/ecp_internal.h
	include/mbedtls/entropy.h
	include/mbedtls/entropy_poll.h
	include/mbedtls/error.h
	include/mbedtls/gcm.h
	include/mbedtls/havege.h
	include/mbedtls/hkdf.h
	include/mbedtls/hmac_drbg.h
	include/mbedtls/md.h
	include/mbedtls/md2.h
	include/mbedtls/md4.h
	include/mbedtls/md5.h
	include/mbedtls/md_internal.h
	include/mbedtls/memory_buffer_alloc.h
	include/mbedtls/net.h
	include/mbedtls/net_sockets.h
	include/mbedtls/nist_kw.h
	include/mbedtls/oid.h
	include/mbedtls/padlock.h
	include/mbedtls/pem.h
	include/mbedtls/pk.h
	include/mbedtls/pk_internal.h
	include/mbedtls/pkcs11.h
	include/mbedtls/pkcs12.h
	include/mbedtls/pkcs5.h
	include/mbedtls/platform.h
	include/mbedtls/platform_time.h
	include/mbedtls/platform_util.h
	include/mbedtls/poly1305.h
	include/mbedtls/ripemd160.h
	include/mbedtls/rsa.h
	include/mbedtls/rsa_internal.h
	include/mbedtls/sha1.h
	include/mbedtls/sha256.h
	include/mbedtls/sha512.h
	include/mbedtls/ssl.h
	include/mbedtls/ssl_cache.h
	include/mbedtls/ssl_ciphersuites.h
	include/mbedtls/ssl_cookie.h
	include/mbedtls/ssl_internal.h
	include/mbedtls/ssl_ticket.h
	include/mbedtls/threading.h
	include/mbedtls/timing.h
	include/mbedtls/version.h
	include/mbedtls/x509.h
	include/mbedtls/x509_crl.h
	include/mbedtls/x509_crt.h
	include/mbedtls/x509_csr.h
	include/mbedtls/xtea.h
	library/CMakeLists.txt
	library/aes.c
	library/aesni.c
	library/arc4.c
	library/aria.c
	library/asn1parse.c
	library/asn1write.c
	library/base64.c
	library/bignum.c
	library/blowfish.c
	library/camellia.c
	library/ccm.c
	library/certs.c
	library/chacha20.c
	library/chachapoly.c
	library/cipher.c
	library/cipher_wrap.c
	library/cmac.c
	library/ctr_drbg.c
	library/debug.c
	library/des.c
	library/dhm.c
	library/ecdh.c
	library/ecdsa.c
	library/ecjpake.c
	library/ecp.c
	library/ecp_curves.c
	library/entropy.c
	library/entropy_poll.c
	library/error.c
	library/gcm.c
	library/havege.c
	library/hkdf.c
	library/hmac_drbg.c
	library/md.c
	library/md2.c
	library/md4.c
	library/md5.c
	library/md_wrap.c
	library/memory_buffer_alloc.c
	library/net_sockets.c
	library/nist_kw.c
	library/oid.c
	library/padlock.c
	library/pem.c
	library/pk.c
	library/pk_wrap.c
	library/pkcs11.c
	library/pkcs12.c
	library/pkcs5.c
	library/pkparse.c
	library/pkwrite.c
	library/platform.c
	library/platform_util.c
	library/poly1305.c
	library/ripemd160.c
	library/rsa.c
	library/rsa_internal.c
	library/sha1.c
	library/sha256.c
	library/sha512.c
	library/ssl_cache.c
	library/ssl_ciphersuites.c
	library/ssl_cli.c
	library/ssl_cookie.c
	library/ssl_srv.c
	library/ssl_ticket.c
	library/ssl_tls.c
	library/threading.c
	library/timing.c
	library/version.c
	library/version_features.c
	library/x509.c
	library/x509_create.c
	library/x509_crl.c
	library/x509_crt.c
Aborting
lorenzofiamingo@MacBook-Pro-di-Lorenzo mbedtls % 

At this point I tried to manually add mbedtls from this branch. The project build worked fine, but when I tried to flash the ESP32 this error came out:

Minimum OpenOCD version v0.10.0-esp32-20201125 is required...

So I tried to replace manully the OpenOCD version to the last one, but other errors came out.
I also tried to change tools.json urls, but this is not working either.
I really don't know how to proceed at this point

Controlling Multiple pins from single accessory

I want to control multiple pins (3 GPIO and 3 PWM) from iphone Home App.
I have successfully controlled one pin from method but i dont know how to control multiple pins.
pls help me with this issue,

LightBulb example does not work reliably

I'm having problems getting the LightBulb example to work reliably. I can pair it to my iPhone, and then I can control it, but then it will eventually stop working. (When I tap the light bulb icon in the home app, the little whirling thing appears in the corner, and eventually it turns into an exclamation point and say "no response" at the bottom of the icon.) Then, after waiting a few minutes, it will start working again. I'm just using the LightBulb app with no changes.

Update apple ADK version

Hi. I noticed that the version of Apple HomeKit you are using is pretty old right now. Any plans on updating to never versions?

LightDemo can't be discoverd by iphone

follow the guide to build, but some error happen, i don't known why.
1970-01-01'T'00:00:00'Z' Default [com.apple.mfi.HomeKit.Platform:KeyValueStore] Error (4354). Key 20 not found in KeyStore
1970-01-01'T'00:00:00'Z' Default [com.apple.mfi.HomeKit.Platform:KeyValueStore] Error (4354). Key 21 not found in KeyStore


1970-01-01'T'00:00:00'Z' Default [com.apple.mfi.HomeKit.Platform:KeyValueStore] Error (4354). Key 20 not found in KeyStore
1970-01-01'T'00:00:00'Z' Default [com.apple.mfi.HomeKit.Platform:KeyValueStore] Error (4354). Key 21 not found in KeyStore

I (1019) phy: phy_version: 4500, 0cd6843, Sep 17 2020, 15:37:07, 0, 0
I (1019) wifi:mode : sta (10:52:1c:68:98:08)
I (1019) wifi:enable tsf
I (1019) wifi station: wifi_init_sta finished.
I (1149) wifi:new:<1,0>, old:<1,0>, ap:<255,255>, sta:<1,0>, prof:1
I (1149) wifi:state: init -> auth (b0)
I (1149) wifi:state: auth -> assoc (0)
I (1159) wifi:state: assoc -> run (10)
I (1159) wifi:connected with Tencent-GuestWiFi, aid = 62, channel 1, BW20, bssid = 00:2a:10:09:bb:b3
I (1159) wifi:security: Open Auth, phy: bgn, rssi: -67
I (1169) wifi:pm start, type: 1

W (1179) wifi:idx:0 (ifx:0, 00:2a:10:09:bb:b3), tid:0, ssn:3206, winSize:64
I (1299) wifi:AP's beacon interval = 104448 us, DTIM period = 1
I (1789) esp_netif_handlers: sta ip: 10.35.192.76, mask: 255.255.255.0, gw: 10.35.192.1
I (1789) wifi station: got ip:10.35.192.76
I (1789) wifi station: connected to ap SSID:Tencent-GuestWiFi password:
1970-01-01'T'00:00:01'Z' Default [com.apple.mfi.HomeKit.Core:AccessoryServer] Version information:
libhap: Unknown

  • Version: Internal (Oct 30 2020 20:02:24) - compatibility version 7
    Using platform: ESP32
  • Version: v4.3-dev-1561-g357a27760-dirty (Oct 30 2020 20:02:32) - compatibility version 7
  • Available features:
    • Key-Value store
    • Accessory setup manager
    • Service discovery
      1970-01-01'T'00:00:01'Z' Default [com.apple.mfi.HomeKit.Platform:KeyValueStore] Error (4354). Key 00 not found in KeyStore
      1970-01-01'T'00:00:01'Z' Default [com.apple.mfi.HomeKit.Platform:Clock] Using 'gettimeofday'.

New MbedTLS issue

I have been compiling fine for the past month or two but, having taken a break for a couple of weeks, I have just returned to find that nothing will compile any more. I can only imagine that maybe some update has broken something. I'm unable to even compile the vanilla Lightbulb example.

I receive the following error when attempting to compile: -

/Users/nicksaintjohn/esp/esp-apple-homekit-adk/homekit_adk/PAL/Crypto/MbedTLS/HAPMbedTLS.c:119:19: error: implicit declaration of function 'mbedtls_ecp_read_key'; did you mean 'mbedtls_ecp_gen_key'? [-Werror=implicit-function-declaration]
         int ret = mbedtls_ecp_read_key(MBEDTLS_ECP_DP_CURVE25519, &our_key, n, X25519_SCALAR_BYTES);
                   ^~~~~~~~~~~~~~~~~~~~
/Users/nicksaintjohn/esp/esp-apple-homekit-adk/homekit_adk/PAL/Crypto/MbedTLS/HAPMbedTLS.c:107:9: note: in definition of macro 'WITH'
         X; \
         ^
/Users/nicksaintjohn/esp/esp-apple-homekit-adk/homekit_adk/PAL/Crypto/MbedTLS/HAPMbedTLS.c:118:5: note: in expansion of macro 'WITH_ECP_KEYPAIR'
     WITH_ECP_KEYPAIR(our_key, {
     ^~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
[974/1025] Building C object esp-idf/port/CMakeFiles/__idf_port.dir/Users/nicksaintjohn/esp/esp-apple-homekit-adk/homekit_adk/HAP/HAPAccessoryValidation.c.obj

I've tried updating and switching to various versions of esp-idf, sometimes yielding different (now fixed) build errors, but when using the latest build (currently on esp-idf v4.2, esptool.py v3.0) I always get stuck at this same error.

I noticed something similar was reported a few months back (#3), but I'm presumably using a much later build, and therefor this should already be fixed!?

Any help or pointers would be greatly appreciated. I'm on MacOS 11.1 (Big Sur)

Change device state manually

Hi there,

Recently, I used Lightbulb example in one of my projects on ESP32 and everything is working, as expected, perfectly.

The problem we came up with was changing the state of the light manually, using a switch or something else but we haven't done it yet!

Actually we changed accessoryConfiguration.state.lightBulbOn to what value we want but it doesn't broadcast and update the status of the light in the app on my iPhone.

I believe that there must be a way (such as an API) to change device state and let other devices (including my iPhone) know of change, but we don't know how!

If someone have had the same need and experience, I'll be so appreciated to share.

Best regards.

use esp32s3 report error Pair Verify M3: Pairing not found.

I use esp32-s3 to run this example, but pairing is failed, the homekit on iphone report it can not add this accessory

and in the idf.py monitor, some error printed:

I (713) wifi_init: WiFi RX IRAM OP enabled
1970-01-01'T'00:00:00'Z'	Default	[com.apple.mfi.HomeKit.Platform:KeyValueStore] Error (4354). Key 20 not found in KeyStore
1970-01-01'T'00:00:00'Z'	Default	[com.apple.mfi.HomeKit.Platform:KeyValueStore] Error (4354). Key 21 not found in KeyStore
I (743) phy_init: phy_version 601,98f2a71,Jun 29 2023,09:58:12
I (783) wifi:mode : sta (68:b6:b3:3f:36:14)
I (783) wifi:enable tsf
I (783) wifi station: wifi_init_sta finished.
1970-01-01'T'00:00:00'Z'	Default	[com.apple.mfi.HomeKit.Core:AccessoryServer] Version information:
I (793) wifi:new:<11,0>, old:<1,0>, ap:<255,255>, sta:<11,0>, prof:1
libhap: Unknown
I (803) wifi:state: init -> auth (b0)
  - Version: Internal (Jul 28 2023 22:08:25) - compatibility version 7
I (803) wifi:state: auth -> assoc (0)
Using platform: ESP32
  - Version: v5.2-dev-1650-g36908cc5fd-dirty (Jul 28 2023 22:08:23) - compatibility version 7
I (823) wifi:state: assoc -> run (10)
  - Available features:
W (823) wifi:[ADDBA]rx delba, code:39, delete tid:0
    - Key-Value store
    - Accessory setup manager
    - Service discovery
I (843) wifi:connected with Haskell, aid = 26, channel 11, BW20, bssid = 48:81:d4:d6:22:fe
I (853) wifi:security: WPA2-PSK, phy: bgn, rssi: -69
1970-01-01'T'00:00:00'Z'	Default	[com.apple.mfi.HomeKit.Platform:KeyValueStore] Error (4354). Key 00 not found in KeyStore
I (853) wifi:pm start, type: 1

I (873) wifi:set rx beacon pti, rx_bcn_pti: 0, bcn_timeout: 25000, mt_pti: 0, mt_time: 10000
I (903) wifi:<ba-add>idx:0 (ifx:0, 48:81:d4:d6:22:fe), tid:0, ssn:75, winSize:64
1970-01-01'T'00:00:00'Z'	Default	[com.apple.mfi.HomeKit.Platform:Clock] Using 'clock_gettime' with 'CLOCK_MONOTONIC'.
I (1033) wifi:AP's beacon interval = 102400 us, DTIM period = 1
I (1873) esp_netif_handlers: sta ip: 192.168.0.123, mask: 255.255.255.0, gw: 192.168.0.1
I (1873) wifi station: got ip:192.168.0.123
I (47013) wifi:<ba-add>idx:1 (ifx:0, 48:81:d4:d6:22:fe), tid:4, ssn:1, winSize:64
1970-01-01'T'00:01:12'Z'	Default	[com.apple.mfi.HomeKit.Platform:KeyValueStore] Error (4354). Key 22 not found in KeyStore
1970-01-01'T'00:01:31'Z'	Default	[com.apple.mfi.HomeKit.Core:PairingPairVerify] Pair Verify M3: Pairing not found.
1970-01-01'T'00:01:32'Z'	Default	[com.apple.mfi.HomeKit.Core:PairingPairVerify] Pair Verify M3: Pairing not found.
1970-01-01'T'00:01:32'Z'	Default	[com.apple.mfi.HomeKit.Core:PairingPairVerify] Pair Verify M3: Pairing not found.

Abort() while HAPAccessoryServerStop

Hello!

In some cases, stopping the accessory server can be helpful.
For example, if you have Bridge.
To update the list of devices working through the bridge, Apple recommends using the HAPAccessoryServerStop function and then restarting through the HAPAccessoryServerStartBridge.

Unfortunately, in this fork, when trying to stop the server, the following error occurs:

After invoke HAPAccessoryServerStop(BridgeAccessoryConfiguration.server) inside scheduled callback

Fault	assertion failed - HAPPlatformLogPOSIXError @ ../esp-apple-homekit-adk/port/src/HAPPlatformLog.c:65
abort() was called at PC 0x400d673f on core 0
0x400d673f: _exit at ../esp-idf/components/newlib/syscalls.c:67

0x40090188: invoke_abort at ../esp-idf/components/esp32/panic.c:159
0x40090539: abort at ../esp-idf/components/esp32/panic.c:174
0x400d673f: _exit at ../esp-idf/components/newlib/syscalls.c:67
0x401d452a: exit at /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32-elf/src/newlib/newlib/libc/stdlib/exit.c:64
0x4010e049: HAPPlatformAbort at ../esp-apple-homekit-adk/port/src/HAPPlatformAbort.c:27
0x40100454: HAPAssertInternal at ../esp-apple-homekit-adk/homekit_adk/PAL/HAPAssert.c:20
0x4010e286: HAPPlatformLogPOSIXError at ../esp-apple-homekit-adk/port/src/HAPPlatformLog.c:65 (discriminator 2)
0x400ffde5: HAPPlatformTCPStreamManagerCloseListener at ../esp-apple-homekit-adk/port/src/HAPPlatformTCPStreamManager.c:332
0x40106f5c: schedule_max_idle_time_timer at ../esp-apple-homekit-adk/homekit_adk/HAP/HAPIPAccessoryServer.c:389
0x40108e0a: handle_server_state_transition_timer at ../esp-apple-homekit-adk/homekit_adk/HAP/HAPIPAccessoryServer.c:3874
0x400ff601: ProcessExpiredTimers at ../esp-apple-homekit-adk/port/src/HAPPlatformRunLoop.c:381
 (inlined by) HAPPlatformRunLoopRun at ../esp-apple-homekit-adk/port/src/HAPPlatformRunLoop.c:638
0x40084d20: HomeKit::Task(void*) at /src/HomeKit/HomeKit.cpp:271

Error occurs here:

    HAPLogDebug(&logObject, "shutdown(%d, SHUT_RDWR);", tcpStreamManager->tcpStreamListener.fileDescriptor);
    e = shutdown(tcpStreamManager->tcpStreamListener.fileDescriptor, SHUT_RDWR);
    if (e != 0) {
        int _errno = errno;
        HAPAssert(e == -1);
        HAPPlatformLogPOSIXError(
                kHAPLogType_Debug,
                "System call 'shutdown' on TCP stream listener socket failed.",
                _errno,
                __func__,
                HAP_FILE,
                __LINE__);
    }

If commented this lines - everything is ok except of memory leaks and i think it is not a good behaviour.

Could you please inspect this issue?

Set up MbedTLS

i have issue with setting up MbedTLS. I get this message:
C:\ESP\esp-idf\components\mbedtls>git checkout -b mbedtls-2.16.6-adk origin/mbedtls-2.16.6-adk
fatal: 'origin/mbedtls-2.16.6-adk' is not a commit and a branch 'mbedtls-2.16.6-adk' cannot be created from it

How to serve multiple accessories?

In the Lightbulb example only covers one accessory.

I have a single ESP32 that controls 8 GPIO pins that I want to operate as independent accessories.

Would this be possible?

error while compiling LightBulb Example

[101/101] Generating binary image from built executable
esptool.py v3.0
Generated C:/esp/esp-idf/esp-apple-homekit-adk/examples/Lightbulb/build/bootloader/bootloader.bin
[996/1026] Building C object esp-idf/port/CMakeFiles/idf_port.dir//homekit_adk/PAL/Crypto/MbedTLS/HAPMbedTLS.c.obj
FAILED: esp-idf/port/CMakeFiles/idf_port.dir//homekit_adk/PAL/Crypto/MbedTLS/HAPMbedTLS.c.obj
ccache C:\esp\tools.espressif\tools\xtensa-esp32-elf\esp-2020r3-8.4.0\xtensa-esp32-elf\bin\xtensa-esp32-elf-gcc.exe -DHAP_LOG_LEVEL=1 -DMBEDTLS_CONFIG_FILE="mbedtls/esp_config.h" -Iconfig -I../../../port/include -I../../../homekit_adk/HAP -I../../../homekit_adk/PAL -I../../../homekit_adk/External/Base64 -I../../../homekit_adk/External/JSON -I../../../homekit_adk/External/HTTP -I../../../../components/newlib/platform_include -I../../../../components/freertos/include -I../../../../components/freertos/xtensa/include -I../../../../components/heap/include -I../../../../components/log/include -I../../../../components/lwip/include/apps -I../../../../components/lwip/include/apps/sntp -I../../../../components/lwip/lwip/src/include -I../../../../components/lwip/port/esp32/include -I../../../../components/lwip/port/esp32/include/arch -I../../../../components/soc/src/esp32/. -I../../../../components/soc/src/esp32/include -I../../../../components/soc/include -I../../../../components/esp_rom/include -I../../../../components/esp_common/include -I../../../../components/esp_system/include -I../../../../components/xtensa/include -I../../../../components/xtensa/esp32/include -I../../../../components/esp32/include -I../../../../components/driver/include -I../../../../components/driver/esp32/include -I../../../../components/esp_ringbuf/include -I../../../../components/efuse/include -I../../../../components/efuse/esp32/include -I../../../../components/espcoredump/include -I../../../../components/esp_timer/include -I../../../../components/esp_ipc/include -I../../../../components/soc/soc/esp32/include -I../../../../components/soc/soc/esp32/../include -I../../../../components/soc/soc/esp32/private_include -I../../../../components/vfs/include -I../../../../components/esp_wifi/include -I../../../../components/esp_wifi/esp32/include -I../../../../components/esp_event/include -I../../../../components/esp_netif/include -I../../../../components/esp_eth/include -I../../../../components/tcpip_adapter/include -I../../../../components/app_trace/include -I../../../../components/nvs_flash/include -I../../../../components/spi_flash/include -I../../../../components/mbedtls/port/include -I../../../../components/mbedtls/mbedtls/include -I../../../../components/mbedtls/esp_crt_bundle/include -I../../../../components/mdns/include -I../../../../components/console -mlongcalls -Wno-frame-address -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -Wall -Werror=all -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wextra -Wno-unused-parameter -Wno-sign-compare -ggdb -Og -std=gnu99 -Wno-old-style-declaration -D_GNU_SOURCE -DIDF_VER="v4.2" -DESP_PLATFORM -MD -MT esp-idf/port/CMakeFiles/idf_port.dir//homekit_adk/PAL/Crypto/MbedTLS/HAPMbedTLS.c.obj -MF esp-idf\port\CMakeFiles_idf_port.dir_\homekit_adk\PAL\Crypto\MbedTLS\HAPMbedTLS.c.obj.d -o esp-idf/port/CMakeFiles/idf_port.dir//homekit_adk/PAL/Crypto/MbedTLS/HAPMbedTLS.c.obj -c C:/esp/esp-idf/esp-apple-homekit-adk/homekit_adk/PAL/Crypto/MbedTLS/HAPMbedTLS.c
C:/esp/esp-idf/esp-apple-homekit-adk/homekit_adk/PAL/Crypto/MbedTLS/HAPMbedTLS.c: In function 'HAP_X25519_scalarmult':
C:/esp/esp-idf/esp-apple-homekit-adk/homekit_adk/PAL/Crypto/MbedTLS/HAPMbedTLS.c:119:19: error: implicit declaration of function 'mbedtls_ecp_read_key'; did you mean 'mbedtls_ecp_gen_key'? [-Werror=implicit-function-declaration]
int ret = mbedtls_ecp_read_key(MBEDTLS_ECP_DP_CURVE25519, &our_key, n, X25519_SCALAR_BYTES);
^~~~~~~~~~~~~~~~~~~~
C:/esp/esp-idf/esp-apple-homekit-adk/homekit_adk/PAL/Crypto/MbedTLS/HAPMbedTLS.c:107:9: note: in definition of macro 'WITH'
X;
^
C:/esp/esp-idf/esp-apple-homekit-adk/homekit_adk/PAL/Crypto/MbedTLS/HAPMbedTLS.c:118:5: note: in expansion of macro 'WITH_ECP_KEYPAIR'
WITH_ECP_KEYPAIR(our_key, {
^~~~~~~~~~~~~~~~
cc1.exe: some warnings being treated as errors
[1001/1026] Building C object esp-idf/port/CMakeFiles/idf_port.dir//homekit_adk/HAP/HAPIPAccessoryServer.c.obj
ninja: build stopped: subcommand failed.
ninja failed with exit code 1

Not lighting up even though successful execution

Hi, I am new to this. I have followed the instructions thoroughly and managed to proceed without any issue, except that the light is not lighting up when I switch it on homekit. I tried finding the file to check the output(which I assumed it's the inbuilt LED) but to no avail. Please advise. Thanks

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.