Giter Site home page Giter Site logo

esp-homekit-sdk's Introduction

ESP HomeKit SDK

Introduction

HomeKit is a framework developed by Apple for communicating with and controlling connected accessories in a user’s home using iOS devices. ESP HomeKit SDK has been developed in-house by Espressif to build Apple HomeKit compatible accessories using ESP32/ESP32-S2/ESP32-C3/ESP8266 SoCs.

Note: If you want to use HomeKit for commercial products, please check here for access to the MFi variant of this SDK. It has the exact same APIs as this and so, moving to it should be easy. However, commercial HomeKit products can be built only with ESP32/ESP32-S2/ESP32-C3 since ESP8266 cannot meet all the HomeKit Certification requirements.

If you want to use a port of Apple's ADK instead, please check here

Features of this SDK:

  • Easy APIs to implement all standard HomeKit profiles defined by Apple.
  • Facility to add customised accessory specific Services and Characteristics.
  • Samples (Fan, Lightbulb, Outlet, Bridge, Data-TLV8, Ethernet) to enable quick accessory development.
  • Support for ESP Unified Provisioning.

Get Started

Set up Host environment

Set up the host environment and ESP IDF (master branch) as per the steps given here.

If you are using ESP8266, set-up ESP8266-RTOS-SDK (master branch) as per the steps given here.

Get esp-homekit-sdk

Please clone this repository using the below command:

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

Note the --recursive option. This is required to pull in the JSON dependencies into esp-homekit-sdk. In case you have already cloned the repository without this option, execute this to pull in the submodules: git submodule update --init --recursive

If you had already cloned the repository and submodules earlier, you may have to execute git submodule sync --recursive once since the submodule paths have changed.

Compile and Flash

You can use esp-homekit-sdk with any ESP32, ESP32-S2, ESP32-C3 or ESP8266 board (though we have tested only with the ESP32-DevKit-C, ESP32-S2-Saola-1, ESP32-C3-DevKit-M-1, ESP8266-DevKit-C). We have provided multiple examples for reference. Compile and flash as below (fan used as example):

For ESP32/ESP32-S2/ESP32-C3

$ cd /path/to/esp-homekit-sdk/examples/fan
$ export ESPPORT=/dev/tty.SLAB_USBtoUART #Set your board's serial port here
$ idf.py set-target <esp32/esp32s2/esp32c3>
$ idf.py flash monitor

For ESP8266

$ cd /path/to/esp-homekit-sdk/examples/fan
$ export ESPPORT=/dev/tty.SLAB_USBtoUART #Set your board's serial port here
$ make defconfig
$ make flash monitor

As the device boots up, you will see two QR codes, a small one for HomeKit and a larger one for Wi-Fi provisioning. Please use any of the Espressif Provisioning Apps for Wi-Fi provisioning.

Note: For the Open source HomeKit SDK, the HomeKit QR code cannot be used for provisioning from the Home app. It can be used only for pairing, after the Wi-Fi provisioning is done. For provisioning from Home app, you will need the MFi variant of the SDK.

Note: If you want to use hard-coded credentials instead of Provisioning, please set the ssid and passphrase by navigating to idf.py menuconfig -> App Wi-Fi -> Source of Wi-Fi Credentials -> Use Hardcoded

After the device connects to your Home Wi-Fi network it can be added in the Home app

Add acccessory in the Home app

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

  • Tap on "Add Accessory" and scan the small QR code mentioned above.
  • If QR code is not visible correctly, you may use the link printed on the serial terminal or follow these steps:
    • Choose the "I Don't Have a Code or Cannot Scan" option.
    • Tap on "Esp-Fan-xxxxxx" 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 "Esp-Fan-xxxxxx added" message.
  • Give a custom name, assign to a room, create scenes as required and you are done.

For ESP8266, the pairing may take a bit longer.

Changing the Setup Code

The HomeKit setup code can be changed by using the CONFIG_EXAMPLE_SETUP_CODE config option (idf.py menuconfig -> Example Configuration -> HomeKit Setup Code). Please also refer the HomeKit Setup Configuration below.

Using Standard Apple HomeKit Profiles

The examples provided in the SDK are for fan, outlet, lightbulb. For using any other standard profiles, please refer the files under components/homekit/hap_apple_profiles/.

Adding Custom Profiles

Please refer the Firmware Upgrades Custom Profile (components/homekit/extras/) to see how to add your own profile. You can use some UUID generator like this to generate your own UUIDs for the services and characteristics.

HomeKit Setup Configuration

As per the HomeKit requirements, the raw setup code should not be stored on the accessory. Instead, the SRP Salt and Verifier generated from the code should be stored. This salt-verifier combination, called as setup info in the ESP HomeKit SDK, needs to be unique for every accessory. This can be provided to the HAP Core using the hap_set_setup_info() API. Another parameter required for setup is the setup id, which also needs to be unique. It is provided to the HAP Core using hap_set_setup_id() API.

In order to ease the task of providing unique setup info and setup id for each accessory, instead of using the above APIs, the same information can be stored in a separate flash partition called factory_nvs (Please see the partitions_hap.csv file in any example). This allows to keep the same firmware image and just flash different factory_nvs images for different accessories. The factory_nvs image fan_factory.bin has been provided for Fan, which can be flashed using esptool. Custom images can be created using the factory_nvs_gen utility in tools/ as below

Usage:

./factory_nvs_gen.py 11122333 ES32 factory

Replace ES32 and 11122333 with the setup code and setup id of your choice. This has been tested with Python 3.7.3.

Flash this using the esptool as below.

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

To use the setup info from this image, you will have to disable the hardcoded setup code by setting CONFIG_EXAMPLE_SETUP_CODE=n (idf.py menuconfig -> Example Configuration -> Use hard-coded setup code -> disable).

The factory_nvs partition can also hold other information like serial numbers, cloud credentials, firmware verification keys, etc. For that, just create a CSV file as per the requirements of NVS Partition Generator Utility and provide it to the factory_nvs_gen using the --infile option. These variables (if stored as binary data) can then be read in the accessory code using hap_factory_keystore_get() API.

Sample CSV (say sample.csv)

key,type,encoding,value
app,namespace,,
serial_num,data,binary,12345

Usage:

./factory_nvs_gen.py --infile sample.csv 11122333 ES32 factory

Flash this using the same command given above.

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

Additional MFi requirements

If you have access to the MFi variant of esp-homekit-sdk, please check additional information here.

Reporting issues

You can report issues directly on Github issues.

esp-homekit-sdk's People

Contributors

cosmo avatar jimmyasyraf avatar lhespress avatar lukehoersten avatar macwyznawca avatar ryankurte avatar sanketwadekar avatar shahpiyushv avatar shubhamdp avatar vikramdattu 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-homekit-sdk's Issues

Revisit: Decryption error/Connection lost on ESP32 with multiple Apple devices running Home

I am the author of Mixiaoxiao/Arduino-HomeKit-ESP8266.

This official HomeKit sdk I am using currently to build my newer projects, and I have made an Arduino library version of this sdk.

But I also got the issue same as #14.

Named "Decryption error/Connection lost on ESP32 with multiple Apple devices running Home".

My issue is as follows:

  1. Both my iPhone and iPad (as a HomeKit hub) connected to ESP, both response ok
  2. My iPhone goes screen off (its WiFi will go sleep too)
  3. log show: Decryption error/Connection lost. Marking session as invalid
  4. then log show: two lines of HomeKit Session terminated (that is, both my iPhone and iPad connections are closed)
  5. My iPad shows “No response”

The problem is that, when my iPhone is disconnected (or just WiFi is not active), my iPad's(same iCloud ID with iPhone) connection will be closed too.
This behavior is NOT as expected.
Same as Brawrdon's comment: #14 (comment)

I figure out the related codes as follows:

  1. int hap_decrypt_data(...)
...
if (read_fn(frame->data, 2, context) < 2)	
	return hap_decrypt_error(session);
...
  1. hap_decrypt_error(hap_secure_session_t *session)
int hap_decrypt_error(hap_secure_session_t *session)
{
	ESP_MFI_DEBUG(ESP_MFI_DEBUG_INFO, "Decryption error/Connection lost. Marking session as invalid");
	if (session) {
		session->state = STATE_INVALID;
        	hap_close_ctrl_sessions(session->ctrl);
	}
	return HAP_FAIL;
}
  1. void hap_close_ctrl_sessions(hap_ctrl_data_t *ctrl)
	for (i = 0; i < HAP_MAX_SESSIONS; i++) {
        	if (!hap_priv.sessions[i])
              		continue;
		if (hap_priv.sessions[i]->ctrl == ctrl) {
			httpd_sess_trigger_close(hap_priv.server, hap_priv.sessions[i]->conn_identifier);
		}
	}

Consider that, in int hap_decrypt_data(...)

int len = read_fn(frame->data, 2, context); 

read_fn here indeed calls the hap_httpd_raw_recv, that is the recv (lwip_recv), try receiving data from tcp connection.
if len is -1, means the tcp-socket is closed;
if len is 0, means nothing received, that is reading is timeout or the peer's WiFi is not active (in sleep mode) now;
if len is 1, means we only received 1 byte during a receiving-timeout time (SO_RCVTIMEO=0x1006=4102, in seconds, maybe?), here we can do consider that we really got the Decryption error/Connection lost. According to the protocol of HomeKit, here, at least 2 bytes should be received.

