You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2022/10/02 21:14:06 UTC

[incubator-nuttx] branch master updated (dbb3c768c3 -> 34b05804b0)

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

acassis pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


    from dbb3c768c3 driver/usersock_dev: Check CONFIG_NET_USRSOCK_DEVICE instead CONFIG_NET_USRSOCK
     new 11d083b358 bluetooth: Remove the unnecessary cast in btuart driver
     new fab8b081c0 bluetooth: Implement btuart_close for btuart upperhalf driver
     new 6ec74d8d36 bluetooth: Forward ioctl to btuart lowerhalf driver
     new fe38cb1bad bluetooth: Implement hciuart_ioctl for btuart lowerhalf shim driver
     new 34b05804b0 bluetooth: Remove hcicollecttask from btuart shim driver

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 drivers/wireless/bluetooth/bt_uart.c          |  61 +++++++---
 drivers/wireless/bluetooth/bt_uart.h          |   3 +
 drivers/wireless/bluetooth/bt_uart_bcm4343x.c |   2 +
 drivers/wireless/bluetooth/bt_uart_cc2564.c   |   2 +
 drivers/wireless/bluetooth/bt_uart_generic.c  |   2 +
 drivers/wireless/bluetooth/bt_uart_shim.c     | 154 +++++++++-----------------
 include/nuttx/wireless/bluetooth/bt_uart.h    |   5 +
 7 files changed, 112 insertions(+), 117 deletions(-)


[incubator-nuttx] 02/05: bluetooth: Implement btuart_close for btuart upperhalf driver

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit fab8b081c0b1167a114bd4eca278e208b241c706
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Sun Oct 2 03:20:15 2022 +0800

    bluetooth: Implement btuart_close for btuart upperhalf driver
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 drivers/wireless/bluetooth/bt_uart.c          | 22 ++++++++++++++++++----
 drivers/wireless/bluetooth/bt_uart.h          |  1 +
 drivers/wireless/bluetooth/bt_uart_bcm4343x.c |  1 +
 drivers/wireless/bluetooth/bt_uart_cc2564.c   |  1 +
 drivers/wireless/bluetooth/bt_uart_generic.c  |  1 +
 5 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/drivers/wireless/bluetooth/bt_uart.c b/drivers/wireless/bluetooth/bt_uart.c
index d0e3a89687..a50f1b0498 100644
--- a/drivers/wireless/bluetooth/bt_uart.c
+++ b/drivers/wireless/bluetooth/bt_uart.c
@@ -275,10 +275,6 @@ int btuart_open(FAR struct bt_driver_s *dev)
   DEBUGASSERT(upper != NULL && upper->lower != NULL);
   lower = upper->lower;
 
-  /* Disable Rx callbacks */
-
-  lower->rxenable(lower, false);
-
   /* Drain any cached Rx data */
 
   lower->rxdrain(lower);
@@ -292,3 +288,21 @@ int btuart_open(FAR struct bt_driver_s *dev)
   lower->rxenable(lower, true);
   return OK;
 }
+
+void btuart_close(FAR struct bt_driver_s *dev)
+{
+  FAR struct btuart_upperhalf_s *upper;
+  FAR const struct btuart_lowerhalf_s *lower;
+
+  upper = (FAR struct btuart_upperhalf_s *)dev;
+  DEBUGASSERT(upper != NULL && upper->lower != NULL);
+  lower = upper->lower;
+
+  /* Disable Rx callbacks */
+
+  lower->rxenable(lower, false);
+
+  /* Detach the Rx event handler */
+
+  lower->rxattach(lower, NULL, NULL);
+}
diff --git a/drivers/wireless/bluetooth/bt_uart.h b/drivers/wireless/bluetooth/bt_uart.h
index 0b8bcc0f45..1abaa507ef 100644
--- a/drivers/wireless/bluetooth/bt_uart.h
+++ b/drivers/wireless/bluetooth/bt_uart.h
@@ -91,5 +91,6 @@ int btuart_send(FAR struct bt_driver_s *dev,
                 enum bt_buf_type_e type,
                 FAR void *data, size_t len);
 int btuart_open(FAR struct bt_driver_s *dev);
