espressif / esp-homekit-sdk

541 stars 98 forks source link

Using local switch without accessory pair #114

Closed leotordo closed 9 months ago

leotordo commented 9 months ago

Hello, I modified lightbulb example. At the end of _lightbulb_threadentry I placed a while(1) loop with the check of a mechanical switch. In this mode I can switch on/off the light via iPhone and via local switch.

There's a problem: at the first poweron the board will go into provisioning for wifi credential and the local swtich doesn't work until I've paired the phone.

How to solve? My application need work with iPhone but also in stand alone without the iPhone paired.

Ideas? Thanks

leotordo commented 9 months ago

addendum

The last procedure launched is _app_wifistart

I (766) app_wifi: Starting provisioning Starting SoftAP with SSID: xxxxx-598300 I (786) phy_init: phy_version 970,1856f88,May 10 2023,17:44:12 I (826) wifi:mode : softAP (dc:54:75:59:83:01) I (826) wifi:Total power save buffer number: 16 I (826) wifi:Init max length of beacon: 752/752 I (826) wifi:Init max length of beacon: 752/752 I (826) esp_netif_lwip: DHCP server started on interface WIFI_AP_DEF with IP: 192.168.4.1

after some minut it goes in timeout

Pairing Mode timed out. Please reboot the device or re-enable pair setup. Deannouncing _hap._tcp mDNS service WAC timed out due to inactivity. Stopping SoftAP. I (602496) wifi:flush txq I (602496) wifi:stop sw txq I (602496) wifi:lmac stop hw txq WAC Stopped I (602506) app_wifi: WAC Stopped WAC Cleanup Finished

leotordo commented 9 months ago

I think I'll try something like this

paired=0;
app_wifi_start(portMAX_DELAY);
paired=1;

then I split the button managing if paired I use the task so I can update the hap also from the mechanical switch

if not paired I manage the mechanical switch from the main loop

leotordo commented 9 months ago

solved!