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. 14 15 #ifndef _ESP_HID_GAP_H_ 16 #define _ESP_HID_GAP_H_ 17 18 #define HIDH_IDLE_MODE 0x00 19 #define HIDH_BLE_MODE 0x01 20 #define HIDH_BT_MODE 0x02 21 #define HIDH_BTDM_MODE 0x03 22 23 #if CONFIG_BT_HID_HOST_ENABLED 24 #if CONFIG_BT_BLE_ENABLED 25 #define HID_HOST_MODE HIDH_BTDM_MODE 26 #else 27 #define HID_HOST_MODE HIDH_BT_MODE 28 #endif 29 #elif CONFIG_BT_BLE_ENABLED 30 #define HID_HOST_MODE HIDH_BLE_MODE 31 #else 32 #define HID_HOST_MODE HIDH_IDLE_MODE 33 #endif 34 35 #include "esp_err.h" 36 #include "esp_log.h" 37 38 #include "esp_bt.h" 39 #include "esp_bt_defs.h" 40 #include "esp_bt_main.h" 41 #include "esp_gap_bt_api.h" 42 #include "esp_hid_common.h" 43 #if CONFIG_BT_BLE_ENABLED 44 #include "esp_gattc_api.h" 45 #include "esp_gatt_defs.h" 46 #include "esp_gap_ble_api.h" 47 #endif 48 49 #ifdef __cplusplus 50 extern "C" { 51 #endif 52 53 typedef struct esp_hidh_scan_result_s { 54 struct esp_hidh_scan_result_s *next; 55 56 esp_bd_addr_t bda; 57 const char *name; 58 int8_t rssi; 59 esp_hid_usage_t usage; 60 esp_hid_transport_t transport; //BT, BLE or USB 61 union { 62 struct { 63 esp_bt_cod_t cod; 64 esp_bt_uuid_t uuid; 65 } bt; 66 struct { 67 esp_ble_addr_type_t addr_type; 68 uint16_t appearance; 69 } ble; 70 }; 71 } esp_hid_scan_result_t; 72 73 esp_err_t esp_hid_gap_init(uint8_t mode); 74 esp_err_t esp_hid_scan(uint32_t seconds, size_t *num_results, esp_hid_scan_result_t **results); 75 void esp_hid_scan_results_free(esp_hid_scan_result_t *results); 76 77 esp_err_t esp_hid_ble_gap_adv_init(uint16_t appearance, const char *device_name); 78 esp_err_t esp_hid_ble_gap_adv_start(void); 79 80 void print_uuid(esp_bt_uuid_t *uuid); 81 const char *ble_addr_type_str(esp_ble_addr_type_t ble_addr_type); 82 83 #ifdef __cplusplus 84 } 85 #endif 86 87 #endif /* _ESP_HIDH_GAP_H_ */ 88