44
44
#define BT_FILTER_TYPE_BLE 1
45
45
#define BT_FILTER_TYPE_COUNT 2
46
46
47
+ #define BT_FILTER_CMD_RESET 0
48
+ #define BT_FILTER_CMD_COUNT 1
49
+
47
50
/****************************************************************************
48
51
* Private Types
49
52
****************************************************************************/
@@ -70,6 +73,7 @@ struct bt_bridge_s
70
73
FAR struct snoop_s * snoop ;
71
74
#endif /* CONFIG_BLUETOOTH_BRIDGE_BTSNOOP */
72
75
atomic_uint refs ;
76
+ bool dispatched [BT_FILTER_CMD_COUNT ];
73
77
};
74
78
75
79
/****************************************************************************
@@ -427,6 +431,45 @@ static int bt_bridge_open(FAR struct bt_driver_s *drv)
427
431
return OK ;
428
432
}
429
433
434
+ static int bt_bridge_send_reset_response (FAR struct bt_driver_s * driver )
435
+ {
436
+ uint8_t reset_response [6 ];
437
+
438
+ reset_response [0 ] = BT_HCI_EVT_CMD_COMPLETE ;
439
+ reset_response [1 ] = 0x04 ;
440
+ reset_response [2 ] = 0x01 ;
441
+ reset_response [3 ] = BT_HCI_OP_RESET & 0xff ;
442
+ reset_response [4 ] = (BT_HCI_OP_RESET >> 8 ) & 0xff ;
443
+ reset_response [5 ] = BT_HCI_SUCCESS ;
444
+
445
+ return bt_netdev_receive (driver , BT_EVT , reset_response ,
446
+ sizeof (reset_response ));
447
+ }
448
+
449
+ static bool bt_bridge_filter_command (FAR struct bt_bridge_s * bridge ,
450
+ FAR struct bt_driver_s * driver ,
451
+ FAR uint8_t * data )
452
+ {
453
+ uint16_t opcode = BT_LE162HOST (((uint16_t * )data )[0 ]);
454
+
455
+ switch (opcode )
456
+ {
457
+ case BT_HCI_OP_RESET :
458
+ if (bridge -> dispatched [BT_FILTER_CMD_RESET ])
459
+ {
460
+ bt_bridge_send_reset_response (driver );
461
+ return true;
462
+ }
463
+
464
+ bridge -> dispatched [BT_FILTER_CMD_RESET ] = true;
465
+ break ;
466
+ default :
467
+ break ;
468
+ }
469
+
470
+ return false;
471
+ }
472
+
430
473
static int bt_bridge_send (FAR struct bt_driver_s * drv ,
431
474
enum bt_buf_type_e type ,
432
475
FAR void * data , size_t len )
@@ -438,6 +481,13 @@ static int bt_bridge_send(FAR struct bt_driver_s *drv,
438
481
irqstate_t flags ;
439
482
440
483
flags = enter_critical_section ();
484
+
485
+ if (bt_bridge_filter_command (bridge , drv , data ))
486
+ {
487
+ leave_critical_section (flags );
488
+ return len ;
489
+ }
490
+
441
491
if (bt_filter_can_send (& device -> filter , type , data , len ))
442
492
{
443
493
leave_critical_section (flags );
0 commit comments