blob: 37f225a8bd4d2850b85dee52c416deee65e13733 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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 */
}
|