esp_hid_gap.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. #ifndef _ESP_HID_GAP_H_
  14. #define _ESP_HID_GAP_H_
  15. #define HIDD_IDLE_MODE 0x00
  16. #define HIDD_BLE_MODE 0x01
  17. #define HIDD_BT_MODE 0x02
  18. #define HIDD_BTDM_MODE 0x03
  19. #if CONFIG_BT_HID_DEVICE_ENABLED
  20. #if CONFIG_BT_BLE_ENABLED
  21. #define HID_DEV_MODE HIDD_BTDM_MODE
  22. #else
  23. #define HID_DEV_MODE HIDD_BT_MODE
  24. #endif
  25. #elif CONFIG_BT_BLE_ENABLED
  26. #define HID_DEV_MODE HIDD_BLE_MODE
  27. #else
  28. #define HID_DEV_MODE HIDD_IDLE_MODE
  29. #endif
  30. #include "esp_err.h"
  31. #include "esp_log.h"
  32. #include "esp_bt.h"
  33. #include "esp_bt_defs.h"
  34. #include "esp_bt_main.h"
  35. #include "esp_gap_bt_api.h"
  36. #include "esp_hid_common.h"
  37. #if CONFIG_BT_BLE_ENABLED
  38. #include "esp_gattc_api.h"
  39. #include "esp_gatt_defs.h"
  40. #include "esp_gap_ble_api.h"
  41. #endif
  42. #ifdef __cplusplus
  43. extern "C" {
  44. #endif
  45. typedef struct esp_hidh_scan_result_s {
  46. struct esp_hidh_scan_result_s *next;
  47. esp_bd_addr_t bda;
  48. const char *name;
  49. int8_t rssi;
  50. esp_hid_usage_t usage;
  51. esp_hid_transport_t transport; //BT, BLE or USB
  52. union {
  53. struct {
  54. esp_bt_cod_t cod;
  55. esp_bt_uuid_t uuid;
  56. } bt;
  57. struct {
  58. esp_ble_addr_type_t addr_type;
  59. uint16_t appearance;
  60. } ble;
  61. };
  62. } esp_hid_scan_result_t;
  63. esp_err_t esp_hid_gap_init(uint8_t mode);
  64. esp_err_t esp_hid_scan(uint32_t seconds, size_t *num_results, esp_hid_scan_result_t **results);
  65. void esp_hid_scan_results_free(esp_hid_scan_result_t *results);
  66. esp_err_t esp_hid_ble_gap_adv_init(uint16_t appearance, const char *device_name);
  67. esp_err_t esp_hid_ble_gap_adv_start(void);
  68. void print_uuid(esp_bt_uuid_t *uuid);
  69. const char *ble_addr_type_str(esp_ble_addr_type_t ble_addr_type);
  70. #ifdef __cplusplus
  71. }
  72. #endif
  73. #endif /* _ESP_HIDH_GAP_H_ */