@@ -76,8 +76,6 @@ BUILD_ASSERT(IS_ENABLED(CONFIG_ZTEST), "Missing DT chosen property for HCI");
76
76
struct bt_dev_raw bt_dev = {
77
77
.hci = BT_HCI_DEV ,
78
78
};
79
- struct bt_hci_raw_cmd_ext * cmd_ext ;
80
- static size_t cmd_ext_size ;
81
79
82
80
struct net_buf * bt_buf_get_rx (enum bt_buf_type type , k_timeout_t timeout )
83
81
{
@@ -172,121 +170,20 @@ int bt_hci_recv(const struct device *dev, struct net_buf *buf)
172
170
return 0 ;
173
171
}
174
172
175
- static void bt_cmd_complete_ext (uint16_t op , uint8_t status )
176
- {
177
- struct net_buf * buf ;
178
- struct bt_hci_evt_cc_status * cc ;
179
-
180
- if (status == BT_HCI_ERR_EXT_HANDLED ) {
181
- return ;
182
- }
183
-
184
- buf = bt_hci_cmd_complete_create (op , sizeof (* cc ));
185
- cc = net_buf_add (buf , sizeof (* cc ));
186
- cc -> status = status ;
187
-
188
- bt_hci_recv (bt_dev .hci , buf );
189
- }
190
-
191
- static uint8_t bt_send_ext (struct net_buf * buf )
192
- {
193
- struct bt_hci_cmd_hdr * hdr ;
194
- struct net_buf_simple_state state ;
195
- int i ;
196
- uint16_t op ;
197
- uint8_t status ;
198
-
199
- status = BT_HCI_ERR_SUCCESS ;
200
-
201
- if (!cmd_ext ) {
202
- return status ;
203
- }
204
-
205
- net_buf_simple_save (& buf -> b , & state );
206
-
207
- if (buf -> len < sizeof (* hdr )) {
208
- LOG_ERR ("No HCI Command header" );
209
- return BT_HCI_ERR_INVALID_PARAM ;
210
- }
211
-
212
- hdr = net_buf_pull_mem (buf , sizeof (* hdr ));
213
- if (buf -> len < hdr -> param_len ) {
214
- LOG_ERR ("Invalid HCI CMD packet length" );
215
- return BT_HCI_ERR_INVALID_PARAM ;
216
- }
217
-
218
- op = sys_le16_to_cpu (hdr -> opcode );
219
-
220
- for (i = 0 ; i < cmd_ext_size ; i ++ ) {
221
- struct bt_hci_raw_cmd_ext * cmd = & cmd_ext [i ];
222
-
223
- if (cmd -> op == op ) {
224
- if (buf -> len < cmd -> min_len ) {
225
- status = BT_HCI_ERR_INVALID_PARAM ;
226
- } else {
227
- status = cmd -> func (buf );
228
- }
229
-
230
- break ;
231
- }
232
- }
233
-
234
- if (status ) {
235
- bt_cmd_complete_ext (op , status );
236
- return status ;
237
- }
238
-
239
- net_buf_simple_restore (& buf -> b , & state );
240
-
241
- return status ;
242
- }
243
-
244
173
int bt_send (struct net_buf * buf )
245
174
{
246
- uint8_t type = bt_buf_get_type (buf );
247
-
248
- LOG_DBG ("buf %p type %u len %u" , buf , type , buf -> len );
249
-
250
175
if (buf -> len == 0 ) {
251
176
return BT_HCI_ERR_INVALID_PARAM ;
252
177
}
253
178
254
- bt_monitor_send (bt_monitor_opcode (type , BT_MONITOR_TX ), buf -> data , buf -> len );
255
-
256
- if (IS_ENABLED (CONFIG_BT_HCI_RAW_CMD_EXT ) && type == BT_BUF_CMD ) {
257
- uint8_t status ;
258
-
259
- status = bt_send_ext (buf );
260
- if (status ) {
261
- return status ;
262
- }
263
- }
179
+ LOG_DBG ("buf %p type %u len %u" , buf , buf -> data [0 ], buf -> len );
264
180
265
- /* Put back the type byte */
266
- bt_buf_set_type ( buf , type );
181
+ bt_monitor_send ( bt_monitor_opcode ( buf -> data [ 0 ], BT_MONITOR_TX ),
182
+ buf -> data + 1 , buf -> len - 1 );
267
183
268
184
return bt_hci_send (bt_dev .hci , buf );
269
185
}
270
186
271
- int bt_hci_raw_set_mode (uint8_t mode )
272
- {
273
- LOG_DBG ("mode %u" , mode );
274
- return 0 ;
275
- }
276
-
277
- uint8_t bt_hci_raw_get_mode (void )
278
- {
279
- return BT_HCI_RAW_MODE_H4 ;
280
- }
281
-
282
- void bt_hci_raw_cmd_ext_register (struct bt_hci_raw_cmd_ext * cmds , size_t size )
283
- {
284
- if (IS_ENABLED (CONFIG_BT_HCI_RAW_CMD_EXT )) {
285
- cmd_ext = cmds ;
286
- cmd_ext_size = size ;
287
- }
288
- }
289
-
290
187
int bt_enable_raw (struct k_fifo * rx_queue )
291
188
{
292
189
int err ;
0 commit comments