src.nth.io/

summaryrefslogtreecommitdiff
path: root/main/app_main.c
diff options
context:
space:
mode:
authorLuke Hoersten <[email protected]>2021-03-12 12:05:39 -0600
committerLuke Hoersten <[email protected]>2021-03-12 12:05:39 -0600
commitf24b74e0881818c8b7ddf7bb786363fa9b142f67 (patch)
tree29b5e82f597c5ca7f7409206d0f471ad2037c3d9 /main/app_main.c
parentc6d3d96ed6a659f7a3c1f616caebe325a3d139bd (diff)
Broke out LED identify service.
Diffstat (limited to 'main/app_main.c')
-rw-r--r--main/app_main.c33
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 */