Bluetooth: Explicitly set LE event mask on init
This allows to disable events not required by application. In future this can be extended to enable events that are not enabled by default. < HCI Command: LE Set Event Mask (0x08|0x0001) plen 8 24.018392 Mask: 0x000000000000001f LE Connection Complete LE Advertising Report LE Connection Update Complete LE Read Remote Used Features Complete LE Long Term Key Request > HCI Event: Command Complete (0x0e) plen 4 24.019215 LE Set Event Mask (0x08|0x0001) ncmd 1 Status: Success (0x00) Change-Id: I29bfaa0743ac9e604a637f51503ff28a9b2074c2 Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
This commit is contained in:
parent
32f1e6d27a
commit
cf1ec9fb7f
2 changed files with 41 additions and 9 deletions
|
@ -180,6 +180,14 @@ struct bt_hci_rp_read_bd_addr {
|
|||
bt_addr_t bdaddr;
|
||||
} __packed;
|
||||
|
||||
#define BT_HCI_OP_LE_SET_EVENT_MASK BT_OP(BT_OGF_LE, 0x0001)
|
||||
struct bt_hci_cp_le_set_event_mask {
|
||||
uint8_t events[8];
|
||||
} __packed;
|
||||
struct bt_hci_rp_le_set_event_mask {
|
||||
uint8_t status;
|
||||
} __packed;
|
||||
|
||||
#define BT_HCI_OP_LE_READ_BUFFER_SIZE BT_OP(BT_OGF_LE, 0x0002)
|
||||
struct bt_hci_rp_le_read_buffer_size {
|
||||
uint8_t status;
|
||||
|
|
|
@ -1400,8 +1400,10 @@ static int common_init(void)
|
|||
|
||||
static int le_init(void)
|
||||
{
|
||||
struct bt_hci_cp_write_le_host_supp *cp_le;
|
||||
struct bt_hci_cp_le_set_event_mask *cp_mask;
|
||||
struct net_buf *buf;
|
||||
struct net_buf *rsp;
|
||||
struct bt_hci_cp_write_le_host_supp *cp;
|
||||
int err;
|
||||
|
||||
/* For now we only support LE capable controllers */
|
||||
|
@ -1428,24 +1430,46 @@ static int le_init(void)
|
|||
net_buf_unref(rsp);
|
||||
|
||||
if (lmp_bredr_capable(bt_dev)) {
|
||||
struct net_buf *buf;
|
||||
|
||||
buf = bt_hci_cmd_create(BT_HCI_OP_LE_WRITE_LE_HOST_SUPP,
|
||||
sizeof(*cp));
|
||||
sizeof(*cp_le));
|
||||
if (!buf) {
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
cp = net_buf_add(buf, sizeof(*cp));
|
||||
cp_le = net_buf_add(buf, sizeof(*cp_le));
|
||||
|
||||
/* Excplicitly enable LE for dual-mode controllers */
|
||||
cp->le = 0x01;
|
||||
cp->simul = 0x00;
|
||||
return bt_hci_cmd_send_sync(BT_HCI_OP_LE_WRITE_LE_HOST_SUPP,
|
||||
buf, NULL);
|
||||
cp_le->le = 0x01;
|
||||
cp_le->simul = 0x00;
|
||||
err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_WRITE_LE_HOST_SUPP, buf,
|
||||
NULL);
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
buf = bt_hci_cmd_create(BT_HCI_OP_LE_SET_EVENT_MASK, sizeof(*cp_mask));
|
||||
if (!buf) {
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
cp_mask = net_buf_add(buf, sizeof(*cp_mask));
|
||||
memset(cp_mask, 0, sizeof(*cp_mask));
|
||||
|
||||
cp_mask->events[0] |= 0x02; /* LE Advertising Report Event */
|
||||
|
||||
#if defined(CONFIG_BLUETOOTH_CONN)
|
||||
cp_mask->events[0] |= 0x01; /* LE Connection Complete Event */
|
||||
cp_mask->events[0] |= 0x04; /* LE Connection Update Complete Event */
|
||||
cp_mask->events[0] |= 0x08; /* LE Read Remote Used Features Compl Evt */
|
||||
#endif /* CONFIG_BLUETOOTH_CONN */
|
||||
|
||||
#if defined(CONFIG_BLUETOOTH_SMP)
|
||||
cp_mask->events[0] |= 0x10; /* LE Long Term Key Request Event */
|
||||
#endif /* CONFIG_BLUETOOTH_SMP */
|
||||
|
||||
return bt_hci_cmd_send_sync(BT_HCI_OP_LE_SET_EVENT_MASK, buf, NULL);
|
||||
}
|
||||
|
||||
static int br_init(void)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue