2021-12-06 01:59:55 -05:00
|
|
|
/*
|
2023-07-31 06:02:07 -04:00
|
|
|
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
|
2021-12-06 01:59:55 -05:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
|
|
|
*/
|
2020-04-29 05:24:01 -04:00
|
|
|
|
|
|
|
#ifndef _ESP_HID_GAP_H_
|
|
|
|
#define _ESP_HID_GAP_H_
|
|
|
|
|
2021-09-07 05:08:43 -04:00
|
|
|
#define HIDD_IDLE_MODE 0x00
|
|
|
|
#define HIDD_BLE_MODE 0x01
|
|
|
|
#define HIDD_BT_MODE 0x02
|
|
|
|
#define HIDD_BTDM_MODE 0x03
|
|
|
|
|
|
|
|
#if CONFIG_BT_HID_DEVICE_ENABLED
|
|
|
|
#if CONFIG_BT_BLE_ENABLED
|
|
|
|
#define HID_DEV_MODE HIDD_BTDM_MODE
|
|
|
|
#else
|
|
|
|
#define HID_DEV_MODE HIDD_BT_MODE
|
|
|
|
#endif
|
|
|
|
#elif CONFIG_BT_BLE_ENABLED
|
|
|
|
#define HID_DEV_MODE HIDD_BLE_MODE
|
2023-07-31 06:02:07 -04:00
|
|
|
#elif CONFIG_BT_NIMBLE_ENABLED
|
|
|
|
#define HID_DEV_MODE HIDD_BLE_MODE
|
2021-09-07 05:08:43 -04:00
|
|
|
#else
|
|
|
|
#define HID_DEV_MODE HIDD_IDLE_MODE
|
|
|
|
#endif
|
|
|
|
|
2020-04-29 05:24:01 -04:00
|
|
|
#include "esp_err.h"
|
|
|
|
#include "esp_log.h"
|
|
|
|
|
|
|
|
#include "esp_bt.h"
|
2023-07-31 06:02:07 -04:00
|
|
|
#if !CONFIG_BT_NIMBLE_ENABLED
|
2020-04-29 05:24:01 -04:00
|
|
|
#include "esp_bt_defs.h"
|
|
|
|
#include "esp_bt_main.h"
|
2021-09-07 05:08:43 -04:00
|
|
|
#include "esp_gap_bt_api.h"
|
2023-07-31 06:02:07 -04:00
|
|
|
#endif
|
2021-09-07 05:08:43 -04:00
|
|
|
#include "esp_hid_common.h"
|
|
|
|
#if CONFIG_BT_BLE_ENABLED
|
2020-04-29 05:24:01 -04:00
|
|
|
#include "esp_gattc_api.h"
|
|
|
|
#include "esp_gatt_defs.h"
|
|
|
|
#include "esp_gap_ble_api.h"
|
2021-09-07 05:08:43 -04:00
|
|
|
#endif
|
2020-04-29 05:24:01 -04:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2023-07-31 06:02:07 -04:00
|
|
|
#if !CONFIG_BT_NIMBLE_ENABLED
|
2020-04-29 05:24:01 -04:00
|
|
|
typedef struct esp_hidh_scan_result_s {
|
|
|
|
struct esp_hidh_scan_result_s *next;
|
|
|
|
|
|
|
|
esp_bd_addr_t bda;
|
|
|
|
const char *name;
|
|
|
|
int8_t rssi;
|
|
|
|
esp_hid_usage_t usage;
|
|
|
|
esp_hid_transport_t transport; //BT, BLE or USB
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
esp_bt_cod_t cod;
|
|
|
|
esp_bt_uuid_t uuid;
|
|
|
|
} bt;
|
|
|
|
struct {
|
|
|
|
esp_ble_addr_type_t addr_type;
|
|
|
|
uint16_t appearance;
|
|
|
|
} ble;
|
|
|
|
};
|
|
|
|
} esp_hid_scan_result_t;
|
|
|
|
|
|
|
|
esp_err_t esp_hid_scan(uint32_t seconds, size_t *num_results, esp_hid_scan_result_t **results);
|
|
|
|
void esp_hid_scan_results_free(esp_hid_scan_result_t *results);
|
2023-07-31 06:02:07 -04:00
|
|
|
const char *ble_addr_type_str(esp_ble_addr_type_t ble_addr_type);
|
|
|
|
void print_uuid(esp_bt_uuid_t *uuid);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
esp_err_t esp_hid_gap_init(uint8_t mode);
|
2020-04-29 05:24:01 -04:00
|
|
|
|
|
|
|
esp_err_t esp_hid_ble_gap_adv_init(uint16_t appearance, const char *device_name);
|
|
|
|
esp_err_t esp_hid_ble_gap_adv_start(void);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* _ESP_HIDH_GAP_H_ */
|