So, here, should be modified to

		int len = read_fn(frame->data, 2, context);
		if (len == 0) { //nothing received, but I think we should NOT consider this is a 'decrypt_error'
			return 0;
		}
		if (len < 2) {
			//len is -1 or 1
			//len = -1: socket disconnected
			//len =  1: try receiving 2 bytes timeout (SO_RCVTIMEO is set in esp_hap_ip_services.c)
			return hap_decrypt_error(session);
		}

Then, in hap_close_ctrl_sessions, all sessions with same ctrl (session->ctrl) will be closed.
In my debug, both my iPhone and iPad are of same ctrl.
All iOS devices with same iCloud ID will have a same ctrl. I am not sure, but it should be.
Here, the problem come out.
Only one device disconnected, but why close all sessions with this ctrl???

So, here, should be modified to

//only close the disconnected session
void hap_close_ctrl_sessions_fix(hap_secure_session_t *session)
{
	if (!session)
		return;
	int i;
	for (i = 0; i < HAP_MAX_SESSIONS; i++) {
       		if (!hap_priv.sessions[i])
            		continue;
		if (hap_priv.sessions[i] == session) {
            		hap_report_event(HAP_EVENT_CTRL_DISCONNECTED, (session->ctrl->info.id),
                    		sizeof((session->ctrl->info.id)));
            		httpd_sess_trigger_close(hap_priv.server, hap_priv.sessions[i]->conn_identifier);
		}
	}
}

Another thing is that, in WiFi connection with other devices, it is really difficult to exactly-know the connection is lost or not.
The peer's WiFi can be in sleep mode(but the connection in lwip can NOT know that), and it' WiFi will response nothing (lwip will always receive 0 byte).
So I think the keepalive of tcp is a good method to do this.
When the peer's WiFi is in sleep mode for a long time, the lwip can know that and just drop it.
This behavior is really meaningful for ESP8266 with small memory(ram), it can quickly release the tcp buffer memory when the peer is no longer active.
And the keepalive option has been implemented both in maximkulkin/esp-homekit/server.c#L3705 and my Mixiaoxiao/Arduino-HomeKit-ESP8266/arduino_homekit_server.cpp#L3006.

I do know the keepalive is not allowed in HomeKit Protocol.
HAP Non-Commercial Version section 6.2.3: "HAP accessory servers must not use keepalive messages, which periodically wake up iOS devices".
But I do consider it is ok to make a config to enable keepalive for hobby projects.

I have just create a bugfix-commit including all above-mentioned modifications for my Arduino-HomeKit-ESP.
Tested for 24 hours and works fine.

Setup ID absent

When following the "HomeKit Setup Configuration", using ./factory_nvs_gen.py and esptool.py, I have an error, when the esp8266 finished reset :
Screen Shot 2021-06-04 at 2 51 44 PM
Am I doing something wrong ?

Invalid value outside constraints appear causes complete accessory failure

IDF Version: v4.2-beta1-227-gf0e87c933
HomeKit Version: current (checked out this week from git from master)

I've built a few homekit devices over the last month and had great success. The SDK is one of the easier ones to work with that I have used. So, in creating another device, I ran into an issue where the accessory would refuse to pair IF I added an ambient light sensor. Additional, if I removed the light sensor and got it to pair, enabling the light sensor against with the now pair accessory would cause the entire sensor would be reported as unresponsive in the home app. It took some effort, but I tracked the issue down to the initial value I set on the light sensor being outside the default expected range defined in esp_hap_apple_profiles/src/hap_apple_chars.c. Not sure this is an issue or it is it working as designed, but setting the value outside the expected range causes the entire accessory to be rendered useless. The problem is my light sensor will read 0 when there is no light...and I really don't want it to display 1 or 0.001. Additionally, I would expect that if the value is outside the correct range, it would continued to work or the SDK would possibly reset the value to the minimum value in this case. For testing purposes, I set the initial value to 0 which causes the pairing error. If I set the initial value to 1.0, it worked.

Not sure if this bug in the ESP Homekit SDK or this is the way the Apple Homekit works when the value is outside the range and the accessory won't work.

The quick fix to the issue was either to set the value to a number inside the range or change esp_hap_apple_profiles/src/hap_apple_chars.c to allow a different range.

The code in esp_hap_apple_profiles/src/hap_apple_chars.c around line 502 has:

 hap_char_float_set_constraints(hc, 0.0001, 100000.0, 0.0);

If I changed line to:

 hap_char_float_set_constraints(hc, 0.0, 100000.0, 0.0);

...the sensor worked correctly when I initialized it to 0.

Questions:

  • if an accessory tries to set a value outside the specified range, should it become unresponsive in the home app?
  • should the value for the light sensor be set 0.0 for a minimum? Or am I expected to make sure the value is within the range?

Reviewing the other issues, it appears similar to #4.

I attached a log of the failed pairing if that is any help.

error_ls.log

Controlling multiple devices with one esp32

Hello Developers,
I have successfully implemented controlling of single light bulb from Accessory button in Home App.
Now I want to add more things like PWM generation on 3 channels and 3 more GPIO to control from different buttons on APP.
Is there any example similar to my requirement. ?

export ESPPORT=/dev/tty.SLAB_USBtoUART doesn't work, SOLUTION below

Hello, in my opinion it is better to use the commands you find below for ESP32
Following the commands given was not working, especially this command was problematic
export ESPPORT=/dev/tty.SLAB_USBtoUART
I was specifying my port name there in several ways but it did not work with my board Wemos D1 R32.

So please use the following commands.
First connect the ESP32 board and use dmesg command to see the USB port name that is assigned to

dmesg
. $HOME/esp/esp-idf/export.sh
cd /home/pi/esp/esp-homekit-sdk/examples/fan                       //put your project folder here
idf.py set-target esp32
idf.py menuconfig                                              //optional
idf.py -p /dev/ttyUSB0 flash
idf.py -p /dev/ttyUSB0 monitor

In this way it works great form me.
I hope it helps someone.

Commercial use

Hi,

I have a question about commercial use. Would the following cases be treated as a commercial use?

  1. Video course for developers/makers that includes building a project based on SDK. Then selling this course.
  2. Sell a kit for self-assembly, for developers/makers of some kind of device e.g. a smart light

Lightbulb example not pairing on ESP8266

Hello all,

I have tried to flash lightbulb example onto esp-12f variant but pairing with Home app failed with the message Couldn't add Esp-Light. Below is the following serial monitor that showed during the pairing process.

######## Starting Pair Setup ########
Pair Setup M1 Received
Pair Setup M2 Successful
Pair Setup M3 Received
Using pair-setup without MFi.
Pair Setup M4 Successful
Pair Setup M5 Received
Pair Setup Successful for FB660B62-3EF5-4F48-9848-4321FDF7B8D5
Updated state number to 2
Re-announcing _hap._tcp mDNS service
Cleaning Pair Setup Context
Cleaning Pair Setup Context
######## Starting Pair Verify ########
Pair Verify M1 Received
Pair Verify M2 Successful
Pair Verify M3 Received
HomeKit Session active
Pair Verify Successful for FB660B62-3EF5-4F48-9848-4321FDF7B8D5
Decryption error/Connection lost. Marking session as invalid
HomeKit Session terminated
######## Starting Pair Verify ########
Pair Verify M1 Received
Pair Verify M2 Successful

I have got smart outlet example working, it seems like it somehow failed during the decryption error state.

Thank you.

Decryption error/Connection lost on ESP8266

I have reported a problem with "data_tlv8" example. When I try to connect to device i getting connection problem at end of paring process:

######## Starting Pair Setup ########
Pair Setup M1 Received
Pair Setup M2 Successful
Cleaning Pair Setup Context
######## Starting Pair Setup ########
Pair Setup M1 Received
Pair Setup M2 Successful
Cleaning Pair Setup Context
######## Starting Pair Setup ########
Pair Setup M1 Received
Pair Setup M2 Successful
Pair Setup M3 Received
Using pair-setup without MFi.
Pair Setup M4 Successful
Pair Setup M5 Received
Pair Setup Successful for B5D20CBA-70F8-45C9-BF33-F978E31F656C
Updated state number to 2
Re-announcing _hap._tcp mDNS service
Cleaning Pair Setup Context
Cleaning Pair Setup Context
######## Starting Pair Verify ########
Pair Verify M1 Received
Pair Verify M2 Successful
Pair Verify M3 Received
HomeKit Session active
Pair Verify Successful for B5D20CBA-70F8-45C9-BF33-F978E31F656C
I (45327) HAP Sensor: Received Read for Current Temperature
I (45329) HAP Sensor: Current Value: 
I (45330) HAP Sensor: Updated Value: 
Value Changed
Read data: 
aa 0b 0c 0d 
Value Changed
Read tlv8: 
Value Changed
Decryption error/Connection lost. Marking session as invalid
HomeKit Session terminated
######## Starting Pair Verify ########
Pair Verify M1 Received
Pair Verify M2 Successful

Lightbulb example work fine with connection but when i change cfg structure to .cid = HAP_CID_SENSOR, i getting this same error at connection.

I have encounter this error because i try to add humidity and temperature characteristics.
My os is Ubuntu 18.04
and sdk version is: commit f2a010a (HEAD -> master, origin/master, origin/HEAD)
esp8266_rtos_sdk version is: commit 66dd5798803a96a9f2a7d77099bc36d7bef918dc (HEAD -> master, origin/master, origin/HEAD)

Hardcode WiFi not able to change after first setup

Hello,

It seems like after the first set of a particular AP name and password, even if I change to a new AP name and password inside make menuconfig it does not connect to the new AP, instead, I am getting a result of app_wifi: Disconnected. Connecting to the AP again...

I have also tried to include WiFi log info under make menuconfig but it does not seem to print those out in the serial monitor.

