Bluetooth: Take advantage of the new net_buf_add_u8() helper
Change-Id: Id062d4f68be1960006926ddf463c2c7ecf42d31a Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
ecff186a82
commit
4c11dda411
1 changed files with 5 additions and 15 deletions
|
@ -474,11 +474,10 @@ static void hci_disconn_complete(struct net_buf *buf)
|
||||||
|
|
||||||
if (atomic_test_bit(bt_dev.flags, BT_DEV_ADVERTISING)) {
|
if (atomic_test_bit(bt_dev.flags, BT_DEV_ADVERTISING)) {
|
||||||
struct net_buf *buf;
|
struct net_buf *buf;
|
||||||
uint8_t adv_enable = 0x01;
|
|
||||||
|
|
||||||
buf = bt_hci_cmd_create(BT_HCI_OP_LE_SET_ADV_ENABLE, 1);
|
buf = bt_hci_cmd_create(BT_HCI_OP_LE_SET_ADV_ENABLE, 1);
|
||||||
if (buf) {
|
if (buf) {
|
||||||
memcpy(net_buf_add(buf, 1), &adv_enable, 1);
|
net_buf_add_u8(buf, BT_HCI_LE_ADV_ENABLE);
|
||||||
bt_hci_cmd_send(BT_HCI_OP_LE_SET_ADV_ENABLE, buf);
|
bt_hci_cmd_send(BT_HCI_OP_LE_SET_ADV_ENABLE, buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -764,7 +763,6 @@ static int set_flow_control(void)
|
||||||
{
|
{
|
||||||
struct bt_hci_cp_host_buffer_size *hbs;
|
struct bt_hci_cp_host_buffer_size *hbs;
|
||||||
struct net_buf *buf;
|
struct net_buf *buf;
|
||||||
uint8_t *enable;
|
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
buf = bt_hci_cmd_create(BT_HCI_OP_HOST_BUFFER_SIZE,
|
buf = bt_hci_cmd_create(BT_HCI_OP_HOST_BUFFER_SIZE,
|
||||||
|
@ -789,8 +787,7 @@ static int set_flow_control(void)
|
||||||
return -ENOBUFS;
|
return -ENOBUFS;
|
||||||
}
|
}
|
||||||
|
|
||||||
enable = net_buf_add(buf, sizeof(*enable));
|
net_buf_add_u8(buf, BT_HCI_CTL_TO_HOST_FLOW_ENABLE);
|
||||||
*enable = 0x01;
|
|
||||||
return bt_hci_cmd_send_sync(BT_HCI_OP_SET_CTL_TO_HOST_FLOW, buf, NULL);
|
return bt_hci_cmd_send_sync(BT_HCI_OP_SET_CTL_TO_HOST_FLOW, buf, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2461,7 +2458,6 @@ int bt_le_adv_start(const struct bt_le_adv_param *param,
|
||||||
{
|
{
|
||||||
struct net_buf *buf;
|
struct net_buf *buf;
|
||||||
struct bt_hci_cp_le_set_adv_parameters *set_param;
|
struct bt_hci_cp_le_set_adv_parameters *set_param;
|
||||||
uint8_t adv_enable;
|
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (!valid_adv_param(param)) {
|
if (!valid_adv_param(param)) {
|
||||||
|
@ -2521,9 +2517,7 @@ int bt_le_adv_start(const struct bt_le_adv_param *param,
|
||||||
return -ENOBUFS;
|
return -ENOBUFS;
|
||||||
}
|
}
|
||||||
|
|
||||||
adv_enable = 0x01;
|
net_buf_add_u8(buf, BT_HCI_LE_ADV_ENABLE);
|
||||||
memcpy(net_buf_add(buf, 1), &adv_enable, 1);
|
|
||||||
|
|
||||||
err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_SET_ADV_ENABLE, buf, NULL);
|
err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_SET_ADV_ENABLE, buf, NULL);
|
||||||
if (err) {
|
if (err) {
|
||||||
return err;
|
return err;
|
||||||
|
@ -2537,7 +2531,6 @@ int bt_le_adv_start(const struct bt_le_adv_param *param,
|
||||||
int bt_le_adv_stop(void)
|
int bt_le_adv_stop(void)
|
||||||
{
|
{
|
||||||
struct net_buf *buf;
|
struct net_buf *buf;
|
||||||
uint8_t adv_enable;
|
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (!atomic_test_bit(bt_dev.flags, BT_DEV_ADVERTISING)) {
|
if (!atomic_test_bit(bt_dev.flags, BT_DEV_ADVERTISING)) {
|
||||||
|
@ -2549,9 +2542,7 @@ int bt_le_adv_stop(void)
|
||||||
return -ENOBUFS;
|
return -ENOBUFS;
|
||||||
}
|
}
|
||||||
|
|
||||||
adv_enable = 0x00;
|
net_buf_add_u8(buf, BT_HCI_LE_ADV_DISABLE);
|
||||||
memcpy(net_buf_add(buf, 1), &adv_enable, 1);
|
|
||||||
|
|
||||||
err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_SET_ADV_ENABLE, buf, NULL);
|
err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_SET_ADV_ENABLE, buf, NULL);
|
||||||
if (err) {
|
if (err) {
|
||||||
return err;
|
return err;
|
||||||
|
@ -2662,8 +2653,7 @@ static int write_scan_enable(uint8_t scan)
|
||||||
return -ENOBUFS;
|
return -ENOBUFS;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(net_buf_add(buf, 1), &scan, 1);
|
net_buf_add_u8(buf, scan);
|
||||||
|
|
||||||
err = bt_hci_cmd_send_sync(BT_HCI_OP_WRITE_SCAN_ENABLE, buf, NULL);
|
err = bt_hci_cmd_send_sync(BT_HCI_OP_WRITE_SCAN_ENABLE, buf, NULL);
|
||||||
if (err) {
|
if (err) {
|
||||||
return err;
|
return err;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue