From 187ec7012d76f4ad792d0892ad359a5945b4f226 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 19 Jun 2025 04:10:03 +0300 Subject: [PATCH] Bluetooth: samples: Use bt_hci_cmd_alloc() Use bt_hci_cmd_alloc() instead of the soon to be deprecated bt_hci_cmd_create(). Signed-off-by: Johan Hedberg --- samples/bluetooth/hci_pwr_ctrl/src/main.c | 8 +++----- samples/bluetooth/hci_vs_scan_req/src/main.c | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/samples/bluetooth/hci_pwr_ctrl/src/main.c b/samples/bluetooth/hci_pwr_ctrl/src/main.c index 13794328489..ef6ca0bbbb2 100644 --- a/samples/bluetooth/hci_pwr_ctrl/src/main.c +++ b/samples/bluetooth/hci_pwr_ctrl/src/main.c @@ -57,7 +57,7 @@ static void read_conn_rssi(uint16_t handle, int8_t *rssi) int err; - buf = bt_hci_cmd_create(BT_HCI_OP_READ_RSSI, sizeof(*cp)); + buf = bt_hci_cmd_alloc(K_FOREVER); if (!buf) { printk("Unable to allocate command buffer\n"); return; @@ -86,8 +86,7 @@ static void set_tx_power(uint8_t handle_type, uint16_t handle, int8_t tx_pwr_lvl struct net_buf *buf, *rsp = NULL; int err; - buf = bt_hci_cmd_create(BT_HCI_OP_VS_WRITE_TX_POWER_LEVEL, - sizeof(*cp)); + buf = bt_hci_cmd_alloc(K_FOREVER); if (!buf) { printk("Unable to allocate command buffer\n"); return; @@ -119,8 +118,7 @@ static void get_tx_power(uint8_t handle_type, uint16_t handle, int8_t *tx_pwr_lv int err; *tx_pwr_lvl = 0xFF; - buf = bt_hci_cmd_create(BT_HCI_OP_VS_READ_TX_POWER_LEVEL, - sizeof(*cp)); + buf = bt_hci_cmd_alloc(K_FOREVER); if (!buf) { printk("Unable to allocate command buffer\n"); return; diff --git a/samples/bluetooth/hci_vs_scan_req/src/main.c b/samples/bluetooth/hci_vs_scan_req/src/main.c index 6e1c4cb6b77..7682c469edf 100644 --- a/samples/bluetooth/hci_vs_scan_req/src/main.c +++ b/samples/bluetooth/hci_vs_scan_req/src/main.c @@ -65,7 +65,7 @@ static void enable_legacy_adv_scan_request_event(bool enable) struct net_buf *buf; int err; - buf = bt_hci_cmd_create(BT_HCI_OP_VS_SET_SCAN_REQ_REPORTS, sizeof(*cp)); + buf = bt_hci_cmd_alloc(K_FOREVER); if (!buf) { printk("%s: Unable to allocate HCI command buffer\n", __func__); return;