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:
Christopher Collins
2016-09-30 12:41:31 -07:00
parent 3150aa98f7
commit fee4a4fa8d
+16 -7
View File
@@ -1137,14 +1137,12 @@ ble_gap_rx_conn_complete(struct hci_le_conn_complete *evt)
if (evt->status != BLE_ERR_SUCCESS) {
/* Determine the role from the status code. */
switch (evt->status) {
case BLE_ERR_DIR_ADV_TMO:
if (ble_gap_adv_active()) {
ble_gap_adv_finished();
}
break;
if (evt->status == BLE_ERR_DIR_ADV_TMO) {
evt->role = BLE_HCI_LE_CONN_COMPLETE_ROLE_SLAVE;
}
default:
switch (evt->role) {
case BLE_HCI_LE_CONN_COMPLETE_ROLE_MASTER:
if (ble_gap_master_in_progress()) {
if (evt->status == BLE_ERR_UNK_CONN_ID) {
/* Connect procedure successfully cancelled. */
@@ -1154,6 +1152,17 @@ ble_gap_rx_conn_complete(struct hci_le_conn_complete *evt)
}
}
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;