Is there any reason for this?

P.s. I am using smart outlet and lightbulb example from the SDK.

Thanks

Decryption error/Connection lost on ESP32 with multiple Apple devices running Home

I'm getting a similar issue as with issue #4 when trying to run the fan example on my ESP32 DevKit v1. It works for about a minute before the accessory becomes unavailable and it returns an error marking the session as invalid. It also doesn't seem to automatically restart (I'm assuming it did in the linked issue because of how their logs looked).

I've tried the recommendation of adding CONFIG_NEWLIB_NANO_FORMAT=n to the sdkconfig.defaults file with no luck.

######## Starting Pair Verify ########
Pair Verify M1 Received
Pair Verify M2 Successful
Socket fd: 53; HTTP Request POST /pair-verify
Pair Verify M3 Received
HomeKit Session active
Pair Verify Successful for 500190B1-CCD4-4373-ADF5-02FAE4650FCF
Socket fd: 53; HTTP Request GET /accessories
Generating HTTP Response
Value Changed
{"accessories":[{"aid":1,"services":[{"iid":1,"type":"3E","characteristics":[{"iid":2,"type":"14","perms":["pw"],"ev":false,"format":"bool"},{"iid":3,"value":"Espressif","type":"20","perms":["pr"],"ev":false,"format":"string"},{"iid":4,"value":"EspFan01","type":"21","perms":["pr"],"ev":false,"format":"string"},{"iid":5,"value":"Esp-Fan-26FB3F","type":"23","perms":["pr"],"ev":false,"format":"string"},{"iid":6,"value":"001122334455","type":"30","perms":["pr"],"ev":false,"format":"string"},{"iid":7,"value":"0.9.0","type":"52","perms":["pr"],"ev":false,"format":"string"},{"iid":10,"value":"RVNQMzJIQVA=","type":"220","perms":["pr"],"ev":false,"format":"data"}]},{"iid":8,"type":"A2","characteristics":[{"iid":9,"value":"1.1.0","type":"37","perms":["pr"],"ev":false,"format":"string"}]},{"iid":11,"type":"40","characteristics":[{"iid":12,"value":false,"type":"25","perms":["pr","pw","ev"],"ev":false,"format":"bool"},{"iid":13,"value":"My Fan","type":"23","perms":["pr"],"ev":false,"format":"string"},{"iid":14,"value":1,"type":"28","perms":["pr","pw","ev"],"ev":false,"format":"int","minValue":0,"maxValue":1,"minStep":1}]},{"iid":15,"type":"d57034d8-3736-11e8-b467-0ed5f89f718b","hidden":true,"characteristics":[{"iid":16,"type":"d57039e2-3736-11e8-b467-0ed5f89f718b","perms":["pw"],"ev":false,"format":"string","description":"FW Upgrade URL"},{"iid":17,"value":0,"type":"d5703b5e-3736-11e8-b467-0ed5f89f718b","perms":["pr","ev"],"ev":false,"format":"int","description":"FW Upgrade Status"}]}]}]}
Notification Sent
Socket fd: 51; Event message: {"characteristics":[{"aid":1,"iid":14,"value":1}]}
Notification Sent
Socket fd: 52; Event message: {"characteristics":[{"aid":1,"iid":14,"value":1}]}
Socket fd: 52; HTTP Request GET /characteristics?id=1.14,1.12
Generating HTTP Response
I (24843) HAP Fan: Received read from 500190B1-CCD4-4373-ADF5-02FAE4650FCF
Value Changed
I (24853) HAP Fan: Received read from 500190B1-CCD4-4373-ADF5-02FAE4650FCF
{"characteristics":[{"aid":1,"iid":14,"value":0},{"aid":1,"iid":12,"value":false}]}
Notification Sent
Socket fd: 51; Event message: {"characteristics":[{"aid":1,"iid":14,"value":0}]}
Decryption error/Connection lost. Marking session as invalid
HomeKit Session terminated

Please add Sprinklers, Faucets, Shower Systems to Category Identifiers

As is available in the Apple HomeKit ADK, and recent versions of the HomeKit specification, please add the Sprinklers, Faucets, and Shower Systems CIDs for accessories of this type.

See: https://github.com/apple/HomeKitADK/blob/4967f698bdcf0af122e13e986a2c9b595a68cdc5/HAP/HAP.h

--- a/components/homekit/esp_hap_core/include/hap.h
+++ b/components/homekit/esp_hap_core/include/hap.h
@@ -222,6 +222,9 @@ typedef enum {
     HAP_CID_AIR_CONDITIONER,
     HAP_CID_HUMIDIFIER,
     HAP_CID_DEHUMIDIFIER,
+    HAP_CID_SPRINKLERS = 28,
+    HAP_CID_FAUCETS = 29,
+    HAP_CID_SHOWERSYSTEMS = 30,
     HAP_CID_MAX,
 } hap_cid_t;

Document concurrency model

I'm looking for more information on the concurrency model of the ESP HomeKit SDK HAP implementation. Does the HAP Core run it's own thread and then the App gets its own thread, etc? Thread safety considerations would be helpful as well.

lightbulb is not Paired

rst:0x1 (POWERON_RESET),boot:0x33 (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:6740
load:0x40078000,len:14240
ho 0 tail 12 room 4
load:0x40080400,len:3500
0x40080400: _init at ??:?

entry 0x4008064c
I (28) boot: ESP-IDF v4.4-dev-1404-gc13afea63 2nd stage bootloader
I (28) boot: compile time 01:13:37
I (28) boot: chip revision: 1
I (32) boot_comm: chip revision: 1, min. bootloader chip revision: 0
I (42) boot.esp32: SPI Speed : 40MHz
I (44) boot.esp32: SPI Mode : DIO
I (49) boot.esp32: SPI Flash Size : 4MB
I (53) boot: Enabling RNG early entropy source...
I (59) boot: Partition Table:
I (62) boot: ## Label Usage Type ST Offset Length
I (69) boot: 0 sec_cert unknown 3f 00 0000d000 00003000
I (77) boot: 1 nvs WiFi data 01 02 00010000 00006000
I (84) boot: 2 otadata OTA data 01 00 00016000 00002000
I (92) boot: 3 phy_init RF data 01 01 00018000 00001000
I (99) boot: 4 ota_0 OTA app 00 10 00020000 00190000
I (107) boot: 5 ota_1 OTA app 00 11 001b0000 00190000
I (114) boot: 6 factory_nvs WiFi data 01 02 00340000 00006000
I (122) boot: 7 nvs_keys NVS keys 01 04 00346000 00001000
I (130) boot: End of partition table
I (134) boot: No factory image, trying OTA 0
I (139) boot_comm: chip revision: 1, min. application chip revision: 0
I (146) esp_image: segment 0: paddr=00020020 vaddr=3f400020 size=428c0h (272576) map
I (253) esp_image: segment 1: paddr=000628e8 vaddr=3ffbdb60 size=0467ch ( 18044) load
I (260) esp_image: segment 2: paddr=00066f6c vaddr=40080000 size=090ach ( 37036) load
I (276) esp_image: segment 3: paddr=00070020 vaddr=400d0020 size=115e80h (1138304) map
I (688) esp_image: segment 4: paddr=00185ea8 vaddr=400890ac size=12d44h ( 77124) load
I (720) esp_image: segment 5: paddr=00198bf4 vaddr=50000000 size=00010h ( 16) load
I (734) boot: Loaded app from partition at offset 0x20000
I (769) boot: Set actual ota_seq=1 in otadata[0]
I (769) boot: Disabling RNG early entropy source...
I (780) cpu_start: Pro cpu up.
I (780) cpu_start: Single core mode
I (791) cpu_start: Pro cpu start user code
I (791) cpu_start: cpu freq: 160000000
I (791) cpu_start: Application information:
I (795) cpu_start: Project name: lightbulb
I (801) cpu_start: App version: c62f64d
I (805) cpu_start: Compile time: Jun 3 2021 01:13:20
I (812) cpu_start: ELF file SHA256: 35da324a148fc259...
I (818) cpu_start: ESP-IDF: v4.4-dev-1404-gc13afea63
I (824) heap_init: Initializing. RAM available for dynamic allocation:
I (831) heap_init: At 3FF80000 len 00002000 (8 KiB): RTCRAM
I (837) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM
I (844) heap_init: At 3FFB6388 len 00001C78 (7 KiB): DRAM
I (850) heap_init: At 3FFB9A20 len 00004108 (16 KiB): DRAM
I (856) heap_init: At 3FFCA8B8 len 00015748 (85 KiB): DRAM
I (862) heap_init: At 3FFE0440 len 0001FBC0 (126 KiB): D/IRAM
I (868) heap_init: At 40078000 len 00008000 (32 KiB): IRAM
I (875) heap_init: At 4009BDF0 len 00004210 (16 KiB): IRAM
I (882) spi_flash: detected chip: gd
I (885) spi_flash: flash io: dio
I (890) cpu_start: Starting scheduler on PRO CPU.
Keystore initialised
Accessory is not Paired with any controller
Database initialised. Accessory Device ID: ##:4F:##:92:F6:##
HAP Initialization succeeded. Version : 4.0-c62f64d
E (937) ledc: freq_hz=5000 duty_resolution=0

Blinds HOMEKIT (servo or stepper motors)

Hello. I will repeat my question here, because this topic is closer.

Hello dear developers! Can I ask you to make examples on servo or stepper motors control? Ideally, these are blinds. PLEASE! There is no information on the internet. It is very difficult for a beginner to understand the examples of other platforms (arduino, esp8266 etc)

I used several resources and instructions:
https://github.com/espressif/esp-iot-solution/tree/master/components/motor/servo
https://github.com/maximkulkin/esp-homekit-demo/wiki/Build-instructions-ESP32
https://github.com/espressif/esp-rainmaker/tree/master/examples/homekit_switch

But I cannot merge the files. I can not. I do not have sufficient knowledge. Could you make an example for motors? This project is my dream! My dream is to make smart blinds. For this reason, I started studying your techniques a few months ago.

I have several esp32 boards.
Stepper motor 28BYJ-48 5V + driver ULN2003.
Also I have servo motor MG996R 5V
And universal driver L298N

Please make an example HOMEKIT MOTOR for which I might understand this.

line 261 of /common/app_wifi/app_wifi.c should add "#ifdef ESP_NETIF_SUPPORTED"

I can not compile when updated to the recent version using ESP8266,
in examples/common/app_wifi/app_wifi.c:
260 /* Register our event handler for Wi-Fi, IP and Provisioning related events */
261 ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &event_handler, wifi_netif));
262 ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &event_handler, NULL));
263 ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_GOT_IP6, &event_handler, NULL));

