Commit 569d9885 authored by Rubin Gerritsen's avatar Rubin Gerritsen Committed by Carles Cufi
Browse files

Bluetooth: ISO: Don't call LE Create Conn Cancel on ISO disconnect



When calling `bt_iso_chan_disconnect()` while the channel is
connecting, the host should simply use HCI Disconnect.

Note: For the peripheral it is not allowed to call HCI Disconnect
on a CIS after it has accepted the CIS request, but before it has
received the CIS established event. The implementation in this
commit does not fix this case. In that case the controller will
return an error code.

Also, this commit does not handle the events following the
HCI Disconnect correctly.
In this particular case, two events are raised by the controller.
See Core_v5.4, Vol 6, Part D, Figure 6.51.

Signed-off-by: default avatarRubin Gerritsen <rubin.gerritsen@nordicsemi.no>
parent 4885dae9
Loading
Loading
Loading
Loading
+14 −5
Original line number Diff line number Diff line
@@ -1498,15 +1498,24 @@ int bt_conn_disconnect(struct bt_conn *conn, uint8_t reason)
		}
		return 0;
	case BT_CONN_CONNECTING:
		if (conn->type == BT_CONN_TYPE_LE) {
			if (IS_ENABLED(CONFIG_BT_CENTRAL)) {
				k_work_cancel_delayable(&conn->deferred_work);
				return bt_le_create_conn_cancel();
			}
		}
#if defined(CONFIG_BT_ISO)
		else if (conn->type == BT_CONN_TYPE_ISO) {
			return conn_disconnect(conn, reason);
		}
#endif /* CONFIG_BT_ISO */
#if defined(CONFIG_BT_BREDR)
		if (conn->type == BT_CONN_TYPE_BR) {
		else if (conn->type == BT_CONN_TYPE_BR) {
			return bt_hci_connect_br_cancel(conn);
		}
#endif /* CONFIG_BT_BREDR */

		if (IS_ENABLED(CONFIG_BT_CENTRAL)) {
			k_work_cancel_delayable(&conn->deferred_work);
			return bt_le_create_conn_cancel();
		else {
			__ASSERT(false, "Invalid conn type %u", conn->type);
		}

		return 0;