+void btuart_close(FAR struct bt_driver_s *dev);
 
 #endif /* __DRIVER_WIRELESS_BLUETOOTH_BT_UART_H */
diff --git a/drivers/wireless/bluetooth/bt_uart_bcm4343x.c b/drivers/wireless/bluetooth/bt_uart_bcm4343x.c
index 503719cd56..b19252c89b 100644
--- a/drivers/wireless/bluetooth/bt_uart_bcm4343x.c
+++ b/drivers/wireless/bluetooth/bt_uart_bcm4343x.c
@@ -423,6 +423,7 @@ int btuart_register(FAR const struct btuart_lowerhalf_s *lower)
   upper->dev.head_reserve = H4_HEADER_SIZE;
   upper->dev.open = btuart_open;
   upper->dev.send = btuart_send;
+  upper->dev.close = btuart_close;
   upper->lower = lower;
 
   /* Load firmware */
diff --git a/drivers/wireless/bluetooth/bt_uart_cc2564.c b/drivers/wireless/bluetooth/bt_uart_cc2564.c
index 2e9d514c8b..ff39218d54 100644
--- a/drivers/wireless/bluetooth/bt_uart_cc2564.c
+++ b/drivers/wireless/bluetooth/bt_uart_cc2564.c
@@ -189,6 +189,7 @@ int btuart_register(FAR const struct btuart_lowerhalf_s *lower)
   upper->dev.head_reserve = H4_HEADER_SIZE;
   upper->dev.open         = btuart_open;
   upper->dev.send         = btuart_send;
+  upper->dev.close        = btuart_close;
   upper->lower            = lower;
 
   /* Load firmware */
diff --git a/drivers/wireless/bluetooth/bt_uart_generic.c b/drivers/wireless/bluetooth/bt_uart_generic.c
index a2a5e01e7a..d194360d36 100644
--- a/drivers/wireless/bluetooth/bt_uart_generic.c
+++ b/drivers/wireless/bluetooth/bt_uart_generic.c
@@ -83,6 +83,7 @@ int btuart_register(FAR const struct btuart_lowerhalf_s *lower)
   upper->dev.head_reserve = H4_HEADER_SIZE;
   upper->dev.open         = btuart_open;
   upper->dev.send         = btuart_send;
+  upper->dev.close        = btuart_close;
   upper->lower            = lower;
 
   /* And register the driver with the network and the Bluetooth stack. */


