mirror of
https://github.com/espressif/esp-nimble.git
synced 2026-09-07 01:30:05 +00:00
BLE Host - Trust conn-complete-evt role field
Prior to this change: for failed connection-complete events, the host fully inferred the role from the status code. A code of BLE_ERR_DIR_ADV_TMO implied the slave role; all other roles implied the master role. Now: for failed connection-complete events, the host only infers the role from the status code when the status is BLE_ERR_DIR_ADV_TMO (role=slave). For all other status codes, the host reads the role field directly. X-Original-Commit: b51a2985222a1c7b5c5ae1e4257caf067dfc1dfd
This commit is contained in:
@@ -1137,14 +1137,12 @@ ble_gap_rx_conn_complete(struct hci_le_conn_complete *evt)
|
|||||||
|
|
||||||
if (evt->status != BLE_ERR_SUCCESS) {
|
if (evt->status != BLE_ERR_SUCCESS) {
|
||||||
/* Determine the role from the status code. */
|
/* Determine the role from the status code. */
|
||||||
switch (evt->status) {
|
if (evt->status == BLE_ERR_DIR_ADV_TMO) {
|
||||||
case BLE_ERR_DIR_ADV_TMO:
|
evt->role = BLE_HCI_LE_CONN_COMPLETE_ROLE_SLAVE;
|
||||||
if (ble_gap_adv_active()) {
|
}
|
||||||
ble_gap_adv_finished();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
switch (evt->role) {
|
||||||
|
case BLE_HCI_LE_CONN_COMPLETE_ROLE_MASTER:
|
||||||
if (ble_gap_master_in_progress()) {
|
if (ble_gap_master_in_progress()) {
|
||||||
if (evt->status == BLE_ERR_UNK_CONN_ID) {
|
if (evt->status == BLE_ERR_UNK_CONN_ID) {
|
||||||
/* Connect procedure successfully cancelled. */
|
/* Connect procedure successfully cancelled. */
|
||||||
@@ -1154,6 +1152,17 @@ ble_gap_rx_conn_complete(struct hci_le_conn_complete *evt)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case BLE_HCI_LE_CONN_COMPLETE_ROLE_SLAVE:
|
||||||
|
if (ble_gap_adv_active()) {
|
||||||
|
ble_gap_adv_finished();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
BLE_HS_LOG(INFO, "controller reported invalid role in connection "
|
||||||
|
" complete event: %d", evt->role);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user