diff options
| author | F. Duncanh <fduncanh@gmail.com> | 2026-03-18 05:14:26 +0000 |
|---|---|---|
| committer | Pouria Mousavizadeh Tehrani <pouria@FreeBSD.org> | 2026-04-10 18:06:34 +0000 |
| commit | 2c6feab253297c21d00601ceef818fcbe4da70d8 (patch) | |
| tree | 6d2203551b5fdb086d2e7e83bafb15dce72b0bd9 | |
| parent | 35bbdfad28626255c63360d98c45e41f2c692ef0 (diff) | |
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
| -rw-r--r-- | usr.sbin/bluetooth/hccontrol/le.c | 23 |
1 files 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 }, |
