Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot connect to accessory from iphone #80

Closed
BbIKTOP opened this issue Mar 21, 2021 · 16 comments
Closed

Cannot connect to accessory from iphone #80

BbIKTOP opened this issue Mar 21, 2021 · 16 comments

Comments

@BbIKTOP
Copy link

BbIKTOP commented Mar 21, 2021

Hi,

Found your library today and cannot get example working. Using EspHapLed8266.ino with esp12f, have following error when connecting from ios14.4.1:

........
IP address: 
172.16.5.249
Free heap: 31984
init_hap_storageFailed to read pair.dat
>>> Home Integration: hap_services added chararacteristic  0: 23 
>>> Home Integration: hap_services added chararacteristic  1: 25 
>>> Home Integration: homekit_is_paired 0
>>> HomeKit: Free heap: 30240
>>> HomeKit: Starting server
>>> HomeKit: Formatting flash at 0x200000
>>> HomeKit: storage init 1
>>> HomeKit: if r
>>> HomeKit: generating id
>>> HomeKit: Generated new accessory ID: 98:F0:04:0B:77:CB
>>> HomeKit: Generated new accessory ID: 1073699004
>>> HomeKit:  key generated
>>> HomeKit:  key saved
>>> HomeKit: Generated new accessory key
>>> HomeKit: find pairings
>>> HomeKit: Preinit pairing context
>>> HomeKit: Using user-specified password: 111-11-111
>>> HomeKit: Free heap: 23896
>>> HomeKit: Calculating public key len=384
>>> HomeKit: Calculating public key result 0
>>> HomeKit: arduino_homekit_preinit success
>>> HomeKit: Configuring mDNS
>>> HomeKit: Wifi Sleep type:2
>>> HomeKit: Set Wifi Sleep type :0
>>> HomeKit: MDNS.begin: ES-CC53, IP: 172.16.5.249
>>> HomeKit: Init server over
>>> HomeKit: WiFiServer receives a new client (current 0, max 8)
>>> HomeKit: Got new client connection: local 172.16.5.249:5556, remote 172.16.5.134:61130
>>> HomeKit: [Client 1073701396] Got client content from the cache 0
>>> HomeKit: [Client 1073701396] new client accepted
>>> HomeKit: [Client 1073701396] Pair Setup Step 1/3
>>> HomeKit: [Client 1073701396] Disconnected!
>>> HomeKit: [Client 1073701396] Closing client connection
>>> HomeKit: Free saved_preinit_pairing_context
>>> HomeKit: [Client 0] Clear the pairing context
>>> HomeKit: [Client 0] client content free
>>> HomeKit: Preinit pairing context
>>> HomeKit: Using user-specified password: 111-11-111
>>> HomeKit: Free heap: 22272
>>> HomeKit: Calculating public key len=384
>>> HomeKit: Calculating public key result 0
>>> HomeKit: arduino_homekit_preinit success
>>> HomeKit: WiFiServer receives a new client (current 0, max 8)
>>> HomeKit: Got new client connection: local 172.16.5.249:5556, remote 172.16.5.134:61131
>>> HomeKit: [Client 1073700452] Got client content from the cache 0
>>> HomeKit: [Client 1073700452] new client accepted
>>> HomeKit: [Client 1073700452] Pair Setup Step 1/3
>>> HomeKit: [Client 1073700452] Connection: close received, client will be disconnected
>>> HomeKit: [Client 1073700452] Closing client connection
>>> HomeKit: Free saved_preinit_pairing_context
>>> HomeKit: [Client 0] Clear the pairing context
>>> HomeKit: [Client 0] client content free
>>> HomeKit: Preinit pairing context
>>> HomeKit: Using user-specified password: 111-11-111
>>> HomeKit: Free heap: 21864
>>> HomeKit: Calculating public key len=384
>>> HomeKit: Calculating public key result 0
>>> HomeKit: arduino_homekit_preinit success
>>> HomeKit: WiFiServer receives a new client (current 0, max 8)
>>> HomeKit: Got new client connection: local 172.16.5.249:5556, remote 172.16.5.134:61132
>>> HomeKit: [Client 1073702980] Got client content from the cache 0
>>> HomeKit: [Client 1073702980] new client accepted
>>> HomeKit: [Client 1073702980] Pair Setup Step 1/3
>>> HomeKit: [Client 1073702980] Pair Setup Step 2/3
>>> HomeKit: [Client 1073702980] Computing SRP shared secret
>>> HomeKit: [Client 1073702980] Verifying peer's proof
>>> HomeKit: [Client 1073702980] Generating own proof
>>> HomeKit: [Client 1073702980] Disconnected!
>>> HomeKit: [Client 1073702980] Closing client connection
>>> HomeKit: Free saved_preinit_pairing_context
>>> HomeKit: [Client 0] Clear the pairing context
>>> HomeKit: [Client 0] client content free
>>> HomeKit: Preinit pairing context
>>> HomeKit: Using user-specified password: 111-11-111
>>> HomeKit: Free heap: 21736
>>> HomeKit: Calculating public key len=384
>>> HomeKit: Calculating public key result 0
>>> HomeKit: arduino_homekit_preinit success
>>> HomeKit: WiFi connected, ip: 172.16.5.249, mask: 255.255.0.0, gw: 172.16.1.1
>>> HomeKit: WiFiServer receives a new client (current 0, max 8)
>>> HomeKit: Got new client connection: local 172.16.5.249:5556, remote 172.16.5.134:61134
>>> HomeKit: [Client 1073700452] Got client content from the cache 0
>>> HomeKit: [Client 1073700452] new client accepted
>>> HomeKit: [Client 1073700452] Pair Setup Step 1/3
>>> HomeKit: [Client 1073700452] Connection: close received, client will be disconnected
>>> HomeKit: [Client 1073700452] Closing client connection
>>> HomeKit: Free saved_preinit_pairing_context
>>> HomeKit: [Client 0] Clear the pairing context
>>> HomeKit: [Client 0] client content free
>>> HomeKit: Preinit pairing context
>>> HomeKit: Using user-specified password: 111-11-111
>>> HomeKit: Free heap: 21800
>>> HomeKit: Calculating public key len=384
>>> HomeKit: Calculating public key result 0
>>> HomeKit: arduino_homekit_preinit success
>>> HomeKit: WiFiServer receives a new client (current 0, max 8)
>>> HomeKit: Got new client connection: local 172.16.5.249:5556, remote 172.16.5.134:61135
>>> HomeKit: [Client 1073700452] Got client content from the cache 0
>>> HomeKit: [Client 1073700452] new client accepted
>>> HomeKit: [Client 1073700452] Pair Setup Step 1/3
>>> HomeKit: [Client 1073700452] Pair Setup Step 2/3
>>> HomeKit: [Client 1073700452] Computing SRP shared secret
>>> HomeKit: [Client 1073700452] Verifying peer's proof
>>> HomeKit: [Client 1073700452] Generating own proof
>>> HomeKit: [Client 1073700452] Disconnected!
>>> HomeKit: [Client 1073700452] Closing client connection
>>> HomeKit: Free saved_preinit_pairing_context
>>> HomeKit: [Client 0] Clear the pairing context
>>> HomeKit: [Client 0] client content free
>>> HomeKit: Preinit pairing context
>>> HomeKit: Using user-specified password: 111-11-111
>>> HomeKit: Free heap: 21496
>>> HomeKit: Calculating public key len=384
>>> HomeKit: Calculating public key result 0
>>> HomeKit: arduino_homekit_preinit success
>>> HomeKit: WiFiServer receives a new client (current 0, max 8)
>>> HomeKit: Got new client connection: local 172.16.5.249:5556, remote 172.16.5.134:61136
>>> HomeKit: [Client 1073699156] Got client content from the cache 0
>>> HomeKit: [Client 1073699156] new client accepted
>>> HomeKit: [Client 1073699156] Pair Setup Step 1/3
>>> HomeKit: WiFiServer receives a new client (current 1, max 8)
>>> HomeKit: Got new client connection: local 172.16.5.249:5556, remote 172.16.5.134:61137
>>> HomeKit: [Client 1073700692] Got client content from the cache 1
>>> HomeKit: [Client 1073700692] new client accepted
>>> HomeKit: [Client 1073700692] Pair Setup Step 1/3
>>> HomeKit: [Client 1073700692] Refusing to pair: another pairing in progress
>>> HomeKit: [Client 1073699156] Disconnected!
>>> HomeKit: [Client 1073700692] Disconnected!
>>> HomeKit: [Client 1073699156] Closing client connection
>>> HomeKit: Free saved_preinit_pairing_context
>>> HomeKit: [Client 0] Clear the pairing context
>>> HomeKit: [Client 0] client content free
>>> HomeKit: Preinit pairing context
>>> HomeKit: Using user-specified password: 111-11-111
>>> HomeKit: Free heap: 21408
>>> HomeKit: Calculating public key len=384
>>> HomeKit: Calculating public key result 0
>>> HomeKit: arduino_homekit_preinit success
>>> HomeKit: [Client 1073700692] Closing client connection
>>> HomeKit: [Client 0] client content free