I think line 261 should add
#ifdef ESP_NETIF_SUPPORTED
261 ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &event_handler, wifi_netif));
#endif

Feature request or Bug?: Example of Motion Detector

Hello,

Im not able to get a Motion Detector recognizes as a Motion Detector. HomeKit detect the Sensor always as Switch.

I used hap_serv_get_char_by_uuid(service, HAP_CHAR_UUID_OCCUPANCY_DETECTED); and .cid = HAP_CID_SENSOR

But its not works...

Illegal Instruction when initializing mqtt client

Hello,

As I am trying to implement MQTT inside the HomeKit thread, I got illegal instruction panic error when trying to initialize MQTT. #include <mqtt_client.h> has been added at the top of the file.

Lightbulb example is the one that I am getting the error, but using smart_outlet will not.

/**
 *  Initialize MQTT
 */
static void mqtt_app_init(void)
{
    esp_mqtt_client_config_t mqtt_cfg = {
        .uri = MQTT_BROKER_URL,
    };

    ESP_LOGI(TAG, "MQTT_BROKER_URL: %s", MQTT_BROKER_URL);

    esp_mqtt_client_handle_t client = esp_mqtt_client_init(&mqtt_cfg);
//    esp_mqtt_client_start(client);
}

mqtt_app_init() has been put after the below lines

    /* After all the initializations are done, start the HAP core */
    hap_start();
    /* Start Wi-Fi */
    app_wifi_start(portMAX_DELAY);

    mqtt_app_init();

Thanks

Basic GPIO example

Can you add a basic LED / Relay with GPIO example for easily understanding especially for beginner.

I spend hours and hours couldn't able to figure out where to add the code to work with homeKit.

lightbulb example not working

The lightbulb example does not work out of the box.

When defining the ledc_timer in lightbulb.c (line 169 cont.) I had to add the duty_resolution property to get it to work.

Complete code:

    // config the timer
    ledc_timer_config_t ledc_timer = {
        //set frequency of pwm
        .freq_hz = 5000,
        //timer mode,
        .speed_mode = LEDC_HIGH_SPEED_MODE,
        //timer index
        .timer_num = LEDC_TIMER_0,
        // resolution of PWM duty
        .duty_resolution = LEDC_TIMER_13_BIT
    };

OS: macOS Catalina 10.15.7
ESP-IDF Version: ESP-IDF v4.3-dev-1197-g8bc19ba89-dirty
esp-homekit-sdk: git commit f2a010a

Anyone tried multiple devices/switches in Homekit example (MEGH-2692)

I want to integrate multiple devices/switches in Homekit example code. The homekit initialization is clear to me but I am getting confused while registering devices ans setting callbacks, so wondering if anyone has already tried this.

Thanks in advance.
Any help is appreciated.

IP camera support

From happy esp32 user 😄,
I'm really enjoying to use your product and this homekit library.

According to HAP specification and apple/HomeKitADK, it seems to have IP camera support, though it looks like quite newly introduced (this Feb? 🔗).

But I failed to found IP camera support in this repo (and also alternative adk repo 🔗)

Did I miss something, or could I get any plan to support camera IP?

Which sdk is best for me?

Hello and thanks for running this amazing community around ESP*.

I am evaluating both esp-homekit-sdk and esp-apple-homekit-adk but I am struggling to understand the reason why there are 2 projects with the same purpose and which one should I go for.

Could you please provide a comparison of the supported features for both projects?

Thanks!

Hardcoded Wi-Fi credentials -- does it work?

Currently, my only option is to use the provisioning app and scan the QR code to get my device connected to my Wi-Fi.

For some reason, when I try to flash my ESP32 with hardcoded Wi-Fi data (via menuconfig), the ESP32 tries to connect, then restarts, and tries again and again.
Same Wi-Fi for both scenarios.

In menuconfig I disabled WPA3 support, to see if it makes any difference (no luck).
I also created an additional 2.4 GHz Wi-Fi access point in my home to see if the problem still exists.
For SSID and password, I used simple characters (a-z, 0-9) to rule out any encoding issues or stuff like that.

This is what my monitor looks like on my main Wi-Fi (2.4 GHz / 5 GHz with WPA2/WPA3):

I (55950) wifi:Send SA Query req with transaction id 410f
I (56160) wifi:Send SA Query req with transaction id c3b7
I (56360) wifi:Send SA Query req with transaction id 452b
I (56570) wifi:Send SA Query req with transaction id 13c0
I (56770) wifi:Send SA Query req with transaction id 1d76
I (56970) wifi:No response to 5 SA Queries, reset connection
I (56970) wifi:state: run -> init (200)
I (56980) wifi:pm stop, total sleep time: 15846362 us / 19093577 us

W (56980) wifi:<ba-del>idx
I (56980) wifi:new:<13,0>, old:<13,0>, ap:<255,255>, sta:<13,0>, prof:1
I (56990) app_wifi: Disconnected. Connecting to the AP again...
I (57360) wifi:new:<13,0>, old:<13,0>, ap:<255,255>, sta:<13,0>, prof:1
I (57360) wifi:state: init -> auth (b0)
I (59840) wifi:state: auth -> assoc (0)
I (59850) wifi:state: assoc -> run (10)
I (59880) wifi:connected with NoNetworkFound, aid = 18, channel 13, BW20, bssid = 44:4e:6d:a5:44:70
I (59890) wifi:security: WPA3-SAE, phy: bgn, rssi: -68
I (59890) wifi:pm start, type: 1

I (59900) wifi:AP's beacon interval = 102400 us, DTIM period = 1
I (60460) app_wifi: Connected with IP Address:10.0.0.146
I (60460) esp_netif_handlers: sta ip: 10.0.0.146, mask: 255.255.0.0, gw: 10.0.0.1

I (62750) wifi:Send SA Query req with transaction id d4a9
I (62950) wifi:Send SA Query req with transaction id 35a1
I (63160) wifi:Send SA Query req with transaction id 23e8
I (63370) wifi:Send SA Query req with transaction id 1f9
I (63570) wifi:Send SA Query req with transaction id 25f4
I (63770) wifi:No response to 5 SA Queries, reset connection
I (63770) wifi:state: run -> init (200)
I (63770) wifi:pm stop, total sleep time: 2155892 us / 3882892 us

W (63780) wifi:<ba-del>idx
I (63780) wifi:new:<13,0>, old:<13,0>, ap:<255,255>, sta:<13,0>, prof:1
I (63790) app_wifi: Disconnected. Connecting to the AP again...
I (64150) wifi:new:<13,0>, old:<13,0>, ap:<255,255>, sta:<13,0>, prof:1
I (64150) wifi:state: init -> auth (b0)
I (66430) wifi:state: auth -> assoc (0)
I (66440) wifi:state: assoc -> run (10)
I (66470) wifi:connected with NoNetworkFound, aid = 18, channel 13, BW20, bssid = 44:4e:6d:a5:44:70
I (66470) wifi:security: WPA3-SAE, phy: bgn, rssi: -67
I (66480) wifi:pm start, type: 1

I (66560) wifi:AP's beacon interval = 102400 us, DTIM period = 1
I (67420) app_wifi: Connected with IP Address:10.0.0.146
I (67420) esp_netif_handlers: sta ip: 10.0.0.146, mask: 255.255.0.0, gw: 10.0.0.1
I (68020) wifi:state: run -> init (22c0)
I (68020) wifi:pm stop, total sleep time: 680035 us / 1537762 us

W (68020) wifi:<ba-del>idx
I (68020) wifi:new:<13,0>, old:<13,0>, ap:<255,255>, sta:<13,0>, prof:1
I (68020) app_wifi: Disconnected. Connecting to the AP again...
I (68390) wifi:new:<13,0>, old:<13,0>, ap:<255,255>, sta:<13,0>, prof:1
I (68390) wifi:state: init -> auth (b0)
I (68400) wifi:state: auth -> assoc (0)
I (68410) wifi:state: assoc -> run (10)
I (68440) wifi:connected with NoNetworkFound, aid = 18, channel 13, BW20, bssid = 44:4e:6d:a5:44:70
I (68440) wifi:security: WPA3-SAE, phy: bgn, rssi: -68
I (68450) wifi:pm start, type: 1

I (68500) wifi:AP's beacon interval = 102400 us, DTIM period = 1
I (69420) app_wifi: Connected with IP Address:10.0.0.146
I (69420) esp_netif_handlers: sta ip: 10.0.0.146, mask: 255.255.0.0, gw: 10.0.0.1

