mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 03:00:34 +03:00
feat(nimble): added HID over Gatt profile support
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -22,7 +14,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if CONFIG_GATTS_ENABLE
|
||||
#if CONFIG_GATTS_ENABLE || CONFIG_BT_NIMBLE_ENABLED
|
||||
|
||||
esp_err_t esp_ble_hidd_dev_init(esp_hidd_dev_t *dev, const esp_hid_device_config_t *config, esp_event_handler_t callback);
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -20,12 +12,16 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if CONFIG_GATTC_ENABLE
|
||||
#if CONFIG_GATTC_ENABLE || CONFIG_BT_NIMBLE_ENABLED
|
||||
|
||||
esp_err_t esp_ble_hidh_init(const esp_hidh_config_t *config);
|
||||
esp_err_t esp_ble_hidh_deinit(void);
|
||||
|
||||
#if CONFIG_BT_NIMBLE_ENABLED
|
||||
esp_hidh_dev_t *esp_ble_hidh_dev_open(uint8_t *bda, uint8_t address_type);
|
||||
#else
|
||||
esp_hidh_dev_t *esp_ble_hidh_dev_open(esp_bd_addr_t bda, esp_ble_addr_type_t address_type);
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_GATTC_ENABLE */
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2022 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2017-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -17,6 +17,9 @@
|
||||
#include "esp_event.h"
|
||||
#include "sys/queue.h"
|
||||
#include "esp_timer.h"
|
||||
#if CONFIG_BT_NIMBLE_ENABLED
|
||||
#include "nimble/ble.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -52,7 +55,11 @@ struct esp_hidh_dev_s {
|
||||
esp_timer_handle_t trans_timer; //transactiion timer
|
||||
uint8_t report_type; //Get_Report tansaction report_type
|
||||
uint8_t report_id; //Get_Report tansaction report_id
|
||||
#if CONFIG_BT_NIMBLE_ENABLED
|
||||
uint8_t *protocol_mode; // protocol mode is unique for each hid service instance
|
||||
#else
|
||||
uint8_t protocol_mode; //device protocol mode
|
||||
#endif
|
||||
bool connected; //we have all required data to communicate
|
||||
bool opened; //we opened the device manually, else the device connected to us
|
||||
bool added; //If lower layer has added the device
|
||||
@@ -82,6 +89,9 @@ struct esp_hidh_dev_s {
|
||||
#if CONFIG_BLUEDROID_ENABLED
|
||||
esp_bd_addr_t bda;
|
||||
#endif /* CONFIG_BLUEDROID_ENABLED */
|
||||
#if CONFIG_BT_NIMBLE_ENABLED
|
||||
uint8_t bda[6];
|
||||
#endif
|
||||
|
||||
union {
|
||||
#if CONFIG_BT_HID_HOST_ENABLED
|
||||
@@ -102,6 +112,15 @@ struct esp_hidh_dev_s {
|
||||
uint16_t battery_ccc_handle;
|
||||
} ble;
|
||||
#endif /* CONFIG_GATTC_ENABLE */
|
||||
#if CONFIG_BT_NIMBLE_ENABLED
|
||||
struct {
|
||||
uint8_t address_type;
|
||||
int conn_id;
|
||||
uint16_t appearance;
|
||||
uint16_t battery_handle;
|
||||
uint16_t battery_ccc_handle;
|
||||
} ble;
|
||||
#endif
|
||||
};
|
||||
TAILQ_ENTRY(esp_hidh_dev_s) devices;
|
||||
};
|
||||
@@ -115,6 +134,10 @@ esp_hidh_dev_t *esp_hidh_dev_get_by_bda(esp_bd_addr_t bda); //BT/BLE
|
||||
esp_hidh_dev_t *esp_hidh_dev_get_by_handle(uint8_t handle); //Classic Bluetooth Only
|
||||
esp_hidh_dev_t *esp_hidh_dev_get_by_conn_id(uint16_t conn_id); //BLE Only
|
||||
#endif /* CONFIG_BLUEDROID_ENABLED */
|
||||
#if CONFIG_BT_NIMBLE_ENABLED
|
||||
esp_hidh_dev_t *esp_hidh_dev_get_by_bda(uint8_t* bda); // BLE Only
|
||||
esp_hidh_dev_t *esp_hidh_dev_get_by_conn_id(uint16_t conn_id); //BLE Only
|
||||
#endif
|
||||
|
||||
esp_hidh_dev_report_t *esp_hidh_dev_get_report_by_id_type_proto(esp_hidh_dev_t *dev, size_t map_index, size_t report_id, int report_type, uint8_t protocol_mode);
|
||||
esp_hidh_dev_report_t *esp_hidh_dev_get_report_by_id_and_type(esp_hidh_dev_t *dev, size_t map_index, size_t report_id, int report_type);
|
||||
|
||||
Reference in New Issue
Block a user