fix(bt/bluedroid): Optimize compatibility with IOS and MACOS devices

This commit is contained in:
zhanghaipeng
2023-10-24 14:52:56 +08:00
parent 0e4d03b4de
commit f825a36c38
3 changed files with 12 additions and 7 deletions

View File

@ -304,7 +304,7 @@ static esp_err_t create_hid_db(esp_ble_hidd_dev_t *dev, int device_index)
add_db_record(_last_db, HIDD_LE_IDX_HID_INFO_VAL, (uint8_t *)&s_hid_info_char_uuid, ESP_GATT_PERM_READ, 4, 4, (uint8_t *)hidInfo); add_db_record(_last_db, HIDD_LE_IDX_HID_INFO_VAL, (uint8_t *)&s_hid_info_char_uuid, ESP_GATT_PERM_READ, 4, 4, (uint8_t *)hidInfo);
add_db_record(_last_db, HIDD_LE_IDX_HID_CTNL_PT_CHAR, (uint8_t *)&s_character_declaration_uuid, ESP_GATT_PERM_READ, 1, 1, (uint8_t *)&s_char_prop_write_nr); add_db_record(_last_db, HIDD_LE_IDX_HID_CTNL_PT_CHAR, (uint8_t *)&s_character_declaration_uuid, ESP_GATT_PERM_READ, 1, 1, (uint8_t *)&s_char_prop_write_nr);
add_db_record(_last_db, HIDD_LE_IDX_HID_CTNL_PT_VAL, (uint8_t *)&s_hid_control_point_uuid, ESP_GATT_PERM_READ, 1, 0, NULL); add_db_record(_last_db, HIDD_LE_IDX_HID_CTNL_PT_VAL, (uint8_t *)&s_hid_control_point_uuid, ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE, 1, 0, NULL);
add_db_record(_last_db, HIDD_LE_IDX_PROTO_MODE_CHAR, (uint8_t *)&s_character_declaration_uuid, ESP_GATT_PERM_READ, 1, 1, (uint8_t *)&s_char_prop_read_write_nr); add_db_record(_last_db, HIDD_LE_IDX_PROTO_MODE_CHAR, (uint8_t *)&s_character_declaration_uuid, ESP_GATT_PERM_READ, 1, 1, (uint8_t *)&s_char_prop_read_write_nr);
add_db_record(_last_db, HIDD_LE_IDX_PROTO_MODE_VAL, (uint8_t *)&s_hid_proto_mode_uuid, ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE, 1, 1, (uint8_t *)&dev->protocol); add_db_record(_last_db, HIDD_LE_IDX_PROTO_MODE_VAL, (uint8_t *)&s_hid_proto_mode_uuid, ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE, 1, 1, (uint8_t *)&dev->protocol);
@ -323,7 +323,7 @@ static esp_err_t create_hid_db(esp_ble_hidd_dev_t *dev, int device_index)
add_db_record(_last_db, index++, (uint8_t *)&s_character_declaration_uuid, ESP_GATT_PERM_READ, 1, 1, (uint8_t *)&s_char_prop_read_notify); add_db_record(_last_db, index++, (uint8_t *)&s_character_declaration_uuid, ESP_GATT_PERM_READ, 1, 1, (uint8_t *)&s_char_prop_read_notify);
report->index = index; report->index = index;
add_db_record(_last_db, index++, (uint8_t *)&s_hid_report_uuid, ESP_GATT_PERM_READ, report->value_len, 0, NULL); add_db_record(_last_db, index++, (uint8_t *)&s_hid_report_uuid, ESP_GATT_PERM_READ, report->value_len, 0, NULL);
add_db_record(_last_db, index++, (uint8_t *)&s_character_client_config_uuid, ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE, 2, 0, NULL); add_db_record(_last_db, index++, (uint8_t *)&s_character_client_config_uuid, ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE_ENCRYPTED, 2, 0, NULL);
} else if (report->report_type == ESP_HID_REPORT_TYPE_OUTPUT) { } else if (report->report_type == ESP_HID_REPORT_TYPE_OUTPUT) {
//Output Report //Output Report
add_db_record(_last_db, index++, (uint8_t *)&s_character_declaration_uuid, ESP_GATT_PERM_READ, 1, 1, (uint8_t *)&s_char_prop_read_write_write_nr); add_db_record(_last_db, index++, (uint8_t *)&s_character_declaration_uuid, ESP_GATT_PERM_READ, 1, 1, (uint8_t *)&s_char_prop_read_write_write_nr);

View File

@ -1,7 +1,7 @@
/* This example code is in the Public Domain (or CC0 licensed, at your option.) /*
Unless required by applicable law or agreed to in writing, this software is * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR *
CONDITIONS OF ANY KIND, either express or implied. * SPDX-License-Identifier: Unlicense OR CC0-1.0
*/ */
#include <stdio.h> #include <stdio.h>
@ -300,7 +300,10 @@ static void hidd_event_callback(void *handler_args, esp_event_base_t base, int32
} }
case ESP_HIDD_CONNECT_EVENT: { case ESP_HIDD_CONNECT_EVENT: {
ESP_LOGI(TAG, "CONNECT"); ESP_LOGI(TAG, "CONNECT");
<<<<<<< HEAD
dev_connected = true;//todo: this should be on auth_complete (in GAP) dev_connected = true;//todo: this should be on auth_complete (in GAP)
=======
>>>>>>> 028fce28f7... fix(bt/bluedroid): Optimize compatibility with IOS and MACOS devices
break; break;
} }
case ESP_HIDD_PROTOCOL_MODE_EVENT: { case ESP_HIDD_PROTOCOL_MODE_EVENT: {

View File

@ -452,7 +452,7 @@ static esp_err_t start_bt_scan(uint32_t seconds)
/* /*
* BLE GAP * BLE GAP
* */ * */
extern void ble_hid_task_start_up(void);
static void ble_gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) static void ble_gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param)
{ {
switch (event) { switch (event) {
@ -501,10 +501,12 @@ static void ble_gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_p
* */ * */
case ESP_GAP_BLE_AUTH_CMPL_EVT: case ESP_GAP_BLE_AUTH_CMPL_EVT:
if (!param->ble_security.auth_cmpl.success) { if (!param->ble_security.auth_cmpl.success) {
// if AUTH ERROR,hid maybe don't work.
ESP_LOGE(TAG, "BLE GAP AUTH ERROR: 0x%x", param->ble_security.auth_cmpl.fail_reason); ESP_LOGE(TAG, "BLE GAP AUTH ERROR: 0x%x", param->ble_security.auth_cmpl.fail_reason);
} else { } else {
ESP_LOGI(TAG, "BLE GAP AUTH SUCCESS"); ESP_LOGI(TAG, "BLE GAP AUTH SUCCESS");
} }
ble_hid_task_start_up();
break; break;
case ESP_GAP_BLE_KEY_EVT: //shows the ble key info share with peer device to the user. case ESP_GAP_BLE_KEY_EVT: //shows the ble key info share with peer device to the user.