[incubator-nuttx] 04/05: bluetooth: Implement hciuart_ioctl for btuart lowerhalf shim driver

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit fe38cb1bada68d35cf7431db4dcf7965279fae93
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Sun Oct 2 03:50:45 2022 +0800

    bluetooth: Implement hciuart_ioctl for btuart lowerhalf shim driver
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 drivers/wireless/bluetooth/bt_uart_shim.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/wireless/bluetooth/bt_uart_shim.c b/drivers/wireless/bluetooth/bt_uart_shim.c
index 4f86131754..fc96e63fcb 100644
--- a/drivers/wireless/bluetooth/bt_uart_shim.c
+++ b/drivers/wireless/bluetooth/bt_uart_shim.c
@@ -89,6 +89,8 @@ static ssize_t hciuart_read(FAR const struct btuart_lowerhalf_s *lower,
 static ssize_t hciuart_write(FAR const struct btuart_lowerhalf_s *lower,
                              FAR const void *buffer, size_t buflen);
 static ssize_t hciuart_rxdrain(FAR const struct btuart_lowerhalf_s *lower);
+static int hciuart_ioctl(FAR const struct btuart_lowerhalf_s *lower,
+                         int cmd, unsigned long arg);
 
 /****************************************************************************
  * Private Functions
@@ -188,12 +190,10 @@ static int
 hciuart_setbaud(FAR const struct btuart_lowerhalf_s *lower, uint32_t baud)
 {
 #ifdef CONFIG_SERIAL_TERMIOS
-  FAR struct hciuart_config_s *config = (FAR struct hciuart_config_s *)lower;
-  FAR struct hciuart_state_s *state = &config->state;
   struct termios tio;
   int ret;
 
-  ret = file_ioctl(&state->f, TCGETS, (long unsigned int)&tio);
+  ret = hciuart_ioctl(lower, TCGETS, (unsigned long)&tio);
   if (ret)
     {
       wlerr("ERROR during TCGETS\n");
@@ -209,7 +209,7 @@ hciuart_setbaud(FAR const struct btuart_lowerhalf_s *lower, uint32_t baud)
 
   tio.c_cflag |= CRTS_IFLOW | CCTS_OFLOW;
 
-  ret = file_ioctl(&state->f, TCSETS, (unsigned long int)&tio);
+  ret = hciuart_ioctl(lower, TCSETS, (unsigned long)&tio);
   if (ret)
     {
       wlerr("ERROR during TCSETS, does UART support CTS/RTS?\n");
@@ -285,11 +285,21 @@ hciuart_write(FAR const struct btuart_lowerhalf_s *lower,
  ****************************************************************************/
 
 static ssize_t hciuart_rxdrain(FAR const struct btuart_lowerhalf_s *lower)
+{
+  return hciuart_ioctl(lower, TCDRN, 0);
+}
+
+/****************************************************************************
+ * Name: hciuart_ioctl
+ ****************************************************************************/
+
+static int hciuart_ioctl(FAR const struct btuart_lowerhalf_s *lower,
+                         int cmd, unsigned long arg)
 {
   FAR struct hciuart_config_s *config = (FAR struct hciuart_config_s *)lower;
   FAR struct hciuart_state_s *s = &config->state;
 
-  return file_ioctl(&s->f, TCDRN, 0);
+  return file_ioctl(&s->f, cmd, arg);
 }
 
 /****************************************************************************
@@ -414,6 +424,7 @@ FAR struct btuart_lowerhalf_s *btuart_shim_getdevice(FAR const char *path)
   n->lower.read     = hciuart_read;
   n->lower.write    = hciuart_write;
   n->lower.rxdrain  = hciuart_rxdrain;
+  n->lower.ioctl    = hciuart_ioctl;
 
   /* Create the monitor thread */
 


[incubator-nuttx] 01/05: bluetooth: Remove the unnecessary cast in btuart driver

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 11d083b35834285dd27d0d7672c4538ba8c41456
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Sun Oct 2 03:23:04 2022 +0800

    bluetooth: Remove the unnecessary cast in btuart driver
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 drivers/wireless/bluetooth/bt_uart.c      | 19 +++++++------------
 drivers/wireless/bluetooth/bt_uart_shim.c |  6 ++----
 2 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/drivers/wireless/bluetooth/bt_uart.c b/drivers/wireless/bluetooth/bt_uart.c
index 2d3bbe092e..d0e3a89687 100644
--- a/drivers/wireless/bluetooth/bt_uart.c
+++ b/drivers/wireless/bluetooth/bt_uart.c
@@ -64,8 +64,7 @@ static ssize_t btuart_read(FAR struct btuart_upperhalf_s *upper,
   ssize_t ntotal = 0;
   ssize_t nread;
 
-  wlinfo("buflen %lu minread %lu\n",
-         (unsigned long)buflen, (unsigned long)minread);
+  wlinfo("buflen %zu minread %zu\n", buflen, minread);
 
   DEBUGASSERT(upper != NULL && upper->lower != NULL);
   lower = upper->lower;
@@ -86,12 +85,11 @@ static ssize_t btuart_read(FAR struct btuart_upperhalf_s *upper,
         }
       else if (nread < 0)
         {
-          wlwarn("Returned error %d\n", (int)nread);
+          wlwarn("Returned error %zd\n", nread);
           return nread;
         }
 
-      wlinfo("read %ld remaining %lu\n",
-             (long)nread, (unsigned long)(buflen - nread));
+      wlinfo("read %zd remaining %zu\n", nread, buflen - nread);
 
       buflen -= nread;
       ntotal += nread;
@@ -124,10 +122,9 @@ static void btuart_rxwork(FAR void *arg)
    */
 
   nread = btuart_read(upper, data, H4_HEADER_SIZE, 0);
-  if (nread != 1)
+  if (nread != H4_HEADER_SIZE)
     {
-      wlwarn("WARNING: Unable to read H4 packet type: %ld\n",
-             (long)nread);
+      wlwarn("WARNING: Unable to read H4 packet type: %zd\n", nread);
       goto errout_with_busy;
     }
 
@@ -149,8 +146,7 @@ static void btuart_rxwork(FAR void *arg)
                       hdrlen, hdrlen);
   if (nread != hdrlen)
     {
-      wlwarn("WARNING: Unable to read H4 packet header: %ld\n",
-          (long)nread);
+      wlwarn("WARNING: Unable to read H4 packet header: %zd\n", nread);
       goto errout_with_busy;
     }
 
@@ -176,8 +172,7 @@ static void btuart_rxwork(FAR void *arg)
                       pktlen, pktlen);
   if (nread != pktlen)
     {
-      wlwarn("WARNING: Unable to read H4 packet: %ld\n",
-          (long)nread);
+      wlwarn("WARNING: Unable to read H4 packet: %zd\n", nread);
       goto errout_with_busy;
     }
 
