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:
parent
446923e4d5
commit
d39d8224be
4 changed files with 39 additions and 21 deletions
|
@ -668,6 +668,7 @@ static void le_set_scan_enable(struct net_buf *buf, struct net_buf **evt)
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_BLUETOOTH_CONTROLLER_STATE_SCAN */
|
#endif /* CONFIG_BLUETOOTH_CONTROLLER_STATE_SCAN */
|
||||||
|
|
||||||
|
#if defined(CONFIG_BLUETOOTH_CENTRAL)
|
||||||
static void le_create_connection(struct net_buf *buf, struct net_buf **evt)
|
static void le_create_connection(struct net_buf *buf, struct net_buf **evt)
|
||||||
{
|
{
|
||||||
struct bt_hci_cp_le_create_conn *cmd = (void *)buf->data;
|
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);
|
*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)
|
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;
|
break;
|
||||||
#endif /* CONFIG_BLUETOOTH_CONTROLLER_STATE_SCAN */
|
#endif /* CONFIG_BLUETOOTH_CONTROLLER_STATE_SCAN */
|
||||||
|
|
||||||
|
#if defined(CONFIG_BLUETOOTH_CENTRAL)
|
||||||
case BT_OCF(BT_HCI_OP_LE_CREATE_CONN):
|
case BT_OCF(BT_HCI_OP_LE_CREATE_CONN):
|
||||||
le_create_connection(cmd, evt);
|
le_create_connection(cmd, evt);
|
||||||
break;
|
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):
|
case BT_OCF(BT_HCI_OP_LE_START_ENCRYPTION):
|
||||||
le_start_encryption(cmd, evt);
|
le_start_encryption(cmd, evt);
|
||||||
break;
|
break;
|
||||||
|
#endif /* CONFIG_BLUETOOTH_CENTRAL */
|
||||||
|
|
||||||
case BT_OCF(BT_HCI_OP_LE_LTK_REQ_REPLY):
|
case BT_OCF(BT_HCI_OP_LE_LTK_REQ_REPLY):
|
||||||
le_ltk_req_reply(cmd, evt);
|
le_ltk_req_reply(cmd, evt);
|
||||||
|
|
|
@ -4,3 +4,4 @@ ccflags-y += -I$(srctree)/subsys/bluetooth/controller
|
||||||
obj-y += crypto.o ctrl.o ll.o
|
obj-y += crypto.o ctrl.o ll.o
|
||||||
obj-$(CONFIG_BLUETOOTH_CONTROLLER_STATE_ADV) += ll_adv.o
|
obj-$(CONFIG_BLUETOOTH_CONTROLLER_STATE_ADV) += ll_adv.o
|
||||||
obj-$(CONFIG_BLUETOOTH_CONTROLLER_STATE_SCAN) += ll_scan.o
|
obj-$(CONFIG_BLUETOOTH_CONTROLLER_STATE_SCAN) += ll_scan.o
|
||||||
|
obj-$(CONFIG_BLUETOOTH_CENTRAL) += ll_master.o
|
||||||
|
|
|
@ -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);
|
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);
|
|
||||||
}
|
|
||||||
|
|
34
subsys/bluetooth/controller/ll_sw/ll_master.c
Normal file
34
subsys/bluetooth/controller/ll_sw/ll_master.c
Normal 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);
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue