Line data Source code
1 1 : /** 2 : * @file 3 : * @brief Public Broadcast Profile (PBP) APIs. 4 : */ 5 : /* 6 : * Copyright 2023 NXP 7 : * Copyright (c) 2024 Nordic Semiconductor ASA 8 : * 9 : * SPDX-License-Identifier: Apache-2.0 10 : */ 11 : 12 : #ifndef ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_PBP_ 13 : #define ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_PBP_ 14 : 15 : /** 16 : * @brief Public Broadcast Profile (PBP) 17 : * 18 : * @defgroup bt_pbp Public Broadcast Profile (PBP) 19 : * 20 : * @since 3.5 21 : * @version 0.8.0 22 : * 23 : * @ingroup bluetooth 24 : * @{ 25 : * 26 : * The Public Broadcast Profile (PBP) is used for public broadcasts by providing additional 27 : * information in the advertising data. 28 : */ 29 : 30 : #include <zephyr/bluetooth/audio/audio.h> 31 : #include <zephyr/bluetooth/bluetooth.h> 32 : #include <zephyr/bluetooth/uuid.h> 33 : #include <zephyr/net_buf.h> 34 : #include <zephyr/sys/util.h> 35 : #include <zephyr/sys/util_macro.h> 36 : 37 : #ifdef __cplusplus 38 : extern "C" { 39 : #endif 40 : 41 : /** 42 : * @brief Minimum size of the Public Broadcast Announcement 43 : * 44 : * It contains the Public Broadcast Announcement UUID (2), the Public Broadcast Announcement 45 : * features (1) and the metadata length (1) 46 : */ 47 1 : #define BT_PBP_MIN_PBA_SIZE (BT_UUID_SIZE_16 + 1 + 1) 48 : 49 : /** Public Broadcast Announcement features */ 50 1 : enum bt_pbp_announcement_feature { 51 : /** Broadcast Streams encryption status */ 52 : BT_PBP_ANNOUNCEMENT_FEATURE_ENCRYPTION = BIT(0), 53 : /** Standard Quality Public Broadcast Audio configuration */ 54 : BT_PBP_ANNOUNCEMENT_FEATURE_STANDARD_QUALITY = BIT(1), 55 : /** High Quality Public Broadcast Audio configuration */ 56 : BT_PBP_ANNOUNCEMENT_FEATURE_HIGH_QUALITY = BIT(2), 57 : }; 58 : 59 : /** 60 : * @brief Creates a Public Broadcast Announcement based on the information received 61 : * in the features parameter. 62 : * 63 : * @param meta Metadata to be included in the advertising data 64 : * @param meta_len Size of the metadata fields to be included in the advertising data 65 : * @param features Public Broadcast Announcement features 66 : * @param pba_data_buf Pointer to store the PBA advertising data. Buffer size needs to be 67 : * meta_len + @ref BT_PBP_MIN_PBA_SIZE. 68 : * 69 : * @return 0 on success or an appropriate error code. 70 : */ 71 1 : int bt_pbp_get_announcement(const uint8_t meta[], size_t meta_len, 72 : enum bt_pbp_announcement_feature features, 73 : struct net_buf_simple *pba_data_buf); 74 : 75 : /** 76 : * @brief Parses the received advertising data corresponding to a Public Broadcast 77 : * Announcement. Returns the advertised Public Broadcast Announcement features and metadata. 78 : * 79 : * @param[in] data Advertising data to be checked 80 : * @param[out] features Pointer to public broadcast source features to store the parsed features in 81 : * @param[out] meta Pointer to the metadata present in the advertising data 82 : * 83 : * @return parsed metadata length on success. 84 : * @retval -EINVAL if @p data, @p features or @p meta are NULL. 85 : * @retval -ENOENT if @p data is not of type @ref BT_DATA_SVC_DATA16 or if the UUID in the service 86 : * data is not @ref BT_UUID_PBA. 87 : * @retval -EMSGSIZE if @p data is not large enough to contain a PBP announcement. 88 : * @retval -EBADMSG if the @p data contains invalid data. 89 : */ 90 1 : int bt_pbp_parse_announcement(struct bt_data *data, enum bt_pbp_announcement_feature *features, 91 : uint8_t **meta); 92 : 93 : #ifdef __cplusplus 94 : } 95 : #endif 96 : 97 : /** 98 : * @} 99 : */ 100 : 101 : #endif /* ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_PBP_ */