@@ -124,20 +124,6 @@ static size_t discovery_results_size;
124124static size_t discovery_results_count ;
125125#endif /* CONFIG_BT_BREDR */
126126
127- struct cmd_state_set {
128- atomic_t * target ;
129- int bit ;
130- bool val ;
131- };
132-
133- void cmd_state_set_init (struct cmd_state_set * state , atomic_t * target , int bit ,
134- bool val )
135- {
136- state -> target = target ;
137- state -> bit = bit ;
138- state -> val = val ;
139- }
140-
141127struct cmd_data {
142128 /** HCI status of the command completion */
143129 uint8_t status ;
@@ -146,7 +132,7 @@ struct cmd_data {
146132 uint16_t opcode ;
147133
148134 /** The state to update when command completes with success. */
149- struct cmd_state_set * state ;
135+ struct bt_hci_cmd_state_set * state ;
150136
151137 /** Used by bt_hci_cmd_send_sync. */
152138 struct k_sem * sync ;
@@ -157,6 +143,12 @@ static struct cmd_data cmd_data[CONFIG_BT_HCI_CMD_COUNT];
157143#define cmd (buf ) (&cmd_data[net_buf_id(buf)])
158144#define acl (buf ) ((struct acl_data *)net_buf_user_data(buf))
159145
146+ void bt_hci_cmd_data_state_set (struct net_buf * buf ,
147+ struct bt_hci_cmd_state_set * state )
148+ {
149+ cmd (buf )-> state = state ;
150+ }
151+
160152/* HCI command buffers. Derive the needed size from BT_BUF_RX_SIZE since
161153 * the same buffer is also used for the response.
162154 */
@@ -484,7 +476,7 @@ struct bt_le_ext_adv *bt_adv_lookup_legacy(void)
484476static int set_le_adv_enable_legacy (struct bt_le_ext_adv * adv , bool enable )
485477{
486478 struct net_buf * buf ;
487- struct cmd_state_set state ;
479+ struct bt_hci_cmd_state_set state ;
488480 int err ;
489481
490482 buf = bt_hci_cmd_create (BT_HCI_OP_LE_SET_ADV_ENABLE , 1 );
@@ -498,7 +490,7 @@ static int set_le_adv_enable_legacy(struct bt_le_ext_adv *adv, bool enable)
498490 net_buf_add_u8 (buf , BT_HCI_LE_ADV_DISABLE );
499491 }
500492
501- cmd_state_set_init (& state , adv -> flags , BT_ADV_ENABLED , enable );
493+ bt_hci_cmd_state_set_init (& state , adv -> flags , BT_ADV_ENABLED , enable );
502494 cmd (buf )-> state = & state ;
503495
504496 err = bt_hci_cmd_send_sync (BT_HCI_OP_LE_SET_ADV_ENABLE , buf , NULL );
@@ -543,7 +535,7 @@ static int set_le_adv_enable_ext(struct bt_le_ext_adv *adv,
543535 const struct bt_le_ext_adv_start_param * param )
544536{
545537 struct net_buf * buf ;
546- struct cmd_state_set state ;
538+ struct bt_hci_cmd_state_set state ;
547539 int err ;
548540
549541 buf = bt_hci_cmd_create (BT_HCI_OP_LE_SET_EXT_ADV_ENABLE , 6 );
@@ -563,7 +555,7 @@ static int set_le_adv_enable_ext(struct bt_le_ext_adv *adv,
563555 net_buf_add_le16 (buf , param ? sys_cpu_to_le16 (param -> timeout ) : 0 );
564556 net_buf_add_u8 (buf , param ? param -> num_events : 0 );
565557
566- cmd_state_set_init (& state , adv -> flags , BT_ADV_ENABLED , enable );
558+ bt_hci_cmd_state_set_init (& state , adv -> flags , BT_ADV_ENABLED , enable );
567559 cmd (buf )-> state = & state ;
568560
569561 err = bt_hci_cmd_send_sync (BT_HCI_OP_LE_SET_EXT_ADV_ENABLE , buf , NULL );
@@ -1061,7 +1053,7 @@ static bool bt_le_adv_random_addr_check(const struct bt_le_adv_param *param)
10611053static int set_le_ext_scan_enable (uint8_t enable , uint16_t duration )
10621054{
10631055 struct bt_hci_cp_le_set_ext_scan_enable * cp ;
1064- struct cmd_state_set state ;
1056+ struct bt_hci_cmd_state_set state ;
10651057 struct net_buf * buf ;
10661058 int err ;
10671059
@@ -1083,8 +1075,8 @@ static int set_le_ext_scan_enable(uint8_t enable, uint16_t duration)
10831075 cp -> duration = sys_cpu_to_le16 (duration );
10841076 cp -> period = 0 ;
10851077
1086- cmd_state_set_init (& state , bt_dev .flags , BT_DEV_SCANNING ,
1087- enable == BT_HCI_LE_SCAN_ENABLE );
1078+ bt_hci_cmd_state_set_init (& state , bt_dev .flags , BT_DEV_SCANNING ,
1079+ enable == BT_HCI_LE_SCAN_ENABLE );
10881080 cmd (buf )-> state = & state ;
10891081
10901082 err = bt_hci_cmd_send_sync (BT_HCI_OP_LE_SET_EXT_SCAN_ENABLE , buf , NULL );
@@ -1098,7 +1090,7 @@ static int set_le_ext_scan_enable(uint8_t enable, uint16_t duration)
10981090static int set_le_scan_enable_legacy (uint8_t enable )
10991091{
11001092 struct bt_hci_cp_le_set_scan_enable * cp ;
1101- struct cmd_state_set state ;
1093+ struct bt_hci_cmd_state_set state ;
11021094 struct net_buf * buf ;
11031095 int err ;
11041096
@@ -1118,8 +1110,8 @@ static int set_le_scan_enable_legacy(uint8_t enable)
11181110
11191111 cp -> enable = enable ;
11201112
1121- cmd_state_set_init (& state , bt_dev .flags , BT_DEV_SCANNING ,
1122- enable == BT_HCI_LE_SCAN_ENABLE );
1113+ bt_hci_cmd_state_set_init (& state , bt_dev .flags , BT_DEV_SCANNING ,
1114+ enable == BT_HCI_LE_SCAN_ENABLE );
11231115 cmd (buf )-> state = & state ;
11241116
11251117 err = bt_hci_cmd_send_sync (BT_HCI_OP_LE_SET_SCAN_ENABLE , buf , NULL );
@@ -1370,7 +1362,7 @@ int bt_le_create_conn_ext(const struct bt_conn *conn)
13701362{
13711363 struct bt_hci_cp_le_ext_create_conn * cp ;
13721364 struct bt_hci_ext_conn_phy * phy ;
1373- struct cmd_state_set state ;
1365+ struct bt_hci_cmd_state_set state ;
13741366 bool use_filter = false;
13751367 struct net_buf * buf ;
13761368 uint8_t own_addr_type ;
@@ -1441,7 +1433,8 @@ int bt_le_create_conn_ext(const struct bt_conn *conn)
14411433 set_phy_conn_param (conn , phy );
14421434 }
14431435
1444- cmd_state_set_init (& state , bt_dev .flags , BT_DEV_INITIATING , true);
1436+ bt_hci_cmd_state_set_init (& state , bt_dev .flags ,
1437+ BT_DEV_INITIATING , true);
14451438 cmd (buf )-> state = & state ;
14461439
14471440 return bt_hci_cmd_send_sync (BT_HCI_OP_LE_EXT_CREATE_CONN , buf , NULL );
@@ -1450,7 +1443,7 @@ int bt_le_create_conn_ext(const struct bt_conn *conn)
14501443int bt_le_create_conn_legacy (const struct bt_conn * conn )
14511444{
14521445 struct bt_hci_cp_le_create_conn * cp ;
1453- struct cmd_state_set state ;
1446+ struct bt_hci_cmd_state_set state ;
14541447 bool use_filter = false;
14551448 struct net_buf * buf ;
14561449 uint8_t own_addr_type ;
@@ -1500,7 +1493,8 @@ int bt_le_create_conn_legacy(const struct bt_conn *conn)
15001493 cp -> conn_latency = sys_cpu_to_le16 (conn -> le .latency );
15011494 cp -> supervision_timeout = sys_cpu_to_le16 (conn -> le .timeout );
15021495
1503- cmd_state_set_init (& state , bt_dev .flags , BT_DEV_INITIATING , true);
1496+ bt_hci_cmd_state_set_init (& state , bt_dev .flags ,
1497+ BT_DEV_INITIATING , true);
15041498 cmd (buf )-> state = & state ;
15051499
15061500 return bt_hci_cmd_send_sync (BT_HCI_OP_LE_CREATE_CONN , buf , NULL );
@@ -1519,11 +1513,12 @@ int bt_le_create_conn(const struct bt_conn *conn)
15191513int bt_le_create_conn_cancel (void )
15201514{
15211515 struct net_buf * buf ;
1522- struct cmd_state_set state ;
1516+ struct bt_hci_cmd_state_set state ;
15231517
15241518 buf = bt_hci_cmd_create (BT_HCI_OP_LE_CREATE_CONN_CANCEL , 0 );
15251519
1526- cmd_state_set_init (& state , bt_dev .flags , BT_DEV_INITIATING , false);
1520+ bt_hci_cmd_state_set_init (& state , bt_dev .flags ,
1521+ BT_DEV_INITIATING , false);
15271522 cmd (buf )-> state = & state ;
15281523
15291524 return bt_hci_cmd_send_sync (BT_HCI_OP_LE_CREATE_CONN_CANCEL , buf , NULL );
@@ -3913,7 +3908,7 @@ static void hci_cmd_done(uint16_t opcode, uint8_t status, struct net_buf *buf)
39133908 }
39143909
39153910 if (cmd (buf )-> state && !status ) {
3916- struct cmd_state_set * update = cmd (buf )-> state ;
3911+ struct bt_hci_cmd_state_set * update = cmd (buf )-> state ;
39173912
39183913 atomic_set_bit_to (update -> target , update -> bit , update -> val );
39193914 }
@@ -7222,7 +7217,7 @@ static int bt_le_per_adv_enable(struct bt_le_ext_adv *adv, bool enable)
72227217{
72237218 struct bt_hci_cp_le_set_per_adv_enable * cp ;
72247219 struct net_buf * buf ;
7225- struct cmd_state_set state ;
7220+ struct bt_hci_cmd_state_set state ;
72267221 int err ;
72277222
72287223 /* TODO: We could setup some default ext adv params if not already set*/
@@ -7245,7 +7240,8 @@ static int bt_le_per_adv_enable(struct bt_le_ext_adv *adv, bool enable)
72457240 cp -> handle = adv -> handle ;
72467241 cp -> enable = enable ? 1 : 0 ;
72477242
7248- cmd_state_set_init (& state , adv -> flags , BT_PER_ADV_ENABLED , enable );
7243+ bt_hci_cmd_state_set_init (& state , adv -> flags ,
7244+ BT_PER_ADV_ENABLED , enable );
72497245 cmd (buf )-> state = & state ;
72507246
72517247 err = bt_hci_cmd_send_sync (BT_HCI_OP_LE_SET_PER_ADV_ENABLE , buf , NULL );
@@ -7482,7 +7478,7 @@ static int bt_le_set_per_adv_recv_enable(
74827478 struct bt_le_per_adv_sync_cb * listener ;
74837479 struct bt_le_per_adv_sync_state_info info ;
74847480 struct net_buf * buf ;
7485- struct cmd_state_set state ;
7481+ struct bt_hci_cmd_state_set state ;
74867482 int err ;
74877483
74887484 if (!atomic_test_bit (bt_dev .flags , BT_DEV_READY )) {
@@ -7516,9 +7512,9 @@ static int bt_le_set_per_adv_recv_enable(
75167512 cp -> handle = sys_cpu_to_le16 (per_adv_sync -> handle );
75177513 cp -> enable = enable ? 1 : 0 ;
75187514
7519- cmd_state_set_init (& state , per_adv_sync -> flags ,
7520- BT_PER_ADV_SYNC_RECV_DISABLED ,
7521- enable );
7515+ bt_hci_cmd_state_set_init (& state , per_adv_sync -> flags ,
7516+ BT_PER_ADV_SYNC_RECV_DISABLED ,
7517+ enable );
75227518 cmd (buf )-> state = & state ;
75237519
75247520 err = bt_hci_cmd_send_sync (BT_HCI_OP_LE_SET_PER_ADV_RECV_ENABLE ,
0 commit comments