fix(ble/bluedroid): unblock sync HCI cmd on Command Status error

Release the BLE sync semaphore and record HCI status when a
synchronous command is rejected via Command Status, since no
Command Complete event follows.


(cherry picked from commit 29ae92f4ef)

Co-authored-by: zhanghaipeng <zhanghaipeng@espressif.com>
This commit is contained in:
Zhang Hai Peng
2026-06-26 20:16:38 +08:00
parent 7a5d027ae1
commit 880d05ccfc
2 changed files with 17 additions and 0 deletions

View File

@@ -518,6 +518,18 @@ static bool filter_incoming_event(BT_HDR *packet)
metadata = (hci_cmd_metadata_t *)(wait_entry->data);
if (metadata->command_status_cb) {
metadata->command_status_cb(status, &metadata->command, metadata->context);
#if ((BLE_50_FEATURE_SUPPORT == TRUE) || (BLE_42_FEATURE_SUPPORT == TRUE))
/* No Command Complete follows a failed Command Status (Core Spec Vol 4 Part E). */
if (status != HCI_SUCCESS) {
BlE_SYNC *sync_info = btsnd_hcic_ble_get_sync_info();
if (!sync_info) {
HCI_TRACE_WARNING("%s sync_info is NULL. opcode = 0x%x", __func__, opcode);
} else if (sync_info->sync_sem && sync_info->opcode == opcode) {
osi_sem_give(&sync_info->sync_sem);
sync_info->opcode = 0;
}
}
#endif // #if ((BLE_50_FEATURE_SUPPORT == TRUE) || (BLE_42_FEATURE_SUPPORT == TRUE))
}
goto intercepted;

View File

@@ -1824,6 +1824,11 @@ static void btu_hcif_command_status_evt(uint8_t status, BT_HDR *command, void *c
{
BT_HDR *event = osi_calloc(sizeof(BT_HDR) + sizeof(command_status_hack_t));
command_status_hack_t *hack = (command_status_hack_t *)&event->data[0];
#if ((BLE_50_FEATURE_SUPPORT == TRUE) || (BLE_42_FEATURE_SUPPORT == TRUE))
if (status != HCI_SUCCESS) {
btsnd_hci_ble_set_status(status);
}
#endif // #if ((BLE_50_FEATURE_SUPPORT == TRUE) || (BLE_42_FEATURE_SUPPORT == TRUE))
hack->callback = btu_hcif_command_status_evt_on_task;
hack->status = status;