It lasts for a few minutes, then home.app on iphone says "Unable to Add Accessory Accessory is not reachable". What am I doing wrong?
Btw, is it ok that

>>> HomeKit: Calculating public key len=384
>>> HomeKit: Calculating public key result 0

Repeats each time?

@BbIKTOP
Copy link
Author

BbIKTOP commented Mar 21, 2021

Another pairing try, restarted esp, this time "/pair.dat" exists, as it has been created at the first run:

.........
IP address: 
172.16.5.249
Free heap: 31984
init_hap_storage>>> HomeKit: init_storage_ex size 0x1c1
>>> Home Integration: hap_services added chararacteristic  0: 23 
>>> Home Integration: hap_services added chararacteristic  1: 25 
>>> Home Integration: homekit_is_paired 0
>>> HomeKit: Free heap: 30240
>>> HomeKit: Starting server
>>> HomeKit: storage init 0
>>> HomeKit: Using existing accessory ID: CC:53:3D:E8:D6:85
>>> HomeKit: find pairings
>>> HomeKit: Preinit pairing context
>>> HomeKit: Using user-specified password: 111-11-111
>>> HomeKit: Free heap: 23896
>>> HomeKit: Calculating public key len=384
>>> HomeKit: Calculating public key result 0
>>> HomeKit: arduino_homekit_preinit success
>>> HomeKit: Configuring mDNS
>>> HomeKit: Wifi Sleep type:2
>>> HomeKit: Set Wifi Sleep type :0
>>> HomeKit: MDNS.begin: ES-CC53, IP: 172.16.5.249
>>> HomeKit: Init server over
>>> HomeKit: WiFiServer receives a new client (current 0, max 8)
>>> HomeKit: Got new client connection: local 172.16.5.249:5556, remote 172.16.5.134:61140
>>> HomeKit: [Client 1073701396] Got client content from the cache 0
>>> HomeKit: [Client 1073701396] new client accepted
>>> HomeKit: [Client 1073701396] Pair Setup Step 1/3
>>> HomeKit: [Client 1073701396] Disconnected!
>>> HomeKit: [Client 1073701396] Closing client connection
>>> HomeKit: Free saved_preinit_pairing_context
>>> HomeKit: [Client 0] Clear the pairing context
>>> HomeKit: [Client 0] client content free
>>> HomeKit: Preinit pairing context
>>> HomeKit: Using user-specified password: 111-11-111
>>> HomeKit: Free heap: 22144
>>> HomeKit: Calculating public key len=384
>>> HomeKit: Calculating public key result 0
>>> HomeKit: arduino_homekit_preinit success
>>> HomeKit: WiFi connected, ip: 172.16.5.249, mask: 255.255.0.0, gw: 172.16.1.1
>>> HomeKit: WiFiServer receives a new client (current 0, max 8)
>>> HomeKit: Got new client connection: local 172.16.5.249:5556, remote 172.16.5.134:61141
>>> HomeKit: [Client 1073703244] Got client content from the cache 0
>>> HomeKit: [Client 1073703244] new client accepted
>>> HomeKit: [Client 1073703244] Pair Setup Step 1/3
>>> HomeKit: [Client 1073703244] Pair Setup Step 2/3
>>> HomeKit: [Client 1073703244] Computing SRP shared secret
>>> HomeKit: [Client 1073703244] Verifying peer's proof
>>> HomeKit: [Client 1073703244] Generating own proof
>>> HomeKit: [Client 1073703244] Socket not available to write size:172,available:0
>>> HomeKit: [Client 1073703244] Attempt :0, available:0
>>> HomeKit: [Client 1073703244] Attempt :1, available:0
>>> HomeKit: [Client 1073703244] Attempt :2, available:0
>>> HomeKit: [Client 1073703244] Attempt :3, available:0
>>> HomeKit: [Client 1073703244] Attempt :4, available:0
!!! HomeKit: [Client 1073703244] socket.write, data_size=172, write_size=0
>>> HomeKit: [Client 1073703244] Disconnected!
>>> HomeKit: WiFi connected, ip: 172.16.5.249, mask: 255.255.0.0, gw: 172.16.1.1
>>> HomeKit: WiFiServer receives a new client (current 1, max 8)
>>> HomeKit: Got new client connection: local 172.16.5.249:5556, remote 172.16.5.134:61142
>>> HomeKit: [Client 1073700788] Got client content from the cache 1
>>> HomeKit: [Client 1073700788] new client accepted
>>> HomeKit: [Client 1073700788] Pair Setup Step 1/3
>>> HomeKit: [Client 1073700788] Refusing to pair: another pairing in progress
>>> HomeKit: [Client 1073700788] Disconnected!
>>> HomeKit: [Client 1073703244] Closing client connection
>>> HomeKit: Free saved_preinit_pairing_context
>>> HomeKit: [Client 0] Clear the pairing context
>>> HomeKit: [Client 0] client content free
>>> HomeKit: Preinit pairing context
>>> HomeKit: Using user-specified password: 111-11-111
>>> HomeKit: Free heap: 22464
>>> HomeKit: Calculating public key len=384
>>> HomeKit: Calculating public key result 0
>>> HomeKit: arduino_homekit_preinit success
>>> HomeKit: [Client 1073700788] Closing client connection
>>> HomeKit: [Client 0] client content free