As I mentioned, it works via the provisioning app without any problems -- on the same Wi-Fi.

Can someone please verify whether the hardcoded method works or point me in the right direction to debug my issue?

Thanks!

EDIT: Don't get confused when you read my log. My Wi-Fi SSID is "NoNetworkFound" :)

ESP8285 Support.

Hi!
Is there any change to support ESP8255 chip by this sdk? Im curios if i should change partitions_hap.csv to fit image to 1MB flash? Now partitions table is design for 3,6MB size. I know, that probably all features like OTA will not fit in the app but this is only for home use so i could live with that.

garage door

绑定提示您可以在生产企业app中允许此配件访问家庭

这个app在哪里呢

Characteristic Notifcations

How to update the temperature sensor value in the Home app at a particular interval in a function other than the read callback.
I have tried hap_char_update_val() and my characteristic has the HAP_CHAR_PERM_PR and HAP_CHAR_PERM_EV permissions. But this doesn't automatically update in Home iOS app.
I have to refresh the app or ask Siri, which means that only the read callback is being triggered.
What am I doing wrong?

SDK multiple sensor support?

I was wondering, does the SDK support having multiple sensors on one accessory? I'm trying to use multiple DS18B20s on one accessory. I've only been able to get 1 to work. Can't figure this out.

hap_char_update_val memory leak

If hap_char_update_val is called from other task than service write or service read, has memory leak. Lost 116-240 bytes after return. Only if value has changed.

ESP32 HomeKit Session terminated problem.

Hello. I have problem on ESP32. I use latest versions esp-homekit-sdk and esp-idf v4.3. Python 3.9.4. macOS Big Sur 11.4. Processor M1.
I took a simple example of a light bulb as it is (without corrections on my part). Compiled / flash ESP32 successful. Without any errors / warnings. The first few minutes of work, everything is fine. After about 1 minutes, the connection is broken and the chip does not respond.
Config and other options set by default.

I (2071) esp_netif_handlers: sta ip: 192.168.1.12, mask: 255.255.255.0, gw: 192.168.1.1
I (2071) app_wifi: Connected with IP Address:192.168.1.12
I (3071) app_wifi: Connected with IPv6 Address:fe80:0000:0000:0000:xxxx:xxxx:xxxx:xxxx
######## Starting Pair Verify ########
Pair Verify M1 Received
Pair Verify M2 Successful
Pair Verify M3 Received
HomeKit Session active. 
Pair Verify Successful for 8FB5698D-3270-4F4E-800E-87EB4D55CBBF
Enabling Keep-Alive on Pair Verify Session
######## Starting Pair Verify ########
Pair Verify M1 Received
Pair Verify M2 Successful
######## Starting Pair Verify ########
Pair Verify M1 Received
Pair Verify M2 Successful
Pair Verify M3 Received
HomeKit Session active. 
Pair Verify Successful for 00D0907C-D100-49B8-83A3-9BED625AFFC6
Enabling Keep-Alive on Pair Verify Session
Events Enabled for aid=1 iid=13
Events Enabled for aid=1 iid=15
Events Enabled for aid=1 iid=16
Events Enabled for aid=1 iid=17
Events Enabled for aid=1 iid=13
Events Enabled for aid=1 iid=15
Events Enabled for aid=1 iid=16
Events Enabled for aid=1 iid=17
Pair Verify M3 Received
HomeKit Session active. 
Pair Verify Successful for 8FB5698D-3270-4F4E-800E-87EB4D55CBBF
Enabling Keep-Alive on Pair Verify Session
Events Enabled for aid=1 iid=13
Events Enabled for aid=1 iid=15
Events Enabled for aid=1 iid=16
Events Enabled for aid=1 iid=17
Events Enabled for aid=1 iid=13
Events Enabled for aid=1 iid=15
Events Enabled for aid=1 iid=16
Events Enabled for aid=1 iid=17
I (45511) HAP lightbulb: Received Write for Light Off
I (45511) lightbulb: lightbulb_set_on : false
Value Changed
Notification Sent
HomeKit Session terminated.
I (155991) HAP lightbulb: Received Write for Light Off
I (155991) lightbulb: lightbulb_set_on : false
Value Changed
Notification Sent
I (157431) HAP lightbulb: Received Write for Light On
I (157431) lightbulb: lightbulb_set_on : true
Value Changed
Notification Sent
I (165421) HAP lightbulb: Received Write for Light Brightness 85
I (165421) lightbulb: lightbulb_set_brightness : 85
Value Changed
I (165421) HAP lightbulb: Received Write for Light On
I (165431) lightbulb: lightbulb_set_on : true
Notification Sent
I (165721) HAP lightbulb: Received Write for Light Brightness 86
I (165721) lightbulb: lightbulb_set_brightness : 86
Value Changed
I (165731) HAP lightbulb: Received Write for Light On
I (165731) lightbulb: lightbulb_set_on : true
Notification Sent
I (165921) HAP lightbulb: Received Write for Light Brightness 85
I (165931) lightbulb: lightbulb_set_brightness : 85
Value Changed
I (165931) HAP lightbulb: Received Write for Light On
I (165931) lightbulb: lightbulb_set_on : true
Notification Sent
HomeKit Session terminated.
HomeKit Session terminated.

This is about one minute of work of the chip. After last Session terminated chip don’t respond. Any logs. In Apple Home Application - device shows as not available. After about 10 minutes awaiting chip start new session.

######## Starting Pair Verify ########
Pair Verify M1 Received
Pair Verify M2 Successful
######## Starting Pair Verify ########
Pair Verify M1 Received
Pair Verify M2 Successful
Pair Verify M3 Received
HomeKit Session active.
Pair Verify Successful for 00D0907C-D100-49B8-83A3-9BED625AFFC6
Enabling Keep-Alive on Pair Verify Session
######## Starting Pair Verify ########
Pair Verify M1 Received
Pair Verify M2 Successful
Pair Verify M3 Received
HomeKit Session active.
Pair Verify Successful for 8FB5698D-3270-4F4E-800E-87EB4D55CBBF
Enabling Keep-Alive on Pair Verify Session
######## Starting Pair Verify ########
Pair Verify M1 Received
Pair Verify M2 Successful
Pair Verify M3 Received
HomeKit Session active.
Pair Verify Successful for 8FB5698D-3270-4F4E-800E-87EB4D55CBBF
Enabling Keep-Alive on Pair Verify Session
Events Enabled for aid=1 iid=13
Events Enabled for aid=1 iid=15
Events Enabled for aid=1 iid=16
Events Enabled for aid=1 iid=17
Pair Verify M3 Received
HomeKit Session active.
Pair Verify Successful for 00D0907C-D100-49B8-83A3-9BED625AFFC6
Enabling Keep-Alive on Pair Verify Session
Events Enabled for aid=1 iid=13
Events Enabled for aid=1 iid=15
Events Enabled for aid=1 iid=16

It works again for about one minute і hangs again. So the process is repeated endlessly.
Please tell me what could I have done wrong? What i needs to be checked?

Adaptive Lighting

Does the commercial version of this SDK have an example and support Adaptive Lighting for Lightbulbs for Colour Temperature Characteristic?

json_generator.h: No such file or directory when compiling example files

Hello,

I have got this error when trying to compile smart-outlet example:

/home/user/esp/esp-homekit-sdk/components/homekit/esp_hap_core/src/esp_hap_ip_services.c:25:10: fatal error: json_generator.h: No such file or directory
 #include <json_generator.h>
          ^~~~~~~~~~~~~~~~~~
compilation terminated.

Is there any way to resolve or install this file?

Thank you.

DHT22 example

I would like to build an Apple Homekit weather station with the DHT22 temperature and humidity sensor.
I am not very familiar with coding yet and wanted to ask if it was possible adding a little program in the example-section of the esp-homekit-sdk that pulls the temperature and humidity data from the DHT22 and provides it to Homekit.

In combination with esp32-deepsleep and some lithium ion batteries this would result in a very decent and economic Homekit weather station.

Thx a lot
maxi

bridge mode does not work with more accessories nodes,

hi,
We were evaluating homekit sdk for bridged mode accessories .
using the bridge example with fan devices, extended the example to check if it can accommodate 32,64,128 Devices.

using IDF version 4.2.0

#define NUM_BRIDGED_ACCESSORIES 64

also we added new characteristic of speed to the fan example

#ifdef (FAN_WITH_CUSTOM_SPEED25)
        hap_char_t *rotation_speed = hap_char_rotation_speed_create(50.0);
        hap_char_float_set_constraints(rotation_speed, 0, 100, 25.0);
        hap_serv_add_char(service, rotation_speed);
#else
	#ifdef (FAN_WITH_CUSTOM_SPEED10)
        hap_char_t *rotation_speed = hap_char_rotation_speed_create(50.0);
        hap_char_float_set_constraints(rotation_speed, 0, 100, 10.0);
        hap_serv_add_char(service, rotation_speed);
	#endif
#endif

During adding accessories (Bridge) to ipad home app the session gets terminated prematurely.

----------Fails to add 32/64 device in Home-----

httpd_parse: parse_block: request URI/header too long
httpd_txrx: httpd_resp_send_err: 414 URI Too Long - URI is too long for server to interpret
HomeKit Session terminated

Needs to increase the http url length to accommodate more devices
------http 1536 ----Ok--------

#
# HTTP Server
#
CONFIG_HTTPD_MAX_REQ_HDR_LEN=512
CONFIG_HTTPD_MAX_URI_LEN=1536
CONFIG_HTTPD_ERR_RESP_NO_DELAY=y
CONFIG_HTTPD_PURGE_BUF_LEN=32
# CONFIG_HTTPD_LOG_PURGE_DATA is not set
# CONFIG_HTTPD_WS_SUPPORT is not set
# end of HTTP Server

