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>
This commit is contained in:
Vinayak Chettimada 2017-02-03 04:50:04 +01:00 committed by Johan Hedberg
commit d39d8224be
4 changed files with 39 additions and 21 deletions

View file

@ -668,6 +668,7 @@ static void le_set_scan_enable(struct net_buf *buf, struct net_buf **evt)
}
#endif /* CONFIG_BLUETOOTH_CONTROLLER_STATE_SCAN */
#if defined(CONFIG_BLUETOOTH_CENTRAL)
static void le_create_connection(struct net_buf *buf, struct net_buf **evt)
{
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)
*evt = cmd_status((!status) ? 0x00 : BT_HCI_ERR_CMD_DISALLOWED);
}
#endif /* CONFIG_BLUETOOTH_CENTRAL */
static void le_ltk_req_reply(struct net_buf *buf, struct net_buf **evt)
{
@ -971,6 +973,7 @@ static int controller_cmd_handle(u8_t ocf, struct net_buf *cmd,
break;
#endif /* CONFIG_BLUETOOTH_CONTROLLER_STATE_SCAN */
#if defined(CONFIG_BLUETOOTH_CENTRAL)
case BT_OCF(BT_HCI_OP_LE_CREATE_CONN):
le_create_connection(cmd, evt);
break;
@ -986,6 +989,7 @@ static int controller_cmd_handle(u8_t ocf, struct net_buf *cmd,
case BT_OCF(BT_HCI_OP_LE_START_ENCRYPTION):
le_start_encryption(cmd, evt);
break;
#endif /* CONFIG_BLUETOOTH_CENTRAL */
case BT_OCF(BT_HCI_OP_LE_LTK_REQ_REPLY):
le_ltk_req_reply(cmd, evt);

View file

@ -4,3 +4,4 @@ ccflags-y += -I$(srctree)/subsys/bluetooth/controller
obj-y += crypto.o ctrl.o ll.o
obj-$(CONFIG_BLUETOOTH_CONTROLLER_STATE_ADV) += ll_adv.o
obj-$(CONFIG_BLUETOOTH_CONTROLLER_STATE_SCAN) += ll_scan.o
obj-$(CONFIG_BLUETOOTH_CENTRAL) += ll_master.o

View file

@ -252,24 +252,3 @@ void ll_addr_set(u8_t addr_type, u8_t const *const bdaddr)
memcpy(_ll_context.pub_addr, bdaddr, BDADDR_SIZE);
}
}
u32_t ll_create_connection(u16_t scan_interval, u16_t scan_window,
u8_t filter_policy, u8_t peer_addr_type,
u8_t *peer_addr, u8_t own_addr_type,
u16_t interval, u16_t latency,
u16_t timeout)
{
u32_t status;
status = radio_connect_enable(peer_addr_type, peer_addr, interval,
latency, timeout);
if (status) {
return status;
}
return radio_scan_enable(0, own_addr_type, (own_addr_type) ?
&_ll_context.rnd_addr[0] :
&_ll_context.pub_addr[0],
scan_interval, scan_window, filter_policy);
}

View file

@ -0,0 +1,34 @@
/*
* Copyright (c) 2016-2017 Nordic Semiconductor ASA
* Copyright (c) 2016 Vinayak Kariappa Chettimada
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr.h>
#include "util/util.h"
#include "pdu.h"
#include "ctrl.h"
#include "ll.h"
u32_t ll_create_connection(u16_t scan_interval, u16_t scan_window,
u8_t filter_policy, u8_t peer_addr_type,
u8_t *peer_addr, u8_t own_addr_type,
u16_t interval, u16_t latency,
u16_t timeout)
{
u32_t status;
status = radio_connect_enable(peer_addr_type, peer_addr, interval,
latency, timeout);
if (status) {
return status;
}
return radio_scan_enable(0, own_addr_type,
ll_addr_get(own_addr_type, NULL),
scan_interval, scan_window, filter_policy);
}