Skip to content

Commit d39d822

Browse files
cvinayakjhedberg
authored andcommitted
Bluetooth: controller: Refactor LL Master role to ll_master.c
Move master role related implementation out into a separate ll_master.c file. Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
1 parent 446923e commit d39d822

File tree

4 files changed

+39
-21
lines changed

4 files changed

+39
-21
lines changed

subsys/bluetooth/controller/hci/hci.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,7 @@ static void le_set_scan_enable(struct net_buf *buf, struct net_buf **evt)
668668
}
669669
#endif /* CONFIG_BLUETOOTH_CONTROLLER_STATE_SCAN */
670670

671+
#if defined(CONFIG_BLUETOOTH_CENTRAL)
671672
static void le_create_connection(struct net_buf *buf, struct net_buf **evt)
672673
{
673674
struct bt_hci_cp_le_create_conn *cmd = (void *)buf->data;
@@ -731,6 +732,7 @@ static void le_start_encryption(struct net_buf *buf, struct net_buf **evt)
731732

732733
*evt = cmd_status((!status) ? 0x00 : BT_HCI_ERR_CMD_DISALLOWED);
733734
}
735+
#endif /* CONFIG_BLUETOOTH_CENTRAL */
734736

735737
static void le_ltk_req_reply(struct net_buf *buf, struct net_buf **evt)
736738
{
@@ -971,6 +973,7 @@ static int controller_cmd_handle(u8_t ocf, struct net_buf *cmd,
971973
break;
972974
#endif /* CONFIG_BLUETOOTH_CONTROLLER_STATE_SCAN */
973975

976+
#if defined(CONFIG_BLUETOOTH_CENTRAL)
974977
case BT_OCF(BT_HCI_OP_LE_CREATE_CONN):
975978
le_create_connection(cmd, evt);
976979
break;
@@ -986,6 +989,7 @@ static int controller_cmd_handle(u8_t ocf, struct net_buf *cmd,
986989
case BT_OCF(BT_HCI_OP_LE_START_ENCRYPTION):
987990
le_start_encryption(cmd, evt);
988991
break;
992+
#endif /* CONFIG_BLUETOOTH_CENTRAL */
989993

990994
case BT_OCF(BT_HCI_OP_LE_LTK_REQ_REPLY):
991995
le_ltk_req_reply(cmd, evt);

subsys/bluetooth/controller/ll_sw/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ ccflags-y += -I$(srctree)/subsys/bluetooth/controller
44
obj-y += crypto.o ctrl.o ll.o
55
obj-$(CONFIG_BLUETOOTH_CONTROLLER_STATE_ADV) += ll_adv.o
66
obj-$(CONFIG_BLUETOOTH_CONTROLLER_STATE_SCAN) += ll_scan.o
7+
obj-$(CONFIG_BLUETOOTH_CENTRAL) += ll_master.o

subsys/bluetooth/controller/ll_sw/ll.c

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -252,24 +252,3 @@ void ll_addr_set(u8_t addr_type, u8_t const *const bdaddr)
252252
memcpy(_ll_context.pub_addr, bdaddr, BDADDR_SIZE);
253253
}
254254
}
255-
256-
u32_t ll_create_connection(u16_t scan_interval, u16_t scan_window,
257-
u8_t filter_policy, u8_t peer_addr_type,
258-
u8_t *peer_addr, u8_t own_addr_type,
259-
u16_t interval, u16_t latency,
260-
u16_t timeout)
261-
{
262-
u32_t status;
263-
264-
status = radio_connect_enable(peer_addr_type, peer_addr, interval,
265-
latency, timeout);
266-
267-
if (status) {
268-
return status;
269-
}
270-
271-
return radio_scan_enable(0, own_addr_type, (own_addr_type) ?
272-
&_ll_context.rnd_addr[0] :
273-
&_ll_context.pub_addr[0],
274-
scan_interval, scan_window, filter_policy);
275-
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (c) 2016-2017 Nordic Semiconductor ASA
3+
* Copyright (c) 2016 Vinayak Kariappa Chettimada
4+
*
5+
* SPDX-License-Identifier: Apache-2.0
6+
*/
7+
8+
#include <zephyr.h>
9+
10+
#include "util/util.h"
11+
12+
#include "pdu.h"
13+
#include "ctrl.h"
14+
#include "ll.h"
15+
16+
u32_t ll_create_connection(u16_t scan_interval, u16_t scan_window,
17+
u8_t filter_policy, u8_t peer_addr_type,
18+
u8_t *peer_addr, u8_t own_addr_type,
19+
u16_t interval, u16_t latency,
20+
u16_t timeout)
21+
{
22+
u32_t status;
23+
24+
status = radio_connect_enable(peer_addr_type, peer_addr, interval,
25+
latency, timeout);
26+
27+
if (status) {
28+
return status;
29+
}
30+
31+
return radio_scan_enable(0, own_addr_type,
32+
ll_addr_get(own_addr_type, NULL),
33+
scan_interval, scan_window, filter_policy);
34+
}

0 commit comments

Comments
 (0)