we could add in batches of 16 first then add another till Total 128.

But could not set or get the read the status of all 128.

added a bulk on and off in home kit app as Home Away(all off) and Enter Home(all on)

at 128 device count

Allocated buffer of size 11746 for the large PUT
Failed to parse HTTPD JSON Data
Freed allocated buffer for PUT
Decryption error/Connection lost. Marking session as invalid
HomeKit Session terminated

Tried to increase CONFIG_HTTPD_MAX_URI_LEN=4096

Then got bored to add the 128 device again in the homekit app had to click and assign each fan to a room :(

Thanks and Regards

Sync service state manually when using physical button

Hi,

I'm making a basic connected light with a physical switch using the lightbulb example. Everything works perfectly except that when I'm using the physical switch, the light state is not sync with the server (for example, the iPhone shows the light is on instead of off).

I'm unable to find the way to notify the server that the light' state has changed. Any idea?

SDK very unresponsive (even for simple Lightbulb)

We have access to your commercial HomeKit SDK. When flashing your simple Lightbulb example, the Lightbulb gets when you switch it very fast on and off, after a few times unresponsive. After some time it can even completely lose the connection stating "No Response". Even if that is not the case, the spinning wheel is often there, and the state changes only deploy slowly to the Hardware.

This is not the case with the open source ESP HomeKit Library from Maxim Kulkin.

What is causing this?

TCH058 Test failure in HCA 3.0.3 (ESP32)

TCH058 - Verify the pairing bit in Status Flag returns to 1 when pairing removed

Using HomeKit Certification Assistant 3.0.3, the test above fails.
I ran the same test using HomeKit Certification Assistant 2.16.2 and it passed. I think 2.16.2 delayed a bit more before listening for advertisements.

Maybe after pairing is removed, the first advertisement needs to be delayed until the pairing bit is set?

Error in Wi-Fi provisioning

When executing the examples and trying to provision the WIFI, the Espressif Provisioning Apps find the bluetooth device.

entry 0x40080664
I (27) boot: ESP-IDF v4.4-dev-2487-g8131d6f46-dirty 2nd stage bootloader
I (27) boot: compile time 23:50:41
I (28) boot: chip revision: 1
I (32) boot_comm: chip revision: 1, min. bootloader chip revision: 0
I (39) boot.esp32: SPI Speed      : 40MHz
I (44) boot.esp32: SPI Mode       : DIO
I (48) boot.esp32: SPI Flash Size : 4MB
I (53) boot: Enabling RNG early entropy source...
I (58) boot: Partition Table:
I (62) boot: ## Label            Usage          Type ST Offset   Length
I (69) boot:  0 sec_cert         unknown          3f 00 0000d000 00003000
I (76) boot:  1 nvs              WiFi data        01 02 00010000 00006000
I (84) boot:  2 otadata          OTA data         01 00 00016000 00002000
I (91) boot:  3 phy_init         RF data          01 01 00018000 00001000
I (99) boot:  4 ota_0            OTA app          00 10 00020000 00190000
I (106) boot:  5 ota_1            OTA app          00 11 001b0000 00190000
I (114) boot:  6 factory_nvs      WiFi data        01 02 00340000 00006000
I (121) boot:  7 nvs_keys         NVS keys         01 04 00346000 00001000
I (129) boot: End of partition table
I (133) boot_comm: chip revision: 1, min. application chip revision: 0
I (140) esp_image: segment 0: paddr=00020020 vaddr=3f400020 size=3ec58h (257112) map
I (242) esp_image: segment 1: paddr=0005ec80 vaddr=3ffbdb60 size=01398h (  5016) load
I (244) esp_image: segment 2: paddr=00060020 vaddr=400d0020 size=115310h (1135376) map
I (659) esp_image: segment 3: paddr=00175338 vaddr=3ffbeef8 size=02fe8h ( 12264) load
I (664) esp_image: segment 4: paddr=00178328 vaddr=40080000 size=1b8ach (112812) load
I (711) esp_image: segment 5: paddr=00193bdc vaddr=50000000 size=00010h (    16) load
I (725) boot: Loaded app from partition at offset 0x20000
I (725) boot: Disabling RNG early entropy source...
I (736) cpu_start: Pro cpu up.
I (736) cpu_start: Single core mode
I (747) cpu_start: Pro cpu start user code
I (747) cpu_start: cpu freq: 160000000
I (747) cpu_start: Application information:
I (751) cpu_start: Project name:     lightbulb
I (756) cpu_start: App version:      c62f64d
I (761) cpu_start: Compile time:     Aug  5 2021 23:50:14
I (767) cpu_start: ELF file SHA256:  745e64b142ad374f...
I (773) cpu_start: ESP-IDF:          v4.4-dev-2487-g8131d6f46-dirty
I (781) heap_init: Initializing. RAM available for dynamic allocation:
I (788) heap_init: At 3FF80000 len 00002000 (8 KiB): RTCRAM
I (794) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM
I (800) heap_init: At 3FFB6388 len 00001C78 (7 KiB): DRAM
I (806) heap_init: At 3FFB9A20 len 00004108 (16 KiB): DRAM
I (812) heap_init: At 3FFCA6B8 len 00015948 (86 KiB): DRAM
I (818) heap_init: At 3FFE0440 len 0001FBC0 (126 KiB): D/IRAM
I (825) heap_init: At 40078000 len 00008000 (32 KiB): IRAM
I (831) heap_init: At 4009B8AC len 00004754 (17 KiB): IRAM
I (838) spi_flash: detected chip: generic
I (842) spi_flash: flash io: dio
I (847) cpu_start: Starting scheduler on PRO CPU.
Keystore initialised
Accessory is not Paired with any controller
Database initialised. Accessory Device ID: 0A:60:FA:B4:26:DF
HAP Initialization succeeded. Version : 4.0-c62f64d
E (914) ledc: freq_hz=5000 duty_resolution=0
I (914) gpio: GPIO[0]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:3
I (924) app_hap_setup_payload: -----QR Code for HomeKit-----
I (934) app_hap_setup_payload: Scan this QR code from the Home app on iOS

  █▀▀▀▀▀█   █▀  █▀▀▀▀▀█
  █ ███ █ █▀▄▀▀ █ ███ █
  █ ▀▀▀ █ ██▀ █ █ ▀▀▀ █
  ▀▀▀▀▀▀▀ █ █ ▀ ▀▀▀▀▀▀▀
  ▀ ▀███▀ ▄▀ ▄█▄██▀██ ▄
  █▄█▄▀▄▀▀▀█▀▄█  ▀  ▄█▄
    ▀▀  ▀▀▄▄▀ ▀▄▀▄ ▄▄█▀
  █▀▀▀▀▀█ ▄  ▄█▀▄█ █ ▀▄
  █ ███ █ █▀█  ▄▀▀█▀  ▀
  █ ▀▀▀ █ ▀█▄ █▄ ▄ █▀ ▄
  ▀▀▀▀▀▀▀ ▀▀ ▀▀▀  ▀▀

I (1014) app_hap_setup_payload: If QR code is not visible, copy paste the below URL in a browser.
https://espressif.github.io/esp-homekit-sdk/qrcode.html?data=X-HM://00527813XES32
MFi auth not supported. Falling back to HAP_MFI_AUTH_NONE
I (1054) wifi:wifi driver task: 3ffcee9c, prio:23, stack:6656, core=0
I (1054) system_api: Base MAC address is not set
I (1054) system_api: read default base MAC address from EFUSE
I (1064) wifi:wifi firmware version: e381636
I (1064) wifi:wifi certification version: v7.0
I (1064) wifi:config NVS flash: enabled
I (1074) wifi:config nano formating: disabled
I (1074) wifi:Init data frame dynamic rx buffer num: 32
I (1074) wifi:Init management frame dynamic rx buffer num: 32
I (1084) wifi:Init management short buffer num: 32
I (1084) wifi:Init dynamic tx buffer num: 32
I (1094) wifi:Init static rx buffer size: 1600
I (1094) wifi:Init static rx buffer num: 10
I (1104) wifi:Init dynamic rx buffer num: 32
I (1104) wifi_init: rx ba win: 6
I (1104) wifi_init: tcpip mbox: 32
I (1114) wifi_init: udp mbox: 10
I (1114) wifi_init: tcp mbox: 6
I (1124) wifi_init: tcp tx win: 5744
I (1124) wifi_init: tcp rx win: 5744
I (1134) wifi_init: tcp mss: 1440
I (1134) wifi_init: WiFi IRAM OP enabled
I (1134) wifi_init: WiFi RX IRAM OP enabled
Setup ID: ES32
HAP Main Loop Started
mDNS initialised
Registering HomeKit web handlers
Announcing _hap._tcp mDNS service
I (1164) wifi_prov_scheme_ble: BT memory released
I (1164) app_wifi: Starting provisioning
I (1184) phy_init: phy_version 4670,719f9f6,Feb 18 2021,17:07:07
I (1264) wifi:mode : sta (3c:61:05:13:54:d8)
I (1264) wifi:enable tsf
I (1274) BTDM_INIT: BT controller compile version [d83d996]
I (1574) wifi_prov_mgr: Provisioning started with service name : PROV_1354D8
I (1574) app_wifi: Provisioning started
I (1574) app_wifi: -----QR Code for ESP Provisioning-----
I (1584) app_wifi: Scan this QR code from the phone app for Provisioning.

  █▀▀▀▀▀█ ▀▀    ▀ ▀  ▀ ▀███ █▀▀▀▀▀█
  █ ███ █ █▄ █▀█ ██▄█▀▄  ▀  █ ███ █
  █ ▀▀▀ █ ▀█▀▀▄ ▀▀▀▀███ ▀ ▄ █ ▀▀▀ █
  ▀▀▀▀▀▀▀ ▀▄▀▄▀ █▄█▄█ ▀ ▀▄▀ ▀▀▀▀▀▀▀
  ▀▀██ ▄▀▄█▄   ▄▄▀█▀ █▀▄ ▄█▀▄ ▀▀█▄█
  ▀█ ▀▀█▀█   ▄▄█▀ ▄▀▀▄▀ ███▀ ▀▄▀▀▀▀
  ▄▀▀▄▀▀▀▄██▄█ ▀▄███ ▄█▄▄█▄▀ █▀▄ ▀
   ▀▄▄ ▄▀ █   █     ██ ▄▀▄ ▄  ▄ █ ▄
   ███ █▀▄▀▄▀▀▄█ ▄▀▄▄ ▀▀▄▀█▄█▄█ █▀█
   ▄▄  ▀▀▀▄▄▀▀█▀▄█▄▄▀▄▄   ▄  ▀▀▄ ▀
  ▄▄ ▀▄▄▀ ▄▀ ▀█▄▀▀█▀▄▄▀▀▀▀ █▄▄  █▀▄
   ▄██ ▄▀▀▄▄█▀▀▄  █   ▀ ██ ▄▄▄ █▀ █
  ▀ ▀ ▀▀▀ █ ▀▄█▀██▄▀▀▄▄   █▀▀▀█▀ ▄▀
  █▀▀▀▀▀█  ▄██ ▀█ ▀ █▀ █▀▄█ ▀ █ █
  █ ███ █ ▄▀▀  █▀▄▀   ▄▀▀▀▀█▀▀▀ ▀█▀
  █ ▀▀▀ █ █ ▀▄▄▀▄▀▄█▀▄▀▀  ▀ █▀▄█▀▀▄
  ▀▀▀▀▀▀▀ ▀ ▀▀▀ ▀  ▀▀  ▀ ▀ ▀▀ ▀ ▀


I (1794) app_wifi: If QR code is not visible, copy paste the below URL in a browser.
https://espressif.github.io/esp-jumpstart/qrcode.html?data={"ver":"v1","name":"PROV_1354D8","pop":"051354d8","transport":"ble"}
I (1814) app_wifi: Provisioning Started. Name : PROV_1354D8, POP : 051354d8

In my iPhone, not found

IMG-5-CE8-A9-A6-DFFE-1

Use a lightbulb example in repo.

Examples not work!

I cannot add devices using Apple Home or RainMaker.

After scanning the QR code, the serial terminal displays

W (29853) wifi:Error! Should use default active scan time parameter for WiFi scan when Bluetooth is enabled!!!!!!

Below is the complete log .

rst:0x1 (POWERON_RESET),boot:0x33 (SPI_FAST_FLASH_BOOT)
flash read err, 1000
ets_main.c 371
ets Jun  8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x33 (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:4
load:0x3fff0034,len:7148
load:0x40078000,len:13212
ho 0 tail 12 room 4
load:0x40080400,len:4568
0x40080400: _init at ??:?

entry 0x400806f4
I (31) boot: ESP-IDF v4.2-408-gc9cf7bcb0-dirty 2nd stage bootloader
I (31) boot: compile time 16:42:44
I (31) boot: chip revision: 1
I (35) boot_comm: chip revision: 1, min. bootloader chip revision: 0
I (44) boot.esp32: SPI Speed      : 40MHz
I (47) boot.esp32: SPI Mode       : DIO
I (52) boot.esp32: SPI Flash Size : 4MB
I (56) boot: Enabling RNG early entropy source...
I (62) boot: Partition Table:
I (65) boot: ## Label            Usage          Type ST Offset   Length
I (72) boot:  0 sec_cert         unknown          3f 00 0000d000 00003000
I (80) boot:  1 nvs              WiFi data        01 02 00010000 00006000
I (87) boot:  2 otadata          OTA data         01 00 00016000 00002000
I (95) boot:  3 phy_init         RF data          01 01 00018000 00001000
I (102) boot:  4 ota_0            OTA app          00 10 00020000 00190000
I (110) boot:  5 ota_1            OTA app          00 11 001b0000 00190000
I (117) boot:  6 factory_nvs      WiFi data        01 02 00340000 00006000
I (125) boot:  7 nvs_keys         NVS keys         01 04 00346000 00001000
I (132) boot: End of partition table
I (137) boot_comm: chip revision: 1, min. application chip revision: 0
I (144) esp_image: segment 0: paddr=0x00020020 vaddr=0x3f400020 size=0x44284 (279172) map
I (259) esp_image: segment 1: paddr=0x000642ac vaddr=0x3ffbdb60 size=0x03fc0 ( 16320) load
I (266) esp_image: segment 2: paddr=0x00068274 vaddr=0x40080000 size=0x00404 (  1028) load
0x40080000: _WindowOverflow4 at /mnt/d/Desktop/wled/esp-idf-4.2/components/freertos/xtensa/xtensa_vectors.S:1730

I (267) esp_image: segment 3: paddr=0x00068680 vaddr=0x40080404 size=0x07998 ( 31128) load
I (289) esp_image: segment 4: paddr=0x00070020 vaddr=0x400d0020 size=0x1121f0 (1122800) map
0x400d0020: _stext at ??:?

I (716) esp_image: segment 5: paddr=0x00182218 vaddr=0x40087d9c size=0x14f50 ( 85840) load
0x40087d9c: r_lld_evt_schedule at ??:?

I (770) boot: Loaded app from partition at offset 0x20000
I (770) boot: Disabling RNG early entropy source...
I (770) cpu_start: Pro cpu up.
I (774) cpu_start: Application information:
I (779) cpu_start: Project name:     lightbulb
I (784) cpu_start: App version:      b3ca71e-dirty
I (789) cpu_start: Compile time:     Apr  7 2021 16:42:25
I (795) cpu_start: ELF file SHA256:  32b8d148af84046c...
I (801) cpu_start: ESP-IDF:          v4.2-408-gc9cf7bcb0-dirty
I (808) cpu_start: Single core mode
I (812) heap_init: Initializing. RAM available for dynamic allocation:
I (819) heap_init: At 3FF80000 len 00002000 (8 KiB): RTCRAM
I (825) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM
I (831) heap_init: At 3FFB6388 len 00001C78 (7 KiB): DRAM
I (838) heap_init: At 3FFB9A20 len 00004108 (16 KiB): DRAM
I (844) heap_init: At 3FFCDEA0 len 00012160 (72 KiB): DRAM
I (850) heap_init: At 3FFE0440 len 0001FBC0 (126 KiB): D/IRAM
I (856) heap_init: At 40078000 len 00008000 (32 KiB): IRAM
I (862) heap_init: At 4009CCEC len 00003314 (12 KiB): IRAM
I (869) cpu_start: Pro cpu start user code
I (886) spi_flash: detected chip: gd
I (887) spi_flash: flash io: dio
I (887) cpu_start: Starting scheduler on PRO CPU.
Keystore initialised
Accessory is not Paired with any controller
Database initialised. Accessory Device ID: 07:DC:1B:58:74:85
HAP Initialization succeeded. Version : 4.0-b3ca71e
I (933) gpio: GPIO[0]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:3 
I (943) app_hap_setup_payload: -----QR Code for HomeKit-----
I (943) app_hap_setup_payload: Scan this QR code from the Home app on iOS

  █▀▀▀▀▀█   █▀  █▀▀▀▀▀█
  █ ███ █ █▀▄▀▀ █ ███ █
  █ ▀▀▀ █ ██▀ █ █ ▀▀▀ █
  ▀▀▀▀▀▀▀ █ █ ▀ ▀▀▀▀▀▀▀
  ▀ ▀███▀ ▄▀ ▄█▄██▀██ ▄
  █▄█▄▀▄▀▀▀█▀▄█  ▀  ▄█▄
    ▀▀  ▀▀▄▄▀ ▀▄▀▄ ▄▄█▀
  █▀▀▀▀▀█ ▄  ▄█▀▄█ █ ▀▄
  █ ███ █ █▀█  ▄▀▀█▀  ▀
  █ ▀▀▀ █ ▀█▄ █▄ ▄ █▀ ▄
  ▀▀▀▀▀▀▀ ▀▀ ▀▀▀  ▀▀


I (1033) app_hap_setup_payload: If QR code is not visible, copy paste the below URL in a browser.
https://espressif.github.io/esp-homekit-sdk/qrcode.html?data=X-HM://00527813XES32
MFi auth not supported. Falling back to HAP_MFI_AUTH_NONE
I (1063) wifi:wifi driver task: 3ffd0f58, prio:23, stack:6656, core=0
I (1063) system_api: Base MAC address is not set
I (1063) system_api: read default base MAC address from EFUSE
I (1083) wifi:wifi firmware version: 3c8d1dd
I (1083) wifi:wifi certification version: v7.0
I (1083) wifi:config NVS flash: enabled
I (1083) wifi:config nano formating: disabled
I (1083) wifi:Init data frame dynamic rx buffer num: 32
I (1093) wifi:Init management frame dynamic rx buffer num: 32
I (1093) wifi:Init management short buffer num: 32
I (1103) wifi:Init dynamic tx buffer num: 32
I (1103) wifi:Init static rx buffer size: 1600
I (1113) wifi:Init static rx buffer num: 10
I (1113) wifi:Init dynamic rx buffer num: 32
I (1113) wifi_init: rx ba win: 6
I (1123) wifi_init: tcpip mbox: 32
I (1123) wifi_init: udp mbox: 10
I (1133) wifi_init: tcp mbox: 6
I (1133) wifi_init: tcp tx win: 5744
I (1133) wifi_init: tcp rx win: 5744
I (1143) wifi_init: tcp mss: 1440
I (1143) wifi_init: WiFi IRAM OP enabled
I (1153) wifi_init: WiFi RX IRAM OP enabled
Setup ID: ES32
HAP Main Loop Started
mDNS initialised
Registering HomeKit web handlers
Announcing _hap._tcp mDNS service
I (1173) wifi_prov_scheme_ble: BT memory released
I (1173) app_wifi: Starting provisioning
I (1183) phy_init: phy_version 4660,0162888,Dec 23 2020
I (1273) wifi:mode : sta (30:ae:a4:49:93:00)
I (1273) BTDM_INIT: BT controller compile version [cbc69c8]
I (1283) phy_init: phy_version 4660,0162888,Dec 23 2020
I (1633) wifi_prov_mgr: Provisioning started with service name : PROV_499300 
I (1633) app_wifi: Provisioning started
I (1643) app_wifi: -----QR Code for ESP Provisioning-----
I (1643) app_wifi: Scan this QR code from the phone app for Provisioning.

  █▀▀▀▀▀█ ▀▀▀█▄█    ▄▄█   ▀ █▀▀▀▀▀█
  █ ███ █  ▀▄█ █▄ ▀▄▄▀▀█▄▄▀ █ ███ █
  █ ▀▀▀ █  ▄▀█▀▄▀ ▀▄▄▀▀██▄█ █ ▀▀▀ █
  ▀▀▀▀▀▀▀ █▄▀ █▄█▄█ ▀▄▀ █ ▀ ▀▀▀▀▀▀▀
  ▄ ▀ █▄▀▄▄▄▄▀▄▄█▄▀▀█▄█▄█▀▀█ ▀▄ ▄▀
  █ ▀ ▀▄▀█▄███▄  ▀█▄█▄▀▀█▀█ ▄█ ▀▄▄█
  ▀▀▀▀▀ ▀ █ ▀▀▀▄▄██▄█▀█ ▀██▀▀▀█▄▄▀
  █▀▀▀▀▀█  █▄█▀▀▀██ ▄▀▄ █▄█ ▀ █ ▄ ▄
  █ ███ █ ███▄█▀▀█▀▄█▄▄ ▀██▀▀▀▀▄▄▀▀
  █ ▀▀▀ █ ▄██▀ ▄█▀█ █▀ ▀▀███▄▀█ █▄█
  ▀▀▀▀▀▀▀ ▀ ▀▀  ▀▀ ▀     ▀▀▀▀▀▀


I (1853) app_wifi: If QR code is not visible, copy paste the below URL in a browser.
https://espressif.github.io/esp-jumpstart/qrcode.html?data={"ver":"v1","name":"PROV_499300","pop":"a4499300","transport":"ble"}ansport":"ble"}
I (1873) app_wifi: Provisioning Started. Name : PROV_499300, POP : a4499300                                     !
W (29853) wifi:Error! Should use default active scan time parameter for WiFi scan when Bluetooth is enabled!!!!!!

bluetooth support?

Looking to implement a bluetooth device for iOS, but there doesn't seem to be any bluetooth support for ESP Homekit.

Am I missing something?

Bug in esp_netif_t declaration at app_wifi/app_wifi.c

Hi!
I have checkout on lates develop on:

  • homekit sdk: b3ca71e
  • esp_8266_RTOS_SDK: d45071563cebe9ca520cbed2537dc840b4d6a1e6

and I'm developing on ESP8285(Gsound SP111 smart plug). When trying to compile i get this error:

In file included from /Volumes/Programowanie/ESP/ESP8266_RTOS_SDK/components/heap/include/esp_heap_caps.h:21,
                 from /Volumes/Programowanie/ESP/ESP8266_RTOS_SDK/components/freertos/include/freertos/private/portable.h:92,
                 from /Volumes/Programowanie/ESP/ESP8266_RTOS_SDK/components/freertos/include/freertos/FreeRTOS.h:62,
                 from /Users/grzegorz/Programowanie/ESP/esp-homekit-sdk/examples/common/app_wifi/app_wifi.c:26:
/Users/grzegorz/Programowanie/ESP/esp-homekit-sdk/examples/common/app_wifi/app_wifi.c: In function 'app_wifi_init':
/Users/grzegorz/Programowanie/ESP/esp-homekit-sdk/examples/common/app_wifi/app_wifi.c:261:94: error: 'wifi_netif' undeclared (first use in this function); did you mean 'wifi_ant_t'?
     ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &event_handler, wifi_netif));
                                                                                              ^~~~~~~~~~
