Bluetooth: host: Fix whitelist for non-central bluetooth applications
Fix compilation issue when wanting to use whitelist in bluetooth applications that does not have CONFIG_BT_CENTRAL defined. These functions are useful even for broadcaster and observer roles. Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit is contained in:
parent
5229276817
commit
23554b00b8
2 changed files with 69 additions and 67 deletions
|
@ -2008,73 +2008,6 @@ static void bt_conn_set_param_le(struct bt_conn *conn,
|
|||
}
|
||||
|
||||
#if defined(CONFIG_BT_WHITELIST)
|
||||
int bt_le_whitelist_add(const bt_addr_le_t *addr)
|
||||
{
|
||||
struct bt_hci_cp_le_add_dev_to_wl *cp;
|
||||
struct net_buf *buf;
|
||||
int err;
|
||||
|
||||
if (!(bt_dev.le.wl_entries < bt_dev.le.wl_size)) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
buf = bt_hci_cmd_create(BT_HCI_OP_LE_ADD_DEV_TO_WL, sizeof(*cp));
|
||||
if (!buf) {
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
cp = net_buf_add(buf, sizeof(*cp));
|
||||
bt_addr_le_copy(&cp->addr, addr);
|
||||
|
||||
err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_ADD_DEV_TO_WL, buf, NULL);
|
||||
if (err) {
|
||||
BT_ERR("Failed to add device to whitelist");
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
bt_dev.le.wl_entries++;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bt_le_whitelist_rem(const bt_addr_le_t *addr)
|
||||
{
|
||||
struct bt_hci_cp_le_rem_dev_from_wl *cp;
|
||||
struct net_buf *buf;
|
||||
int err;
|
||||
|
||||
buf = bt_hci_cmd_create(BT_HCI_OP_LE_REM_DEV_FROM_WL, sizeof(*cp));
|
||||
if (!buf) {
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
cp = net_buf_add(buf, sizeof(*cp));
|
||||
bt_addr_le_copy(&cp->addr, addr);
|
||||
|
||||
err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_REM_DEV_FROM_WL, buf, NULL);
|
||||
if (err) {
|
||||
BT_ERR("Failed to remove device from whitelist");
|
||||
return err;
|
||||
}
|
||||
|
||||
bt_dev.le.wl_entries--;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bt_le_whitelist_clear(void)
|
||||
{
|
||||
int err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_CLEAR_WL, NULL, NULL);
|
||||
|
||||
if (err) {
|
||||
BT_ERR("Failed to clear whitelist");
|
||||
return err;
|
||||
}
|
||||
|
||||
bt_dev.le.wl_entries = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bt_conn_create_auto_le(const struct bt_le_conn_param *param)
|
||||
{
|
||||
struct bt_conn *conn;
|
||||
|
|
|
@ -5896,6 +5896,75 @@ int bt_le_scan_stop(void)
|
|||
}
|
||||
#endif /* CONFIG_BT_OBSERVER */
|
||||
|
||||
#if defined(CONFIG_BT_WHITELIST)
|
||||
int bt_le_whitelist_add(const bt_addr_le_t *addr)
|
||||
{
|
||||
struct bt_hci_cp_le_add_dev_to_wl *cp;
|
||||
struct net_buf *buf;
|
||||
int err;
|
||||
|
||||
if (!(bt_dev.le.wl_entries < bt_dev.le.wl_size)) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
buf = bt_hci_cmd_create(BT_HCI_OP_LE_ADD_DEV_TO_WL, sizeof(*cp));
|
||||
if (!buf) {
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
cp = net_buf_add(buf, sizeof(*cp));
|
||||
bt_addr_le_copy(&cp->addr, addr);
|
||||
|
||||
err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_ADD_DEV_TO_WL, buf, NULL);
|
||||
if (err) {
|
||||
BT_ERR("Failed to add device to whitelist");
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
bt_dev.le.wl_entries++;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bt_le_whitelist_rem(const bt_addr_le_t *addr)
|
||||
{
|
||||
struct bt_hci_cp_le_rem_dev_from_wl *cp;
|
||||
struct net_buf *buf;
|
||||
int err;
|
||||
|
||||
buf = bt_hci_cmd_create(BT_HCI_OP_LE_REM_DEV_FROM_WL, sizeof(*cp));
|
||||
if (!buf) {
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
cp = net_buf_add(buf, sizeof(*cp));
|
||||
bt_addr_le_copy(&cp->addr, addr);
|
||||
|
||||
err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_REM_DEV_FROM_WL, buf, NULL);
|
||||
if (err) {
|
||||
BT_ERR("Failed to remove device from whitelist");
|
||||
return err;
|
||||
}
|
||||
|
||||
bt_dev.le.wl_entries--;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bt_le_whitelist_clear(void)
|
||||
{
|
||||
int err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_CLEAR_WL, NULL, NULL);
|
||||
|
||||
if (err) {
|
||||
BT_ERR("Failed to clear whitelist");
|
||||
return err;
|
||||
}
|
||||
|
||||
bt_dev.le.wl_entries = 0;
|
||||
return 0;
|
||||
}
|
||||
#endif /* defined(CONFIG_BT_WHITELIST) */
|
||||
|
||||
int bt_le_set_chan_map(u8_t chan_map[5])
|
||||
{
|
||||
struct bt_hci_cp_le_set_host_chan_classif *cp;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue