#include "key.h" #include "esp_log.h" #include "driver/gpio.h" static key_ble_cb_t s_ble_gattc_write_char_cb; void key_init() { gpio_config_t gpio_grb_led_structer; gpio_grb_led_structer.intr_type = GPIO_INTR_DISABLE; gpio_grb_led_structer.mode = GPIO_MODE_INPUT; gpio_grb_led_structer.pin_bit_mask = GPIO_KEY_INPUT_PIN_SEL; gpio_grb_led_structer.pull_down_en = 0; gpio_grb_led_structer.pull_up_en = 0; gpio_config(&gpio_grb_led_structer); } void key_schedule() { if (gpio_get_level(KEY_REC) == 0) { /* code */ ESP_LOGI("Finny", "KEY_REC level 0"); while (gpio_get_level(KEY_REC) == 0) { } s_ble_gattc_write_char_cb("{ \"order\": \"setPosition\", \"index\": 0, \"speedLevel\": 0, \"position\": 180, \"direction\": 1 }"); ESP_LOGI("Finny", "stop"); } if (gpio_get_level(KEY_MODE) == 0) { /* code */ ESP_LOGI("Finny", "KEY_MODE level 0"); while (gpio_get_level(KEY_MODE) == 0) { } s_ble_gattc_write_char_cb("{ \"order\": \"setPosition\", \"index\": 0, \"speedLevel\": 0, \"position\": 360, \"direction\": 1 }"); ESP_LOGI("Finny", "stop"); } } void key_ble_send_cmd_reg(key_ble_cb_t cb) { s_ble_gattc_write_char_cb = cb; };