@Yurik72
Copy link
Owner

Yurik72 commented Mar 21, 2021 via email

@BbIKTOP
Copy link
Author

BbIKTOP commented Mar 21, 2021

Maybe I did something wrong, but I just copied an example, downloaded lib and followed instructions. Could you advice me please any steps to check/fix? have no idea where to start tbh

@BbIKTOP
Copy link
Author

BbIKTOP commented Mar 21, 2021

Here, as my first try was using PIO, I made another try with freshly installed Arduino 1.8.13:

..ip:172.16.5.249,mask:255.255.0.0,gw:172.16.1.1
.
IP address: 
172.16.5.249
Free heap: 34040
init_hap_storageFailed to read pair.dat
>>> Home Integration: hap_services added chararacteristic  0: 23 
>>> Home Integration: hap_services added chararacteristic  1: 25 
>>> Home Integration: homekit_is_paired 0
>>> HomeKit: Free heap: 32056
>>> HomeKit: Starting server
>>> HomeKit: Formatting flash at 0x200000
>>> HomeKit: storage init 1
>>> HomeKit: if r
>>> HomeKit: generating id
>>> HomeKit: Generated new accessory ID: 01:57:E3:E4:30:5E
>>> HomeKit: Generated new accessory ID: 1073697436
>>> HomeKit:  key generated
>>> HomeKit:  key saved
>>> HomeKit: Generated new accessory key
>>> HomeKit: find pairings
>>> HomeKit: Preinit pairing context
>>> HomeKit: Using user-specified password: 111-11-111
>>> HomeKit: Free heap: 25376
>>> HomeKit: Calculating public key len=384
>>> HomeKit: Calculating public key result 0
pm open,type:2 0
>>> HomeKit: arduino_homekit_preinit success
>>> HomeKit: Configuring mDNS
>>> HomeKit: Wifi Sleep type:2
sleep disable
>>> HomeKit: Set Wifi Sleep type :0
>>> HomeKit: MDNS.begin: ES-0516, IP: 172.16.5.249
>>> HomeKit: Init server over
>>> HomeKit: WiFiServer receives a new client (current 0, max 8)
>>> HomeKit: Got new client connection: local 172.16.5.249:5556, remote 172.16.5.134:61245
>>> HomeKit: [Client 1073700012] Got client content from the cache 0
>>> HomeKit: [Client 1073700012] new client accepted
>>> HomeKit: [Client 1073700012] Pair Setup Step 1/3
>>> HomeKit: [Client 1073700012] Connection: close received, client will be disconnected
>>> HomeKit: [Client 1073700012] Closing client connection
>>> HomeKit: Free saved_preinit_pairing_context
>>> HomeKit: [Client 0] Clear the pairing context
>>> HomeKit: [Client 0] client content free
>>> HomeKit: Preinit pairing context
>>> HomeKit: Using user-specified password: 111-11-111
>>> HomeKit: Free heap: 22696
>>> HomeKit: Calculating public key len=384
>>> HomeKit: Calculating public key result 0
>>> HomeKit: arduino_homekit_preinit success
>>> HomeKit: WiFiServer receives a new client (current 0, max 8)
>>> HomeKit: Got new client connection: local 172.16.5.249:5556, remote 172.16.5.134:61246
>>> HomeKit: [Client 1073701508] Got client content from the cache 0
>>> HomeKit: [Client 1073701508] new client accepted
>>> HomeKit: [Client 1073701508] Pair Setup Step 1/3
>>> HomeKit: [Client 1073701508] Connection: close received, client will be disconnected
>>> HomeKit: [Client 1073701508] Closing client connection
>>> HomeKit: Free saved_preinit_pairing_context
>>> HomeKit: [Client 0] Clear the pairing context
>>> HomeKit: [Client 0] client content free
>>> HomeKit: Preinit pairing context
>>> HomeKit: Using user-specified password: 111-11-111
>>> HomeKit: Free heap: 22424
>>> HomeKit: Calculating public key len=384
>>> HomeKit: Calculating public key result 0
>>> HomeKit: arduino_homekit_preinit success
>>> HomeKit: WiFiServer receives a new client (current 0, max 8)
>>> HomeKit: Got new client connection: local 172.16.5.249:5556, remote 172.16.5.134:61247
>>> HomeKit: [Client 1073697588] Got client content from the cache 0
>>> HomeKit: [Client 1073697588] new client accepted
>>> HomeKit: [Client 1073697588] Pair Setup Step 1/3
>>> HomeKit: [Client 1073697588] Connection: close received, client will be disconnected
>>> HomeKit: [Client 1073697588] Closing client connection
>>> HomeKit: Free saved_preinit_pairing_context
>>> HomeKit: [Client 0] Clear the pairing context
>>> HomeKit: [Client 0] client content free
>>> HomeKit: Preinit pairing context
>>> HomeKit: Using user-specified password: 111-11-111
>>> HomeKit: Free heap: 22136
>>> HomeKit: Calculating public key len=384
>>> HomeKit: Calculating public key result 0
>>> HomeKit: arduino_homekit_preinit success
>>> HomeKit: WiFiServer receives a new client (current 0, max 8)
>>> HomeKit: Got new client connection: local 172.16.5.249:5556, remote 172.16.5.134:61248
>>> HomeKit: [Client 1073699204] Got client content from the cache 0
>>> HomeKit: [Client 1073699204] new client accepted
>>> HomeKit: [Client 1073699204] Pair Setup Step 1/3
>>> HomeKit: [Client 1073699204] Connection: close received, client will be disconnected
>>> HomeKit: [Client 1073699204] Closing client connection
>>> HomeKit: Free saved_preinit_pairing_context
>>> HomeKit: [Client 0] Clear the pairing context
>>> HomeKit: [Client 0] client content free
>>> HomeKit: Preinit pairing context
>>> HomeKit: Using user-specified password: 111-11-111
>>> HomeKit: Free heap: 21904
>>> HomeKit: Calculating public key len=384
>>> HomeKit: Calculating public key result 0
>>> HomeKit: arduino_homekit_preinit success
>>> HomeKit: WiFiServer receives a new client (current 0, max 8)
>>> HomeKit: Got new client connection: local 172.16.5.249:5556, remote 172.16.5.134:61249
>>> HomeKit: [Client 1073698428] Got client content from the cache 0
>>> HomeKit: [Client 1073698428] new client accepted
>>> HomeKit: [Client 1073698428] Pair Setup Step 1/3
>>> HomeKit: [Client 1073698428] Connection: close received, client will be disconnected
>>> HomeKit: [Client 1073698428] Closing client connection
>>> HomeKit: Free saved_preinit_pairing_context
>>> HomeKit: [Client 0] Clear the pairing context
>>> HomeKit: [Client 0] client content free
>>> HomeKit: Preinit pairing context
>>> HomeKit: Using user-specified password: 111-11-111
>>> HomeKit: Free heap: 21720
>>> HomeKit: Calculating public key len=384
>>> HomeKit: Calculating public key result 0
>>> HomeKit: arduino_homekit_preinit success

