This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 8e17e1657be27b71483a36f4d05415a9c459853f
Author: chengkai <[email protected]>
AuthorDate: Mon Dec 4 18:06:37 2023 +0800

    bluetooth: fix bt bridge would not filter vendor hci cmd
    
    when downloading rtk firmware with vendor hci cmd sending to
    bt bridge, which would not filter that hci cmd.
    
    Signed-off-by: chengkai <[email protected]>
---
 drivers/wireless/bluetooth/bt_bridge.c    | 24 ++++++++++++++++++------
 include/nuttx/wireless/bluetooth/bt_hci.h |  1 +
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/drivers/wireless/bluetooth/bt_bridge.c 
b/drivers/wireless/bluetooth/bt_bridge.c
index 46e86ba5ea..b4790e3f0b 100644
--- a/drivers/wireless/bluetooth/bt_bridge.c
+++ b/drivers/wireless/bluetooth/bt_bridge.c
@@ -133,6 +133,21 @@ static bool bt_filter_set(FAR uint16_t *array, int size, 
uint16_t old,
   return false;
 }
 
+static bool bt_filter_ogf_is_valid(uint8_t ogf)
+{
+  switch (ogf)
+    {
+    case BT_OGF_BASEBAND:
+    case BT_OGF_LINK_CTRL:
+    case BT_OGF_INFO:
+    case BT_OGF_LE:
+    case BT_OGF_VS_RTK:
+      return true;
+    default:
+      return false;
+    }
+}
+
 static bool bt_filter_set_handle(FAR uint16_t *handle, int size,
                                  uint16_t old, uint16_t new)
 {
@@ -292,8 +307,7 @@ static bool bt_filter_can_recv(FAR struct bt_filter_s 
*filter,
             evt = (FAR void *)&buffer[2];
             ogf = evt->opcode >> 10;
 
-            if (BT_OGF_BASEBAND == ogf || BT_OGF_LINK_CTRL == ogf
-                || BT_OGF_INFO == ogf || BT_OGF_LE == ogf)
+            if (bt_filter_ogf_is_valid(ogf))
               {
                 return bt_filter_free_opcode(filter, evt->opcode);
               }
@@ -314,8 +328,7 @@ static bool bt_filter_can_recv(FAR struct bt_filter_s 
*filter,
             stat = (FAR void *)&buffer[2];
             ogf = stat->opcode >> 10;
 
-            if (BT_OGF_BASEBAND == ogf || BT_OGF_LINK_CTRL == ogf
-                || BT_OGF_INFO == ogf || BT_OGF_LE == ogf)
+            if (bt_filter_ogf_is_valid(ogf))
               {
                 return bt_filter_free_opcode(filter, stat->opcode);
               }
@@ -372,8 +385,7 @@ static bool bt_filter_can_send(FAR struct bt_filter_s 
*filter,
           break;
         }
 
-      if (BT_OGF_BASEBAND == ogf || BT_OGF_LINK_CTRL == ogf
-          || BT_OGF_INFO == ogf || BT_OGF_LE == ogf)
+      if (bt_filter_ogf_is_valid(ogf))
         {
           if (!bt_filter_alloc_opcode(filter, opcode))
             {
diff --git a/include/nuttx/wireless/bluetooth/bt_hci.h 
b/include/nuttx/wireless/bluetooth/bt_hci.h
index 67d7cb3ca1..f6839b6421 100644
--- a/include/nuttx/wireless/bluetooth/bt_hci.h
+++ b/include/nuttx/wireless/bluetooth/bt_hci.h
@@ -113,6 +113,7 @@
 #define BT_OGF_INFO              0x04
 #define BT_OGF_STATUS            0x05
 #define BT_OGF_LE                0x08
+#define BT_OGF_VS_RTK            0x3f
 
 /* Construct OpCode from OGF and OCF */
 

Reply via email to