LCOV - code coverage report
Current view: top level - zephyr/bluetooth/audio - pbp.h Coverage Total Hit
Test: new.info Lines: 100.0 % 5 5
Test Date: 2025-09-05 20:47:19

            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              : #include <stddef.h>
      30              : #include <stdint.h>
      31              : 
      32              : #include <zephyr/bluetooth/audio/audio.h>
      33              : #include <zephyr/bluetooth/bluetooth.h>
      34              : #include <zephyr/bluetooth/uuid.h>
      35              : #include <zephyr/net_buf.h>
      36              : #include <zephyr/sys/util.h>
      37              : #include <zephyr/sys/util_macro.h>
      38              : 
      39              : #ifdef __cplusplus
      40              : extern "C" {
      41              : #endif
      42              : 
      43              : /**
      44              :  * @brief Minimum size of the Public Broadcast Announcement
      45              :  *
      46              :  * It contains the Public Broadcast Announcement UUID (2), the Public Broadcast Announcement
      47              :  * features (1) and the metadata length (1)
      48              :  */
      49            1 : #define BT_PBP_MIN_PBA_SIZE             (BT_UUID_SIZE_16 + 1 + 1)
      50              : 
      51              : /** Public Broadcast Announcement features */
      52            1 : enum bt_pbp_announcement_feature {
      53              :         /** Broadcast Streams encryption status */
      54              :         BT_PBP_ANNOUNCEMENT_FEATURE_ENCRYPTION = BIT(0),
      55              :         /** Standard Quality Public Broadcast Audio configuration */
      56              :         BT_PBP_ANNOUNCEMENT_FEATURE_STANDARD_QUALITY = BIT(1),
      57              :         /** High Quality Public Broadcast Audio configuration */
      58              :         BT_PBP_ANNOUNCEMENT_FEATURE_HIGH_QUALITY = BIT(2),
      59              : };
      60              : 
      61              : /**
      62              :  * @brief Creates a Public Broadcast Announcement based on the information received
      63              :  * in the features parameter.
      64              :  *
      65              :  * @param meta          Metadata to be included in the advertising data
      66              :  * @param meta_len      Size of the metadata fields to be included in the advertising data
      67              :  * @param features      Public Broadcast Announcement features
      68              :  * @param pba_data_buf  Pointer to store the PBA advertising data. Buffer size needs to be
      69              :  *                      meta_len + @ref BT_PBP_MIN_PBA_SIZE.
      70              :  *
      71              :  * @return 0 on success or an appropriate error code.
      72              :  */
      73            1 : int bt_pbp_get_announcement(const uint8_t meta[], size_t meta_len,
      74              :                             enum bt_pbp_announcement_feature features,
      75              :                             struct net_buf_simple *pba_data_buf);
      76              : 
      77              : /**
      78              :  * @brief Parses the received advertising data corresponding to a Public Broadcast
      79              :  * Announcement. Returns the advertised Public Broadcast Announcement features and metadata.
      80              :  *
      81              :  * @param[in]  data     Advertising data to be checked
      82              :  * @param[out] features Pointer to public broadcast source features to store the parsed features in
      83              :  * @param[out] meta     Pointer to the metadata present in the advertising data
      84              :  *
      85              :  * @return parsed metadata length on success.
      86              :  * @retval -EINVAL if @p data, @p features or @p meta are NULL.
      87              :  * @retval -ENOENT if @p data is not of type @ref BT_DATA_SVC_DATA16 or if the UUID in the service
      88              :  * data is not @ref BT_UUID_PBA.
      89              :  * @retval -EMSGSIZE if @p data is not large enough to contain a PBP announcement.
      90              :  * @retval -EBADMSG if the @p data contains invalid data.
      91              :  */
      92            1 : int bt_pbp_parse_announcement(struct bt_data *data, enum bt_pbp_announcement_feature *features,
      93              :                               uint8_t **meta);
      94              : 
      95              : #ifdef __cplusplus
      96              : }
      97              : #endif
      98              : 
      99              : /**
     100              :  * @}
     101              :  */
     102              : 
     103              : #endif /* ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_PBP_ */
        

Generated by: LCOV version 2.0-1