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

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


The following commit(s) were added to refs/heads/master by this push:
     new 6fbf576d9 btsak: fix advertising restart and scan response
6fbf576d9 is described below

commit 6fbf576d9cd37223a21caaaa9095543c5dbdc7cb
Author: bigcat2026 <[email protected]>
AuthorDate: Thu Nov 5 18:23:07 2026 +0800

    btsak: fix advertising restart and scan response
    
    Fix the scan response name placement: the complete local name belongs in
    sd[0], not sd[1].  Also issue SIOCBTADVSTOP before SIOCBTADVSTART so a
    previously running advertisement is stopped before it is restarted.
    
    Signed-off-by: bigcat2026 <[email protected]>
---
 wireless/bluetooth/btsak/btsak_advertise.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/wireless/bluetooth/btsak/btsak_advertise.c 
b/wireless/bluetooth/btsak/btsak_advertise.c
index 0418f0670..b4e777678 100644
--- a/wireless/bluetooth/btsak/btsak_advertise.c
+++ b/wireless/bluetooth/btsak/btsak_advertise.c
@@ -123,9 +123,9 @@ static void btsak_cmd_advertisestart(FAR struct btsak_s 
*btsak,
   ad[0].data[0] = BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR;
 
   memset(&sd, 0, 2 * sizeof(struct bt_eir_s));
-  sd[1].len         = sizeof("btsak");
-  sd[1].type        = BT_EIR_NAME_COMPLETE;
-  strlcpy((FAR char *)sd[1].data, "btsak", sizeof(sd[1].data));
+  sd[0].len         = sizeof("btsak");
+  sd[0].type        = BT_EIR_NAME_COMPLETE;
+  strlcpy((FAR char *)sd[0].data, "btsak", sizeof(sd[0].data));
 
   memset(&btreq, 0, sizeof(struct btreq_s));
   strlcpy(btreq.btr_name, btsak->ifname, IFNAMSIZ);
@@ -138,6 +138,9 @@ static void btsak_cmd_advertisestart(FAR struct btsak_s 
*btsak,
   sockfd = btsak_socket(btsak);
   if (sockfd >= 0)
     {
+      (void)ioctl(sockfd, SIOCBTADVSTOP,
+                  (unsigned long)((uintptr_t)&btreq));
+
       ret = ioctl(sockfd, SIOCBTADVSTART,
                   (unsigned long)((uintptr_t)&btreq));
       if (ret < 0)

Reply via email to