@BbIKTOP
Copy link
Author

BbIKTOP commented Mar 21, 2021

Looks like I found the reason:

>>> HomeKit: Got new client connection: local 172.16.5.249:5556, remote 172.16.5.134:61845
>>> HomeKit: [Client 1073701540] Got client content from the cache 0
>>> HomeKit: [Client 1073701540] new client accepted
>>> HomeKit: [Client 1073701540] Pair Setup Step 1/3
>>> HomeKit: [Client 1073701540] Pair Setup Step 2/3
>>> HomeKit: [Client 1073701540] Computing SRP shared secret
>>> HomeKit: [Client 1073701540] Verifying peer's proof
>>> HomeKit: [Client 1073701540] Generating own proof
state: 5 -> 2 (7c0)
rm 0
pm close 7
>>> HomeKit: [Client 1073701540] Disconnected!
reconnect
state: 2 -> 0 (0)
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 1
cnt 

connected with etogo.net, channel 6
dhcp client start...
ip:172.16.5.249,mask:255.255.0.0,gw:172.16.1.1
>>> HomeKit: WiFi connected, ip: 172.16.5.249, mask: 255.255.0.0, gw: 172.16.1.1
>>> HomeKit: [Client 1073701540] Closing client connection
>>> HomeKit: Free saved_preinit_pairing_context
>>> HomeKit: [Client 0] Clear the pairing context
>>> HomeKit: [Client 0] client content free
>>> HomeKit: Preinit pairing context
>>> HomeKit: Using user-specified password: 111-11-111
>>> HomeKit: Free heap: 23240
>>> HomeKit: Calculating public key len=384
>>> HomeKit: Calculating public key result 0
pm open,type:0 0
>>> HomeKit: arduino_homekit_preinit success

