1 /* Copyright (c) 2024 Nordic Semiconductor ASA
2  * SPDX-License-Identifier: Apache-2.0
3  */
4 
5 #include <stdint.h>
6 #include <testlib/conn.h>
7 #include <zephyr/bluetooth/bluetooth.h>
8 #include <zephyr/bluetooth/conn.h>
9 #include <zephyr/bluetooth/gatt.h>
10 #include <zephyr/bluetooth/hci_types.h>
11 #include <zephyr/kernel.h>
12 #include <zephyr/logging/log.h>
13 #include <zephyr/sys/__assert.h>
14 
bt_testlib_disconnect(struct bt_conn ** connp,uint8_t reason)15 int bt_testlib_disconnect(struct bt_conn **connp, uint8_t reason)
16 {
17 	int err;
18 
19 	__ASSERT_NO_MSG(connp);
20 	__ASSERT_NO_MSG(*connp);
21 
22 	err = bt_conn_disconnect(*connp, BT_HCI_ERR_REMOTE_USER_TERM_CONN);
23 
24 	if (!err) {
25 		bt_testlib_wait_disconnected(*connp);
26 		bt_testlib_conn_unref(connp);
27 	}
28 
29 	return err;
30 }
31