diff --git a/drivers/wireless/bluetooth/bt_uart_shim.c b/drivers/wireless/bluetooth/bt_uart_shim.c
index 40952504f6..4f86131754 100644
--- a/drivers/wireless/bluetooth/bt_uart_shim.c
+++ b/drivers/wireless/bluetooth/bt_uart_shim.c
@@ -241,8 +241,7 @@ hciuart_read(FAR const struct btuart_lowerhalf_s *lower,
   FAR struct hciuart_config_s *config = (FAR struct hciuart_config_s *)lower;
   FAR struct hciuart_state_s *state = &config->state;
 
-  wlinfo("config %p buffer %p buflen %lu\n",
-         config, buffer, (unsigned long)buflen);
+  wlinfo("config %p buffer %p buflen %zu\n", config, buffer, buflen);
 
   /* NOTE: This assumes that the caller has exclusive access to the Rx
    * buffer, i.e., one lower half instance can server only one upper half!
@@ -272,8 +271,7 @@ hciuart_write(FAR const struct btuart_lowerhalf_s *lower,
   FAR struct hciuart_config_s *config = (FAR struct hciuart_config_s *)lower;
   FAR struct hciuart_state_s *state = &config->state;
 
-  wlinfo("config %p buffer %p buflen %lu\n",
-         config, buffer, (unsigned long)buflen);
+  wlinfo("config %p buffer %p buflen %zu\n", config, buffer, buflen);
 
   return file_write(&state->f, buffer, buflen);
 }


[incubator-nuttx] 05/05: bluetooth: Remove hcicollecttask from btuart shim driver

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 34b05804b09846276206b136a914730e7c6fdb72
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Sun Oct 2 04:28:53 2022 +0800

    bluetooth: Remove hcicollecttask from btuart shim driver
    
    monitor POLLIN event through callback mechanism instead
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 drivers/wireless/bluetooth/bt_uart_shim.c | 135 +++++++++---------------------
 1 file changed, 39 insertions(+), 96 deletions(-)

diff --git a/drivers/wireless/bluetooth/bt_uart_shim.c b/drivers/wireless/bluetooth/bt_uart_shim.c
index fc96e63fcb..c579a5a064 100644
--- a/drivers/wireless/bluetooth/bt_uart_shim.c
+++ b/drivers/wireless/bluetooth/bt_uart_shim.c
@@ -30,7 +30,6 @@
 #include <poll.h>
 #include <stdbool.h>
 #include <stdint.h>
-#include <stdio.h>
 #include <string.h>
 #include <sys/stat.h>
 #include <sys/types.h>
@@ -40,8 +39,6 @@
 #include <nuttx/fs/ioctl.h>
 #include <nuttx/spinlock.h>
 #include <nuttx/kmalloc.h>
-#include <nuttx/kthread.h>
-#include <nuttx/semaphore.h>
 #include <nuttx/serial/tioctl.h>
 #include <nuttx/wireless/bluetooth/bt_uart_shim.h>
 
@@ -59,9 +56,7 @@ struct hciuart_state_s
   FAR void *arg;                /* Rx callback argument */
 
   struct file f;                /* File structure */
-  bool enabled;                 /* Flag indicating that reception is enabled */
-
-  pid_t serialmontask;          /* The receive serial octets task handle */
+  struct pollfd p;              /* Poll structure */
 };
 
 struct hciuart_config_s
