HomeSpan / HomeSpan

HomeKit Library for the Arduino-ESP32
MIT License
1.53k stars 146 forks source link

"No Response" after working for a while #235

Closed jpasqua closed 2 years ago

jpasqua commented 2 years ago

First of all, this library looks great and I really appreciate your efforts on it.

I've just started using the library and I am having problems that are very similar to those described in #22, but that issue is closed and I don't see a resolution.

I am using example 16 (Stateless Programmable Switches) with no modification. Hardware is an ESP32 D1 Mini. It boots, connects and works properly for a while, but eventually I see "No Response" from both the iPhone (iPhone 11 Pro Max, iOS 15.1) and Mac (27" iMac running Monterey).

I have appended an annotated log below in which I query status (s command) with various combinations of the Home app running/not running on the iPhone and Mac. Search for "[[ " to see my comments.

ets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:10100
ho 0 tail 12 room 4
load:0x40080400,len:5856
entry 0x400806a8

************************************************************
Welcome to HomeSpan!
Apple HomeKit for the Espressif ESP-32 WROOM and Arduino IDE
************************************************************

** Please ensure serial monitor is set to transmit <newlines>

Message Logs:     Level 2
Status LED:       Pin -  *** WARNING: Status LED Pin is UNDEFINED
Device Control:   Pin -  *** WARNING: Device Control Pin is UNDEFINED
Sketch Version:   n/a
HomeSpan Version: 1.4.2
Arduino-ESP Ver.: 1.0.5-rc4
ESP-IDF Version:  3.3.4
ESP32 Chip:       ESP32-D0WDQ6 Rev 1 dual-core 4MB Flash
ESP32 Board:      d1_mini32
PWM Resources:    16 channels, 8 timers, max 20-bit duty resolution
Sodium Version:   1.0.12-idf  Lib 9.4
MbedTLS Version:  mbed TLS 2.16.7
Sketch Compiled:  Jan 13 2022 14:30:14

Device Name:      HomeSpan Bridge

Configuring PushButton: Pin=23
Configuring Programmable Pushbutton: Pin=23  Index=1
Configuring PushButton: Pin=5
Configuring Programmable Pushbutton: Pin=5  Index=2

*** HomeSpan Info ***

➤ Accessory:  AID=1
   ➟ Service AccessoryInformation:  IID=1, UUID="3E"
      ⇨ Characteristic Name("Bridge #1"):  IID=2, UUID="23"
      ⇨ Characteristic Manufacturer("HomeSpan"):  IID=3, UUID="20"
      ⇨ Characteristic SerialNumber("123-ABC"):  IID=4, UUID="30"
      ⇨ Characteristic Model("HS Bridge"):  IID=5, UUID="21"
      ⇨ Characteristic FirmwareRevision("0.9"):  IID=6, UUID="52"
      ⇨ Characteristic Identify(0):  IID=7, UUID="14"
   ➟ Service HAPProtocolInformation:  IID=8, UUID="A2"
      ⇨ Characteristic Version("1.1.0"):  IID=9, UUID="37"
➤ Accessory:  AID=2
   ➟ Service AccessoryInformation:  IID=1, UUID="3E"
      ⇨ Characteristic Name("PushButton Switches"):  IID=2, UUID="23"
      ⇨ Characteristic Manufacturer("HomeSpan"):  IID=3, UUID="20"
      ⇨ Characteristic SerialNumber("123-ABC"):  IID=4, UUID="30"
      ⇨ Characteristic Model("Prog Switches"):  IID=5, UUID="21"
      ⇨ Characteristic FirmwareRevision("0.9"):  IID=6, UUID="52"
      ⇨ Characteristic Identify(0):  IID=7, UUID="14"
   ➟ Service StatelessProgrammableSwitch:  IID=8, UUID="89"
      ⇨ Characteristic ProgrammableSwitchEvent(0):  IID=9, UUID="73", Range=[0,2]
      ⇨ Characteristic ServiceLabelIndex(1):  IID=10, UUID="CB", Range=[1,255]
      ▼ SpanButton: Pin=23, Single=5ms, Double=200ms, Long=2000ms
   ➟ Service StatelessProgrammableSwitch:  IID=11, UUID="89"
      ⇨ Characteristic ProgrammableSwitchEvent(0):  IID=12, UUID="73", Range=[0,2]
      ⇨ Characteristic ServiceLabelIndex(2):  IID=13, UUID="CB", Range=[1,255]
      ▼ SpanButton: Pin=5, Single=5ms, Double=200ms, Long=2000ms

Range Check: No Warnings

Configured as Bridge: YES

Service                         UUID         AID  IID  Update  Loop  Button  Linked Services
------------------------------  ----  ----------  ---  ------  ----  ------  ---------------
AccessoryInformation              3E           1    1     YES    NO      NO  -
HAPProtocolInformation            A2           1    8      NO    NO      NO  -
AccessoryInformation              3E           2    1     YES    NO      NO  -
StatelessProgrammableSwitch       89           2    8      NO    NO     YES  -
StatelessProgrammableSwitch       89           2   11      NO    NO     YES  -

*** End Info ***

Accessory ID:      02:4F:69:91:59:C2                               LTPK: 28BE7F68DACC96DB4AE828ECA8308E29E3F36EE5221D216305DF9F06D4ACCBB4
Paired Controller: 2E198672-45E8-4CFA-83BD-73D0E3353799   (admin)  LTPK: DF1327319731F9DB2EF2E6CB42EB867D83A8BF7041AB334F7C4521502CF44C2A

Accessory configuration number: 1

HomeSpan Bridge is READY!

Trying to connect to NoRoom.  Waiting 1 second(s) for response...
Successfully connected to NoRoom! IP Address: 192.168.1.122

Starting MDNS...

HostName:      HomeSpan-024F699159C2.local:80
Display Name:  HomeSpan Bridge
Model Name:    HomeSpan-ESP32
Setup ID:      HSPN

Starting Web (HTTP) Server supporting up to 8 simultaneous connections...

Found button press on pin: 5  type: SINGLE
Found button press on pin: 23  type: SINGLE
Found button press on pin: 23  type: SINGLE
Found button press on pin: 5  type: LONG
Found button press on pin: 23  type: LONG

[[ With no HomeKit app running ]]

*** HomeSpan Status ***

IP Address:        192.168.1.122

Accessory ID:      02:4F:69:91:59:C2                               LTPK: 28BE7F68DACC96DB4AE828ECA8308E29E3F36EE5221D216305DF9F06D4ACCBB4
Paired Controller: 2E198672-45E8-4CFA-83BD-73D0E3353799   (admin)  LTPK: DF1327319731F9DB2EF2E6CB42EB867D83A8BF7041AB334F7C4521502CF44C2A

Connection #0 (unconnected)
Connection #1 (unconnected)
Connection #2 (unconnected)
Connection #3 (unconnected)
Connection #4 (unconnected)
Connection #5 (unconnected)
Connection #6 (unconnected)
Connection #7 (unconnected)

*** End Status ***

*** HomeSpan Status ***

IP Address:        192.168.1.122

Accessory ID:      02:4F:69:91:59:C2                               LTPK: 28BE7F68DACC96DB4AE828ECA8308E29E3F36EE5221D216305DF9F06D4ACCBB4
Paired Controller: 2E198672-45E8-4CFA-83BD-73D0E3353799   (admin)  LTPK: DF1327319731F9DB2EF2E6CB42EB867D83A8BF7041AB334F7C4521502CF44C2A

Connection #0 (unconnected)
Connection #1 (unconnected)
Connection #2 (unconnected)
Connection #3 (unconnected)
Connection #4 (unconnected)
Connection #5 (unconnected)
Connection #6 (unconnected)
Connection #7 (unconnected)

*** End Status ***

=======================================
** Client #0 Connected: (51 sec) 192.168.1.119 on Socket 2/10

<<<<<<<<< 192.168.1.119 <<<<<<<<<
POST /pair-verify HTTP/1.1
Host: HomeSpan\032Bridge._hap._tcp.local
Content-Length: 37
Content-Type: application/pairing+tlv8
------------ END BODY! ------------
STATE(1) 01
PUBKEY(32) 0EF889098746E4EA27070E6DB0B35ECEC992A2894DA540D42BC4E32CC4714436
------------ END TLVS! ------------
In Pair Verify #0 (192.168.1.119)...Found <M1>
------- ENCRYPTING SUB-TLVS -------
SIGNATURE(64) 0F5A8121BF11F56C6FC1DFA5176635CFBBB07055E9FA55587AE0A44F11F94006A4337A866C627C7439DA78B60C2BFC926DC49213454F4DCC792F12C36537D304
IDENTIFIER(17) 30323A34463A36393A39313A35393A4332
---------- END SUB-TLVS! ----------

>>>>>>>>>> 192.168.1.119 >>>>>>>>>>
HTTP/1.1 200 OK
Content-Type: application/pairing+tlv8
Content-Length: 140

STATE(1) 02
PUBKEY(32) EEC90B110B956F7B38B9D512572F7BA73072364BC59DF4155DF0D5113D5A2C73
ENC.DATA(101) DE694A5FD91A27E0D216A5C1D64775C5B589B5D5D3433A294B9E87E21F11CEB421D1E5645D20D4AF0A2619D73971649FC7BA1DEE91CCBE8414FECCF8E65D5232FCC9EF437A7383C27F4F0E1CD1AAB7AD6F1E3498C7F222F367CF5B276B4E8E41EDC547B82C
------------ SENT! --------------

<<<<<<<<< 192.168.1.119 <<<<<<<<<
POST /pair-verify HTTP/1.1
Host: HomeSpan\032Bridge._hap._tcp.local
Content-Length: 125
Content-Type: application/pairing+tlv8
------------ END BODY! ------------
STATE(1) 03
ENC.DATA(120) A52BC53EB6788534B453B7C048166D187E8423B349B315DDEED3FDD450EBEA375B819FF3021266901DD368BA003B721B02182ECE48CD7CA25AFD5E3A0AB21FAB1163BF2D908855FEFEB273681BE21324961DA80645D88A117C44329F690923E4518681CA72D1DBCF4BB065DD57B22C7EED2389BE4E6ABEFC
------------ END TLVS! ------------
In Pair Verify #0 (192.168.1.119)...Found <M3>
SIGNATURE(64) 400390C716C0007B174722AB4F10581A4DE071F2A7CE7337492A6D2382EEA14A21D7C6515C40F863EB19E6D74F760B7ECE604B92A33CD0E5AD7E17FCF67F880F
IDENTIFIER(36) 32453139383637322D343545382D344346412D383342442D373344304533333533373939
------- END DECRYPTED TLVS! -------
Found Controller: 2E198672-45E8-4CFA-83BD-73D0E3353799 (admin)

>>>>>>>>>> 192.168.1.119 >>>>>>>>>>
HTTP/1.1 200 OK
Content-Type: application/pairing+tlv8
Content-Length: 3

STATE(1) 04
------------ SENT! --------------

*** SESSION VERIFICATION COMPLETE *** 

<<<< #### 192.168.1.119 #### <<<<
GET /accessories HTTP/1.1
Host: HomeSpan\032Bridge._hap._tcp.local
------------ END BODY! ------------
In Get Accessories #0 (192.168.1.119)...

>>>>>>>>>> 192.168.1.119 >>>>>>>>>>
HTTP/1.1 200 OK
Content-Type: application/hap+json
Content-Length: 1474

{"accessories":[{"aid":1,"services":[{"iid":1,"type":"3E","characteristics":[{"iid":2,"type":"23","value":"Bridge #1","format":"string","perms":["pr"]},{"iid":3,"type":"20","value":"HomeSpan","format":"string","perms":["pr"]},{"iid":4,"type":"30","value":"123-ABC","format":"string","perms":["pr"]},{"iid":5,"type":"21","value":"HS Bridge","format":"string","perms":["pr"]},{"iid":6,"type":"52","value":"0.9","format":"string","perms":["pr"]},{"iid":7,"type":"14","format":"bool","perms":["pw"]}]},{"iid":8,"type":"A2","characteristics":[{"iid":9,"type":"37","value":"1.1.0","format":"string","perms":["pr"]}]}]},{"aid":2,"services":[{"iid":1,"type":"3E","characteristics":[{"iid":2,"type":"23","value":"PushButton Switches","format":"string","perms":["pr"]},{"iid":3,"type":"20","value":"HomeSpan","format":"string","perms":["pr"]},{"iid":4,"type":"30","value":"123-ABC","format":"string","perms":["pr"]},{"iid":5,"type":"21","value":"Prog Switches","format":"string","perms":["pr"]},{"iid":6,"type":"52","value":"0.9","format":"string","perms":["pr"]},{"iid":7,"type":"14","format":"bool","perms":["pw"]}]},{"iid":8,"type":"89","characteristics":[{"iid":9,"type":"73","value":null,"format":"uint8","perms":["pr","ev",]},{"iid":10,"type":"CB","value":1,"format":"uint8","perms":["pr"]}]},{"iid":11,"type":"89","characteristics":[{"iid":12,"type":"73","value":null,"format":"uint8","perms":["pr","ev",]},{"iid":13,"type":"CB","value":2,"format":"uint8","perms":["pr"]}]}]}]}
-------- SENT ENCRYPTED! --------

<<<< #### 192.168.1.119 #### <<<<
GET /characteristics?id=2.10,2.13 HTTP/1.1
Host: HomeSpan\032Bridge._hap._tcp.local
------------ END BODY! ------------
In Get Characteristics #0 (192.168.1.119)...

>>>>>>>>>> 192.168.1.119 >>>>>>>>>>
HTTP/1.1 200 OK
Content-Type: application/hap+json
Content-Length: 79

{"characteristics":[{"iid":10,"value":1,"aid":2},{"iid":13,"value":2,"aid":2}]}
-------- SENT ENCRYPTED! --------

<<<< #### 192.168.1.119 #### <<<<
PUT /characteristics HTTP/1.1
Host: HomeSpan\032Bridge._hap._tcp.local
Content-Length: 78
Content-Type: application/hap+json
------------ END BODY! ------------
{"characteristics":[{"aid":2,"iid":9,"ev":true},{"aid":2,"iid":12,"ev":true}]}
------------ END JSON! ------------
In Put Characteristics #0 (192.168.1.119)...
Notification Request for aid=2 iid=9: true
Notification Request for aid=2 iid=12: true

>>>>>>>>>> 192.168.1.119 >>>>>>>>>>
HTTP/1.1 204 No Content

-------- SENT ENCRYPTED! --------

[[ With Home App running on the iPhone ]]

*** HomeSpan Status ***

IP Address:        192.168.1.122

Accessory ID:      02:4F:69:91:59:C2                               LTPK: 28BE7F68DACC96DB4AE828ECA8308E29E3F36EE5221D216305DF9F06D4ACCBB4
Paired Controller: 2E198672-45E8-4CFA-83BD-73D0E3353799   (admin)  LTPK: DF1327319731F9DB2EF2E6CB42EB867D83A8BF7041AB334F7C4521502CF44C2A

Connection #0 192.168.1.119 on Socket 2/10  ID=2E198672-45E8-4CFA-83BD-73D0E3353799   (admin)
Connection #1 (unconnected)
Connection #2 (unconnected)
Connection #3 (unconnected)
Connection #4 (unconnected)
Connection #5 (unconnected)
Connection #6 (unconnected)
Connection #7 (unconnected)

*** End Status ***

=======================================
** Client #1 Connected: (60 sec) 192.168.1.143 on Socket 3/10

<<<<<<<<< 192.168.1.143 <<<<<<<<<
POST /pair-verify HTTP/1.1
Host: HomeSpan\032Bridge._hap._tcp.local
Content-Length: 37
Content-Type: application/pairing+tlv8
------------ END BODY! ------------
STATE(1) 01
PUBKEY(32) A5C62FCBECBC2C598BA076F0CB05C1F66088CE8E23FE04960FD483350782CA68
------------ END TLVS! ------------
In Pair Verify #1 (192.168.1.143)...Found <M1>
------- ENCRYPTING SUB-TLVS -------
SIGNATURE(64) 2493021CF4C840AAD55716DC8D04F13AAFF0EB10A7B886E9BA751E9BE0343011C3F253C0F759B228DA523DD3383802CE94BDE7157991F174AF2ED2B1C82F0E01
IDENTIFIER(17) 30323A34463A36393A39313A35393A4332
---------- END SUB-TLVS! ----------

>>>>>>>>>> 192.168.1.143 >>>>>>>>>>
HTTP/1.1 200 OK
Content-Type: application/pairing+tlv8
Content-Length: 140

STATE(1) 02
PUBKEY(32) 16C051AE6BE997384DB0E83BB76C8BEF8FF424790805D5119AFCA1B045EE087A
ENC.DATA(101) 6C7C6631B8A3612A71F3A2A99704BB18F7623F5D8E64048AD2AED34FD0FFE699A4683EF9D5EF57338C571FF90970C9528D9CB1EA1C617EC6C192C0E29B617ADE5717D1D59657B1D0848A61F1DF8F6A42D85186B0D064A58F58B65FF93DAE3A39718E62B4F7
------------ SENT! --------------

<<<<<<<<< 192.168.1.143 <<<<<<<<<
POST /pair-verify HTTP/1.1
Host: HomeSpan\032Bridge._hap._tcp.local
Content-Length: 125
Content-Type: application/pairing+tlv8
------------ END BODY! ------------
STATE(1) 03
ENC.DATA(120) 969EC6E07E1B7056D061E15DCE9CA96E6E2096D4A1120B1E6500D910A470A2AA8F10A9760F834673CD8F212EBEA4DF700288EF4738CDAD46457574837CA21456C375712EC599690F5325D3666B665E2489D083623F9C40048927229138F4B43F7BD88224D8BEA16698AEF6A1A7B6F575A6DD6E14EDE2C5FB
------------ END TLVS! ------------
In Pair Verify #1 (192.168.1.143)...Found <M3>
SIGNATURE(64) DA2D5FF656A5DD838B346B97DA6433E82A7E41AB370F0362F17924C6EC06A6EBF61DEE244437C3D08E8E20B35F7F1BE6F0CEB9BD04B7A26163ECB7E89046CD06
IDENTIFIER(36) 32453139383637322D343545382D344346412D383342442D373344304533333533373939
------- END DECRYPTED TLVS! -------
Found Controller: 2E198672-45E8-4CFA-83BD-73D0E3353799 (admin)

>>>>>>>>>> 192.168.1.143 >>>>>>>>>>
HTTP/1.1 200 OK
Content-Type: application/pairing+tlv8
Content-Length: 3

STATE(1) 04
------------ SENT! --------------

*** SESSION VERIFICATION COMPLETE *** 

<<<< #### 192.168.1.143 #### <<<<
GET /accessories HTTP/1.1
Host: HomeSpan\032Bridge._hap._tcp.local
------------ END BODY! ------------
In Get Accessories #1 (192.168.1.143)...

>>>>>>>>>> 192.168.1.143 >>>>>>>>>>
HTTP/1.1 200 OK
Content-Type: application/hap+json
Content-Length: 1474

{"accessories":[{"aid":1,"services":[{"iid":1,"type":"3E","characteristics":[{"iid":2,"type":"23","value":"Bridge #1","format":"string","perms":["pr"]},{"iid":3,"type":"20","value":"HomeSpan","format":"string","perms":["pr"]},{"iid":4,"type":"30","value":"123-ABC","format":"string","perms":["pr"]},{"iid":5,"type":"21","value":"HS Bridge","format":"string","perms":["pr"]},{"iid":6,"type":"52","value":"0.9","format":"string","perms":["pr"]},{"iid":7,"type":"14","format":"bool","perms":["pw"]}]},{"iid":8,"type":"A2","characteristics":[{"iid":9,"type":"37","value":"1.1.0","format":"string","perms":["pr"]}]}]},{"aid":2,"services":[{"iid":1,"type":"3E","characteristics":[{"iid":2,"type":"23","value":"PushButton Switches","format":"string","perms":["pr"]},{"iid":3,"type":"20","value":"HomeSpan","format":"string","perms":["pr"]},{"iid":4,"type":"30","value":"123-ABC","format":"string","perms":["pr"]},{"iid":5,"type":"21","value":"Prog Switches","format":"string","perms":["pr"]},{"iid":6,"type":"52","value":"0.9","format":"string","perms":["pr"]},{"iid":7,"type":"14","format":"bool","perms":["pw"]}]},{"iid":8,"type":"89","characteristics":[{"iid":9,"type":"73","value":null,"format":"uint8","perms":["pr","ev",]},{"iid":10,"type":"CB","value":1,"format":"uint8","perms":["pr"]}]},{"iid":11,"type":"89","characteristics":[{"iid":12,"type":"73","value":null,"format":"uint8","perms":["pr","ev",]},{"iid":13,"type":"CB","value":2,"format":"uint8","perms":["pr"]}]}]}]}
-------- SENT ENCRYPTED! --------

<<<< #### 192.168.1.143 #### <<<<
PUT /characteristics HTTP/1.1
Host: HomeSpan\032Bridge._hap._tcp.local
Content-Length: 78
Content-Type: application/hap+json
------------ END BODY! ------------
{"characteristics":[{"aid":2,"iid":9,"ev":true},{"aid":2,"iid":12,"ev":true}]}
------------ END JSON! ------------
In Put Characteristics #1 (192.168.1.143)...
Notification Request for aid=2 iid=9: true
Notification Request for aid=2 iid=12: true

>>>>>>>>>> 192.168.1.143 >>>>>>>>>>
HTTP/1.1 204 No Content

-------- SENT ENCRYPTED! --------

<<<< #### 192.168.1.143 #### <<<<
PUT /characteristics HTTP/1.1
Host: HomeSpan\032Bridge._hap._tcp.local
Content-Length: 78
Content-Type: application/hap+json
------------ END BODY! ------------
{"characteristics":[{"aid":2,"iid":9,"ev":true},{"aid":2,"iid":12,"ev":true}]}
------------ END JSON! ------------
In Put Characteristics #1 (192.168.1.143)...
Notification Request for aid=2 iid=9: true
Notification Request for aid=2 iid=12: true

>>>>>>>>>> 192.168.1.143 >>>>>>>>>>
HTTP/1.1 204 No Content

-------- SENT ENCRYPTED! --------

<<<< #### 192.168.1.143 #### <<<<
GET /characteristics?id=2.10,2.13 HTTP/1.1
Host: HomeSpan\032Bridge._hap._tcp.local
------------ END BODY! ------------
In Get Characteristics #1 (192.168.1.143)...

>>>>>>>>>> 192.168.1.143 >>>>>>>>>>
HTTP/1.1 200 OK
Content-Type: application/hap+json
Content-Length: 79

{"characteristics":[{"iid":10,"value":1,"aid":2},{"iid":13,"value":2,"aid":2}]}
-------- SENT ENCRYPTED! --------

[[ With Home App running on the iPhone and iMac ]]

*** HomeSpan Status ***

IP Address:        192.168.1.122

Accessory ID:      02:4F:69:91:59:C2                               LTPK: 28BE7F68DACC96DB4AE828ECA8308E29E3F36EE5221D216305DF9F06D4ACCBB4
Paired Controller: 2E198672-45E8-4CFA-83BD-73D0E3353799   (admin)  LTPK: DF1327319731F9DB2EF2E6CB42EB867D83A8BF7041AB334F7C4521502CF44C2A

Connection #0 192.168.1.119 on Socket 2/10  ID=2E198672-45E8-4CFA-83BD-73D0E3353799   (admin)
Connection #1 192.168.1.143 on Socket 3/10  ID=2E198672-45E8-4CFA-83BD-73D0E3353799   (admin)
Connection #2 (unconnected)
Connection #3 (unconnected)
Connection #4 (unconnected)
Connection #5 (unconnected)
Connection #6 (unconnected)
Connection #7 (unconnected)

*** End Status ***

<<<< #### 192.168.1.143 #### <<<<
GET /characteristics?id=2.10,2.13 HTTP/1.1
Host: HomeSpan\032Bridge._hap._tcp.local
------------ END BODY! ------------
In Get Characteristics #1 (192.168.1.143)...

>>>>>>>>>> 192.168.1.143 >>>>>>>>>>
HTTP/1.1 200 OK
Content-Type: application/hap+json
Content-Length: 79

{"characteristics":[{"iid":10,"value":1,"aid":2},{"iid":13,"value":2,"aid":2}]}
-------- SENT ENCRYPTED! --------

[[ With Home App running on the iPhone and iMac ]]

*** HomeSpan Status ***

IP Address:        192.168.1.122

Accessory ID:      02:4F:69:91:59:C2                               LTPK: 28BE7F68DACC96DB4AE828ECA8308E29E3F36EE5221D216305DF9F06D4ACCBB4
Paired Controller: 2E198672-45E8-4CFA-83BD-73D0E3353799   (admin)  LTPK: DF1327319731F9DB2EF2E6CB42EB867D83A8BF7041AB334F7C4521502CF44C2A

Connection #0 192.168.1.119 on Socket 2/10  ID=2E198672-45E8-4CFA-83BD-73D0E3353799   (admin)
Connection #1 192.168.1.143 on Socket 3/10  ID=2E198672-45E8-4CFA-83BD-73D0E3353799   (admin)
Connection #2 (unconnected)
Connection #3 (unconnected)
Connection #4 (unconnected)
Connection #5 (unconnected)
Connection #6 (unconnected)
Connection #7 (unconnected)

*** End Status ***

[[ Force-quit Home app on the iPhone ]]
[[ With Home App running on the iMac only ]]

*** HomeSpan Status ***

IP Address:        192.168.1.122

Accessory ID:      02:4F:69:91:59:C2                               LTPK: 28BE7F68DACC96DB4AE828ECA8308E29E3F36EE5221D216305DF9F06D4ACCBB4
Paired Controller: 2E198672-45E8-4CFA-83BD-73D0E3353799   (admin)  LTPK: DF1327319731F9DB2EF2E6CB42EB867D83A8BF7041AB334F7C4521502CF44C2A

Connection #0 192.168.1.119 on Socket 2/10  ID=2E198672-45E8-4CFA-83BD-73D0E3353799   (admin)
Connection #1 192.168.1.143 on Socket 3/10  ID=2E198672-45E8-4CFA-83BD-73D0E3353799   (admin)
Connection #2 (unconnected)
Connection #3 (unconnected)
Connection #4 (unconnected)
Connection #5 (unconnected)
Connection #6 (unconnected)
Connection #7 (unconnected)

*** End Status ***

[[ With Home App running on the iMac only ]]

*** HomeSpan Status ***

IP Address:        192.168.1.122

Accessory ID:      02:4F:69:91:59:C2                               LTPK: 28BE7F68DACC96DB4AE828ECA8308E29E3F36EE5221D216305DF9F06D4ACCBB4
Paired Controller: 2E198672-45E8-4CFA-83BD-73D0E3353799   (admin)  LTPK: DF1327319731F9DB2EF2E6CB42EB867D83A8BF7041AB334F7C4521502CF44C2A

Connection #0 192.168.1.119 on Socket 2/10  ID=2E198672-45E8-4CFA-83BD-73D0E3353799   (admin)
Connection #1 192.168.1.143 on Socket 3/10  ID=2E198672-45E8-4CFA-83BD-73D0E3353799   (admin)
Connection #2 (unconnected)
Connection #3 (unconnected)
Connection #4 (unconnected)
Connection #5 (unconnected)
Connection #6 (unconnected)
Connection #7 (unconnected)

*** End Status ***

[[ With Home App running on the iMac only ]]

*** HomeSpan Status ***

IP Address:        192.168.1.122

Accessory ID:      02:4F:69:91:59:C2                               LTPK: 28BE7F68DACC96DB4AE828ECA8308E29E3F36EE5221D216305DF9F06D4ACCBB4
Paired Controller: 2E198672-45E8-4CFA-83BD-73D0E3353799   (admin)  LTPK: DF1327319731F9DB2EF2E6CB42EB867D83A8BF7041AB334F7C4521502CF44C2A

Connection #0 (unconnected)
Connection #1 192.168.1.143 on Socket 3/10  ID=2E198672-45E8-4CFA-83BD-73D0E3353799   (admin)
Connection #2 (unconnected)
Connection #3 (unconnected)
Connection #4 (unconnected)
Connection #5 (unconnected)
Connection #6 (unconnected)
Connection #7 (unconnected)

*** End Status ***

[[ Quit the Home App on the Mac ]]
[[ With Home App not running anywhere ]]

*** HomeSpan Status ***

IP Address:        192.168.1.122

Accessory ID:      02:4F:69:91:59:C2                               LTPK: 28BE7F68DACC96DB4AE828ECA8308E29E3F36EE5221D216305DF9F06D4ACCBB4
Paired Controller: 2E198672-45E8-4CFA-83BD-73D0E3353799   (admin)  LTPK: DF1327319731F9DB2EF2E6CB42EB867D83A8BF7041AB334F7C4521502CF44C2A

Connection #0 (unconnected)
Connection #1 (unconnected)
Connection #2 (unconnected)
Connection #3 (unconnected)
Connection #4 (unconnected)
Connection #5 (unconnected)
Connection #6 (unconnected)
Connection #7 (unconnected)

*** End Status ***

[[ Tried running Home App on iPhone and iMac, but both show "No Response" ]]

*** HomeSpan Status ***

IP Address:        192.168.1.122

Accessory ID:      02:4F:69:91:59:C2                               LTPK: 28BE7F68DACC96DB4AE828ECA8308E29E3F36EE5221D216305DF9F06D4ACCBB4
Paired Controller: 2E198672-45E8-4CFA-83BD-73D0E3353799   (admin)  LTPK: DF1327319731F9DB2EF2E6CB42EB867D83A8BF7041AB334F7C4521502CF44C2A

Connection #0 (unconnected)
Connection #1 (unconnected)
Connection #2 (unconnected)
Connection #3 (unconnected)
Connection #4 (unconnected)
Connection #5 (unconnected)
Connection #6 (unconnected)
Connection #7 (unconnected)

*** End Status ***
HomeSpan commented 2 years ago

Were you able to resolve this? Connection issues like this are unfortunately very difficult to debug since the symptom is usually that the iPhone (or iMac, etc.) appears not to be trying to connect to HomeSpan at all, as opposed to HomeSpan failing upon receiving a connection.

Others with this type of issue have reported various solutions that usually involve settings on their router, or an update to their router logic. This includes router configurations to ensure cross-communication between 2.4GHz and 5GHz bands (if you have a dual-band router) since the ESP32 operates on 2.4GHz only, and the iPhone can operate on both. Do you have any other commercial HomeKit devices?

HomeSpan commented 2 years ago

Also, can you also try one of the other examples (such as the lightbulb). Stateless Programmable Switches are unique services since there are no controls on the iPhone to operate the devices. It's the device that triggers operations in HomeKit (this may require having an Apple device that can be used as a HomeKit Hub).

aLAN-LDZ commented 2 years ago

Hey, I have the same problem - after work for some time - "The device does not answer" - in the Home application. I do not know if it can somehow save logs? My device works without connecting to USB. I can not deal with it, the code is not complicated. Other original devices do not have these problems

HomeSpan commented 2 years ago

Can you try the following test. When the device is no longer responding, open your browser and try to connect. You should be able to simple enter the full name of the host (with the .local suffix) reported in the Serial Monitor when the device first connects to WiFi. If you've not changed any of the defaults, the host name should look something like this: HomeSpan-83BA5A1FFBA0.local:80, where the 6-byte code is randomly generated and will be specific to your device.

If the browser can connect it should immediately return with a blank page. If the device is also connected via USB and you set the log level to L2 in the Serial Monitor you should be able to see the connection attempt, along with an error message indicating the URL was not found (which is fine - we are only testing the availability of a connection)

If the browser can't connect, the browser should hang while waiting for a connection, though may time-out after some period of time (maybe a minute or more). Also. the Serial monitor will not show any activity since HomeSpan will not have received an inbound connection.

If a connection is possible with the browser even though the Home App won't connect, this indicates there is a problem specific to the interaction between HomeSpan and the Home App. If a connection cannot be made with the browser, then the issue is not necessarily HomeKit-related, but is more a general WiFi/connectivity issue.

HomeSpan commented 2 years ago

I think I may have stumbled onto the potential issue. Some of my devices occasionally drop out, but always come back after 30 seconds or so. Recently, I noticed that when one drops out, others do as well. This is rather odd since the devices are all running different versions of the software and were started at different times.

The common cause seems to MDNS broadcasting. When I see a device drop out, I can still connect to it via the web using its IP address (per above). But it does not appear in a discovery of MDNS broadcast which HomeKit requires. In other words, if the Home App does not see an MDNS broadcast, it does not even try to connect the device. Since HomeKit uses a variety of custom tags in the MDNS broadcast, this is not simply a matter of resolving the hostname - all the MDNS tags need to be broadcast for HomeKit to operate.

The fact that multi devices drop out for brief periods at the same time suggests that my router is either not caching the MDNS info correctly, or it is blocking new MDNS requests, or something like that. Also, all devices seems to come back on line together after 30 seconds (MDNS broadcasts all start working again).

Some Googling shows this is not an uncommon issue - others have reported similar behavior with MDNS that is unrelated to HomeKit. I will continue researching to see if there is a solution.

jpasqua commented 2 years ago

Sorry for the late response - for some reason I didn’t get a notification that there were responses to the issue. I will check the mdns vs. direct IP connection later today and report back. Thank you for investigating.

jpasqua commented 2 years ago

UPDATE: Of course now I can't get it to fail! It has been running since yesterday and when I tried connecting to it again this morning, it was still visible. Needless to say, I can also connect via the web. It's not immediately obvious to me that there is anything different in my network. I will continue to investigate.

aLAN-LDZ commented 2 years ago

a little pity that we have such a problem - I wanted to do with this library a controller for underfloor heating but in this case I have to pause :(

HomeSpan commented 2 years ago

@jpasqua, sorry for not noticing this before, but according to the log file you posted, though you are using the latest version of HomeSpan (1.4.2), you have a very outdated version of the Arduino-ESP32 board manager (1.0.5-rc4). The latest version is 2.0.2 and there have been a number of improvements related to connectivity (including MDNS). You may want to update to the latest version of the board manager and see if that helps address some of the connectivity issues.

jpasqua commented 2 years ago

@homespan, I am planning to do so, but once I cut over to the newer version i have a lot of retesting of other projects to do to ensure that nothing breaks. As a result I've been procrastinating, but I will do it this week.

jpasqua commented 2 years ago

OK, it stopped responding again today and as you requested, I tried hitting the web interface directly. It did respond to that as you can see below. I checked status, hit web interface, and then checked status again twice.

I will upgrade to ESP32 v2.0.2 and try again. However, given that it is intermittent I may not be able to report back with any clarity for a while (unless it drops right away).

*** HomeSpan Status ***

IP Address:        192.168.1.122

Accessory ID:      02:4F:69:91:59:C2                               LTPK: 28BE7F68DACC96DB4AE828ECA8308E29E3F36EE5221D216305DF9F06D4ACCBB4
Paired Controller: 2E198672-45E8-4CFA-83BD-73D0E3353799   (admin)  LTPK: DF1327319731F9DB2EF2E6CB42EB867D83A8BF7041AB334F7C4521502CF44C2A

Connection #0 (unconnected)
Connection #1 (unconnected)
Connection #2 (unconnected)
Connection #3 (unconnected)
Connection #4 (unconnected)
Connection #5 (unconnected)
Connection #6 (unconnected)
Connection #7 (unconnected)

*** End Status ***
*** ERROR:  Bad GET request - URL not found

*** HomeSpan Status ***

IP Address:        192.168.1.122

Accessory ID:      02:4F:69:91:59:C2                               LTPK: 28BE7F68DACC96DB4AE828ECA8308E29E3F36EE5221D216305DF9F06D4ACCBB4
Paired Controller: 2E198672-45E8-4CFA-83BD-73D0E3353799   (admin)  LTPK: DF1327319731F9DB2EF2E6CB42EB867D83A8BF7041AB334F7C4521502CF44C2A

Connection #0 (unconnected)
Connection #1 (unconnected)
Connection #2 (unconnected)
Connection #3 (unconnected)
Connection #4 (unconnected)
Connection #5 (unconnected)
Connection #6 (unconnected)
Connection #7 (unconnected)

*** End Status ***

*** HomeSpan Status ***

IP Address:        192.168.1.122

Accessory ID:      02:4F:69:91:59:C2                               LTPK: 28BE7F68DACC96DB4AE828ECA8308E29E3F36EE5221D216305DF9F06D4ACCBB4
Paired Controller: 2E198672-45E8-4CFA-83BD-73D0E3353799   (admin)  LTPK: DF1327319731F9DB2EF2E6CB42EB867D83A8BF7041AB334F7C4521502CF44C2A

Connection #0 (unconnected)
Connection #1 (unconnected)
Connection #2 (unconnected)
Connection #3 (unconnected)
Connection #4 (unconnected)
Connection #5 (unconnected)
Connection #6 (unconnected)
Connection #7 (unconnected)

*** End Status ***
jpasqua commented 2 years ago

I've been running on version ESP32 v2.0.2 for a bit over a day now and it is still responding. I will update the status again after another 24 hours.

HomeSpan commented 2 years ago

Thanks - that's good news (at least for now).

aLAN-LDZ commented 2 years ago

In my case, it seems that after upgrading to Arduino-ESP Ver .: 2.0.2 the problem has been resolved. Throughout the day, the connection has not been broken

jpasqua commented 2 years ago

Update 2: After another 18 hours the device is still connected. I will update the status again tomorrow and if everything looks good, I'll close the issue.

In the mean time I'll get a simple PCB ready for fab.

jpasqua commented 2 years ago

After another 26 hours my unit is still online, so I'm going to close this issue.

nicosandller commented 2 years ago

hey @jpasqua how did you update Arduino-ESP Ver ? Are you using platformIO on VS code by any chance?

My Serial output:

Message Logs:     Level 0
Status LED:       Pin -  *** WARNING: Status LED Pin is UNDEFINED
Device Control:   Pin -  *** WARNING: Device Control Pin is UNDEFINED
Sketch Version:   n/a
HomeSpan Version: 1.5.0
Arduino-ESP Ver.: 1.0.6
ESP-IDF Version:  3.3.5
ESP32 Chip:       ESP32-D0WDQ6 Rev 1 dual-core 4MB Flash
ESP32 Board:      doitESP32devkitV1
PWM Resources:    16 channels, 8 timers, max 20-bit duty resolution
Sodium Version:   1.0.12-idf  Lib 9.4
MbedTLS Version:  mbed TLS 2.16.7
Sketch Compiled:  Mar  4 2022 10:08:43

its outdated but I'm not sure how to update it. This is the Espressif32 plaftorm installed framework-arduinoespressif32 version:

it looks like platform IO hasn't updated arduino-esp32 aka:

framework-arduinoespressif32 | framework |   | ~3.10006.0 | 3.10006.210326 (1.0.6) https://registry.platformio.org/tools/platformio/framework-arduinoespressif32/versions

to the latest version updated december 2021:

https://github.com/espressif/arduino-esp32

EDIT (SOLUTION):

Leaving a link to this issue here in case anyone comes looking:

https://github.com/platformio/platform-espressif32/issues/619

An easy way to update arduino-esp32 is adding a platform_package like so on the configuration file in case you're using platformIO:

platform = espressif32
platform_packages =
   framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.2