From 8c8ac6f13c1a8c94bfcc6111822bf2cc0019ac04 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Tue, 2 Apr 2024 15:22:58 -0400 Subject: [PATCH] bthost: Add bthost_set_base This adds bthost_set_base which takes create of creating the PA data using bt_ad to add BAA service data and then generating the PA data which is then passed to bthost_set_pa_data. --- emulator/bthost.c | 19 +++++++++++++++++++ emulator/bthost.h | 1 + 2 files changed, 20 insertions(+) diff --git a/emulator/bthost.c b/emulator/bthost.c index 627b771ea..ca405d721 100644 --- a/emulator/bthost.c +++ b/emulator/bthost.c @@ -3174,6 +3174,25 @@ void bthost_set_pa_data(struct bthost *bthost, const uint8_t *data, set_pa_data(bthost, data, len, 0); } +void bthost_set_base(struct bthost *bthost, const uint8_t *data, uint8_t len) +{ + struct bt_ad *ad; + bt_uuid_t uuid; + uint8_t *pa_data; + size_t pa_len; + + bt_uuid16_create(&uuid, BAA_SERVICE); + + ad = bt_ad_new(); + bt_ad_set_max_len(ad, BT_PA_MAX_DATA_LEN); + bt_ad_add_service_data(ad, &uuid, (void *)data, len); + + pa_data = bt_ad_generate(ad, &pa_len); + bthost_set_pa_data(bthost, pa_data, pa_len); + + bt_ad_unref(ad); +} + void bthost_set_pa_enable(struct bthost *bthost, uint8_t enable) { struct bt_hci_cmd_le_set_pa_enable cp; diff --git a/emulator/bthost.h b/emulator/bthost.h index f03262d46..0c488e32a 100644 --- a/emulator/bthost.h +++ b/emulator/bthost.h @@ -104,6 +104,7 @@ void bthost_set_ext_adv_enable(struct bthost *bthost, uint8_t enable); void bthost_set_pa_params(struct bthost *bthost); void bthost_set_pa_data(struct bthost *bthost, const uint8_t *data, uint8_t len); +void bthost_set_base(struct bthost *bthost, const uint8_t *data, uint8_t len); void bthost_set_pa_enable(struct bthost *bthost, uint8_t enable); void bthost_create_big(struct bthost *bthost, uint8_t num_bis, uint8_t enc, const uint8_t *bcode); -- 2.47.3