@@ -80,6 +75,7 @@ struct hciuart_config_s
 
 static void hciuart_rxattach(FAR const struct btuart_lowerhalf_s *lower,
                              btuart_rxcallback_t callback, FAR void *arg);
+static void hciuart_rxpollcb(FAR struct pollfd *fds);
 static void hciuart_rxenable(FAR const struct btuart_lowerhalf_s *lower,
                              bool enable);
 static int hciuart_setbaud(FAR const struct btuart_lowerhalf_s *lower,
@@ -142,6 +138,35 @@ hciuart_rxattach(FAR const struct btuart_lowerhalf_s *lower,
   spin_unlock_irqrestore(NULL, flags);
 }
 
+/****************************************************************************
+ * Name: hciuart_rxpollcb
+ *
+ * Description:
+ *   Callback to receive the UART driver POLLIN notification.
+ *
+ ****************************************************************************/
+
+static void hciuart_rxpollcb(FAR struct pollfd *fds)
+{
+  FAR struct hciuart_config_s *n = (FAR struct hciuart_config_s *)fds->arg;
+  FAR struct hciuart_state_s *s = &n->state;
+
+  if (fds->revents & POLLIN)
+    {
+      fds->revents = 0;
+      if (s->callback != NULL)
+        {
+          wlinfo("Activating callback\n");
+          s->callback(&n->lower, s->arg);
+        }
+      else
+        {
+          wlwarn("Dropping data (no CB)\n");
+          hciuart_rxdrain(&n->lower);
+        }
+    }
+}
+
 /****************************************************************************
  * Name: hciuart_rxenable
  *
@@ -161,15 +186,10 @@ static void hciuart_rxenable(FAR const struct btuart_lowerhalf_s *lower,
   FAR struct hciuart_config_s *config = (FAR struct hciuart_config_s *)lower;
   FAR struct hciuart_state_s *s = &config->state;
 
-  irqstate_t flags = spin_lock_irqsave(NULL);
-  if (enable != s->enabled)
+  if (enable != !!s->p.priv)
     {
-      wlinfo(enable ? "Enable\n" : "Disable\n");
+      file_poll(&s->f, &s->p, enable);
     }
-
-  s->enabled = enable;
-
-  spin_unlock_irqrestore(NULL, flags);
 }
 
 /****************************************************************************
@@ -302,74 +322,6 @@ static int hciuart_ioctl(FAR const struct btuart_lowerhalf_s *lower,
   return file_ioctl(&s->f, cmd, arg);
 }
 
-/****************************************************************************
- * Name: hcicollecttask
- *
- * Description:
- *   Loop and alert when serial data arrive
- *
- ****************************************************************************/
-
-static int hcicollecttask(int argc, FAR char **argv)
-{
-  FAR struct hciuart_config_s *n;
-  FAR struct hciuart_state_s *s;
-  struct pollfd p;
-
-  n = (FAR struct hciuart_config_s *)
-    ((uintptr_t)strtoul(argv[1], NULL, 0));
-  s = &n->state;
-
-  /* Put materials into poll structure */
-
-  p.ptr = &s->f;
-  p.events = POLLIN | POLLFILE;
-
-  for (; ; )
-    {
-      /* Wait for data to arrive */
-
-      int ret = nx_poll(&p, 1, -1);
-      if (ret < 0)
-        {
-          wlwarn("Poll interrupted %d\n", ret);
-          continue;
-        }
-
-      wlinfo("Poll completed %d\n", p.revents);
-
-      /* Given the nature of file_poll, there are multiple reasons why
-       * we might be here, so make sure we only consider the read.
-       */
-
-      if (p.revents & POLLIN)
-        {
-          if (!s->enabled)
-            {
-              /* We aren't expected to be listening, so drop these data */
-
-              wlwarn("Dropping data\n");
-              hciuart_rxdrain(&n->lower);
-            }
-          else
-            {
-              if (s->callback != NULL)
-                {
-                  wlinfo("Activating callback\n");
-                  s->callback(&n->lower, s->arg);
-                }
-              else
-                {
-                  wlwarn("Dropping data (no CB)\n");
-                  hciuart_rxdrain(&n->lower);
-                }
-            }
-        }
-    }
-
-  return OK;
-}
-
 /****************************************************************************
  * Public Functions
  ****************************************************************************/
@@ -393,8 +345,6 @@ FAR struct btuart_lowerhalf_s *btuart_shim_getdevice(FAR const char *path)
 {
   FAR struct hciuart_config_s *n;
   FAR struct hciuart_state_s *s;
-  FAR char *argv[2];
-  char arg1[16];
   int ret;
 
   /* Get the memory for this shim instance */
@@ -416,6 +366,12 @@ FAR struct btuart_lowerhalf_s *btuart_shim_getdevice(FAR const char *path)
       return NULL;
     }
 
+  /* Setup poll structure */
+
+  s->p.events = POLLIN;
+  s->p.arg    = n;
+  s->p.cb     = hciuart_rxpollcb;
+
   /* Hook the routines in */
 
   n->lower.rxattach = hciuart_rxattach;
@@ -426,18 +382,5 @@ FAR struct btuart_lowerhalf_s *btuart_shim_getdevice(FAR const char *path)
   n->lower.rxdrain  = hciuart_rxdrain;
   n->lower.ioctl    = hciuart_ioctl;
 
-  /* Create the monitor thread */
-
-  snprintf(arg1, 16, "%p", n);
-  argv[0] = arg1;
-  argv[1] = NULL;
-
-  ret = kthread_create("BT HCI Rx", CONFIG_BLUETOOTH_TXCONN_PRIORITY,
-                       CONFIG_DEFAULT_TASK_STACKSIZE, hcicollecttask, argv);
-  if (ret > 0)
-    {
-      s->serialmontask = (pid_t)ret;
-    }
-
   return (FAR struct btuart_lowerhalf_s *)n;
 }


[incubator-nuttx] 03/05: bluetooth: Forward ioctl to btuart lowerhalf driver

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 6ec74d8d364d7bfb6a4bdef6dc80efc1cebe769b
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Sun Oct 2 03:34:17 2022 +0800

    bluetooth: Forward ioctl to btuart lowerhalf driver
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 drivers/wireless/bluetooth/bt_uart.c          | 20 ++++++++++++++++++++
 drivers/wireless/bluetooth/bt_uart.h          |  2 ++
 drivers/wireless/bluetooth/bt_uart_bcm4343x.c |  1 +
 drivers/wireless/bluetooth/bt_uart_cc2564.c   |  1 +
 drivers/wireless/bluetooth/bt_uart_generic.c  |  1 +
 include/nuttx/wireless/bluetooth/bt_uart.h    |  5 +++++
 6 files changed, 30 insertions(+)

diff --git a/drivers/wireless/bluetooth/bt_uart.c b/drivers/wireless/bluetooth/bt_uart.c
index a50f1b0498..b56be92dbd 100644
--- a/drivers/wireless/bluetooth/bt_uart.c
+++ b/drivers/wireless/bluetooth/bt_uart.c
@@ -306,3 +306,23 @@ void btuart_close(FAR struct bt_driver_s *dev)
 
   lower->rxattach(lower, NULL, NULL);
 }
