src.nth.io/

summaryrefslogtreecommitdiff
path: root/main/src
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/src
parentc6d3d96ed6a659f7a3c1f616caebe325a3d139bd (diff)
Broke out LED identify service.
Diffstat (limited to 'main/src')
-rw-r--r--main/src/led.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/main/src/led.c b/main/src/led.c
new file mode 100644
index 0000000..37f225a
--- /dev/null
+++ b/main/src/led.c
@@ -0,0 +1,48 @@
+#include <stdio.h>
+#include <string.h>
+#include <freertos/FreeRTOS.h>
+#include <freertos/task.h>
+#include <freertos/timers.h>
+#include <freertos/queue.h>
+#include <esp_log.h>
+#include <driver/gpio.h>
+#include <driver/adc.h>
+
+#include <hap.h>
+
+#include <hap_apple_servs.h>
+#include <hap_apple_chars.h>
+
+#include <app_wifi.h>
+#include <app_hap_setup_payload.h>
+
+#include <led.h>
+#include <event_queue.h>
+
+int intercom_led_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;
+}
+
+void intercom_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 */
+} \ No newline at end of file