Skip to content

Commit

Permalink
Bluetooth: hci_core: Exclude conn creation related code for non-central
Browse files Browse the repository at this point in the history
Don't build the code that is related to central role if the target
does not support connection creation.
This helps to reduce the application image size that implement
either Observer, Peripheral or Broadcaster role.

Note:
BT_CENTRAL implies BT_CONN and BT_OBSERVER

Signed-off-by: Mariusz Skamra <[email protected]>
  • Loading branch information
MariuszSkamra authored and jhedberg committed Jun 27, 2018
1 parent 80e02a9 commit f3ba6e3
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions subsys/bluetooth/host/hci_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ static void hci_num_completed_packets(struct net_buf *buf)
}
}

#if defined(CONFIG_BT_CENTRAL)
static int hci_le_create_conn(const struct bt_conn *conn)
{
struct net_buf *buf;
Expand All @@ -574,6 +575,7 @@ static int hci_le_create_conn(const struct bt_conn *conn)

return bt_hci_cmd_send_sync(BT_HCI_OP_LE_CREATE_CONN, buf, NULL);
}
#endif /* CONFIG_BT_CENTRAL */

static void hci_stack_dump(const struct k_thread *thread, void *user_data)
{
Expand Down Expand Up @@ -633,10 +635,12 @@ static void hci_disconn_complete(struct net_buf *buf)
return;
}

#if defined(CONFIG_BT_CENTRAL)
if (atomic_test_bit(conn->flags, BT_CONN_AUTO_CONNECT)) {
bt_conn_set_state(conn, BT_CONN_CONNECT_SCAN);
bt_le_scan_update(false);
}
#endif /* CONFIG_BT_CENTRAL */

bt_conn_unref(conn);

Expand Down Expand Up @@ -1181,6 +1185,7 @@ static void le_conn_update_complete(struct net_buf *buf)
bt_conn_unref(conn);
}

#if defined(CONFIG_BT_CENTRAL)
static void check_pending_conn(const bt_addr_le_t *id_addr,
const bt_addr_le_t *addr, u8_t evtype)
{
Expand Down Expand Up @@ -1240,6 +1245,7 @@ static void check_pending_conn(const bt_addr_le_t *id_addr,
bt_conn_unref(conn);
bt_le_scan_update(false);
}
#endif /* CONFIG_BT_CENTRAL */

#if defined(CONFIG_BT_HCI_ACL_FLOW_CONTROL)
static int set_flow_control(void)
Expand Down Expand Up @@ -3175,9 +3181,9 @@ static void le_adv_report(struct net_buf *buf)
net_buf_simple_restore(&buf->b, &state);
}

#if defined(CONFIG_BT_CONN)
#if defined(CONFIG_BT_CENTRAL)
check_pending_conn(&id_addr, &info->addr, info->evt_type);
#endif /* CONFIG_BT_CONN */
#endif /* CONFIG_BT_CENTRAL */

/* Get next report iteration by moving pointer to right offset
* in buf according to spec 4.2, Vol 2, Part E, 7.7.65.2.
Expand Down

0 comments on commit f3ba6e3

Please sign in to comment.