/Volumes/Programowanie/ESP/ESP8266_RTOS_SDK/components/esp_common/include/esp_err.h:117:31: note: in definition of macro 'ESP_ERROR_CHECK'
         esp_err_t __err_rc = (x);                                       \
                               ^
/Users/grzegorz/Programowanie/ESP/esp-homekit-sdk/examples/common/app_wifi/app_wifi.c:261:94: note: each undeclared identifier is reported only once for each function it appears in
     ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &event_handler, wifi_netif));
                                                                                              ^~~~~~~~~~
/Volumes/Programowanie/ESP/ESP8266_RTOS_SDK/components/esp_common/include/esp_err.h:117:31: note: in definition of macro 'ESP_ERROR_CHECK'
         esp_err_t __err_rc = (x);

After my investigation I see that in file link_to_file at line 261, you are trying to pass wifi_netif object to event handler initialization function. This is problem when you are trying to compile for target that don't support new netif abstraction. I suppose fix should look like in my patch.

diff --git a/examples/common/app_wifi/app_wifi.c b/examples/common/app_wifi/app_wifi.c
index 286d957..2d24b1d 100644
--- a/examples/common/app_wifi/app_wifi.c
+++ b/examples/common/app_wifi/app_wifi.c
@@ -255,10 +255,14 @@ void app_wifi_init(void)
     /* Initialize Wi-Fi including netif with default config */
 #ifdef ESP_NETIF_SUPPORTED
     esp_netif_t *wifi_netif = esp_netif_create_default_wifi_sta();
 #endif

     /* Register our event handler for Wi-Fi, IP and Provisioning related events */
