Skip to content

Commit eb980c8

Browse files
jhedbergolivier-le-sage
authored andcommitted
[nrf fromtree] Bluetooth: tests: 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 <[email protected]> (cherry picked from commit b0bed23)
1 parent ebed2bf commit eb980c8

File tree

26 files changed

+55
-64
lines changed

26 files changed

+55
-64
lines changed

tests/bluetooth/df/connection_cte_req/src/test_cte_req_enable.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ int send_conn_cte_req_enable(uint16_t conn_handle,
6363
struct bt_hci_cp_le_conn_cte_req_enable *cp;
6464
struct net_buf *buf;
6565

66-
buf = bt_hci_cmd_create(BT_HCI_OP_LE_CONN_CTE_REQ_ENABLE, sizeof(*cp));
66+
buf = bt_hci_cmd_alloc(K_FOREVER);
6767
if (!buf) {
6868
return -ENOBUFS;
6969
}

tests/bluetooth/df/connection_cte_req/src/test_cte_set_rx_params.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ int send_set_conn_cte_rx_params(uint16_t conn_handle,
4848

4949
uint8_t ant_ids_num = (params != NULL ? params->switch_pattern_len : 0);
5050

51-
buf = bt_hci_cmd_create(BT_HCI_OP_LE_SET_CONN_CTE_RX_PARAMS, sizeof(*cp) + ant_ids_num);
51+
buf = bt_hci_cmd_alloc(K_FOREVER);
5252
if (!buf) {
5353
return -ENOBUFS;
5454
}

tests/bluetooth/df/connection_cte_tx_params/src/test_set_conn_cte_tx_params.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ static int send_set_conn_cte_tx_params(uint16_t conn_handle,
5959
uint8_t *dest_ant_ids;
6060
struct net_buf *buf;
6161

62-
buf = bt_hci_cmd_create(BT_HCI_OP_LE_SET_CONN_CTE_TX_PARAMS,
63-
sizeof(*cp) + params->switch_pattern_len);
62+
buf = bt_hci_cmd_alloc(K_FOREVER);
6463
if (!buf) {
6564
return -ENOBUFS;
6665
}

tests/bluetooth/df/connectionless_cte_rx/src/test_set_iq_sampling_enable.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ int send_set_scan_cte_rx_enable(uint16_t sync_handle,
5656
struct bt_hci_cp_le_set_cl_cte_sampling_enable *cp;
5757
struct net_buf *buf;
5858

59-
buf = bt_hci_cmd_create(BT_HCI_OP_LE_SET_CL_CTE_SAMPLING_ENABLE,
60-
sizeof(*cp) + params->num_ant_ids);
59+
buf = bt_hci_cmd_alloc(K_FOREVER);
6160
if (!buf) {
6261
return -ENOBUFS;
6362
}

tests/bluetooth/df/connectionless_cte_tx/src/common.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ void common_set_cl_cte_tx_params(void)
5959
struct net_buf *buf;
6060
int err;
6161

62-
buf = bt_hci_cmd_create(BT_HCI_OP_LE_SET_CL_CTE_TX_PARAMS,
63-
sizeof(*cp) + ARRAY_SIZE(ant_ids));
62+
buf = bt_hci_cmd_alloc(K_FOREVER);
6463
zassert_not_null(buf, "Failed to create HCI cmd object");
6564

6665
cp = net_buf_add(buf, sizeof(*cp));

tests/bluetooth/df/connectionless_cte_tx/src/test_set_cl_cte_tx_enable.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ int send_set_cl_cte_tx_enable(uint8_t adv_handle, atomic_t *adv_flags,
3535
struct bt_hci_cmd_state_set state;
3636
struct net_buf *buf;
3737

38-
buf = bt_hci_cmd_create(BT_HCI_OP_LE_SET_CL_CTE_TX_ENABLE, sizeof(*cp));
38+
buf = bt_hci_cmd_alloc(K_FOREVER);
3939
if (!buf) {
4040
return -ENOBUFS;
4141
}

tests/bluetooth/df/connectionless_cte_tx/src/test_set_cl_cte_tx_param.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ int send_set_cl_cte_tx_params(uint8_t adv_handle, uint8_t cte_len,
5454
struct bt_hci_cp_le_set_cl_cte_tx_params *cp;
5555
struct net_buf *buf;
5656

57-
buf = bt_hci_cmd_create(BT_HCI_OP_LE_SET_CL_CTE_TX_PARAMS,
58-
sizeof(*cp) + switch_pattern_len);
57+
buf = bt_hci_cmd_alloc(K_FOREVER);
5958
zassert_not_null(buf, "Failed to create HCI cmd object");
6059

6160
cp = net_buf_add(buf, sizeof(*cp));

tests/bluetooth/hci_codecs_info/src/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ ZTEST(test_hci_codecs_info, test_read_codec_capabilities)
185185
bt_enable(NULL);
186186

187187
/* Read Local Supported Codec Capabilities */
188-
buf = bt_hci_cmd_create(BT_HCI_OP_READ_CODEC_CAPABILITIES, sizeof(*cp));
188+
buf = bt_hci_cmd_alloc(K_FOREVER);
189189
cp = net_buf_add(buf, sizeof(*cp));
190190

191191
cp->codec_id.coding_format = READ_CAPABS_CODING_FMT;
@@ -268,7 +268,7 @@ ZTEST(test_hci_codecs_info, test_read_ctlr_delay)
268268
bt_enable(NULL);
269269

270270
/* Read Local Supported Controller Delay */
271-
buf = bt_hci_cmd_create(BT_HCI_OP_READ_CTLR_DELAY, sizeof(*cp));
271+
buf = bt_hci_cmd_alloc(K_FOREVER);
272272
cp = net_buf_add(buf, sizeof(*cp) + sizeof(read_delay_codec_config));
273273

274274
cp->codec_id.coding_format = READ_DELAY_CODING_FMT;

tests/bluetooth/host/conn/mocks/hci_core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
#include "hci_core.h"
1313

14-
DEFINE_FAKE_VALUE_FUNC(struct net_buf *, bt_hci_cmd_create, uint16_t, uint8_t);
14+
DEFINE_FAKE_VALUE_FUNC(struct net_buf *, bt_hci_cmd_alloc, k_timeout_t);
1515
DEFINE_FAKE_VALUE_FUNC(int, bt_hci_cmd_send_sync, uint16_t, struct net_buf *, struct net_buf **);
1616
DEFINE_FAKE_VALUE_FUNC(int, bt_hci_le_read_remote_features, struct bt_conn *);
1717
DEFINE_FAKE_VALUE_FUNC(int, bt_hci_disconnect, uint16_t, uint8_t);

tests/bluetooth/host/conn/mocks/hci_core.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
/* List of fakes used by this unit tester */
1111
#define HCI_CORE_MOCKS_FFF_FAKES_LIST(FAKE) \
12-
FAKE(bt_hci_cmd_create) \
12+
FAKE(bt_hci_cmd_alloc) \
1313
FAKE(bt_hci_cmd_send_sync) \
1414
FAKE(bt_hci_le_read_remote_features) \
1515
FAKE(bt_hci_disconnect) \
@@ -24,7 +24,7 @@
2424
FAKE(bt_lookup_id_addr) \
2525
FAKE(bt_le_set_phy)
2626

27-
DECLARE_FAKE_VALUE_FUNC(struct net_buf *, bt_hci_cmd_create, uint16_t, uint8_t);
27+
DECLARE_FAKE_VALUE_FUNC(struct net_buf *, bt_hci_cmd_alloc, k_timeout_t);
2828
DECLARE_FAKE_VALUE_FUNC(int, bt_hci_cmd_send_sync, uint16_t, struct net_buf *, struct net_buf **);
2929
DECLARE_FAKE_VALUE_FUNC(int, bt_hci_le_read_remote_features, struct bt_conn *);
3030
DECLARE_FAKE_VALUE_FUNC(int, bt_hci_disconnect, uint16_t, uint8_t);

0 commit comments

Comments
 (0)