peros550 / esp-homekit-multiple-sensors

A firmware for ESP8266 based devices to be used as Homekit sensors and Thermostats.
MIT License
31 stars 7 forks source link

The accessory can't pair #4

Closed renandw closed 5 years ago

renandw commented 5 years ago

Hi. I am having a problem with this example. I can see the accessory in the Home.app but I can't pair it

                                                      �'o��|���n��clpp_task_hdl : 3fff07c0, prio:14, stack:512

pm_task_hdl : 3fff00b0, prio:1, stack:176 frc2_timer_task_hdl:0x3fff47c0, prio:12, stack:200

ESP-Open-SDK ver: 0.0.1 compiled @ Jul 28 2019 16:16:11 phy ver: 273, pp ver: 8.3

wifi_config: Initializing WiFi config !!! wifi_config: No configuration found wifi_config: Starting AP mode wifi_config: Starting DHCP server mode : sta(a4:cf:12:bf:18:62) + softAP(a6:cf:12:bf:18:62) add if0 add if1 bcn 100 wifi_config: Starting WiFi scan wifi_config: Starting DNS server wifi_config: Starting HTTP server no buf for probe, ie len 0 no buf for probe, ie len 0 scandone scandone add 1 aid 1 station: 78:7b:8a:81:ae:47 join, AID = 1 scandone scandone wifi_config: Connecting to Mansão SP 02 scandone add 0 aid 1 cnt

connected with Mansão SP 02, channel 6 dhcp client start... ip:172.20.10.9,mask:255.255.255.240,gw:172.20.10.1

wifi_config: Connected to WiFi network station: 78:7b:8a:81:ae:47 leave, AID = 1 rm match bcn 0 del if1 mode : sta(a4:cf:12:bf:18:62) Function called without core lock wifi_config: Stopping DNS server wifi_config: Stopping HTTP server

can you please help me. thanks

peros550 commented 5 years ago

Did you erase flash before flashing ?

renandw commented 5 years ago

yes, I did. It just don't pair :/

peros550 commented 5 years ago

Can you post a log taken right after the moment you tried to pair through home app ?

renandw commented 5 years ago

I did: make erase_flash And than I used: make test. The entire log is what I posted :/ The blue led doesn’t even blink when trying to pair. I thought that might be some of my configuration and used virtual box to redo all the process from the beginning. And it doesn’t work. But tried others examples from maxim esp-HomeKit-Demi that works fine.

I am lost :/

peros550 commented 5 years ago

Right after you have configured the WiFi, and as soon as you are able to see the accessory in the home app, you need to disconnect power for a few seconds and then try pairing. This has happened to me. I believe it has to do with too much memory being used so far by the device.

renandw commented 5 years ago

here it is (I tried to disconnect from power 3 times)

renan@esphomekit:~/projects/esp-homekit-multiple-sensors/examples/multiple_sensors$ make erase_flash esptool.py -p /dev/ttyUSB0 --baud 115200 erase_flash esptool.py v1.2 Connecting... Running Cesanta flasher stub... Erasing flash (this may take a while)... Erase took 3.1 seconds renan@esphomekit:~/projects/esp-homekit-multiple-sensors/examples/multiple_sensors$ make test esptool.py -p /dev/ttyUSB0 --baud 115200 write_flash -fs 8m -fm dout -ff 40m \ 0x0 /home/renan/projects/esp-open-rtos/bootloader/firmware_prebuilt/rboot.bin 0x1000 /home/renan/projects/esp-open-rtos/bootloader/firmware_prebuilt/blank_config.bin 0x2000 ./firmware/multiple_sensors.bin esptool.py v1.2 Connecting... Running Cesanta flasher stub... Flash params set to 0x0320 Writing 4096 @ 0x0... 4096 (100 %) Wrote 4096 bytes at 0x0 in 0.4 seconds (88.6 kbit/s)... Writing 4096 @ 0x1000... 4096 (100 %) Wrote 4096 bytes at 0x1000 in 0.4 seconds (87.6 kbit/s)... Writing 454656 @ 0x2000... 454656 (100 %) Wrote 454656 bytes at 0x2000 in 39.4 seconds (92.2 kbit/s)... Leaving... /home/renan/projects/esp-open-rtos//utils/filteroutput.py --port /dev/ttyUSB0 --baud 115200 --elf ./build/multiple_sensors.out Opening /dev/ttyUSB0 at 115200bps... Booting rom 0. ,�r�n� ��+�E*1[ ���kn� l�r�P��+��1[ @�r�X%�؂'Ȥnͭ}����0x3fff47c0, prio:12, stack:200