Looks like ESP12 Wifi disconnects on heavy load. Is it possible to fix, either on my side or in the lib, like adding "delay" to make wifi stack working, or something?
Thank you!

@Yurik72
Copy link
Owner

Yurik72 commented Mar 21, 2021 via email

@BbIKTOP
Copy link
Author

BbIKTOP commented Mar 21, 2021

I've got Unifi APs setup, did restart for AP that has this ESP connected to. The same ESP12 works fine with Espressif RTOS Homekit example right now.

@Yurik72
Copy link
Owner

Yurik72 commented Mar 21, 2021 via email

@BbIKTOP
Copy link
Author

BbIKTOP commented Mar 21, 2021

Thank you! Please tell me, if you'd need any assistance, like testing and so on.

@BbIKTOP
Copy link
Author

BbIKTOP commented Mar 22, 2021

Found it. Типа.
I suppose, the problem is that:
Arduino Core for ESP8266 is based on nonos sdk, so it is single threaded. During long calculations in the s_mp_exptmod, wifi timeout occurs and wifi restarts after that. The solution is to call yield(), which will sort wifi things out, I suppose. After a brief investigation, have added yield() in the integer.c line 3532:

  bitbuf = 0;

  for (;;) {
    yield();
    /* grab next digit as required */

$ diff integer.c integer.c.orig
3532d3531
<     yield();

And everything works so far. Every single connect works fine, I tried it about 20+ times. I cannot make a PR as wolfSSL is not in the repo. Maybe it will be a good idea to wrap it in the some #ifdef to make it called for ESP8266 only, as ESP32 is multithreaded RTOS based and does not have such a problem.

Можно ли добавить такой пачь в репу? Спасибо огромное!

Yurik72 added a commit that referenced this issue Mar 22, 2021
@Yurik72
Copy link
Owner

Yurik72 commented Mar 22, 2021

Ok, thanks for investigation, I defintelly not met with that before.
I have used yield definetelly as much as needed but not in S_MP_EXPTMOD
Your fix already integrated and commited

@BbIKTOP
Copy link
Author

BbIKTOP commented Mar 22, 2021

if (yieldNow - yieldTime > 500) is too much, change to if (yieldNow - yieldTime > 20) please

@Yurik72
Copy link
Owner

Yurik72 commented Mar 22, 2021 via email

@BbIKTOP
Copy link
Author

BbIKTOP commented Mar 22, 2021

Конечно. Я проверил - иногда работает, иногда нет. Чаще работает, но иногда сбоит, наверное от ключа зависит. Я подумал и вообще убрал проверку времени, показалось, что от нее вреда больше, поскольку каждый раз millis() вызывается, создавая ненужную нагрузку. Оставил только if(cnt++>20), пока что "полет нормальный" (ну, не считая протечек из соседней проблемы)

@mgx0
Copy link

mgx0 commented Mar 24, 2021

Hello,

where can do a change? I'm experiencing the same problem.

the line Connection: close received, client will be disconnected comes when I press "Continue" after entering the pairing code. I have tried on NodeMCU clones, ESP-12E/F and also on this

I'm currently using latest version of the library

> Executing task in folder HomeKitTest5-8266: pio device monitor <

--- Available filters and text transformations: colorize, debug, default, direct, esp8266_exception_decoder, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at http://bit.ly/pio-monitor-filters
--- Miniterm on /dev/cu.usbserial-142340  115200,8,N,1 ---
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
>>> HomeKit: Calculating public key len=384
>>> HomeKit: Calculating public key result 0
>>> HomeKit: arduino_homekit_preinit success
>>> HomeKit: Configuring mDNS
>>> HomeKit: Wifi Sleep type:2
>>> HomeKit: Set Wifi Sleep type :0
>>> HomeKit: MDNS.begin: SHT-112A, IP: 10.0.0.235
>>> homekit_mdns_init: Accessory Setup ID = YK72
>>> HomeKit: Init server over
>>> HomeKit: WiFiServer receives a new client (current 0, max 8)
>>> HomeKit: Got new client connection: local 10.0.0.235:5556, remote 10.0.0.50:55566
>>> HomeKit: [Client 1073700340] Got client content from the cache 0
>>> HomeKit: [Client 1073700340] new client accepted
>>> homekit_client_process: [Client 1073700340] Reading 126 bytes
>>> homekit_server_on_message_complete: http_parser message_complete
>>> homekit_server_on_pair_setup: Pair Setup
>>> homekit_server_on_pair_setup: Free heap: 23384
>>> tlv_debug: Got following TLV values:
>>> tlv_debug: Type 0 value (1 bytes): \x00
>>> tlv_debug: Type 6 value (1 bytes): \x01
>>> HomeKit: [Client 1073700340] Pair Setup Step 1/3
>>> homekit_server_on_pair_setup: Free heap: 23312
>>> send_tlv_response: [Client 1073700340] Sending TLV response
>>> tlv_debug: Got following TLV values:
>>> tlv_debug: Type 3 value (384 bytes): \xB2\xBA\x04BKq\xD2\xC7\x9A\xD3~\xB1Yv(\xFC\xD5\xCB\xF0\x91\xEDF\xB2\x07\x0Eq\xEE\xC4\xC0Y<\x9B\x01\xC1\xEE\xA9y\xB8w\xB8:\x8A\xA8H\xB2T\x88\xB5J&\xB4\x96a\x9B\xE4\xA2AZ@\xC3\xA9p\xBAC\xAA\xA3\x07\xB7\xAD\xCB\xD7\x11\xC7iV\xF7\xAF\xA4\xA42\xC1yE \xF1\x98_\xB8Fs))\xA39i\xD8\xFC?\x07\x19\xA5.\x0E\x054\x86UJ\xA1\x9Cg\x9D\xA6v\x11\x86>d\x035\x96␡\x1Eiv\xA31\x91d\xD0~\xF2\x8A\x14\xBF\xD1\xD8\xE81f\xA8\x0D\xD3)\xC8\x81\x13\xBB\xD0+\xAD\xCEx\x9E8\x0B\x01\xF8\x0F5\xB1\xF9\xA8|x\x0B.\x07%\x10\x97\xCB\x93\xF1\x09*\xDD\xB9>\xA9B\xB3_\xF2\x06@\xEA{\xD6#\xE0\xDEq\x83ok\x031\xC3\xC2\x1Am\xD0\x90^\x92\xD9\xB8+\xB0\xEE\\\x10\xC2\xE4\x01\x82\x82\xEBc\x01\x10\xEC\xBF3\x85qa\x1Ee\x099\x0D\x89#\x98\xE2\xF6\x9E\xB2Cy\x01\xEEe\x11@\x02\xE4\xB6\x11\xEE\x1B\xEBS\x8A\xD2\xE68\xC0e\x980\xF3\x00\x03v>$;\xBF\x97\x8C$\xDF{\xCD\x12\xB8T\x00\xB3<#\xBDd.\x92\xF1\xC00\xCE:\xAD\xD7\xBB\x98\xFE\x01pp\x93\xD6\x93\x9C\xFC\x9D\xA2\x9A\xFD\xC0\xEEkrf\xCE\x81\xC0\x1C1\xA9\xE6\xAD\xF9c\xBCM\xC7\x12e\xE6\xE5\xF8\xA4k\xEB\x9C\xEA%\xE8v\x01\xEC\x85\xC7\xB6\xC81a\x15\x07\xF3\xCD\xCD\xA4␡\xBD\xB6}\x9E\x8A:\x83/\xC2\x9C\xD1\x818\x02\xD2\xFF\xDB`\xE9D\x8F{\xF9/\xA8\xEC\xDB@
>>> tlv_debug: Type 2 value (16 bytes): \x97\xFDto\xAA\x84^\xE7\x18\xB3X\xD4\xDA\xC3\xF8\xB8
>>> tlv_debug: Type 6 value (1 bytes): \x02
>>> client_send: [Client 1073700340] send data size=513, encrypted=false
>>> client_send: [Client 1073700340] Sending payload: HTTP/1.1 200 OK\x0D\x0AContent-Type: application/pairing+tlv8\x0D\x0AContent-Length: 409\x0D\x0AConnection: keep-alive\x0D\x0A\x0D\x0A\x03\xFF\xB2\xBA\x04BKq\xD2\xC7\x9A\xD3~\xB1Yv(\xFC\xD5\xCB\xF0\x91\xEDF\xB2\x07\x0Eq\xEE\xC4\xC0Y<\x9B\x01\xC1\xEE\xA9y\xB8w\xB8:\x8A\xA8H\xB2T\x88\xB5J&\xB4\x96a\x9B\xE4\xA2AZ@\xC3\xA9p\xBAC\xAA\xA3\x07\xB7\xAD\xCB\xD7\x11\xC7iV\xF7\xAF\xA4\xA42\xC1yE \xF1\x98_\xB8Fs))\xA39i\xD8\xFC?\x07\x19\xA5.\x0E\x054\x86UJ\xA1\x9Cg\x9D\xA6v\x11\x86>d\x035\x96␡\x1Eiv\xA31\x91d\xD0~\xF2\x8A\x14\xBF\xD1\xD8\xE81f\xA8\x0D\xD3)\xC8\x81\x13\xBB\xD0+\xAD\xCEx\x9E8\x0B\x01\xF8\x0F5\xB1\xF9\xA8|x\x0B.\x07%\x10\x97\xCB\x93\xF1\x09*\xDD\xB9>\xA9B\xB3_\xF2\x06@\xEA{\xD6#\xE0\xDEq\x83ok\x031\xC3\xC2\x1Am\xD0\x90^\x92\xD9\xB8+\xB0\xEE\\\x10\xC2\xE4\x01\x82\x82\xEBc\x01\x10\xEC\xBF3\x85qa\x1Ee\x099\x0D\x89#\x98\xE2\xF6\x9E\xB2Cy\x01\xEEe\x11@\x02\xE4\xB6\x11\xEE\x1B\xEBS\x03\x81\x8A\xD2\xE68\xC0e\x980\xF3\x00\x03v>$;\xBF\x97\x8C$\xDF{\xCD\x12\xB8T\x00\xB3<#\xBDd.\x92\xF1\xC00\xCE:\xAD\xD7\xBB\x98\xFE\x01pp\x93\xD6\x93\x9C\xFC\x9D\xA2\x9A\xFD\xC0\xEEkrf\xCE\x81\xC0\x1C1\xA9\xE6\xAD\xF9c\xBCM\xC7\x12e\xE6\xE5\xF8\xA4k\xEB\x9C\xEA%\xE8v\x01\xEC\x85\xC7\xB6\xC81a\x15\x07\xF3\xCD\xCD\xA4␡\xBD\xB6}\x9E\x8A:\x83/\xC2\x9C\xD1\x818\x02\xD2\xFF\xDB`\xE9D\x8F{\xF9/\xA8\xEC\xDB@\x02\x10\x97\xFDto\xAA\x84^\xE7\x18\xB3X\xD4\xDA\xC3\xF8\xB8\x06\x01\x02
>>> homekit_server_on_pair_setup: [Client 1073700340] Server on pair setup end
>>> homekit_client_process: [Client 1073700340] Reading 536 bytes
>>> homekit_client_process: [Client 1073700340] Reading 43 bytes
>>> HomeKit: [Client 1073700340] Connection: close received, client will be disconnected
>>> HomeKit: [Client 1073700340] Closing client connection
>>> homekit_server_close_client: [Client 1073700340] The sockect is stoped
>>> HomeKit: Free saved_preinit_pairing_context
>>> HomeKit: [Client 0] Clear the pairing context
>>> HomeKit: [Client 0] client content free
>>> HomeKit: Preinit pairing context
>>> crypto_srp_new: crypto_srp_new
>>> crypto_srp_new: Initializing SRP
>>> arduino_homekit_preinit: Free heap: 25672
>>> HomeKit: Using user-specified password: 111-11-111
>>> HomeKit: Free heap: 23960
>>> HomeKit: Calculating public key len=384
>>> HomeKit: Calculating public key result 0
>>> HomeKit: arduino_homekit_preinit success
>>> HomeKit: WiFiServer receives a new client (current 0, max 8)
>>> HomeKit: Got new client connection: local 10.0.0.235:5556, remote 10.0.0.50:55568
>>> HomeKit: [Client 1073700332] Got client content from the cache 0
>>> HomeKit: [Client 1073700332] new client accepted
>>> homekit_client_process: [Client 1073700332] Reading 126 bytes
>>> homekit_server_on_message_complete: http_parser message_complete
>>> homekit_server_on_pair_setup: Pair Setup
>>> homekit_server_on_pair_setup: Free heap: 23216
>>> tlv_debug: Got following TLV values:
>>> tlv_debug: Type 0 value (1 bytes): \x00
>>> tlv_debug: Type 6 value (1 bytes): \x01
>>> HomeKit: [Client 1073700332] Pair Setup Step 1/3
>>> homekit_server_on_pair_setup: Free heap: 23144
>>> send_tlv_response: [Client 1073700332] Sending TLV response
>>> tlv_debug: Got following TLV values:
>>> tlv_debug: Type 3 value (384 bytes): \xD7\xD9\x85\xA4␡\x09\xF6)Z/\xAB\xD0Z\xD2\xD6m\x15\x18b?\x91\xFE\x99\xBC\x1B:\xC8\x87\x1A2\xED/\x1F\xAF}\xE8Y\xF1/\x0A\x05:\xA4\xBD\xBB\x08\x19\x9A)\xC3\xFEg\xE3\xDFMk\x14\xF0`\x9128\xA5\xFFa\xE9\xF9\xC4\xAB\\\x92\x96\xA5\xCD\xEE\xE0=\x07\xBD\xD6r\xAD:\x13\x14\xBF|t\xB1\x93\xF2\xD4m1\x8Fb{If\x14\x91\x03LI]\xEC\xB9\xDC~v\x19\xCF<\xBA\xF1\xBD\x8F\xA7\xEC\xF2\xE0\x18\xD4\xFB/l\xD5\xA7\x90\xA8\xB6"\xD1T\xDAa\xD3\x09k\x91\xB1\x88\x11P s\xDA\x9EU[ j \xBF{f]e\xA5\xCC\x9Ajf\xD6%w <'7.f*\xFB\x17Ve\x07I~\xAF\x02\xA5\xF0\xF0\xC7\xB6\xFB-\x99\x04m\xA31NU\xB6\xC0e\xC1\x13\xE0{]-\x13\xB4\x9BC\xD3V\x9C\x18\x86+?6\x98\xA6\xA1m\xB6$\x1BL\x8C\xBE\x04\\2\xB8\xF0\x10CE\xC7\x15\\\x19cmm\x08\x19$\xB2\x06\xFE\xD9\xD1\x80\xDF\xDBCd\xBE[>\xAE\xF3\xDC4\x82\xA6\x94\x07Cj\x9D\xE0\xD3|␡\xA9C|\x85\xEA\x96\xFC/#mbw\xBC}\\m\xAEo\xC7\xBC\xC0.\xBE\x00p\x81\xF0\xC567\x0A\xABt#{h\xFBk\xF0$\x0ELz\x81\x02\xB2\x18\xB6\xEA\xC2\x99\xF1\xEB3i\x19b\x89\x08\x98\xB9}IO\xE3=r7z\xF6\xF6e\x9B\xA4\x88\xB6P\x88U\x19l<\xF8\x87\xB6\x13\x1A\xEC\xD7X)\x96\xA8s\xBD\xDD\xCB\x9A\xC1\xE0xht\xC7\xC9B\x01\xB5\xBE\xCF\xCA
>>> tlv_debug: Type 2 value (16 bytes): \xE2D\xEA\xCE\xD5\x09\x11\x13d\xC0\xC6\x10\x9DQ\xFFY
>>> tlv_debug: Type 6 value (1 bytes): \x02
>>> client_send: [Client 1073700332] send data size=513, encrypted=false
>>> client_send: [Client 1073700332] Sending payload: HTTP/1.1 200 OK\x0D\x0AContent-Type: application/pairing+tlv8\x0D\x0AContent-Length: 409\x0D\x0AConnection: keep-alive\x0D\x0A\x0D\x0A\x03\xFF\xD7\xD9\x85\xA4␡\x09\xF6)Z/\xAB\xD0Z\xD2\xD6m\x15\x18b?\x91\xFE\x99\xBC\x1B:\xC8\x87\x1A2\xED/\x1F\xAF}\xE8Y\xF1/\x0A\x05:\xA4\xBD\xBB\x08\x19\x9A)\xC3\xFEg\xE3\xDFMk\x14\xF0`\x9128\xA5\xFFa\xE9\xF9\xC4\xAB\\\x92\x96\xA5\xCD\xEE\xE0=\x07\xBD\xD6r\xAD:\x13\x14\xBF|t\xB1\x93\xF2\xD4m1\x8Fb{If\x14\x91\x03LI]\xEC\xB9\xDC~v\x19\xCF<\xBA\xF1\xBD\x8F\xA7\xEC\xF2\xE0\x18\xD4\xFB/l\xD5\xA7\x90\xA8\xB6"\xD1T\xDAa\xD3\x09k\x91\xB1\x88\x11P s\xDA\x9EU[ j \xBF{f]e\xA5\xCC\x9Ajf\xD6%w <'7.f*\xFB\x17Ve\x07I~\xAF\x02\xA5\xF0\xF0\xC7\xB6\xFB-\x99\x04m\xA31NU\xB6\xC0e\xC1\x13\xE0{]-\x13\xB4\x9BC\xD3V\x9C\x18\x86+?6\x98\xA6\xA1m\xB6$\x1BL\x8C\xBE\x04\\2\xB8\xF0\x10CE\xC7\x15\\\x19cmm\x08\x19$\xB2\x06\xFE\xD9\xD1\x80\xDF\xDBCd\x03\x81\xBE[>\xAE\xF3\xDC4\x82\xA6\x94\x07Cj\x9D\xE0\xD3|␡\xA9C|\x85\xEA\x96\xFC/#mbw\xBC}\\m\xAEo\xC7\xBC\xC0.\xBE\x00p\x81\xF0\xC567\x0A\xABt#{h\xFBk\xF0$\x0ELz\x81\x02\xB2\x18\xB6\xEA\xC2\x99\xF1\xEB3i\x19b\x89\x08\x98\xB9}IO\xE3=r7z\xF6\xF6e\x9B\xA4\x88\xB6P\x88U\x19l<\xF8\x87\xB6\x13\x1A\xEC\xD7X)\x96\xA8s\xBD\xDD\xCB\x9A\xC1\xE0xht\xC7\xC9B\x01\xB5\xBE\xCF\xCA\x02\x10\xE2D\xEA\xCE\xD5\x09\x11\x13d\xC0\xC6\x10\x9DQ\xFFY\x06\x01\x02
>>> homekit_server_on_pair_setup: [Client 1073700332] Server on pair setup end
>>> homekit_client_process: [Client 1073700332] Reading 536 bytes
>>> homekit_client_process: [Client 1073700332] Reading 43 bytes
>>> HomeKit: [Client 1073700332] Connection: close received, client will be disconnected
>>> HomeKit: [Client 1073700332] Closing client connection
>>> homekit_server_close_client: [Client 1073700332] The sockect is stoped
>>> HomeKit: Free saved_preinit_pairing_context
>>> HomeKit: [Client 0] Clear the pairing context
>>> HomeKit: [Client 0] client content free
>>> HomeKit: Preinit pairing context
>>> crypto_srp_new: crypto_srp_new
>>> crypto_srp_new: Initializing SRP
>>> arduino_homekit_preinit: Free heap: 25360
>>> HomeKit: Using user-specified password: 111-11-111
>>> HomeKit: Free heap: 23648

@mgx0
Copy link

mgx0 commented Mar 24, 2021

I'll probably open a new issue for that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants