esp_hid_gap.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. #include "esp_err.h"
  16. #include "esp_log.h"
  17. #include "esp_bt.h"
  18. #include "esp_bt_defs.h"
  19. #include "esp_bt_main.h"
  20. #include "esp_gattc_api.h"
  21. #include "esp_gatt_defs.h"
  22. #include "esp_gap_ble_api.h"
  23. #include "esp_gap_bt_api.h"
  24. #include "esp_hid_common.h"
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28. typedef struct esp_hidh_scan_result_s {
  29. struct esp_hidh_scan_result_s *next;
  30. esp_bd_addr_t bda;
  31. const char *name;
  32. int8_t rssi;
  33. esp_hid_usage_t usage;
  34. esp_hid_transport_t transport; //BT, BLE or USB
  35. union {
  36. struct {
  37. esp_bt_cod_t cod;
  38. esp_bt_uuid_t uuid;
  39. } bt;
  40. struct {
  41. esp_ble_addr_type_t addr_type;
  42. uint16_t appearance;
  43. } ble;
  44. };
  45. } esp_hid_scan_result_t;
  46. esp_err_t esp_hid_gap_init(uint8_t mode);
  47. esp_err_t esp_hid_scan(uint32_t seconds, size_t *num_results, esp_hid_scan_result_t **results);
  48. void esp_hid_scan_results_free(esp_hid_scan_result_t *results);
  49. esp_err_t esp_hid_ble_gap_adv_init(uint16_t appearance, const char *device_name);
  50. esp_err_t esp_hid_ble_gap_adv_start(void);
  51. void print_uuid(esp_bt_uuid_t *uuid);
  52. const char *ble_addr_type_str(esp_ble_addr_type_t ble_addr_type);
  53. #ifdef __cplusplus
  54. }
  55. #endif
  56. #endif /* _ESP_HIDH_GAP_H_ */