+#ifdef ESP_NETIF_SUPPORTED
     ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &event_handler, wifi_netif));
+#else
+    ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &event_handler, NULL));
+#endif
     ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &event_handler, NULL));
     ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_GOT_IP6, &event_handler, NULL));

Maybe you should not pass wifi_netif object, because it's not used as far as I see.

Please check that.

Check whether is in pairing process

Hello,

As pairing on ESP8266 is using quite much processing power, and as my program needs to monitor the gpio state continuously (i.e. using while loop), the monitor task will kind of disturbing the HomeKit pairing process which leads to failure (although setting lower priority than HomeKit task).

Is there any variable that can be tracked whether it is pairing with Home app or not?

Below is the pairing process serial monitor:

######## Starting Pair Setup ########
Pair Setup M1 Received
Pair Setup M2 Successful
Cleaning Pair Setup Context
######## Starting Pair Setup ########
Pair Setup M1 Received
Pair Setup M2 Successful
Cleaning Pair Setup Context
######## Starting Pair Setup ########
Pair Setup M1 Received
Pair Setup M2 Successful
Cleaning Pair Setup Context
######## Starting Pair Setup ########
Pair Setup M1 Received
Pair Setup M2 Successful
Cleaning Pair Setup Context
######## Starting Pair Setup ########
Pair Setup M1 Received
Pair Setup M2 Successful
Pair Setup M3 Received
Using pair-setup without MFi.
Pair Setup M4 Successful
Pair Setup M5 Received
Pair Setup Successful for FB660B62-3EF5-4F48-9848-4321FDF7B8D5
Updated state number to 2
Re-announcing _hap._tcp mDNS service
Cleaning Pair Setup Context
Cleaning Pair Setup Context
######## Starting Pair Verify ########
Pair Verify M1 Received
Pair Verify M2 Successful
Pair Verify M3 Received
HomeKit Session active
Pair Verify Successful for FB660B62-3EF5-4F48-9848-4321FDF7B8D5
Events Enabled for aid=1 iid=13
Events Enabled for aid=1 iid=16
Events Enabled for aid=1 iid=13
Events Enabled for aid=1 iid=16
Add Pairing received
Added Controller 96A1340C-6F2E-425E-9287-51090BB7A174
I (75784) HAP lightswitch: Accessory identified

It seems like ######## Starting Pair Setup ######## indicates it is now in pairing process and I (75784) HAP lightswitch: Accessory identified shows the pairing process is mostly done.

Thank you,
Lawrence

RF transmitter

I'm trying to connect an RF transmitter to HomeKit.
The ideal would be to have a long press gesture button service, that sends the signal as long the user is holding the finger on the screen, but I didn't find anything in the apple-defined services (I tried the StatelessProgrammableSwitch, but it is intended for handling other services). So I moved to a switch that waits 1s and then turns back to off. Despite my low experience I managed to create a working sample. The only problem is that if I repeatedly press the key in that second, the program buffers all the user requests creating an unwanted behavior (practically a blinking light).
Is there a way to stop and restart incoming requests? Or a completely different but better way to handle this problem?
Sorry but I'm really new to this...

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.