diff options
Diffstat (limited to 'main/app_main.c')
| -rw-r--r-- | main/app_main.c | 33 |
1 files changed, 3 insertions, 30 deletions
diff --git a/main/app_main.c b/main/app_main.c index 22e511f..e39f652 100644 --- a/main/app_main.c +++ b/main/app_main.c @@ -18,6 +18,7 @@ #include <app_wifi.h> #include <app_hap_setup_payload.h> +#include <led.h> #include <lock.h> #include <bell.h> #include <event_queue.h> @@ -31,34 +32,6 @@ /* static uint8_t tlv8buff[128]; static hap_data_val_t null_tlv8 = {.buf = &tlv8buff, .buflen = 127}; */ -static void led_init(uint32_t key_gpio_pin) -{ - gpio_config_t io_conf; - - io_conf.intr_type = GPIO_INTR_DISABLE; /* Interrupt for falling edge */ - io_conf.pin_bit_mask = 1 << key_gpio_pin; /* Bit mask of the pins */ - io_conf.mode = GPIO_MODE_OUTPUT; /* Set as input mode */ - io_conf.pull_up_en = GPIO_PULLUP_DISABLE; /* Disable internal pull-up */ - io_conf.pull_down_en = GPIO_PULLDOWN_ENABLE; /* Enable internal pull-down */ - - gpio_config(&io_conf); /* Set the GPIO configuration */ -} - -static int intercom_identify(hap_acc_t *ha) -{ - ESP_LOGI(TAG, "Accessory identified"); - - for (int i = 0; i < 3; i++) - { - gpio_set_level(CONFIG_HOMEKIT_INTERCOM_LED_GPIO_PIN, 1); - vTaskDelay(pdMS_TO_TICKS(500)); - gpio_set_level(CONFIG_HOMEKIT_INTERCOM_LED_GPIO_PIN, 0); - vTaskDelay(pdMS_TO_TICKS(500)); - } - - return HAP_SUCCESS; -} - static void intercom_thread_entry(void *p) { hap_init(HAP_TRANSPORT_WIFI); /* Initialize the HAP core */ @@ -74,7 +47,7 @@ static void intercom_thread_entry(void *p) .fw_rev = "0.1.0", .hw_rev = NULL, .pv = "1.1.0", - .identify_routine = intercom_identify, + .identify_routine = intercom_led_identify, .cid = HAP_CID_DOOR, }; @@ -92,7 +65,7 @@ static void intercom_thread_entry(void *p) hap_acc_add_serv(intercom_accessory, intercom_bell_init(CONFIG_HOMEKIT_INTERCOM_BELL_GPIO_PIN)); hap_acc_add_serv(intercom_accessory, intercom_lock_init(CONFIG_HOMEKIT_INTERCOM_LOCK_GPIO_PIN)); - led_init(CONFIG_HOMEKIT_INTERCOM_LED_GPIO_PIN); + intercom_led_init(CONFIG_HOMEKIT_INTERCOM_LED_GPIO_PIN); hap_add_accessory(intercom_accessory); /* Add the Accessory to the HomeKit Database */ |
