|
1 | | -// Copyright 2017-2019 Espressif Systems (Shanghai) PTE LTD |
2 | | -// |
3 | | -// Licensed under the Apache License, Version 2.0 (the "License"); |
4 | | -// you may not use this file except in compliance with the License. |
5 | | -// You may obtain a copy of the License at |
6 | | - |
7 | | -// http://www.apache.org/licenses/LICENSE-2.0 |
8 | | -// |
9 | | -// Unless required by applicable law or agreed to in writing, software |
10 | | -// distributed under the License is distributed on an "AS IS" BASIS, |
11 | | -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | | -// See the License for the specific language governing permissions and |
13 | | -// limitations under the License. |
| 1 | +/* |
| 2 | + * SPDX-FileCopyrightText: 2017-2025 Espressif Systems (Shanghai) CO LTD |
| 3 | + * |
| 4 | + * SPDX-License-Identifier: Apache-2.0 |
| 5 | + */ |
14 | 6 |
|
15 | 7 | #pragma once |
16 | 8 |
|
@@ -221,6 +213,63 @@ esp_err_t esp_hidd_dev_event_handler_register(esp_hidd_dev_t *dev, esp_event_han |
221 | 213 | */ |
222 | 214 | esp_err_t esp_hidd_dev_event_handler_unregister(esp_hidd_dev_t *dev, esp_event_handler_t callback, esp_hidd_event_t event); |
223 | 215 |
|
| 216 | +/** |
| 217 | + * @brief Connection information structure for querying connections |
| 218 | + */ |
| 219 | +typedef struct { |
| 220 | + uint16_t conn_id; /*!< Connection ID */ |
| 221 | + uint8_t remote_bda[6]; /*!< Remote device address */ |
| 222 | +} esp_hidd_conn_info_t; |
| 223 | + |
| 224 | +/** |
| 225 | + * @brief Set the active connection for unicast mode |
| 226 | + * @param dev : pointer to the device |
| 227 | + * @param conn_id : connection ID to set as active (sends to this connection only) |
| 228 | + * |
| 229 | + * @return: ESP_OK on success, ESP_ERR_NOT_FOUND if connection not found |
| 230 | + * @note: This disables broadcast mode automatically |
| 231 | + */ |
| 232 | +esp_err_t esp_hidd_dev_set_active_conn(esp_hidd_dev_t *dev, uint16_t conn_id); |
| 233 | + |
| 234 | +/** |
| 235 | + * @brief Query all active connections |
| 236 | + * @param dev : pointer to the device |
| 237 | + * @param conn_list : pointer to array to store connection info |
| 238 | + * @param max_count : maximum number of connections that can be stored |
| 239 | + * @param[out] count : actual number of connections returned |
| 240 | + * |
| 241 | + * @return: ESP_OK on success |
| 242 | + */ |
| 243 | +esp_err_t esp_hidd_dev_get_connections(esp_hidd_dev_t *dev, esp_hidd_conn_info_t *conn_list, size_t max_count, size_t *count); |
| 244 | + |
| 245 | +/** |
| 246 | + * @brief Enable or disable broadcast mode |
| 247 | + * @param dev : pointer to the device |
| 248 | + * @param enable : true to broadcast to all connections, false for unicast to active connection |
| 249 | + * |
| 250 | + * @return: ESP_OK on success |
| 251 | + * @note: In broadcast mode, all connected devices receive the events |
| 252 | + */ |
| 253 | +esp_err_t esp_hidd_dev_set_broadcast_mode(esp_hidd_dev_t *dev, bool enable); |
| 254 | + |
| 255 | +/** |
| 256 | + * @brief Get the currently active connection (unicast) when not in broadcast mode |
| 257 | + * @param dev : pointer to the device |
| 258 | + * @param[out] conn_id : connection ID of the active connection |
| 259 | + * |
| 260 | + * @return: ESP_OK on success, ESP_ERR_NOT_FOUND if no active connection, ESP_ERR_NOT_SUPPORTED if transport doesn't support multi-connection |
| 261 | + */ |
| 262 | +esp_err_t esp_hidd_dev_get_active_conn(esp_hidd_dev_t *dev, uint16_t *conn_id); |
| 263 | + |
| 264 | +/** |
| 265 | + * @brief Query whether the device is in broadcast mode |
| 266 | + * @param dev : pointer to the device |
| 267 | + * @param[out] enabled : true if broadcast mode is enabled, false otherwise |
| 268 | + * |
| 269 | + * @return: ESP_OK on success, ESP_ERR_NOT_SUPPORTED if transport doesn't support multi-connection |
| 270 | + */ |
| 271 | +esp_err_t esp_hidd_dev_is_broadcast_mode(esp_hidd_dev_t *dev, bool *enabled); |
| 272 | + |
224 | 273 | #ifdef __cplusplus |
225 | 274 | } |
226 | 275 | #endif |
0 commit comments