Bluetooth: Audio: Add implementation for PBP and dedicated sample apps.
PBP API allows sources to create a Public Broadcast Announcement. PBP API to parse a Public Broadcast Announcement. public_broadcast_source application starts extended advertising and includes a Public Broadcast Announcement. The advertised broadcast audio stream quality will cycle between high and standard quality. public_broadcast_sink application scans for broadcast sources and synchronizes to the first found source which defines a Public Broadcast Announcement including a High Quality Public Broadcast Audio Stream configuration. Add bsim tests for Public Broadcast Profile APIs. Add shell implementation for Public Broadcast Profile APIs. Signed-off-by: Daniela Andreea Dumitrache <danielaandreea.dumitrache@nxp.com>
This commit is contained in:
parent
afc319e3fa
commit
3bfb2e3ab2
36 changed files with 2436 additions and 3 deletions
88
subsys/bluetooth/audio/shell/pbp.c
Normal file
88
subsys/bluetooth/audio/shell/pbp.c
Normal file
|
@ -0,0 +1,88 @@
|
|||
/** @file
|
||||
* @brief Bluetooth Public Broadcast Profile shell
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2023 NXP
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <zephyr/kernel.h>
|
||||
#include <zephyr/shell/shell.h>
|
||||
#include <zephyr/sys/util.h>
|
||||
#include <zephyr/bluetooth/audio/pbp.h>
|
||||
|
||||
#include "shell/bt.h"
|
||||
|
||||
#define PBS_DEMO 'P', 'B', 'P'
|
||||
|
||||
const uint8_t pba_metadata[] = {
|
||||
BT_AUDIO_CODEC_DATA(BT_AUDIO_METADATA_TYPE_PROGRAM_INFO, PBS_DEMO)
|
||||
};
|
||||
|
||||
/* Buffer to hold the Public Broadcast Announcement */
|
||||
NET_BUF_SIMPLE_DEFINE_STATIC(pbp_ad_buf, BT_PBP_MIN_PBA_SIZE + ARRAY_SIZE(pba_metadata));
|
||||
|
||||
enum bt_pbp_announcement_feature pbp_features;
|
||||
extern const struct shell *ctx_shell;
|
||||
|
||||
static int cmd_pbp_set_features(const struct shell *sh, size_t argc, char **argv)
|
||||
{
|
||||
int err = 0;
|
||||
enum bt_pbp_announcement_feature features;
|
||||
|
||||
features = shell_strtoul(argv[1], 16, &err);
|
||||
if (err != 0) {
|
||||
shell_error(sh, "Could not parse received features: %d", err);
|
||||
|
||||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
pbp_features = features;
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
size_t pbp_ad_data_add(struct bt_data data[], size_t data_size)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = bt_pbp_get_announcement(pba_metadata,
|
||||
ARRAY_SIZE(pba_metadata),
|
||||
pbp_features,
|
||||
&pbp_ad_buf);
|
||||
|
||||
if (err != 0) {
|
||||
shell_info(ctx_shell, "Create Public Broadcast Announcement");
|
||||
} else {
|
||||
shell_error(ctx_shell, "Failed to create Public Broadcast Announcement: %d", err);
|
||||
}
|
||||
|
||||
__ASSERT(data_size > 0, "No space for Public Broadcast Announcement");
|
||||
data[0].type = BT_DATA_SVC_DATA16;
|
||||
data[0].data_len = pbp_ad_buf.len;
|
||||
data[0].data = pbp_ad_buf.data;
|
||||
|
||||
return 1U;
|
||||
}
|
||||
|
||||
static int cmd_pbp(const struct shell *sh, size_t argc, char **argv)
|
||||
{
|
||||
if (argc > 1) {
|
||||
shell_error(sh, "%s unknown parameter: %s", argv[0], argv[1]);
|
||||
} else {
|
||||
shell_error(sh, "%s missing subcomand", argv[0]);
|
||||
}
|
||||
|
||||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
SHELL_STATIC_SUBCMD_SET_CREATE(pbp_cmds,
|
||||
SHELL_CMD_ARG(set_features, NULL,
|
||||
"Set the Public Broadcast Announcement features",
|
||||
cmd_pbp_set_features, 2, 0),
|
||||
SHELL_SUBCMD_SET_END
|
||||
);
|
||||
|
||||
SHELL_CMD_ARG_REGISTER(pbp, &pbp_cmds, "Bluetooth pbp shell commands", cmd_pbp, 1, 1);
|
Loading…
Add table
Add a link
Reference in a new issue