Skip to content

Commit

Permalink
host: refactor BLE Audio
Browse files Browse the repository at this point in the history
This patch refactors BLE Audio library to conform to new directory tree
introduced in a979570.

LE Audio related files present in host/include, host/src and
host/services were moved to corelated folders in host/audio.

Experimental system config BLE_AUDIO enabling LE Audio feature was introduced.

Naming convention for BLE Audio functions, structures and files was
unified - replaced `bcst` shorthand with `broadcast`. For example,
ble_audio_pub_bcst_announcement_feat was renamed to
ble_audio_pub_broadcast_announcement_feat.

Contents of host/include/ble_audio_common.h was incorporated into
host/audio/include/audio/ble_audio.h.

Apps and Auracast service were adjusted to new config and include paths.

BLE_MAX_BIG and BLE_MAX_BIS renamed to BLE_ISO_MAX_BIGS and
BLE_ISO_MAX_BISES, respectevaly.
  • Loading branch information
KKopyscinski committed Mar 1, 2024
1 parent 409aac4 commit a04a6d2
Show file tree
Hide file tree
Showing 34 changed files with 393 additions and 420 deletions.
1 change: 1 addition & 0 deletions .github/test_build_apps_syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ syscfg.vals:
BLE_PERIODIC_ADV_SYNC_BIGINFO_REPORTS: 1
BLE_ISO: 1
BLE_ISO_TEST: 1
BLE_AUDIO: 1
BLE_ISO_BROADCAST_SOURCE: 1
BLE_HCI_VS: 1
BLE_POWER_CONTROL: 1
Expand Down
2 changes: 1 addition & 1 deletion apps/auracast/pkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ pkg.deps:
- nimble/host/util
- nimble/host/services/gap
- nimble/host/store/config
- nimble/host/audio/services/auracast
- "@apache-mynewt-core/kernel/os"
- "@apache-mynewt-core/sys/console"
- "@apache-mynewt-core/sys/log"
- "@apache-mynewt-core/sys/stats"
- "@apache-mynewt-core/sys/sysinit"
- "@apache-mynewt-core/sys/id"
- "@apache-mynewt-nimble/nimble/host/services/auracast"
4 changes: 2 additions & 2 deletions apps/auracast/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static os_membuf_t bis_mem[
static struct os_mempool bis_pool;

static os_membuf_t codec_spec_mem[
OS_MEMPOOL_SIZE(MYNEWT_VAL(BLE_MAX_BIS) * 2, 19)
OS_MEMPOOL_SIZE(MYNEWT_VAL(BLE_ISO_MAX_BISES) * 2, 19)
];
static struct os_mempool codec_spec_pool;

Expand Down Expand Up @@ -156,7 +156,7 @@ auracast_init()
assert(rc == 0);

rc = os_mempool_init(&codec_spec_pool,
MYNEWT_VAL(BLE_MAX_BIS) * 2, 19,
MYNEWT_VAL(BLE_ISO_MAX_BISES) * 2, 19,
codec_spec_mem, "codec_spec_pool");
assert(rc == 0);
}
Expand Down
6 changes: 3 additions & 3 deletions apps/auracast/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ syscfg.vals:
BLE_VERSION: 54
BLE_ISO: 1
BLE_ISO_BROADCAST_SOURCE: 1
BLE_MAX_BIG: 1
BLE_MAX_BIS: 2
BLE_ISO_MAX_BIGS: 1
BLE_ISO_MAX_BISES: 2

BLE_PHY_NRF52_HEADERMASK_WORKAROUND: 1
BLE_AUDIO: 1
2 changes: 1 addition & 1 deletion apps/btshell/src/btshell.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "host/ble_gatt.h"
#include "host/ble_gap.h"
#if (MYNEWT_VAL(BLE_ISO_BROADCAST_SOURCE))
#include "host/ble_audio_broadcast_source.h"
#include "audio/ble_audio_broadcast_source.h"
#endif

