git: 2c6feab25329 - main - hccontrol: Support generic Bluetooth LE AdvData

From: Pouria Mousavizadeh Tehrani <pouria_at_FreeBSD.org>
Date: Fri, 10 Apr 2026 18:06:46 UTC
The branch main has been updated by pouria:

URL: https://cgit.FreeBSD.org/src/commit/?id=2c6feab253297c21d00601ceef818fcbe4da70d8

commit 2c6feab253297c21d00601ceef818fcbe4da70d8
Author:     F. Duncanh <fduncanh@gmail.com>
AuthorDate: 2026-03-18 05:14:26 +0000
Commit:     Pouria Mousavizadeh Tehrani <pouria@FreeBSD.org>
CommitDate: 2026-04-10 18:06:34 +0000

    hccontrol: Support generic Bluetooth LE AdvData
    
    hccontrol LE_Set_Advertising_Data does not currently allow construction
    of manufacturer-specific type 0xFF AdvData.  Fixed by a new data-entry
    option -b "b1,b2,b3,...,bn" where b's are 8-bit byte strings (octets).
    
    Signed-off-by: F. Duncanh <fduncanh@gmail.com>
    Reviewed by: takawata, pouria
    Pull Request: https://github.com/freebsd/freebsd-src/pull/2082
---
 usr.sbin/bluetooth/hccontrol/le.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/usr.sbin/bluetooth/hccontrol/le.c b/usr.sbin/bluetooth/hccontrol/le.c
index 6d5440643b45..fbcee1451b0a 100644
--- a/usr.sbin/bluetooth/hccontrol/le.c
+++ b/usr.sbin/bluetooth/hccontrol/le.c
@@ -182,7 +182,7 @@ parse_param(int argc, char *argv[], char *buf, int *len)
 	uint16_t value;
 	optreset = 1;
 	optind = 0;
-	while ((ch = getopt(argc, argv , "n:f:u:")) != -1) {
+	while ((ch = getopt(argc, argv , "n:f:u:b:")) != -1) {
 		switch(ch){
 		case 'n':
 			datalen = strlen(optarg);
@@ -218,7 +218,24 @@ parse_param(int argc, char *argv[], char *buf, int *len)
 				curbuf += 2;
 				*lenpos += 2;
 			}
-				
+			break;
+		case 'b':
+			datalen = 1;
+			token = optarg;
+			while ((token = strchr(token, ',')) != NULL) {
+				datalen++;
+				token++;
+			}
+			if ((curbuf + datalen + 1) >= buflast)
+				goto done;
+			curbuf[0] = datalen;
+			curbuf++;
+			token = optarg;
+			while ((token = strsep(&optarg, ",")) != NULL) {
+				value = strtol(token, NULL, 16);
+				curbuf[0] = value & 0xff;
+				curbuf++;
+			}
 		}
 	}
 done:
@@ -1297,7 +1314,7 @@ struct hci_command le_commands[] = {
   },
   {
 	  "le_set_advertising_data",
-	  "le_set_advertising_data -n $name -f $flag -u $uuid16,$uuid16 \n"
+	  "le_set_advertising_data -n $name -f $flag -u $uuid16,$uuid16 -b $byte,$byte,...,$byte\n"
 	  "set LE device advertising packed data",
 	  &le_set_advertising_data
   },