esp_hid_gap.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Unlicense OR CC0-1.0
  5. */
  6. #ifndef _ESP_HID_GAP_H_
  7. #define _ESP_HID_GAP_H_
  8. #define HIDD_IDLE_MODE 0x00
  9. #define HIDD_BLE_MODE 0x01
  10. #define HIDD_BT_MODE 0x02
  11. #define HIDD_BTDM_MODE 0x03
  12. #if CONFIG_BT_HID_DEVICE_ENABLED
  13. #if CONFIG_BT_BLE_ENABLED
  14. #define HID_DEV_MODE HIDD_BTDM_MODE
  15. #else
  16. #define HID_DEV_MODE HIDD_BT_MODE
  17. #endif
  18. #elif CONFIG_BT_BLE_ENABLED
  19. #define HID_DEV_MODE HIDD_BLE_MODE
  20. #else
  21. #define HID_DEV_MODE HIDD_IDLE_MODE
  22. #endif
  23. #include "esp_err.h"
  24. #include "esp_log.h"
  25. #include "esp_bt.h"
  26. #include "esp_bt_defs.h"
  27. #include "esp_bt_main.h"
  28. #include "esp_gap_bt_api.h"
  29. #include "esp_hid_common.h"
  30. #if CONFIG_BT_BLE_ENABLED
  31. #include "esp_gattc_api.h"
  32. #include "esp_gatt_defs.h"
  33. #include "esp_gap_ble_api.h"
  34. #endif
  35. #ifdef __cplusplus
  36. extern "C" {
  37. #endif
  38. typedef struct esp_hidh_scan_result_s {
  39. struct esp_hidh_scan_result_s *next;
  40. esp_bd_addr_t bda;
  41. const char *name;
  42. int8_t rssi;
  43. esp_hid_usage_t usage;
  44. esp_hid_transport_t transport; //BT, BLE or USB
  45. union {
  46. struct {
  47. esp_bt_cod_t cod;
  48. esp_bt_uuid_t uuid;
  49. } bt;
  50. struct {
  51. esp_ble_addr_type_t addr_type;
  52. uint16_t appearance;
  53. } ble;
  54. };
  55. } esp_hid_scan_result_t;
  56. esp_err_t esp_hid_gap_init(uint8_t mode);
  57. esp_err_t esp_hid_scan(uint32_t seconds, size_t *num_results, esp_hid_scan_result_t **results);
  58. void esp_hid_scan_results_free(esp_hid_scan_result_t *results);
  59. esp_err_t esp_hid_ble_gap_adv_init(uint16_t appearance, const char *device_name);
  60. esp_err_t esp_hid_ble_gap_adv_start(void);
  61. void print_uuid(esp_bt_uuid_t *uuid);
  62. const char *ble_addr_type_str(esp_ble_addr_type_t ble_addr_type);
  63. #ifdef __cplusplus
  64. }
  65. #endif
  66. #endif /* _ESP_HIDH_GAP_H_ */