Closed matheusesperanca closed 2 years ago
@matheusesperanca , you can use the push button logic from here and register your callback.
Sample:
button_handle_t btn_handle = iot_button_create(BUTTON_GPIO, BUTTON_ACTIVE_LEVEL);
if (btn_handle) {
/* Register a callback for a button tap (short press) event */
iot_button_set_evt_cb(btn_handle, BUTTON_CB_TAP, push_btn_cb, NULL);
}
In the push_btn_cb, you can turn on/off the light and also report the state change to HomeKit by calling hap_char_update_val()
Solved, thanks!
@shahpiyushv and which "HAP characteristic object handle" and "Pointer to new value" to use?
After hours of searching, I found out...
//turn on light
hap_val_t appliance_value = {
.b = true
};
hap_char_t *temp = hap_serv_get_char_by_uuid(service, HAP_CHAR_UUID_ON);
hap_char_update_val(temp, &appliance_value);
Hi there,
I used Lightbulb example on ESP32 and everything is working.
I can't find some solution to get the handlers to change the light state manually (with a switch), how I can do this?
Thanks.