Bluetooth: controller: Refactor LL Scan state to ll_scan.c file

Move scanning state related implementation out into a
separate ll_scan.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 446923e4d5
4 changed files with 55 additions and 38 deletions

View file

@ -628,6 +628,7 @@ static void le_set_adv_enable(struct net_buf *buf, struct net_buf **evt)
}
#endif /* CONFIG_BLUETOOTH_CONTROLLER_STATE_ADV */
#if defined(CONFIG_BLUETOOTH_CONTROLLER_STATE_SCAN)
static void le_set_scan_param(struct net_buf *buf, struct net_buf **evt)
{
struct bt_hci_cp_le_set_scan_param *cmd = (void *)buf->data;
@ -665,6 +666,7 @@ static void le_set_scan_enable(struct net_buf *buf, struct net_buf **evt)
ccst = cmd_complete(evt, sizeof(*ccst));
ccst->status = (!status) ? 0x00 : BT_HCI_ERR_CMD_DISALLOWED;
}
#endif /* CONFIG_BLUETOOTH_CONTROLLER_STATE_SCAN */
static void le_create_connection(struct net_buf *buf, struct net_buf **evt)
{
@ -959,6 +961,7 @@ static int controller_cmd_handle(u8_t ocf, struct net_buf *cmd,
break;
#endif /* CONFIG_BLUETOOTH_CONTROLLER_STATE_ADV */
#if defined(CONFIG_BLUETOOTH_CONTROLLER_STATE_SCAN)
case BT_OCF(BT_HCI_OP_LE_SET_SCAN_PARAM):
le_set_scan_param(cmd, evt);
break;
@ -966,6 +969,7 @@ static int controller_cmd_handle(u8_t ocf, struct net_buf *cmd,
case BT_OCF(BT_HCI_OP_LE_SET_SCAN_ENABLE):
le_set_scan_enable(cmd, evt);
break;
#endif /* CONFIG_BLUETOOTH_CONTROLLER_STATE_SCAN */
case BT_OCF(BT_HCI_OP_LE_CREATE_CONN):
le_create_connection(cmd, evt);

View file

@ -3,3 +3,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

View file

@ -52,14 +52,6 @@ static struct {
u8_t rnd_addr[BDADDR_SIZE];
} _ll_context;
static struct {
u16_t interval;
u16_t window;
u8_t scan_type:1;
u8_t tx_addr:1;
u8_t filter_policy:1;
} _ll_scan_params;
void mayfly_enable_cb(u8_t caller_id, u8_t callee_id, u8_t enable)
{
(void)caller_id;
@ -261,36 +253,6 @@ void ll_addr_set(u8_t addr_type, u8_t const *const bdaddr)
}
}
void ll_scan_params_set(u8_t scan_type, u16_t interval, u16_t window,
u8_t own_addr_type, u8_t filter_policy)
{
_ll_scan_params.scan_type = scan_type;
_ll_scan_params.interval = interval;
_ll_scan_params.window = window;
_ll_scan_params.tx_addr = own_addr_type;
_ll_scan_params.filter_policy = filter_policy;
}
u32_t ll_scan_enable(u8_t enable)
{
u32_t status;
if (enable) {
status = radio_scan_enable(_ll_scan_params.scan_type,
_ll_scan_params.tx_addr,
(_ll_scan_params.tx_addr) ?
&_ll_context.rnd_addr[0] :
&_ll_context.pub_addr[0],
_ll_scan_params.interval,
_ll_scan_params.window,
_ll_scan_params.filter_policy);
} else {
status = radio_scan_disable();
}
return status;
}
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,

View file

@ -0,0 +1,50 @@
/*
* 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"
static struct {
u16_t interval;
u16_t window;
u8_t scan_type:1;
u8_t tx_addr:1;
u8_t filter_policy:1;
} ll_scan;
void ll_scan_params_set(u8_t scan_type, u16_t interval, u16_t window,
u8_t own_addr_type, u8_t filter_policy)
{
ll_scan.scan_type = scan_type;
ll_scan.interval = interval;
ll_scan.window = window;
ll_scan.tx_addr = own_addr_type;
ll_scan.filter_policy = filter_policy;
}
u32_t ll_scan_enable(u8_t enable)
{
u32_t status;
if (!enable) {
status = radio_scan_disable();
return status;
}
status = radio_scan_enable(ll_scan.scan_type, ll_scan.tx_addr,
ll_addr_get(ll_scan.tx_addr, NULL),
ll_scan.interval, ll_scan.window,
ll_scan.filter_policy);
return status;
}