Open AramVartanyan opened 3 years ago
We have the same problem
I've tried using iOS 15 beta in my iPhone with this results:
phy ver: 273, pp ver: 8.3
Using Sensor at GPIO0.
mode : sta(fc:f5:c4:93:ff:0f)
add if0
>>> HomeKit: Starting server
>>> HomeKit: Formatting HomeKit storage at 0x100000
>>> HomeKit: Generated new accessory ID: 4B:18:2D:74:01:6B
>>> HomeKit: Generated new accessory key
>>> HomeKit: Configuring mDNS
mDNS announcement: Name=Garagentor md=GDOpv=1.0id=4B:18:2D:74:01:6Bc#=1s#=1ff=0sf=1ci=4 Port=5556 TTL=4500
scandone
add 0
aid 8
cnt
connected with HOMEKIT, channel 8
dhcp client start...
ip:192.168.100.78,mask:255.255.255.0,gw:192.168.100.1
>>> HomeKit: Got new client connection: 4 from 192.168.100.35
>>> HomeKit: [Client 4] Pair Setup Step 1/3
>>> HomeKit: Got new client connection: 5 from 192.168.100.35
>>> HomeKit: [Client 4] Closing client connection
>>> HomeKit: [Client 5] Pair Setup Step 1/3
>>> HomeKit: [Client 5] Closing client connection
>>> HomeKit: Got new client connection: 4 from 192.168.100.35
>>> HomeKit: [Client 4] Pair Setup Step 1/3
>>> HomeKit: Got new client connection: 5 from 192.168.100.35
>>> HomeKit: [Client 4] Closing client connection
>>> HomeKit: [Client 5] Pair Setup Step 1/3
>>> HomeKit: [Client 5] Closing client connection
and right after failing, tried with the iPad on iOS14:
>>> HomeKit: Got new client connection: 4 from 192.168.100.27
>>> HomeKit: [Client 4] Pair Setup Step 1/3
>>> HomeKit: [Client 4] Pair Setup Step 2/3
>>> HomeKit: [Client 4] Pair Setup Step 3/3
>>> HomeKit: Added pairing with FF8F5239-0D1E-401F-9801-D108619DFA94
>>> HomeKit: Configuring mDNS
mDNS announcement: Name=Garagentor md=GDOpv=1.0id=4B:18:2D:74:01:6Bc#=1s#=1ff=0sf=0ci=4 Port=5556 TTL=4500
>>> HomeKit: [Client 4] Successfully paired
>>> HomeKit: [Client 4] Closing client connection
>>> HomeKit: Got new client connection: 4 from 192.168.100.27
>>> HomeKit: [Client 4] Pair Verify Step 1/2
>>> HomeKit: [Client 4] Pair Verify Step 2/2
>>> HomeKit: [Client 4] Found pairing with FF8F5239-0D1E-401F-9801-D108619DFA94
>>> HomeKit: [Client 4] Verification successful, secure session established
>>> HomeKit: [Client 4] Get Accessories
returning current door state 'closed'.
Returning target door state 'closed'.
Notifying homekit that target door state is now 'closed'
Notifying changed 'Target Door State'
Notifying homekit that current door state is now 'closed'
Notifying changed 'Current Door State'
returning current door state 'closed'.
returning current door state 'closed'.
Returning target door state 'closed'.
>>> HomeKit: [Client 4] Update Characteristics
>>> HomeKit: [Client 4] Update Characteristics
>>> HomeKit: [Client 4] Get Characteristics
returning current door state 'closed'.
returning current door state 'closed'.
Returning target door state 'closed'.
>>> HomeKit: [Client 4] Add Pairing
>>> HomeKit: Added pairing with EAACB744-8CB3-4EC6-9DEC-E93F2C4A737B
>>> HomeKit: Got new client connection: 5 from 192.168.100.47
>>> HomeKit: [Client 5] Pair Verify Step 1/2
>>> HomeKit: [Client 5] Pair Verify Step 2/2
>>> HomeKit: [Client 5] Found pairing with FF8F5239-0D1E-401F-9801-D108619DFA94
>>> HomeKit: [Client 5] Verification successful, secure session established
>>> HomeKit: [Client 5] Get Accessories
returning current door state 'closed'.
returning current door state 'closed'.
Returning target door state 'closed'.
>>> HomeKit: [Client 5] Update Characteristics
>>> HomeKit: [Client 5] Update Characteristics
>>> HomeKit: [Client 5] Update Characteristics
>>> HomeKit: Got new client connection: 6 from 192.168.100.9
>>> HomeKit: [Client 6] Pair Verify Step 1/2
>>> HomeKit: [Client 6] Pair Verify Step 2/2
>>> HomeKit: [Client 6] Found pairing with FF8F5239-0D1E-401F-9801-D108619DFA94
>>> HomeKit: [Client 6] Verification successful, secure session established
>>> HomeKit: [Client 5] Update Characteristics
>>> HomeKit: [Client 6] Get Accessories
returning current door state 'closed'.
returning current door state 'closed'.
Returning target door state 'closed'.
>>> HomeKit: [Client 6] Update Characteristics
>>> HomeKit: [Client 6] Update Characteristics
>>> HomeKit: [Client 5] Update Characteristics
>>> HomeKit: [Client 5] Update Characteristics
>>> HomeKit: [Client 4] Update Characteristics
in my case, it was the example: https://github.com/maximkulkin/esp-homekit-demo/blob/master/examples/garage/garage.c
anyone got an answer?
@AramVartanyan what beta version are you running?
@renandw Actually my initial test was with an iPad having the first public beta that Apple released. The situation is unchanged with the current version 19A5307g. Also the error messages are visible with debug enabled. There is no issue pairing with devices having iOS 14 and than the accessory can be controlled by iOS 15 Home app.
Some tracing done on a working device and one using the esp-homekit repo shows that apple has decided to enforce a 10s timeout on each of the Pair-Setup transactions. This timeout is not part of the R1 spec (HomeKit Accessory Protocol Specification (Non-Commercial Version) Release R1) nor R2 spec (HomeKit Accessory Protocol Specification Non-Commercial Version Release R2) and even in the section 6.5 (R1) or 7.5 (R2) item 37 it says:
37. Accessories must implement a 10 second HAP procedure timeout, all HAP procedures including
Pair-Verify and Pair-Resume (with the exception of Pair-Setup) must complete within 10 seconds,
if a procedure fails to complete within the procedure timeout the accessory must drop the
security session and also drop the Bluetooth link.
This is the only reference to this concept, and it applies only to the bluetooth chapter and even then the Pair-Setup is excluded.
Having found this, can those that are doing beta testing report to Apple
that for devices reporting as R1 or R2 in their mdns messages (pv=1.0
or pv=1.1
), they should not enforce this timeout as 10s but remain with their timeouts as applied up till iOS14.
Meanwhile we will see if we can accelerate the critical step, but that might not be easy at all... Anyone with ideas how to do that is welcome to contribute ;-)
Hi, esp8266 with current wolfssl version will cross 10s border for sure on pair setup :( it takes 25 seconds approx Meanwhile, mbedtls with optimized build flags shows 12s result Yes its still out of 10s range but at-least not so much far from it.
No. 10s timeout is for each pair stage There are 3 stages, but 2 firsts are the critical.
wolfSSL takes 14s for each one, and mbedtls takes about 5s.
This could help to migrate to MbedTLS: https://github.com/apple/HomeKitADK/blob/master/PAL/Crypto/MbedTLS/HAPMbedTLS.c
Me too interested you @maximkulkin update library!
Highly appreciated if you can solve the problem. Thanks in advance Maxim 👍
Please, take a look on this topic. Your library is our salvation for many DIY projects. Thank you very much in advance.
+1☝️
Today I've successfully paired 3 examples (garage, sonoff basic and led) in the latest iOS 15 public beta. Apple released the public beta today. Don't know if this is related to the issue: https://9to5mac.com/2021/08/13/apple-home-matter-smart-home-delay/
Issue seems to be solved, but... IMO, migrating to MbedTLS library is a better solution to avoid those issues. Apple uses MbedTLS in Homekit accessory examples instead wolfSSL. If esp-homekit library uses MbedTLS, it will solve any future issue with Apple.
And MbedTLS has better performance than wolfSSL.
Dear Maxim,
I have faced an issue with pairing to Apple Home under iOS 15. It turns out that they have changed something in the pairing process with the new version.
I have noticed that right after attempt to send the payload the following error appears:
!!! HomeKit: [Client 1] Failed to write response (errno 104)
It could be a bug related to the unfinished beta, but it could be just another HAP version update.
The full log is bellow.
Regards
This is an example code, similar to the one running above: https://github.com/AramVartanyan/esp-homekit-demo/blob/master/examples/shelly1/shelly1.c
I have also tested it with a Setup ID and the result is the same.