From f0b104346a95b9d922289eb9fe947367fe75828c Mon Sep 17 00:00:00 2001 From: Emil Gydesen Date: Wed, 14 Dec 2022 23:45:18 +0100 Subject: [PATCH] Bluetooth: Audio: Shell: Fix off-by-one issue with the HAS uuid If the advertising is connectable, and we have privacy, then according to the HAP spec, we should not advertise the HAS uuid. This was done by simply truncating the advertising data, but it was only truncated by 1, instead of by the size of the UUID. Signed-off-by: Emil Gydesen --- subsys/bluetooth/shell/audio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/subsys/bluetooth/shell/audio.c b/subsys/bluetooth/shell/audio.c index edb863c65e6..dc29b771091 100644 --- a/subsys/bluetooth/shell/audio.c +++ b/subsys/bluetooth/shell/audio.c @@ -2144,7 +2144,7 @@ ssize_t audio_ad_data_add(struct bt_data *data_array, const size_t data_array_si IF_ENABLED(CONFIG_BT_GTBS, (BT_UUID_16_ENCODE(BT_UUID_GTBS_VAL),)) IF_ENABLED(CONFIG_BT_TBS, (BT_UUID_16_ENCODE(BT_UUID_TBS_VAL),)) IF_ENABLED(CONFIG_BT_VCP_VOL_REND, (BT_UUID_16_ENCODE(BT_UUID_VCS_VAL),)) - IF_ENABLED(CONFIG_BT_HAS, (BT_UUID_16_ENCODE(BT_UUID_HAS_VAL),)) + IF_ENABLED(CONFIG_BT_HAS, (BT_UUID_16_ENCODE(BT_UUID_HAS_VAL),)) /* Shall be last */ }; size_t ad_len = 0; @@ -2202,7 +2202,7 @@ ssize_t audio_ad_data_add(struct bt_data *data_array, const size_t data_array_si * Service UUID in the Service UUID AD type field of the advertising data * or scan response. */ - data_array[ad_len].data_len = ARRAY_SIZE(ad_ext_uuid16) - 1; + data_array[ad_len].data_len = ARRAY_SIZE(ad_ext_uuid16) - BT_UUID_SIZE_16; } else { data_array[ad_len].data_len = ARRAY_SIZE(ad_ext_uuid16); }