#ifdef __cplusplus
Expand Down
6 changes: 3 additions & 3 deletions apps/btshell/src/cmd_iso.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ static struct iso_rx_stats {
uint64_t valid_cnt;
uint64_t error_cnt;
uint64_t lost_cnt;
} rx_stats_pool[MYNEWT_VAL(BLE_MAX_BIS)];
} rx_stats_pool[MYNEWT_VAL(BLE_ISO_MAX_BISES)];

static void
iso_rx_stats_update(uint16_t conn_handle, const struct ble_iso_rx_data_info *info,
Expand Down Expand Up @@ -305,9 +305,9 @@ const struct shell_cmd_help cmd_iso_big_sync_create_help = {
int
cmd_iso_big_sync_create(int argc, char **argv)
{
struct ble_iso_bis_params bis_params[MYNEWT_VAL(BLE_MAX_BIS)];
struct ble_iso_bis_params bis_params[MYNEWT_VAL(BLE_ISO_MAX_BISES)];
struct ble_iso_big_sync_create_params params = { 0 };
uint8_t bis_idxs[MYNEWT_VAL(BLE_MAX_BIS)];
uint8_t bis_idxs[MYNEWT_VAL(BLE_ISO_MAX_BISES)];
uint8_t big_handle;
int rc;

Expand Down
4 changes: 2 additions & 2 deletions apps/btshell/src/cmd_leaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
* under the License.
*/

#include "host/ble_audio_broadcast_source.h"
#include "cmd_leaudio.h"
#include "btshell.h"
#include "console/console.h"
#include "errno.h"

#if (MYNEWT_VAL(BLE_ISO_BROADCAST_SOURCE))
#if (MYNEWT_VAL(BLE_AUDIO))
#include "audio/ble_audio_broadcast_source.h"
int
cmd_leaudio_base_add(int argc, char **argv)
{
Expand Down
40 changes: 21 additions & 19 deletions apps/btshell/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@
#include "host/ble_gatt.h"
#include "host/ble_store.h"
#include "host/ble_sm.h"
#include "host/ble_audio_common.h"
#include "host/ble_audio_broadcast_source.h"
#if MYNEWT_VAL(BLE_AUDIO)
#include "audio/ble_audio_broadcast_source.h"
#include "audio/ble_audio.h"
#endif
#include "host/util/util.h"

/* Mandatory services. */
Expand Down Expand Up @@ -132,35 +134,35 @@ struct ble_sm_sc_oob_data oob_data_remote;

#if MYNEWT_VAL(BLE_ISO_BROADCAST_SOURCE)
static struct {struct ble_audio_base *base; uint8_t adv_instance;}
btshell_base_list[MYNEWT_VAL(BLE_MAX_BIG)];
btshell_base_list[MYNEWT_VAL(BLE_ISO_MAX_BIGS)];

static os_membuf_t btshell_base_mem[
OS_MEMPOOL_SIZE(MYNEWT_VAL(BLE_MAX_BIG),
OS_MEMPOOL_SIZE(MYNEWT_VAL(BLE_ISO_MAX_BIGS),
sizeof(struct ble_audio_base))
];
static struct os_mempool btshell_base_pool;

static os_membuf_t btshell_big_params_mem[
OS_MEMPOOL_SIZE(MYNEWT_VAL(BLE_MAX_BIG),
OS_MEMPOOL_SIZE(MYNEWT_VAL(BLE_ISO_MAX_BIGS),
sizeof(struct ble_iso_big_params))
];
static struct os_mempool btshell_big_params_pool;

/** Mempool size: in worst case every BIS is in separate subgroup */
static os_membuf_t btshell_big_sub_mem[
OS_MEMPOOL_SIZE(MYNEWT_VAL(BLE_MAX_BIS),
OS_MEMPOOL_SIZE(MYNEWT_VAL(BLE_ISO_MAX_BISES),
sizeof(struct ble_audio_big_subgroup))
];
static struct os_mempool btshell_big_sub_pool;

static os_membuf_t btshell_bis_mem[
OS_MEMPOOL_SIZE(MYNEWT_VAL(BLE_MAX_BIS),
OS_MEMPOOL_SIZE(MYNEWT_VAL(BLE_ISO_MAX_BISES),
sizeof(struct ble_audio_bis))
];
static struct os_mempool btshell_bis_pool;

static os_membuf_t btshell_metadata_mem[
OS_MEMPOOL_SIZE(MYNEWT_VAL(BLE_MAX_BIS),
OS_MEMPOOL_SIZE(MYNEWT_VAL(BLE_ISO_MAX_BISES),
MYNEWT_VAL(BLE_EXT_ADV_MAX_SIZE) - 27)
];
static struct os_mempool btshell_metadata_pool;
Expand All @@ -171,12 +173,12 @@ static struct os_mempool btshell_metadata_pool;
* has one. This is inefficient but possible and should not cause error if
* used that way */
static os_membuf_t btshell_codec_spec_mem[
OS_MEMPOOL_SIZE(MYNEWT_VAL(BLE_MAX_BIS) * 2, 9)
OS_MEMPOOL_SIZE(MYNEWT_VAL(BLE_ISO_MAX_BISES) * 2, 9)
];
static struct os_mempool btshell_codec_spec_pool;

static os_membuf_t btshell_big_params_mem[
OS_MEMPOOL_SIZE(MYNEWT_VAL(BLE_MAX_BIG), sizeof(struct ble_iso_big_params))
OS_MEMPOOL_SIZE(MYNEWT_VAL(BLE_ISO_MAX_BIGS), sizeof(struct ble_iso_big_params))
];
static struct os_mempool btshell_big_params_pool;
#endif
Expand Down Expand Up @@ -2767,7 +2769,7 @@ static int
btshell_base_find_free(void)
{
int i;
for (i = 0; i < MYNEWT_VAL(BLE_MAX_BIG); i++) {
for (i = 0; i < MYNEWT_VAL(BLE_ISO_MAX_BIGS); i++) {
if (btshell_base_list[i].base == NULL) {
return i;
}
Expand All @@ -2780,7 +2782,7 @@ static struct ble_audio_base *
btshell_base_find(uint8_t adv_instance)
{
int i;
for (i = 0; i < MYNEWT_VAL(BLE_MAX_BIG); i++) {
for (i = 0; i < MYNEWT_VAL(BLE_ISO_MAX_BIGS); i++) {
if (btshell_base_list[i].adv_instance == adv_instance) {
return btshell_base_list[i].base;
}
Expand Down Expand Up @@ -3082,38 +3084,38 @@ mynewt_main(int argc, char **argv)
assert(rc == 0);
#endif
#if (MYNEWT_VAL(BLE_ISO_BROADCAST_SOURCE))
rc = os_mempool_init(&btshell_base_pool, MYNEWT_VAL(BLE_MAX_BIG),
rc = os_mempool_init(&btshell_base_pool, MYNEWT_VAL(BLE_ISO_MAX_BIGS),
sizeof(struct ble_audio_base),
btshell_base_mem,
"btshell_base_pool");
assert(rc == 0);
rc = os_mempool_init(&btshell_big_params_pool, MYNEWT_VAL(BLE_MAX_BIG),
rc = os_mempool_init(&btshell_big_params_pool, MYNEWT_VAL(BLE_ISO_MAX_BIGS),
sizeof(struct ble_iso_big_params),
btshell_big_params_mem,
"btshell_big_params_pool");
assert(rc == 0);
rc = os_mempool_init(&btshell_big_sub_pool, MYNEWT_VAL(BLE_MAX_BIS),
rc = os_mempool_init(&btshell_big_sub_pool, MYNEWT_VAL(BLE_ISO_MAX_BISES),
sizeof(struct ble_audio_big_subgroup),
btshell_big_sub_mem,
"btshell_big_sub_pool");
assert(rc == 0);
rc = os_mempool_init(&btshell_bis_pool, MYNEWT_VAL(BLE_MAX_BIS),
rc = os_mempool_init(&btshell_bis_pool, MYNEWT_VAL(BLE_ISO_MAX_BISES),
sizeof(struct ble_audio_bis), btshell_bis_mem,
"btshell_bis_pool");
assert(rc == 0);

rc = os_mempool_init(&btshell_metadata_pool, MYNEWT_VAL(BLE_MAX_BIS),
rc = os_mempool_init(&btshell_metadata_pool, MYNEWT_VAL(BLE_ISO_MAX_BISES),
MYNEWT_VAL(BLE_EXT_ADV_MAX_SIZE) - 27,
btshell_metadata_mem, "btshell_metadata_pool");
assert(rc == 0);

rc = os_mempool_init(&btshell_codec_spec_pool,
MYNEWT_VAL(BLE_MAX_BIS) * 2, 19,
MYNEWT_VAL(BLE_ISO_MAX_BISES) * 2, 19,
btshell_codec_spec_mem, "btshell_codec_spec_pool");
assert(rc == 0);

rc = os_mempool_init(&btshell_big_params_pool,
MYNEWT_VAL(BLE_MAX_BIG),
MYNEWT_VAL(BLE_ISO_MAX_BIGS),
sizeof(struct ble_iso_big_params),
btshell_big_params_mem, "btshell_big_params_pool");
assert(rc == 0);
Expand Down
1 change: 1 addition & 0 deletions apps/leaudio_broadcaster/pkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pkg.deps:
- nimble/host/util
- nimble/host/services/gap
- nimble/host/store/config
- nimble/host/audio
- "@apache-mynewt-core/kernel/os"
- "@apache-mynewt-core/sys/console"
- "@apache-mynewt-core/sys/log"
Expand Down
8 changes: 4 additions & 4 deletions apps/leaudio_broadcaster/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
#include "host/ble_hs.h"
#include "host/util/util.h"

#include "host/ble_audio_broadcast_source.h"
#include "host/ble_audio_common.h"
#include "audio/ble_audio_broadcast_source.h"
#include "audio/ble_audio.h"
#include "host/ble_iso.h"

#include "hal/hal_gpio.h"
Expand Down Expand Up @@ -53,7 +53,7 @@ static os_membuf_t bis_mem[
static struct os_mempool bis_pool;

static os_membuf_t codec_spec_mem[
OS_MEMPOOL_SIZE(MYNEWT_VAL(BLE_MAX_BIS) * 2, 19)
OS_MEMPOOL_SIZE(MYNEWT_VAL(BLE_ISO_MAX_BISES) * 2, 19)
];
static struct os_mempool codec_spec_pool;

Expand Down Expand Up @@ -182,7 +182,7 @@ broadcaster_init()
assert(rc == 0);

rc = os_mempool_init(&codec_spec_pool,
MYNEWT_VAL(BLE_MAX_BIS) * 2, 19,
MYNEWT_VAL(BLE_ISO_MAX_BISES) * 2, 19,
codec_spec_mem, "codec_spec_pool");
assert(rc == 0);
}
Expand Down
5 changes: 3 additions & 2 deletions apps/leaudio_broadcaster/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@ syscfg.vals:
MSYS_1_BLOCK_COUNT: 32

BLE_VERSION: 54
BLE_AUDIO: 1
BLE_ISO: 1
BLE_ISO_BROADCAST_SOURCE: 1
BLE_MAX_BIG: 1
BLE_MAX_BIS: 2
BLE_ISO_MAX_BIGS: 1
BLE_ISO_MAX_BISES: 2

syscfg.vals.BSP_NRF5340:
MCU_MPU_ENABLE: 1
Expand Down
Loading

0 comments on commit a04a6d2

Please sign in to comment.