Bluetooth: Fix notifying about cancelled connection attempt

If LE Create Connection was cancelled LE Connection Complete event
status is set to Unknown Connection Identifier and doesn't contain
valid remote address. In such case we need to look for connection
object in CONNECT state without using address. There can be only one
object in that state anyway so this is OK also for other error codes.

Change-Id: Ie61d47b8bb7ade6b2ab4db14ee394a65bb4e642b
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
This commit is contained in:
Szymon Janc 2016-06-08 05:56:30 +02:00
parent 609843a527
commit c6fdf09340
1 changed files with 16 additions and 7 deletions

View File

@ -611,14 +611,15 @@ static void le_conn_complete(struct net_buf *buf)
BT_DBG("status %u handle %u role %u %s", evt->status, handle,
evt->role, bt_addr_le_str(&evt->peer_addr));
id_addr = find_id_addr(&evt->peer_addr);
/* Make lookup to check if there's a connection object in CONNECT state
* associated with passed peer LE address.
*/
conn = bt_conn_lookup_state_le(id_addr, BT_CONN_CONNECT);
if (evt->status) {
/*
* if there was an error we are only interested in pending
* connection so there is no need to check ID address as
* only one connection can be in that state
*
* Depending on error code address might not be valid anyway.
*/
conn = bt_conn_lookup_state_le(NULL, BT_CONN_CONNECT);
if (!conn) {
return;
}
@ -636,6 +637,14 @@ static void le_conn_complete(struct net_buf *buf)
return;
}
id_addr = find_id_addr(&evt->peer_addr);
/*
* Make lookup to check if there's a connection object in
* CONNECT state associated with passed peer LE address.
*/
conn = bt_conn_lookup_state_le(id_addr, BT_CONN_CONNECT);
if (evt->role == BT_CONN_ROLE_SLAVE) {
/*
* clear advertising even if we are not able to add connection