From 6f30198ca30dfd2a69486e11ccb60ae774d621cd Mon Sep 17 00:00:00 2001 From: Tomas Rezucha Date: Thu, 21 Dec 2023 22:52:16 +0100 Subject: [PATCH] feat(esp_hid): Add Connection Request event This event is useful for situations where the HID device requests connection. Typically in USB transport. --- components/esp_hid/include/esp_hidh.h | 28 +++++++++++++------------ components/esp_hid/src/esp_hid_common.c | 3 ++- tools/ci/check_copyright_ignore.txt | 1 - 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/components/esp_hid/include/esp_hidh.h b/components/esp_hid/include/esp_hidh.h index d49f76e680..ab8b377e1d 100644 --- a/components/esp_hid/include/esp_hidh.h +++ b/components/esp_hid/include/esp_hidh.h @@ -1,16 +1,8 @@ -// Copyright 2017-2019 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2017-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once @@ -44,6 +36,7 @@ typedef enum { ESP_HIDH_CLOSE_EVENT, /*!< HID device closed */ ESP_HIDH_START_EVENT, /*!< HID host stack started, used only for Classic Bluetooth */ ESP_HIDH_STOP_EVENT, /*!< HID host stack stopped, used only for Classic Bluetooth */ + ESP_HIDH_CONN_REQUEST_EVENT, /*!< HID device requested connection, used only for USB */ ESP_HIDH_MAX_EVENT, /*!< HID events end marker */ } esp_hidh_event_t; @@ -119,6 +112,15 @@ typedef union { esp_hid_trans_type_t trans_type; /*!< HID host feature transaction type, used only for Classic Bluetooth */ } feature; /*!< HID callback param of ESP_HIDH_FEATURE_EVENT */ + /** + * @brief ESP_HIDH_CONN_REQUEST_EVENT + */ + struct { + esp_hid_transport_t trans_type; /*!< Transport type, currently only USB */ + esp_hid_address_t address; /*!< Address of the device */ + const void *dev_info; /*!< Information about the device that requests connection. usb_intf_desc_t* for USB */ + } conn_request; + } esp_hidh_event_data_t; typedef struct { diff --git a/components/esp_hid/src/esp_hid_common.c b/components/esp_hid/src/esp_hid_common.c index 69d987fcbf..ed4afc8947 100644 --- a/components/esp_hid/src/esp_hid_common.c +++ b/components/esp_hid/src/esp_hid_common.c @@ -1,10 +1,11 @@ /* - * SPDX-FileCopyrightText: 2017-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2017-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #include +#include #include "esp_log.h" #include "esp_err.h" #include "esp_hid_common.h" diff --git a/tools/ci/check_copyright_ignore.txt b/tools/ci/check_copyright_ignore.txt index 895204a08e..6c7863ad41 100644 --- a/tools/ci/check_copyright_ignore.txt +++ b/tools/ci/check_copyright_ignore.txt @@ -404,7 +404,6 @@ components/esp_event/host_test/fixtures.hpp components/esp_hid/include/esp_hidd.h components/esp_hid/include/esp_hidd_gatts.h components/esp_hid/include/esp_hidd_transport.h -components/esp_hid/include/esp_hidh.h components/esp_hid/include/esp_hidh_bluedroid.h components/esp_hid/include/esp_hidh_gattc.h components/esp_hid/private/bt_hidd.h