Closed yz88 closed 4 years ago
Contact sensor code was not designed to be compatible with ESP-IDF. You should take a look at toggle.c in esp-button repository. I have updated it to compile for ESP-IDF and added a button example to get you started. You just need to use toggle instead of button, it triggers callback whenever it's state changes (which is exactly what contact sensor does). All you need to do with button example is to change HomeKit accessory declaration to whichever one you need (e.g. door-sensor).
trying to adapt the door-sensor example for an esp32. During compilation I'm facing two errors:
esp-homekit-demo/examples/esp32/contact-sensor/main/contact_sensor.c:2:22: fatal error: etstimer.h: No such file or directory compilation terminated.
and/esp-homekit-demo/examples/esp32/contact-sensor/main/contact_sensor.c:7:29: fatal error: esplibs/libmain.h: No such file or directory compilation terminated.
How do I adapt the esp8266 example to esp32? From the door-sensor example I copied the
contact_sencor.h
andcontact_sensor.c
files to mymain
folder.