From 364b720d6210e5a23314254ca9beaa8857abbedf Mon Sep 17 00:00:00 2001 From: Szymon Czapracki Date: Mon, 8 Apr 2024 12:08:36 +0200 Subject: [PATCH] nimble/bttester: Various fixes in BAP bttester part MYNEWT_VAL is corrected in multiple places for an up-to-date name. Missing semicolon and invalid function name are fixed in btp_bap.c Codec configuration is now set on BIS level, as setting it on subgroup level caused tests to fail. --- apps/bttester/src/btp/bttester.h | 4 +-- apps/bttester/src/btp_bap.c | 45 ++++++++++++++------------------ apps/bttester/src/btp_core.c | 8 +++--- apps/bttester/syscfg.yml | 2 ++ 4 files changed, 28 insertions(+), 31 deletions(-) diff --git a/apps/bttester/src/btp/bttester.h b/apps/bttester/src/btp/bttester.h index 5d7e1219d2..7cb82b5c92 100644 --- a/apps/bttester/src/btp/bttester.h +++ b/apps/bttester/src/btp/bttester.h @@ -142,12 +142,12 @@ gatt_svr_register_cb(struct ble_gatt_register_ctxt *ctxt, void *arg); int gatt_svr_init(void); -#if MYNEWT_VAL(BLE_ISO_BROADCASTER) +#if MYNEWT_VAL(BLE_ISO_BROADCAST_SOURCE) uint8_t tester_init_bap(void); uint8_t tester_unregister_bap(void); -#endif /* MYNEWT_VAL(BLE_ISO_BROADCASTER) */ +#endif /* MYNEWT_VAL(BLE_ISO_BROADCAST_SOURCE) */ #endif /* __BTTESTER_H__ */ diff --git a/apps/bttester/src/btp_bap.c b/apps/bttester/src/btp_bap.c index b6a92ac623..5a2d06c811 100644 --- a/apps/bttester/src/btp_bap.c +++ b/apps/bttester/src/btp_bap.c @@ -21,7 +21,7 @@ #include "syscfg/syscfg.h" -#if MYNEWT_VAL(BLE_ISO_BROADCASTER) +#if MYNEWT_VAL(BLE_ISO_BROADCAST_SOURCE) #include "btp/btp_bap.h" @@ -38,9 +38,6 @@ #include "audio/ble_audio.h" #include "host/ble_iso.h" -#include "bsp/bsp.h" - - #define BROADCAST_ADV_INSTANCE 1 static struct ble_audio_big_subgroup big_subgroup; @@ -158,7 +155,6 @@ base_create(const struct bap_broadcast_source_setup_cmd *cmd) uint16_t chan_loc = BLE_AUDIO_LOCATION_FRONT_LEFT | BLE_AUDIO_LOCATION_FRONT_RIGHT; - uint8_t codec_spec_config[] = BLE_AUDIO_BUILD_CODEC_CONFIG(sampling_freq, frame_duration, chan_loc, max_sdu, ); @@ -166,25 +162,24 @@ base_create(const struct bap_broadcast_source_setup_cmd *cmd) tester_base.broadcast_id = sampling_freq; tester_base.presentation_delay = sampling_freq * 10000; - big_subgroup.bis_cnt = MYNEWT_VAL(BROADCASTER_CHAN_NUM); + big_subgroup.bis_cnt = MYNEWT_VAL(BLE_ISO_MAX_BISES); /** LC3 */ big_subgroup.codec_id.format = 0x06; - big_subgroup.codec_spec_config_len = sizeof(codec_spec_config); - - big_subgroup.codec_spec_config_len = os_memblock_get(&codec_spec_pool); - - memcpy(big_subgroup.codec_spec_config, - codec_spec_config, - sizeof(codec_spec_config)); + big_subgroup.codec_spec_config_len = 0; bis = os_memblock_get(&bis_pool); if (!bis) { - return BLE_HS_ENOMEM + return BLE_HS_ENOMEM; } - bis->codec_spec_config_len = 0; + bis->codec_spec_config = os_memblock_get(&codec_spec_pool); + memcpy(bis->codec_spec_config, + codec_spec_config, + sizeof(codec_spec_config)); + bis->codec_spec_config_len = sizeof(codec_spec_config); + bis->idx = 1; STAILQ_INSERT_HEAD(&big_subgroup.bises, bis, next); STAILQ_INSERT_HEAD(&tester_base.subs, &big_subgroup, next); @@ -221,6 +216,15 @@ broadcast_source_setup(const void *cmd, uint16_t cmd_len, void *rsp, base_create(source_config); + big_params.sdu_interval = sdu_interval; + big_params.max_sdu = max_sdu; + big_params.max_transport_latency = 8; + big_params.rtn = source_config->rtn; + big_params.phy = BLE_HCI_LE_PHY_2M; + big_params.packing = 0; + big_params.framing = source_config->framing; + big_params.encryption = 0; + struct ble_gap_periodic_adv_params periodic_params = { .itvl_min = 30, .itvl_max = 30, @@ -237,15 +241,6 @@ broadcast_source_setup(const void *cmd, uint16_t cmd_len, void *rsp, .sid = BROADCAST_ADV_INSTANCE, }; - big_params.sdu_interval = sdu_interval; - big_params.max_sdu = max_sdu; - big_params.max_transport_latency = 8; - big_params.rtn = source_config->rtn; - big_params.phy = BLE_HCI_LE_PHY_2M; - big_params.packing = 0; - big_params.framing = source_config->framing; - big_params.encryption = 0; - struct ble_broadcast_create_params create_params = { .base = &tester_base, .extended_params = &extended_params, @@ -422,5 +417,5 @@ tester_unregister_bap(void) return BTP_STATUS_SUCCESS; } -#endif /* MYNEWT_VAL(BLE_ISO_BROADCASTER) */ +#endif /* MYNEWT_VAL(BLE_ISO_BROADCAST_SOURCE) */ diff --git a/apps/bttester/src/btp_core.c b/apps/bttester/src/btp_core.c index f7a4bc4f92..a7b1878322 100644 --- a/apps/bttester/src/btp_core.c +++ b/apps/bttester/src/btp_core.c @@ -102,11 +102,11 @@ register_service(const void *cmd, uint16_t cmd_len, status = tester_init_mesh(); break; #endif /* MYNEWT_VAL(BLE_MESH) */ -#if MYNEWT_VAL(BLE_ISO_BROADCASTER) +#if MYNEWT_VAL(BLE_ISO_BROADCAST_SOURCE) case BTP_SERVICE_ID_BAP: status = tester_init_bap(); break; -#endif /* MYNEWT_VAL(BLE_ISO_BROADCASTER) */ +#endif /* MYNEWT_VAL(BLE_ISO_BROADCAST_SOURCE) */ case BTP_SERVICE_ID_GATTC: status = tester_init_gatt_cl(); break; @@ -159,11 +159,11 @@ unregister_service(const void *cmd, uint16_t cmd_len, case BTP_SERVICE_ID_GATTC: status = tester_unregister_gatt_cl(); break; -#if MYNEWT_VAL(BLE_ISO_BROADCASTER) +#if MYNEWT_VAL(BLE_ISO_BROADCAST_SOURCE) case BTP_SERVICE_ID_BAP: status = tester_unregister_bap(); break; -#endif /* MYNEWT_VAL(BLE_ISO_BROADCASTER) */ +#endif /* MYNEWT_VAL(BLE_ISO_BROADCAST_SOURCE) */ default: status = BTP_STATUS_FAILED; break; diff --git a/apps/bttester/syscfg.yml b/apps/bttester/syscfg.yml index bb4d6f775f..80c377a7c1 100644 --- a/apps/bttester/syscfg.yml +++ b/apps/bttester/syscfg.yml @@ -97,6 +97,8 @@ syscfg.vals: BLE_ISO_MAX_BISES: 1 BLE_ISO_MAX_BIGS: 1 BLE_EXT_ADV: 1 + BLE_PHY_2M: 1 + BLE_EXT_ADV_MAX_SIZE: 40 BLE_PERIODIC_ADV: 1 BLE_ISO_BROADCAST_SOURCE: 1 BLE_MULTI_ADV_INSTANCES: 1