Bluetooth: Refactor check_pending_conn error handling

If anything went wrong just report connection failed. This makes
code easier to read and less error prone. Also makes sure that
scanning is reenabled with correct parameters on failure.

Change-Id: I7387571f6dbf308511694a635aa47d5371a81616
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
This commit is contained in:
Szymon Janc 2016-05-04 17:13:16 +02:00 committed by Johan Hedberg
commit ac52cffa32

View file

@ -846,12 +846,12 @@ static void check_pending_conn(const bt_addr_le_t *id_addr,
}
if (bt_hci_stop_scanning()) {
goto done;
goto failed;
}
#if defined(CONFIG_BLUETOOTH_PRIVACY)
if (bt_smp_create_rpa(bt_dev.irk, &conn->le.init_addr.a)) {
goto done;
goto failed;
}
conn->le.init_addr.type = BT_ADDR_LE_RANDOM;
#else
@ -861,16 +861,18 @@ static void check_pending_conn(const bt_addr_le_t *id_addr,
bt_addr_le_copy(&conn->le.resp_addr, addr);
if (hci_le_create_conn(conn)) {
conn->err = BT_HCI_ERR_UNSPECIFIED;
bt_conn_set_state(conn, BT_CONN_DISCONNECTED);
bt_le_scan_update(false);
goto done;
goto failed;
}
bt_conn_set_state(conn, BT_CONN_CONNECT);
done:
bt_conn_unref(conn);
return;
failed:
conn->err = BT_HCI_ERR_UNSPECIFIED;
bt_conn_set_state(conn, BT_CONN_DISCONNECTED);
bt_conn_unref(conn);
bt_le_scan_update(false);
}
static int set_flow_control(void)