ESP-Open-SDK ver: 0.0.1 compiled @ Jul 28 2019 16:16:11 phy ver: 273, pp ver: 8.3

wifi_config: Initializing WiFi config !!! wifi_config: No configuration found wifi_config: Starting AP mode wifi_config: Starting DHCP server mode : sta(a4:cf:12:bf:18:62) + softAP(a6:cf:12:bf:18:62) add if0 add if1 bcn 100 wifi_config: Starting WiFi scan wifi_config: Starting DNS server wifi_config: Starting HTTP server scandone scandone sdlܟ<�l�|

     �l�
        #|����s�bdc��'o�$g'���cp��dsdsd8�g��l

                                             c
                                              n�|Čd�c��g'�lćd`�o
                                                                �dgs���o
                                                                        ��$p�'�
                                                                               {�ܜ��
                                                                                    co�|쏇p��o'�
                                                                                                �l �'o$`'{���o�� s��'
                                                                                                                     ��`;l�c�gn���p<�#
 lc�p`�

�c��'o�o�b�gb8�o$�'�n�o~

l$xc��`�'�nl$o���

             �d���`�'�n���b

                           �
                            dlds$�#�og��$�no'����n�o$�b�og��$�og'��`
                                                                     ���`rl�og��|���g�
                                                                                      �cdpp_task_hdl : 3fff07c0, prio:14, stack:512

pm_task_hdl : 3fff00b0, prio:1, stack:176 !!! wifi_config: No configuration found0

wifi_config: Starting AP mode wifi_config: Starting DHCP server mode : sta(a4:cf:12:bf:18:62) + softAP(a6:cf:12:bf:18:62) add if0 add if1 bcn 100 wifi_config: Starting WiFi scan wifi_config: Starting DNS server wifi_config: Starting HTTP server scandone scandone add 1 aid 1 station: 78:7b:8a:81:ae:47 join, AID = 1 no buf for probe, ie len 0 no buf for probe, ie len 0 scandone scandone scandone add 2 aid 2 station: b8:e8:56:44:5a:38 join, AID = 2 scandone scandone station: 78:7b:8a:81:ae:47 leave, AID = 1 rm match scandone scandone scandone wifi_config: Connecting to Mansão SP 02 scandone wifi_config: Connecting to Mansão SP 02 scandone !!! wifi_config: WiFi scan failed scandone add 0 aid 2 cnt

connected with Mansão SP 02, channel 6 dhcp client start... ip:172.20.10.9,mask:255.255.255.240,gw:172.20.10.1

wifi_config: Connected to WiFi network station: b8:e8:56:44:5a:38 leave, AID = 2 rm match bcn 0 del if1 mode : sta(a4:cf:12:bf:18:62) Function called without core lock wifi_config: Stopping HTTP server wifi_config: Stopping DNS server scandone pp_task_hdl : 3fff07c0, prio:14, stack:512 pm_task_hdl : 3fff00b0, prio:1, stack:176 frc2_timer_task_hdl:0x3fff47c0, prio:12, stack:200

ESP-Open-SDK ver: 0.0.1 compiled @ Jul 28 2019 16:16:11 phy ver: 273, pp ver: 8.3

wifi_config: Initializing WiFi config wifi_config: Connecting to Mansão SP 02 mode : sta(a4:cf:12:bf:18:62) add if0 scandone add 0 aid 2 cnt

connected with Mansão SP 02, channel 6 dhcp client start... ip:172.20.10.9,mask:255.255.255.240,gw:172.20.10.1

wifi_config: Connected to WiFi network ��ogl n;���g ��{ۓo ��sd�c�no���x| �c dc�p`c�c�c��og��g�c�ncp~�gl�o��o�gb

                                                                   dlp#�� �n�ollg���

                                                                                    �$���`�o��o����c
                                                                                                    �$dl?{l�c�g'��l�go����o�gl�c�gn��l�'o��`
       ���`sd
             �gn��|���'�
                        �clpp_task_hdl : 3fff07c0, prio:14, stack:512

pm_task_hdl : 3fff00b0, prio:1, stack:176 frc2_timer_task_hdl:0x3fff47c0, prio:12, stack:200

ESP-Open-SDK ver: 0.0.1 compiled @ Jul 28 2019 16:16:11 phy ver: 273, pp ver: 8.3

wifi_config: Initializing WiFi config wifi_config: Connecting to Mansão SP 02 mode : sta(a4:cf:12:bf:18:62) add if0 scandone add 0 aid 1 cnt

connected with Mansão SP 02, channel 6 dhcp client start... ip:172.20.10.9,mask:255.255.255.240,gw:172.20.10.1

wifi_config: Connected to WiFi network pp_task_hdl : 3fff07c0, prio:14, stack:512 pm_task_hdl : 3fff00b0, prio:1, stack:176 frc2_timer_task_hdl:0x3fff47c0, prio:12, stack:200

ESP-Open-SDK ver: 0.0.1 compiled @ Jul 28 2019 16:16:11 phy ver: 273, pp ver: 8.3

wifi_config: Initializing WiFi config wifi_config: Connecting to Mansão SP 02 mode : sta(a4:cf:12:bf:18:62) add if0 scandone add 0 aid 1 cnt

connected with Mansão SP 02, channel 6 dhcp client start... ip:172.20.10.9,mask:255.255.255.240,gw:172.20.10.1

wifi_config: Connected to WiFi network

peros550 commented 5 years ago

@maximkulkin I would like to ask for your help. If you have time, could you please have a look in this issue. I'm not sure but above logs do not show a client failure to pair. It's like pairing was not attempted at all. Am I correct?

renandw commented 5 years ago

It’s really weird. Exactly, is like pairing wasn’t attempted. But it appears in home app. I will try in another Esp8266 wemos d1 board. See if it works.

maximkulkin commented 5 years ago

I do not see logs that HomeKit server ever started on accessory. Please doublecheck what you’re actually seeing.

RavenSystem commented 5 years ago

If it appears in Home app, for sure is because a residual mDNS announce, but it is old. As Max says, there is not Homekit server started in those logs.

royfocker19 commented 5 years ago

If you are using a wemos d1 mini maybe you should change 8 to 32 in flash size inside makefile. I experienced that same problem, Maxim examples use 32 (4mb) instead of 8.

renandw commented 5 years ago

Thanks. I will try that. Also I will try with a nodemcu. Thanks guys

Em 1 de ago de 2019, à(s) 06:43, royfocker19 notifications@github.com escreveu:

 If you are using a we mod d1 mini maybe you should change 8m to 32? Please check make file, I think the is an error there.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

renandw commented 5 years ago

Thanks. I will try that. Also I will try with a nodemcu. Thanks very much

Em 1 de ago de 2019, à(s) 06:43, royfocker19 notifications@github.com escreveu:  If you are using a we mod d1 mini maybe you should change 8m to 32? Please check make file, I think the is an error there.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

peros550 commented 5 years ago

Thanks. I will try that. Also I will try with a nodemcu. Thanks very much Em 1 de ago de 2019, à(s) 06:43, royfocker19 @.***> escreveu:  If you are using a we mod d1 mini maybe you should change 8m to 32? Please check make file, I think the is an error there. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

@renandw Did you have any luck? I just paired a new Wemos D1 mini using example: multiple_sensors_ac. I had though to reboot the device a few times in order to complete.

During the pairing process I was getting an error message (see below) but the process continued and then paired successfully.

>>> HomeKit: [Client 4] Pair Setup Step 1/3
>>> HomeKit: [Client 4] Pair Setup Step 2/3
>>> mdns_reply could not alloc 1460
>>> mdns_reply could not alloc 1460
>>> mdns_reply could not alloc 1460
>>> mdns_reply could not alloc 1460
>>> mdns_reply could not alloc 1460
>>> mdns_reply could not alloc 1460
>>> HomeKit: [Client 4] Pair Setup Step 3/3
>>> HomeKit: Added pairing with 3E2BCECA-DBEB-4AC7-85C7-4FAA27DFC2C1
>>> HomeKit: Configuring mDNS
mDNS announcement: Name=Homekit Sensor-037983-30A9 md=MultipleSe0id=30:A9:DA:13:51:1Fc#=1s#=1ff=0sf=0ci=9 Port=5556 TTL=4500
>>> HomeKit: [Client 4] Successfully paired
>>> HomeKit: [Client 4] Closing client connection
>>> HomeKit: Got new client connection: 4
>>> HomeKit: [Client 4] Pair Verify Step 1/2
>>> HomeKit: [Client 4] Pair Verify Step 2/2
>>> HomeKit: [Client 4] Found pairing with 3E2BCEC-4AC7-85C7-4FAA27DFC2C1
>>> HomeKit: [Client 4] Verification successful, secure session established
>>> HomeKit: [Client 4] Get Accessories
renandw commented 5 years ago

No, unfortunately I had no luck. I’ve tried with a nodeMCU but even show in Home.app :/ I’m still trying to figure it out. But thanks very much

On 18 Aug 2019, at 12:37, peros550 notifications@github.com wrote:

Thanks. I will try that. Also I will try with a nodemcu. Thanks very much … <x-msg://1/#> Em 1 de ago de 2019, à(s) 06:43, royfocker19 @.***> escreveu:  If you are using a we mod d1 mini maybe you should change 8m to 32? Please check make file, I think the is an error there. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

Did you have any luck? I just paired a new Wemos D1 mini using example: multiple_sensors_ac. I had though to reboot the device a few times in order to complete.

During the pairing process I was getting an error message (see below) but the process continued and then paired successfully.

HomeKit: [Client 4] Pair Setup Step 1/3 HomeKit: [Client 4] Pair Setup Step 2/3 mdns_reply could not alloc 1460 mdns_reply could not alloc 1460 mdns_reply could not alloc 1460 mdns_reply could not alloc 1460 mdns_reply could not alloc 1460 mdns_reply could not alloc 1460 HomeKit: [Client 4] Pair Setup Step 3/3 HomeKit: Added pairing with 3E2BCECA-DBEB-4AC7-85C7-4FAA27DFC2C1 HomeKit: Configuring mDNS mDNS announcement: Name=Homekit Sensor-037983-30A9 md=MultipleSe0id=30:A9:DA:13:51:1Fc#=1s#=1ff=0sf=0ci=9 Port=5556 TTL=4500 HomeKit: [Client 4] Successfully paired HomeKit: [Client 4] Closing client connection HomeKit: Got new client connection: 4 HomeKit: [Client 4] Pair Verify Step 1/2 HomeKit: [Client 4] Pair Verify Step 2/2 HomeKit: [Client 4] Found pairing with 3E2BCEC-4AC7-85C7-4FAA27DFC2C1 HomeKit: [Client 4] Verification successful, secure session established HomeKit: [Client 4] Get Accessories — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/peros550/esp-homekit-multiple-sensors/issues/4?email_source=notifications&email_token=AMC3AJKNNZGVQGI2BVGIWRTQFFUE3A5CNFSM4IHM5ODKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4RCOLY#issuecomment-522331951, or mute the thread https://github.com/notifications/unsubscribe-auth/AMC3AJL2IHBKCHAEAHYYSULQFFUE3ANCNFSM4IHM5ODA.

peros550 commented 5 years ago

Hi @renandw

Maxim's reviewed your logs previously and he gave a good hint. The Homekit server hasn't even started, therefore you shouldn't even be able to find the accessory in the Home app.

We just need to find out why the Homekit server didn't start.

Judging from your second log, I think the device seems to always reboot right after it connects to Wifi network "Mansão SP 02". This is strange.

A few more questions and basic troubleshooting steps from my side:

1) Which and how many esp8266 based devices have you tried so far? (Personally I'm using Wemos D1 mini) 2) Have you made any changes to the code (i.e changing GPIOs etc)? 3) Have you tried using both examples (multiple_sensors.c & multiple_sensors_ac.c ) , if yes both of these have the same results? 4) Would it be possible to try flashing and pairing again a device with no sensors/modules attached to it? 5) Do you keep a close distance between your esp8266 and your router?

I don't have enough experience with the flash tool (esptool.py) but I can see a difference in the esptool's version. You are using 1.2 while I use v2.6.

I'm not sure if that could cause any issue.

/projects/esp-homekit-multiple-sensors/examples/multiple_sensors$ make test
esptool.py -p /dev/ttyUSB0 --baud 115200 write_flash -fs 8m -fm dout -ff 40m 
0x0 /home/renan/projects/esp-open-rtos/bootloader/firmware_prebuilt/rboot.bin 0x1000 /home/renan/projects/esp-open-rtos/bootloader/firmware_prebuilt/blank_config.bin 0x2000 ./firmware/multiple_sensors.bin
esptool.py v1.2
Connecting...
Running Cesanta flasher stub...

and mine :

FW firmware/multiple_sensors_ac.bin
WARNING: Flash size arguments in megabits like '8m' are deprecated.
Please use the equivalent size '1MB'.
Megabit arguments may be removed in a future release.
esptool.py v2.6-beta1
Creating image for ESP8266...
esptool.py -p /dev/ttyUSB0 --baud 115200 write_flash -fs 8m -fm dout -ff 40m \
        0x0 /home/jpap/projects/esp-open-rtos/bootloader/firmware_prebuilt/rboot.bin 0x1000 /home/jpap/projects/esp-open-rtos/bootloader/firmware_prebuilt/blank_config.bin 0x2000 ./firmware/multiple_sensors_ac.bin
WARNING: Flash size arguments in megabits like '8m' are deprecated.
Please use the equivalent size '1MB'.
Megabit arguments may be removed in a future release.
esptool.py v2.6-beta1
Serial port /dev/ttyUSB0
Connecting....
renandw commented 5 years ago

hi @peros550 I've tried a Wemos D1 mini and a NodeMCU, with no changes at all to the code and without the sensors. But I only tried one example (multiple_sensors.c). A few hours ago I've tried the multiple_sensors_ac and it worked like a charm.

connected with Mansão SP 02, channel 1 dhcp client start... ip:192.168.15.22,mask:255.255.255.0,gw:192.168.15.1

wifi_config: Connected to WiFi network CONNECTED TO >>> WIFI <<< HomeKit: Starting server HomeKit: Formatting flash at 0x8c000 HomeKit: Generated new accessory ID: E3:9B:99:26:6E:5C HomeKit: Generated new accessory key HomeKit: Configuring mDNS mDNS announcement: Name=Homekit Sensor-3D043A-E39B md=MultipleSensorspv=1.0id=E3:9B:99:26:6E:5Cc#=1s#=1ff=0sf=1ci=9 Port=5556 TTL=4500 SERVER JUST INITIALIZED HomeKit: Got new client connection: 4 CLIENT JUST CONNECTED HomeKit: [Client 4] Pair Setup Step 1/3 HomeKit: [Client 4] Pair Setup Step 2/3 mdns_reply could not alloc 1460 mdns_reply could not alloc 1460 HomeKit: [Client 4] Pair Setup Step 3/3 HomeKit: Added pairing with FF8F5239-0D1E-401F-9801-D108619DFA94 CLIENT JUST PAIRED HomeKit: Configuring mDNS mDNS announcement: Name=Homekit Sensor-3D043A-E39B md=MultipleSensorspv=1.0id=E3:9B:99:26:6E:5Cc#=1s#=1ff=0sf=0ci=9 Port=5556 TTL=4500 HomeKit: [Client 4] Successfully paired HomeKit: [Client 4] Closing client connection HomeKit: Got new client connection: 4 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 HomeKit: [Client 4] Update Characteristics HomeKit: [Client 4] Update Characteristics HomeKit: [Client 4] Update Characteristics HomeKit: [Client 4] Update Characteristics HomeKit: [Client 4] Update Characteristics HomeKit: [Client 4] Update Characteristics HomeKit: [Client 4] Update Characteristics HomeKit: [Client 4] Update Characteristics HomeKit: [Client 4] Add Pairing HomeKit: Added pairing with EAACB744-8CB3-4EC6-9DEC-E93F2C4A737B CLIENT JUST PAIRED HomeKit: [Client 4] Get Characteristics HomeKit: [Client 4] Update Characteristics Temperature sensor identify HomeKit: [Client 4] Get Characteristics HomeKit: [Client 4] Get Characteristics HomeKit: [Client 4] Get Characteristics HomeKit: [Client 4] Update Characteristics identify HomeKit: [Client 4] Get Characteristics HomeKit: [Client 4] Get Characteristics HomeKit: [Client 4] Get Characteristics HomeKit: [Client 4] Update Characteristics Light sensor identify HomeKit: [Client 4] Get Characteristics HomeKit: [Client 4] Get Characteristics HomeKit: [Client 4] Get Characteristics HomeKit: [Client 4] Update Characteristics identify HomeKit: [Client 4] Get Characteristics HomeKit: [Client 4] Get Characteristics HomeKit: [Client 4] Get Characteristics HomeKit: [Client 4] Update Characteristics

Thanks for the support.

peros550 commented 5 years ago

Initially I built the multiple_sensors example and it worked great.

Then I wanted to add an A/C accessory and focused all my efforts on multiple_sensors_ac which is the evolution of multiple_sensors. All my testing these days was with multiple_sensors_ac.

I'll have to check what happened with multiple_sensors example and does not work.

Sorry for the mess

maximkulkin commented 5 years ago

Ok, I was looking at multiple_sensors_ac too, but after looking at non-ac version the answer is pretty obvious: it crashes because it tries to use event callback with old wifi_config API. You need to change wifi_config_init to wifi_config_init2.

peros550 commented 5 years ago

Thank you Maxim! @renandw The code is updated. Give it a try and let us know if it worked for you.

Have a good day to all of you.

renandw commented 5 years ago

Thank you Peros. I will check when I get home. Really nice!! Thanks a lot everybody

Em 20 de ago de 2019, à(s) 04:26, peros550 notifications@github.com escreveu:

 Thank you Maxim! @renandw The code is updated. Give it a try and let us know if it worked for you.

Have a good day to all of you.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

renandw commented 5 years ago

Fantastic! it worked! thanks @peros550