+
+int btuart_ioctl(FAR struct bt_driver_s *dev,
+                 int cmd, unsigned long arg)
+{
+  FAR struct btuart_upperhalf_s *upper;
+  FAR const struct btuart_lowerhalf_s *lower;
+
+  upper = (FAR struct btuart_upperhalf_s *)dev;
+  DEBUGASSERT(upper != NULL && upper->lower != NULL);
+  lower = upper->lower;
+
+  if (lower->ioctl)
+    {
+      return lower->ioctl(lower, cmd, arg);
+    }
+  else
+    {
+      return -ENOTTY;
+    }
+}
diff --git a/drivers/wireless/bluetooth/bt_uart.h b/drivers/wireless/bluetooth/bt_uart.h
index 1abaa507ef..9aeb32c297 100644
--- a/drivers/wireless/bluetooth/bt_uart.h
+++ b/drivers/wireless/bluetooth/bt_uart.h
@@ -92,5 +92,7 @@ int btuart_send(FAR struct bt_driver_s *dev,
                 FAR void *data, size_t len);
 int btuart_open(FAR struct bt_driver_s *dev);
 void btuart_close(FAR struct bt_driver_s *dev);
+int btuart_ioctl(FAR struct bt_driver_s *dev,
+                 int cmd, unsigned long arg);
 
 #endif /* __DRIVER_WIRELESS_BLUETOOTH_BT_UART_H */
diff --git a/drivers/wireless/bluetooth/bt_uart_bcm4343x.c b/drivers/wireless/bluetooth/bt_uart_bcm4343x.c
index b19252c89b..620b05884b 100644
--- a/drivers/wireless/bluetooth/bt_uart_bcm4343x.c
+++ b/drivers/wireless/bluetooth/bt_uart_bcm4343x.c
@@ -424,6 +424,7 @@ int btuart_register(FAR const struct btuart_lowerhalf_s *lower)
   upper->dev.open = btuart_open;
   upper->dev.send = btuart_send;
   upper->dev.close = btuart_close;
+  upper->dev.ioctl = btuart_ioctl;
   upper->lower = lower;
 
   /* Load firmware */
diff --git a/drivers/wireless/bluetooth/bt_uart_cc2564.c b/drivers/wireless/bluetooth/bt_uart_cc2564.c
index ff39218d54..aa2c1da688 100644
--- a/drivers/wireless/bluetooth/bt_uart_cc2564.c
+++ b/drivers/wireless/bluetooth/bt_uart_cc2564.c
@@ -190,6 +190,7 @@ int btuart_register(FAR const struct btuart_lowerhalf_s *lower)
   upper->dev.open         = btuart_open;
   upper->dev.send         = btuart_send;
   upper->dev.close        = btuart_close;
+  upper->dev.ioctl        = btuart_ioctl;
   upper->lower            = lower;
 
   /* Load firmware */
diff --git a/drivers/wireless/bluetooth/bt_uart_generic.c b/drivers/wireless/bluetooth/bt_uart_generic.c
index d194360d36..6b462cf2ff 100644
--- a/drivers/wireless/bluetooth/bt_uart_generic.c
+++ b/drivers/wireless/bluetooth/bt_uart_generic.c
@@ -84,6 +84,7 @@ int btuart_register(FAR const struct btuart_lowerhalf_s *lower)
   upper->dev.open         = btuart_open;
   upper->dev.send         = btuart_send;
   upper->dev.close        = btuart_close;
+  upper->dev.ioctl        = btuart_ioctl;
   upper->lower            = lower;
 
   /* And register the driver with the network and the Bluetooth stack. */
diff --git a/include/nuttx/wireless/bluetooth/bt_uart.h b/include/nuttx/wireless/bluetooth/bt_uart.h
index 98bdda78ee..bd92e478a3 100644
--- a/include/nuttx/wireless/bluetooth/bt_uart.h
+++ b/include/nuttx/wireless/bluetooth/bt_uart.h
@@ -137,6 +137,11 @@ struct btuart_lowerhalf_s
   /* Flush/drain all buffered RX data */
 
   CODE ssize_t (*rxdrain)(FAR const struct btuart_lowerhalf_s *lower);
+
+  /* Lower-half logic may support platform-specific ioctl commands */
+
+  CODE int (*ioctl)(FAR const struct btuart_lowerhalf_s *lower,
+                    int cmd, unsigned long arg);
 };
 
 /****************************************************************************