From dbdfd2995b2b600aca13d8c99c556dfed68f09c3 Mon Sep 17 00:00:00 2001 From: Wolfgang Puffitsch Date: Wed, 15 Jan 2020 12:54:53 +0100 Subject: [PATCH] Bluetooth: host: Guard calls to bt_conn functions Guard calls to bt_conn functions in bt_le_adv_start_internal with IS_ENABLED(CONFIG_BT_PERIPHERAL) to avoid undefined symbols in builds that do not support that role. Signed-off-by: Wolfgang Puffitsch --- subsys/bluetooth/host/hci_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/subsys/bluetooth/host/hci_core.c b/subsys/bluetooth/host/hci_core.c index 9ef977e5d18..e06179e5c0b 100644 --- a/subsys/bluetooth/host/hci_core.c +++ b/subsys/bluetooth/host/hci_core.c @@ -5957,14 +5957,14 @@ int bt_le_adv_start_internal(const struct bt_le_adv_param *param, err = set_advertise_enable(true); if (err) { BT_ERR("Failed to start advertiser"); - if (conn) { + if (IS_ENABLED(CONFIG_BT_PERIPHERAL) && conn) { bt_conn_set_state(conn, BT_CONN_DISCONNECTED); bt_conn_unref(conn); } return err; } - if (conn) { + if (IS_ENABLED(CONFIG_BT_PERIPHERAL) && conn) { /* If undirected connectable advertiser we have created a * connection object that we don't yet give to the application. * Since we don't give the application a reference to manage in