text stringlengths 9 39.2M | dir stringlengths 25 226 | lang stringclasses 163 values | created_date timestamp[s] | updated_date timestamp[s] | repo_name stringclasses 751 values | repo_full_name stringclasses 752 values | star int64 1.01k 183k | len_tokens int64 1 18.5M |
|---|---|---|---|---|---|---|---|---|
```objective-c
*/
#include <stddef.h>
#include <stdint.h>
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_EAD_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_EAD_H_
#include <zephyr/kernel.h>
#include <zephyr/bluetooth/bluetooth.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Encrypted Advertising Data (EAD)
* @defgroup bt_ead Encrypted Advertising Data (EAD)
* @ingroup bluetooth
* @{
*/
/** Randomizer size in bytes */
#define BT_EAD_RANDOMIZER_SIZE 5
/** Key size in bytes */
#define BT_EAD_KEY_SIZE 16
/** Initialisation Vector size in bytes */
#define BT_EAD_IV_SIZE 8
/** MIC size in bytes */
#define BT_EAD_MIC_SIZE 4
/** Get the size (in bytes) of the encrypted advertising data for a given
* payload size in bytes.
*/
#define BT_EAD_ENCRYPTED_PAYLOAD_SIZE(payload_size) \
((payload_size) + BT_EAD_RANDOMIZER_SIZE + BT_EAD_MIC_SIZE)
/** Get the size (in bytes) of the decrypted payload for a given payload size in
* bytes.
*/
#define BT_EAD_DECRYPTED_PAYLOAD_SIZE(encrypted_payload_size) \
((encrypted_payload_size) - (BT_EAD_RANDOMIZER_SIZE + BT_EAD_MIC_SIZE))
/**
* @brief Encrypt and authenticate the given advertising data.
*
* The resulting data in @p encrypted_payload will look like that:
* - Randomizer is added in the @ref BT_EAD_RANDOMIZER_SIZE first bytes;
* - Encrypted payload is added ( @p payload_size bytes);
* - MIC is added in the last @ref BT_EAD_MIC_SIZE bytes.
*
* @attention The function must be called each time the RPA is updated or the
* data are modified.
*
* @note The term `advertising structure` is used to describe the advertising
* data with the advertising type and the length of those two.
*
* @param[in] session_key Key of @ref BT_EAD_KEY_SIZE bytes used for the
* encryption.
* @param[in] iv Initialisation Vector used to generate the nonce. It must be
* changed each time the Session Key changes.
* @param[in] payload Advertising Data to encrypt. Can be multiple advertising
* structures that are concatenated.
* @param[in] payload_size Size of the Advertising Data to encrypt.
* @param[out] encrypted_payload Encrypted Ad Data including the Randomizer and
* the MIC. Size must be at least @ref BT_EAD_RANDOMIZER_SIZE + @p
* payload_size + @ref BT_EAD_MIC_SIZE. Use @ref
* BT_EAD_ENCRYPTED_PAYLOAD_SIZE to get the right size.
*
* @retval 0 Data have been correctly encrypted and authenticated.
* @retval -EIO Error occurred during the encryption or the authentication.
* @retval -EINVAL One of the argument is a NULL pointer.
* @retval -ECANCELED Error occurred during the random number generation.
*/
int bt_ead_encrypt(const uint8_t session_key[BT_EAD_KEY_SIZE], const uint8_t iv[BT_EAD_IV_SIZE],
const uint8_t *payload, size_t payload_size, uint8_t *encrypted_payload);
/**
* @brief Decrypt and authenticate the given encrypted advertising data.
*
* @note The term `advertising structure` is used to describe the advertising
* data with the advertising type and the length of those two.
*
* @param[in] session_key Key of 16 bytes used for the encryption.
* @param[in] iv Initialisation Vector used to generate the `nonce`.
* @param[in] encrypted_payload Encrypted Advertising Data received. This
* should only contain the advertising data from the received
* advertising structure, not the length nor the type.
* @param[in] encrypted_payload_size Size of the received advertising data in
* bytes. Should be equal to the length field of the received
* advertising structure, minus the size of the type (1 byte).
* @param[out] payload Decrypted advertising payload. Use @ref
* BT_EAD_DECRYPTED_PAYLOAD_SIZE to get the right size.
*
* @retval 0 Data have been correctly decrypted and authenticated.
* @retval -EIO Error occurred during the decryption or the authentication.
* @retval -EINVAL One of the argument is a NULL pointer or @p
* encrypted_payload_size is less than @ref
* BT_EAD_RANDOMIZER_SIZE + @ref BT_EAD_MIC_SIZE.
*/
int bt_ead_decrypt(const uint8_t session_key[BT_EAD_KEY_SIZE], const uint8_t iv[BT_EAD_IV_SIZE],
const uint8_t *encrypted_payload, size_t encrypted_payload_size,
uint8_t *payload);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_EAD_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/ead.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 1,054 |
```objective-c
/** @file
* @brief Bluetooth data buffer API
*/
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_BUF_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_BUF_H_
/**
* @brief Data buffers
* @defgroup bt_buf Data buffers
* @ingroup bluetooth
* @{
*/
#include <stdint.h>
#include <zephyr/net/buf.h>
#include <zephyr/bluetooth/hci.h>
#include <zephyr/sys/util.h>
#ifdef __cplusplus
extern "C" {
#endif
/** Possible types of buffers passed around the Bluetooth stack */
enum bt_buf_type {
/** HCI command */
BT_BUF_CMD,
/** HCI event */
BT_BUF_EVT,
/** Outgoing ACL data */
BT_BUF_ACL_OUT,
/** Incoming ACL data */
BT_BUF_ACL_IN,
/** Outgoing ISO data */
BT_BUF_ISO_OUT,
/** Incoming ISO data */
BT_BUF_ISO_IN,
/** H:4 data */
BT_BUF_H4,
};
/** @brief This is a base type for bt_buf user data. */
struct bt_buf_data {
uint8_t type;
};
/* Headroom reserved in buffers, primarily for HCI transport encoding purposes */
#define BT_BUF_RESERVE 1
/** Helper to include reserved HCI data in buffer calculations */
#define BT_BUF_SIZE(size) (BT_BUF_RESERVE + (size))
/** Helper to calculate needed buffer size for HCI ACL packets */
#define BT_BUF_ACL_SIZE(size) BT_BUF_SIZE(BT_HCI_ACL_HDR_SIZE + (size))
/** Helper to calculate needed buffer size for HCI Event packets. */
#define BT_BUF_EVT_SIZE(size) BT_BUF_SIZE(BT_HCI_EVT_HDR_SIZE + (size))
/** Helper to calculate needed buffer size for HCI Command packets. */
#define BT_BUF_CMD_SIZE(size) BT_BUF_SIZE(BT_HCI_CMD_HDR_SIZE + (size))
/** Helper to calculate needed buffer size for HCI ISO packets. */
#define BT_BUF_ISO_SIZE(size) BT_BUF_SIZE(BT_HCI_ISO_HDR_SIZE + \
BT_HCI_ISO_SDU_TS_HDR_SIZE + \
(size))
/** Data size needed for HCI ACL RX buffers */
#define BT_BUF_ACL_RX_SIZE BT_BUF_ACL_SIZE(CONFIG_BT_BUF_ACL_RX_SIZE)
/** Data size needed for HCI Event RX buffers */
#define BT_BUF_EVT_RX_SIZE BT_BUF_EVT_SIZE(CONFIG_BT_BUF_EVT_RX_SIZE)
#if defined(CONFIG_BT_ISO)
#define BT_BUF_ISO_RX_SIZE BT_BUF_ISO_SIZE(CONFIG_BT_ISO_RX_MTU)
#define BT_BUF_ISO_RX_COUNT CONFIG_BT_ISO_RX_BUF_COUNT
#else
#define BT_BUF_ISO_RX_SIZE 0
#define BT_BUF_ISO_RX_COUNT 0
#endif /* CONFIG_BT_ISO */
/** Data size needed for HCI ACL, HCI ISO or Event RX buffers */
#define BT_BUF_RX_SIZE (MAX(MAX(BT_BUF_ACL_RX_SIZE, BT_BUF_EVT_RX_SIZE), \
BT_BUF_ISO_RX_SIZE))
/** Buffer count needed for HCI ACL, HCI ISO or Event RX buffers */
#define BT_BUF_RX_COUNT (MAX(MAX(CONFIG_BT_BUF_EVT_RX_COUNT, \
CONFIG_BT_BUF_ACL_RX_COUNT), \
BT_BUF_ISO_RX_COUNT))
/** Data size needed for HCI Command buffers. */
#define BT_BUF_CMD_TX_SIZE BT_BUF_CMD_SIZE(CONFIG_BT_BUF_CMD_TX_SIZE)
/** Allocate a buffer for incoming data
*
* This will set the buffer type so bt_buf_set_type() does not need to
* be explicitly called.
*
* @param type Type of buffer. Only BT_BUF_EVT, BT_BUF_ACL_IN and BT_BUF_ISO_IN
* are allowed.
* @param timeout Non-negative waiting period to obtain a buffer or one of the
* special values K_NO_WAIT and K_FOREVER.
* @return A new buffer.
*/
struct net_buf *bt_buf_get_rx(enum bt_buf_type type, k_timeout_t timeout);
/** Allocate a buffer for outgoing data
*
* This will set the buffer type so bt_buf_set_type() does not need to
* be explicitly called.
*
* @param type Type of buffer. Only BT_BUF_CMD, BT_BUF_ACL_OUT or
* BT_BUF_H4, when operating on H:4 mode, are allowed.
* @param timeout Non-negative waiting period to obtain a buffer or one of the
* special values K_NO_WAIT and K_FOREVER.
* @param data Initial data to append to buffer.
* @param size Initial data size.
* @return A new buffer.
*/
struct net_buf *bt_buf_get_tx(enum bt_buf_type type, k_timeout_t timeout,
const void *data, size_t size);
/** Allocate a buffer for an HCI Event
*
* This will set the buffer type so bt_buf_set_type() does not need to
* be explicitly called.
*
* @param evt HCI event code
* @param discardable Whether the driver considers the event discardable.
* @param timeout Non-negative waiting period to obtain a buffer or one of
* the special values K_NO_WAIT and K_FOREVER.
* @return A new buffer.
*/
struct net_buf *bt_buf_get_evt(uint8_t evt, bool discardable, k_timeout_t timeout);
/** Set the buffer type
*
* @param buf Bluetooth buffer
* @param type The BT_* type to set the buffer to
*/
static inline void bt_buf_set_type(struct net_buf *buf, enum bt_buf_type type)
{
((struct bt_buf_data *)net_buf_user_data(buf))->type = type;
}
/** Get the buffer type
*
* @param buf Bluetooth buffer
*
* @return The BT_* type to of the buffer
*/
static inline enum bt_buf_type bt_buf_get_type(struct net_buf *buf)
{
return (enum bt_buf_type)((struct bt_buf_data *)net_buf_user_data(buf))
->type;
}
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_BUF_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/buf.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 1,252 |
```objective-c
/** @file
* @brief Bluetooth L2CAP handling
*/
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_L2CAP_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_L2CAP_H_
/**
* @brief L2CAP
* @defgroup bt_l2cap L2CAP
* @ingroup bluetooth
* @{
*/
#include <sys/types.h>
#include <zephyr/sys/atomic.h>
#include <zephyr/bluetooth/buf.h>
#include <zephyr/bluetooth/conn.h>
#include <zephyr/bluetooth/hci.h>
#ifdef __cplusplus
extern "C" {
#endif
/** L2CAP PDU header size, used for buffer size calculations */
#define BT_L2CAP_HDR_SIZE 4
/** Maximum Transmission Unit (MTU) for an outgoing L2CAP PDU. */
#define BT_L2CAP_TX_MTU (CONFIG_BT_L2CAP_TX_MTU)
/** Maximum Transmission Unit (MTU) for an incoming L2CAP PDU. */
#define BT_L2CAP_RX_MTU (CONFIG_BT_BUF_ACL_RX_SIZE - BT_L2CAP_HDR_SIZE)
/** @brief Helper to calculate needed buffer size for L2CAP PDUs.
* Useful for creating buffer pools.
*
* @param mtu Needed L2CAP PDU MTU.
*
* @return Needed buffer size to match the requested L2CAP PDU MTU.
*/
#define BT_L2CAP_BUF_SIZE(mtu) BT_BUF_ACL_SIZE(BT_L2CAP_HDR_SIZE + (mtu))
/** L2CAP SDU header size, used for buffer size calculations */
#define BT_L2CAP_SDU_HDR_SIZE 2
/** @brief Maximum Transmission Unit for an unsegmented outgoing L2CAP SDU.
*
* The Maximum Transmission Unit for an outgoing L2CAP SDU when sent without
* segmentation, i.e. a single L2CAP SDU will fit inside a single L2CAP PDU.
*
* The MTU for outgoing L2CAP SDUs with segmentation is defined by the
* size of the application buffer pool.
*/
#define BT_L2CAP_SDU_TX_MTU (BT_L2CAP_TX_MTU - BT_L2CAP_SDU_HDR_SIZE)
/** @brief Maximum Transmission Unit for an unsegmented incoming L2CAP SDU.
*
* The Maximum Transmission Unit for an incoming L2CAP SDU when sent without
* segmentation, i.e. a single L2CAP SDU will fit inside a single L2CAP PDU.
*
* The MTU for incoming L2CAP SDUs with segmentation is defined by the
* size of the application buffer pool. The application will have to define
* an alloc_buf callback for the channel in order to support receiving
* segmented L2CAP SDUs.
*/
#define BT_L2CAP_SDU_RX_MTU (BT_L2CAP_RX_MTU - BT_L2CAP_SDU_HDR_SIZE)
/**
*
* @brief Helper to calculate needed buffer size for L2CAP SDUs.
* Useful for creating buffer pools.
*
* @param mtu Required BT_L2CAP_*_SDU.
*
* @return Needed buffer size to match the requested L2CAP SDU MTU.
*/
#define BT_L2CAP_SDU_BUF_SIZE(mtu) BT_L2CAP_BUF_SIZE(BT_L2CAP_SDU_HDR_SIZE + (mtu))
struct bt_l2cap_chan;
/** @typedef bt_l2cap_chan_destroy_t
* @brief Channel destroy callback
*
* @param chan Channel object.
*/
typedef void (*bt_l2cap_chan_destroy_t)(struct bt_l2cap_chan *chan);
/** @brief Life-span states of L2CAP CoC channel.
*
* Used only by internal APIs dealing with setting channel to proper state
* depending on operational context.
*
* A channel enters the @ref BT_L2CAP_CONNECTING state upon @ref
* bt_l2cap_chan_connect, @ref bt_l2cap_ecred_chan_connect or upon returning
* from @ref bt_l2cap_server.accept.
*
* When a channel leaves the @ref BT_L2CAP_CONNECTING state, @ref
* bt_l2cap_chan_ops.connected is called.
*/
typedef enum bt_l2cap_chan_state {
/** Channel disconnected */
BT_L2CAP_DISCONNECTED,
/** Channel in connecting state */
BT_L2CAP_CONNECTING,
/** Channel in config state, BR/EDR specific */
BT_L2CAP_CONFIG,
/** Channel ready for upper layer traffic on it */
BT_L2CAP_CONNECTED,
/** Channel in disconnecting state */
BT_L2CAP_DISCONNECTING,
} __packed bt_l2cap_chan_state_t;
/** @brief Status of L2CAP channel. */
typedef enum bt_l2cap_chan_status {
/** Channel can send at least one PDU */
BT_L2CAP_STATUS_OUT,
/** @brief Channel shutdown status
*
* Once this status is notified it means the channel will no longer be
* able to transmit or receive data.
*/
BT_L2CAP_STATUS_SHUTDOWN,
/** @brief Channel encryption pending status */
BT_L2CAP_STATUS_ENCRYPT_PENDING,
/* Total number of status - must be at the end of the enum */
BT_L2CAP_NUM_STATUS,
} __packed bt_l2cap_chan_status_t;
/** @brief L2CAP Channel structure. */
struct bt_l2cap_chan {
/** Channel connection reference */
struct bt_conn *conn;
/** Channel operations reference */
const struct bt_l2cap_chan_ops *ops;
sys_snode_t node;
bt_l2cap_chan_destroy_t destroy;
ATOMIC_DEFINE(status, BT_L2CAP_NUM_STATUS);
};
/** @brief LE L2CAP Endpoint structure. */
struct bt_l2cap_le_endpoint {
/** Endpoint Channel Identifier (CID) */
uint16_t cid;
/** Endpoint Maximum Transmission Unit */
uint16_t mtu;
/** Endpoint Maximum PDU payload Size */
uint16_t mps;
/** Endpoint credits */
atomic_t credits;
};
/** @brief LE L2CAP Channel structure. */
struct bt_l2cap_le_chan {
/** Common L2CAP channel reference object */
struct bt_l2cap_chan chan;
/** @brief Channel Receiving Endpoint.
*
* If the application has set an alloc_buf channel callback for the
* channel to support receiving segmented L2CAP SDUs the application
* should initialize the MTU of the Receiving Endpoint. Otherwise the
* MTU of the receiving endpoint will be initialized to
* @ref BT_L2CAP_SDU_RX_MTU by the stack.
*
* This is the source of the MTU, MPS and credit values when sending
* L2CAP_LE_CREDIT_BASED_CONNECTION_REQ/RSP and
* L2CAP_CONFIGURATION_REQ.
*/
struct bt_l2cap_le_endpoint rx;
/** Pending RX MTU on ECFC reconfigure, used internally by stack */
uint16_t pending_rx_mtu;
/** Channel Transmission Endpoint.
*
* This is an image of the remote's rx.
*
* The MTU and MPS is controlled by the remote by
* L2CAP_LE_CREDIT_BASED_CONNECTION_REQ/RSP or L2CAP_CONFIGURATION_REQ.
*/
struct bt_l2cap_le_endpoint tx;
/** Channel Transmission queue (for SDUs) */
struct k_fifo tx_queue;
#if defined(CONFIG_BT_L2CAP_DYNAMIC_CHANNEL)
/** Segment SDU packet from upper layer */
struct net_buf *_sdu;
uint16_t _sdu_len;
#if defined(CONFIG_BT_L2CAP_SEG_RECV)
uint16_t _sdu_len_done;
#endif /* CONFIG_BT_L2CAP_SEG_RECV */
struct k_work rx_work;
struct k_fifo rx_queue;
bt_l2cap_chan_state_t state;
/** Remote PSM to be connected */
uint16_t psm;
/** Helps match request context during CoC */
uint8_t ident;
bt_security_t required_sec_level;
/* Response Timeout eXpired (RTX) timer */
struct k_work_delayable rtx_work;
struct k_work_sync rtx_sync;
#endif
/** @internal To be used with @ref bt_conn.upper_data_ready */
sys_snode_t _pdu_ready;
/** @internal To be used with @ref bt_conn.upper_data_ready */
atomic_t _pdu_ready_lock;
/** @internal Holds the length of the current PDU/segment */
size_t _pdu_remaining;
};
/**
* @brief Helper macro getting container object of type bt_l2cap_le_chan
* address having the same container chan member address as object in question.
*
* @param _ch Address of object of bt_l2cap_chan type
*
* @return Address of in memory bt_l2cap_le_chan object type containing
* the address of in question object.
*/
#define BT_L2CAP_LE_CHAN(_ch) CONTAINER_OF(_ch, struct bt_l2cap_le_chan, chan)
/** @brief BREDR L2CAP Endpoint structure. */
struct bt_l2cap_br_endpoint {
/** Endpoint Channel Identifier (CID) */
uint16_t cid;
/** Endpoint Maximum Transmission Unit */
uint16_t mtu;
};
/** @brief BREDR L2CAP Channel structure. */
struct bt_l2cap_br_chan {
/** Common L2CAP channel reference object */
struct bt_l2cap_chan chan;
/** Channel Receiving Endpoint */
struct bt_l2cap_br_endpoint rx;
/** Channel Transmission Endpoint */
struct bt_l2cap_br_endpoint tx;
/* For internal use only */
atomic_t flags[1];
bt_l2cap_chan_state_t state;
/** Remote PSM to be connected */
uint16_t psm;
/** Helps match request context during CoC */
uint8_t ident;
bt_security_t required_sec_level;
/* Response Timeout eXpired (RTX) timer */
struct k_work_delayable rtx_work;
struct k_work_sync rtx_sync;
/** @internal To be used with @ref bt_conn.upper_data_ready */
sys_snode_t _pdu_ready;
/** @internal To be used with @ref bt_conn.upper_data_ready */
atomic_t _pdu_ready_lock;
/** @internal Queue of net bufs not yet sent to lower layer */
struct k_fifo _pdu_tx_queue;
};
/** @brief L2CAP Channel operations structure.
*
* The object has to stay valid and constant for the lifetime of the channel.
*/
struct bt_l2cap_chan_ops {
/** @brief Channel connected callback
*
* If this callback is provided it will be called whenever the
* connection completes.
*
* @param chan The channel that has been connected
*/
void (*connected)(struct bt_l2cap_chan *chan);
/** @brief Channel disconnected callback
*
* If this callback is provided it will be called whenever the
* channel is disconnected, including when a connection gets
* rejected.
*
* @param chan The channel that has been Disconnected
*/
void (*disconnected)(struct bt_l2cap_chan *chan);
/** @brief Channel encrypt_change callback
*
* If this callback is provided it will be called whenever the
* security level changed (indirectly link encryption done) or
* authentication procedure fails. In both cases security initiator
* and responder got the final status (HCI status) passed by
* related to encryption and authentication events from local host's
* controller.
*
* @param chan The channel which has made encryption status changed.
* @param status HCI status of performed security procedure caused
* by channel security requirements. The value is populated
* by HCI layer and set to 0 when success and to non-zero (reference to
* HCI Error Codes) when security/authentication failed.
*/
void (*encrypt_change)(struct bt_l2cap_chan *chan, uint8_t hci_status);
/** @brief Channel alloc_seg callback
*
* If this callback is provided the channel will use it to allocate
* buffers to store segments. This avoids wasting big SDU buffers with
* potentially much smaller PDUs. If this callback is supplied, it must
* return a valid buffer.
*
* @param chan The channel requesting a buffer.
*
* @return Allocated buffer.
*/
struct net_buf *(*alloc_seg)(struct bt_l2cap_chan *chan);
/** @brief Channel alloc_buf callback
*
* If this callback is provided the channel will use it to allocate
* buffers to store incoming data. Channels that requires segmentation
* must set this callback.
* If the application has not set a callback the L2CAP SDU MTU will be
* truncated to @ref BT_L2CAP_SDU_RX_MTU.
*
* @param chan The channel requesting a buffer.
*
* @return Allocated buffer.
*/
struct net_buf *(*alloc_buf)(struct bt_l2cap_chan *chan);
/** @brief Channel recv callback
*
* @param chan The channel receiving data.
* @param buf Buffer containing incoming data.
*
* @note This callback is mandatory, unless
* @kconfig{CONFIG_BT_L2CAP_SEG_RECV} is enabled and seg_recv is
* supplied.
*
* @return 0 in case of success or negative value in case of error.
* @return -EINPROGRESS in case where user has to confirm once the data
* has been processed by calling
* @ref bt_l2cap_chan_recv_complete passing back
* the buffer received with its original user_data
* which contains the number of segments/credits
* used by the packet.
*/
int (*recv)(struct bt_l2cap_chan *chan, struct net_buf *buf);
/** @brief Channel sent callback
*
* This callback will be called once the controller marks the SDU
* as completed. When the controller does so is implementation
* dependent. It could be after the SDU is enqueued for transmission,
* or after it is sent on air.
*
* @param chan The channel which has sent data.
*/
void (*sent)(struct bt_l2cap_chan *chan);
/** @brief Channel status callback
*
* If this callback is provided it will be called whenever the
* channel status changes.
*
* @param chan The channel which status changed
* @param status The channel status
*/
void (*status)(struct bt_l2cap_chan *chan, atomic_t *status);
/* @brief Channel released callback
*
* If this callback is set it is called when the stack has release all
* references to the channel object.
*/
void (*released)(struct bt_l2cap_chan *chan);
/** @brief Channel reconfigured callback
*
* If this callback is provided it will be called whenever peer or
* local device requested reconfiguration. Application may check
* updated MTU and MPS values by inspecting chan->le endpoints.
*
* @param chan The channel which was reconfigured
*/
void (*reconfigured)(struct bt_l2cap_chan *chan);
#if defined(CONFIG_BT_L2CAP_SEG_RECV)
/** @brief Handle L2CAP segments directly
*
* This is an alternative to @ref bt_l2cap_chan_ops.recv. They cannot
* be used together.
*
* This is called immediately for each received segment.
*
* Unlike with @ref bt_l2cap_chan_ops.recv, flow control is explicit.
* Each time this handler is invoked, the remote has permanently used
* up one credit. Use @ref bt_l2cap_chan_give_credits to give credits.
*
* The start of an SDU is marked by `seg_offset == 0`. The end of an
* SDU is marked by `seg_offset + seg->len == sdu_len`.
*
* The stack guarantees that:
* - The sender had the credit.
* - The SDU length does not exceed MTU.
* - The segment length does not exceed MPS.
*
* Additionally, the L2CAP protocol is such that:
* - Segments come in order.
* - SDUs cannot be interleaved or aborted halfway.
*
* @note With this alternative API, the application is responsible for
* setting the RX MTU and MPS. The MPS must not exceed @ref BT_L2CAP_RX_MTU.
*
* @param chan The receiving channel.
* @param sdu_len Byte length of the SDU this segment is part of.
* @param seg_offset The byte offset of this segment in the SDU.
* @param seg The segment payload.
*/
void (*seg_recv)(struct bt_l2cap_chan *chan, size_t sdu_len,
off_t seg_offset, struct net_buf_simple *seg);
#endif /* CONFIG_BT_L2CAP_SEG_RECV */
};
/**
* @brief Headroom needed for outgoing L2CAP PDUs.
*/
#define BT_L2CAP_CHAN_SEND_RESERVE (BT_L2CAP_BUF_SIZE(0))
/**
* @brief Headroom needed for outgoing L2CAP SDUs.
*/
#define BT_L2CAP_SDU_CHAN_SEND_RESERVE (BT_L2CAP_SDU_BUF_SIZE(0))
/** @brief L2CAP Server structure. */
struct bt_l2cap_server {
/** @brief Server PSM.
*
* Possible values:
* 0 A dynamic value will be auto-allocated when
* bt_l2cap_server_register() is called.
*
* 0x0001-0x007f Standard, Bluetooth SIG-assigned fixed values.
*
* 0x0080-0x00ff Dynamically allocated. May be pre-set by the
* application before server registration (not
* recommended however), or auto-allocated by the
* stack if the app gave 0 as the value.
*/
uint16_t psm;
/** Required minimum security level */
bt_security_t sec_level;
/** @brief Server accept callback
*
* This callback is called whenever a new incoming connection requires
* authorization.
*
* @warning It is the responsibility of this callback to zero out the
* parent of the chan object.
*
* @param conn The connection that is requesting authorization
* @param server Pointer to the server structure this callback relates to
* @param chan Pointer to received the allocated channel
*
* @return 0 in case of success or negative value in case of error.
* @return -ENOMEM if no available space for new channel.
* @return -EACCES if application did not authorize the connection.
* @return -EPERM if encryption key size is too short.
*/
int (*accept)(struct bt_conn *conn, struct bt_l2cap_server *server,
struct bt_l2cap_chan **chan);
sys_snode_t node;
};
/** @brief Register L2CAP server.
*
* Register L2CAP server for a PSM, each new connection is authorized using
* the accept() callback which in case of success shall allocate the channel
* structure to be used by the new connection.
*
* For fixed, SIG-assigned PSMs (in the range 0x0001-0x007f) the PSM should
* be assigned to server->psm before calling this API. For dynamic PSMs
* (in the range 0x0080-0x00ff) server->psm may be pre-set to a given value
* (this is however not recommended) or be left as 0, in which case upon
* return a newly allocated value will have been assigned to it. For
* dynamically allocated values the expectation is that it's exposed through
* a GATT service, and that's how L2CAP clients discover how to connect to
* the server.
*
* @param server Server structure.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_l2cap_server_register(struct bt_l2cap_server *server);
/** @brief Register L2CAP server on BR/EDR oriented connection.
*
* Register L2CAP server for a PSM, each new connection is authorized using
* the accept() callback which in case of success shall allocate the channel
* structure to be used by the new connection.
*
* @param server Server structure.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_l2cap_br_server_register(struct bt_l2cap_server *server);
/** @brief Connect Enhanced Credit Based L2CAP channels
*
* Connect up to 5 L2CAP channels by PSM, once the connection is completed
* each channel connected() callback will be called. If the connection is
* rejected disconnected() callback is called instead.
*
* @warning It is the responsibility of the caller to zero out the
* parents of the chan objects.
*
* @param conn Connection object.
* @param chans Array of channel objects.
* @param psm Channel PSM to connect to.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_l2cap_ecred_chan_connect(struct bt_conn *conn,
struct bt_l2cap_chan **chans, uint16_t psm);
/** @brief Reconfigure Enhanced Credit Based L2CAP channels
*
* Reconfigure up to 5 L2CAP channels. Channels must be from the same bt_conn.
* Once reconfiguration is completed each channel reconfigured() callback will
* be called. MTU cannot be decreased on any of provided channels.
*
* @param chans Array of channel objects. Null-terminated. Elements after the
* first 5 are silently ignored.
* @param mtu Channel MTU to reconfigure to.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_l2cap_ecred_chan_reconfigure(struct bt_l2cap_chan **chans, uint16_t mtu);
/** @brief Connect L2CAP channel
*
* Connect L2CAP channel by PSM, once the connection is completed channel
* connected() callback will be called. If the connection is rejected
* disconnected() callback is called instead.
* Channel object passed (over an address of it) as second parameter shouldn't
* be instantiated in application as standalone. Instead of, application should
* create transport dedicated L2CAP objects, i.e. type of bt_l2cap_le_chan for
* LE and/or type of bt_l2cap_br_chan for BR/EDR. Then pass to this API
* the location (address) of bt_l2cap_chan type object which is a member
* of both transport dedicated objects.
*
* @warning It is the responsibility of the caller to zero out the
* parent of the chan object.
*
* @param conn Connection object.
* @param chan Channel object.
* @param psm Channel PSM to connect to.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_l2cap_chan_connect(struct bt_conn *conn, struct bt_l2cap_chan *chan,
uint16_t psm);
/** @brief Disconnect L2CAP channel
*
* Disconnect L2CAP channel, if the connection is pending it will be
* canceled and as a result the channel disconnected() callback is called.
* Regarding to input parameter, to get details see reference description
* to bt_l2cap_chan_connect() API above.
*
* @param chan Channel object.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_l2cap_chan_disconnect(struct bt_l2cap_chan *chan);
/** @brief Send data to L2CAP channel
*
* Send data from buffer to the channel. If credits are not available, buf will
* be queued and sent as and when credits are received from peer.
* Regarding to first input parameter, to get details see reference description
* to bt_l2cap_chan_connect() API above.
*
* Network buffer fragments (ie `buf->frags`) are not supported.
*
* When sending L2CAP data over an BR/EDR connection the application is sending
* L2CAP PDUs. The application is required to have reserved
* @ref BT_L2CAP_CHAN_SEND_RESERVE bytes in the buffer before sending.
* The application should use the BT_L2CAP_BUF_SIZE() helper to correctly
* size the buffers for the for the outgoing buffer pool.
*
* When sending L2CAP data over an LE connection the application is sending
* L2CAP SDUs. The application shall reserve
* @ref BT_L2CAP_SDU_CHAN_SEND_RESERVE bytes in the buffer before sending.
*
* The application can use the BT_L2CAP_SDU_BUF_SIZE() helper to correctly size
* the buffer to account for the reserved headroom.
*
* When segmenting an L2CAP SDU into L2CAP PDUs the stack will first attempt to
* allocate buffers from the channel's `alloc_seg` callback and will fallback
* on the stack's global buffer pool (sized
* @kconfig{CONFIG_BT_L2CAP_TX_BUF_COUNT}).
*
* @warning The buffer's user_data _will_ be overwritten by this function. Do
* not store anything in it. As soon as a call to this function has been made,
* consider ownership of user_data transferred into the stack.
*
* @note Buffer ownership is transferred to the stack in case of success, in
* case of an error the caller retains the ownership of the buffer.
*
* @return 0 in case of success or negative value in case of error.
* @return -EINVAL if `buf` or `chan` is NULL.
* @return -EINVAL if `chan` is not either BR/EDR or LE credit-based.
* @return -EINVAL if buffer doesn't have enough bytes reserved to fit header.
* @return -EINVAL if buffer's reference counter != 1
* @return -EMSGSIZE if `buf` is larger than `chan`'s MTU.
* @return -ENOTCONN if underlying conn is disconnected.
* @return -ESHUTDOWN if L2CAP channel is disconnected.
* @return -other (from lower layers) if chan is BR/EDR.
*/
int bt_l2cap_chan_send(struct bt_l2cap_chan *chan, struct net_buf *buf);
/** @brief Give credits to the remote
*
* Only available for channels using @ref bt_l2cap_chan_ops.seg_recv.
* @kconfig{CONFIG_BT_L2CAP_SEG_RECV} must be enabled to make this function
* available.
*
* Each credit given allows the peer to send one segment.
*
* This function depends on a valid @p chan object. Make sure to
* default-initialize or memset @p chan when allocating or reusing it for new
* connections.
*
* Adding zero credits is not allowed.
*
* Credits can be given before entering the @ref BT_L2CAP_CONNECTING state.
* Doing so will adjust the 'initial credits' sent in the connection PDU.
*
* Must not be called while the channel is in @ref BT_L2CAP_CONNECTING state.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_l2cap_chan_give_credits(struct bt_l2cap_chan *chan, uint16_t additional_credits);
/** @brief Complete receiving L2CAP channel data
*
* Complete the reception of incoming data. This shall only be called if the
* channel recv callback has returned -EINPROGRESS to process some incoming
* data. The buffer shall contain the original user_data as that is used for
* storing the credits/segments used by the packet.
*
* @param chan Channel object.
* @param buf Buffer containing the data.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_l2cap_chan_recv_complete(struct bt_l2cap_chan *chan,
struct net_buf *buf);
#ifdef __cplusplus
}
#endif
/**
* @}
*/
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_L2CAP_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/l2cap.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 6,295 |
```objective-c
/**
* @file testing.h
* @brief Internal API for Bluetooth testing.
*/
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_TESTING_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_TESTING_H_
#include <stdint.h>
#if defined(CONFIG_BT_MESH)
#include <zephyr/bluetooth/mesh.h>
#endif /* CONFIG_BT_MESH */
/**
* @brief Bluetooth testing
* @defgroup bt_test_cb Bluetooth testing callbacks
* @ingroup bluetooth
* @{
*/
#ifdef __cplusplus
extern "C" {
#endif
/** @brief Bluetooth Testing callbacks structure.
*
* Callback structure to be used for Bluetooth testing purposes.
* Allows access to Bluetooth stack internals, not exposed by public API.
*/
struct bt_test_cb {
#if defined(CONFIG_BT_MESH)
void (*mesh_net_recv)(uint8_t ttl, uint8_t ctl, uint16_t src, uint16_t dst,
const void *payload, size_t payload_len);
void (*mesh_model_recv)(uint16_t src, uint16_t dst, const void *payload,
size_t payload_len);
void (*mesh_model_bound)(uint16_t addr, const struct bt_mesh_model *model,
uint16_t key_idx);
void (*mesh_model_unbound)(uint16_t addr, const struct bt_mesh_model *model,
uint16_t key_idx);
void (*mesh_prov_invalid_bearer)(uint8_t opcode);
void (*mesh_trans_incomp_timer_exp)(void);
#endif /* CONFIG_BT_MESH */
sys_snode_t node;
};
/** Register callbacks for Bluetooth testing purposes
*
* @param cb bt_test_cb callback structure
*
* @retval 0 Success.
* @retval -EEXIST if @p cb was already registered.
*/
int bt_test_cb_register(struct bt_test_cb *cb);
/** Unregister callbacks for Bluetooth testing purposes
*
* @param cb bt_test_cb callback structure
*/
void bt_test_cb_unregister(struct bt_test_cb *cb);
/** Send Friend Subscription List Add message.
*
* Used by Low Power node to send the group address for which messages are to
* be stored by Friend node.
*
* @param group Group address
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_test_mesh_lpn_group_add(uint16_t group);
/** Send Friend Subscription List Remove message.
*
* Used by Low Power node to remove the group addresses from Friend node
* subscription list. Messages sent to those addresses will not be stored
* by Friend node.
*
* @param groups Group addresses
* @param groups_count Group addresses count
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_test_mesh_lpn_group_remove(uint16_t *groups, size_t groups_count);
/** Clear replay protection list cache.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_test_mesh_rpl_clear(void);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_TESTING_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/testing.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 640 |
```objective-c
/** @file
* @brief Bluetooth subsystem core APIs.
*/
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_BLUETOOTH_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_BLUETOOTH_H_
/**
* @brief Bluetooth APIs
* @defgroup bluetooth Bluetooth APIs
* @ingroup connectivity
* @{
*/
#include <stdbool.h>
#include <string.h>
#include <zephyr/sys/util.h>
#include <zephyr/net/buf.h>
#include <zephyr/bluetooth/gap.h>
#include <zephyr/bluetooth/addr.h>
#include <zephyr/bluetooth/crypto.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Generic Access Profile (GAP)
* @defgroup bt_gap Generic Access Profile (GAP)
* @since 1.0
* @version 1.0.0
* @ingroup bluetooth
* @{
*/
/**
* Convenience macro for specifying the default identity. This helps
* make the code more readable, especially when only one identity is
* supported.
*/
#define BT_ID_DEFAULT 0
/** Opaque type representing an advertiser. */
struct bt_le_ext_adv;
/** Opaque type representing an periodic advertising sync. */
struct bt_le_per_adv_sync;
/* Don't require everyone to include conn.h */
struct bt_conn;
/* Don't require everyone to include iso.h */
struct bt_iso_biginfo;
/* Don't require everyone to include direction.h */
struct bt_df_per_adv_sync_iq_samples_report;
struct bt_le_ext_adv_sent_info {
/** The number of advertising events completed. */
uint8_t num_sent;
};
struct bt_le_ext_adv_connected_info {
/** Connection object of the new connection */
struct bt_conn *conn;
};
struct bt_le_ext_adv_scanned_info {
/** Active scanner LE address and type */
bt_addr_le_t *addr;
};
struct bt_le_per_adv_data_request {
/** The first subevent data can be set for */
uint8_t start;
/** The number of subevents data can be set for */
uint8_t count;
};
struct bt_le_per_adv_response_info {
/** The subevent the response was received in */
uint8_t subevent;
/** @brief Status of the subevent indication.
*
* 0 if subevent indication was transmitted.
* 1 if subevent indication was not transmitted.
* All other values RFU.
*/
uint8_t tx_status;
/** The TX power of the response in dBm */
int8_t tx_power;
/** The RSSI of the response in dBm */
int8_t rssi;
/** The Constant Tone Extension (CTE) of the advertisement (@ref bt_df_cte_type) */
uint8_t cte_type;
/** The slot the response was received in */
uint8_t response_slot;
};
struct bt_le_ext_adv_cb {
/**
* @brief The advertising set has finished sending adv data.
*
* This callback notifies the application that the advertising set has
* finished sending advertising data.
* The advertising set can either have been stopped by a timeout or
* because the specified number of advertising events has been reached.
*
* @param adv The advertising set object.
* @param info Information about the sent event.
*/
void (*sent)(struct bt_le_ext_adv *adv,
struct bt_le_ext_adv_sent_info *info);
/**
* @brief The advertising set has accepted a new connection.
*
* This callback notifies the application that the advertising set has
* accepted a new connection.
*
* @param adv The advertising set object.
* @param info Information about the connected event.
*/
void (*connected)(struct bt_le_ext_adv *adv,
struct bt_le_ext_adv_connected_info *info);
/**
* @brief The advertising set has sent scan response data.
*
* This callback notifies the application that the advertising set has
* has received a Scan Request packet, and has sent a Scan Response
* packet.
*
* @param adv The advertising set object.
* @param addr Information about the scanned event.
*/
void (*scanned)(struct bt_le_ext_adv *adv,
struct bt_le_ext_adv_scanned_info *info);
#if defined(CONFIG_BT_PRIVACY)
/**
* @brief The RPA validity of the advertising set has expired.
*
* This callback notifies the application that the RPA validity of
* the advertising set has expired. The user can use this callback
* to synchronize the advertising payload update with the RPA rotation.
*
* If rpa sharing is enabled and rpa expired cb of any adv-sets belonging
* to same adv id returns false, then adv-sets will continue with old rpa
* through out the rpa rotations.
*
* @param adv The advertising set object.
*
* @return true to rotate the current RPA, or false to use it for the
* next rotation period.
*/
bool (*rpa_expired)(struct bt_le_ext_adv *adv);
#endif /* defined(CONFIG_BT_PRIVACY) */
#if defined(CONFIG_BT_PER_ADV_RSP)
/**
* @brief The Controller indicates it is ready to transmit one or more subevent.
*
* This callback notifies the application that the controller has requested
* data for upcoming subevents.
*
* @param adv The advertising set object.
* @param request Information about the upcoming subevents.
*/
void (*pawr_data_request)(struct bt_le_ext_adv *adv,
const struct bt_le_per_adv_data_request *request);
/**
* @brief The Controller indicates that one or more synced devices have
* responded to a periodic advertising subevent indication.
*
* @param adv The advertising set object.
* @param info Information about the responses received.
* @param buf The received data. NULL if the controller reported
* that it did not receive any response.
*/
void (*pawr_response)(struct bt_le_ext_adv *adv, struct bt_le_per_adv_response_info *info,
struct net_buf_simple *buf);
#endif /* defined(CONFIG_BT_PER_ADV_RSP) */
};
/**
* @typedef bt_ready_cb_t
* @brief Callback for notifying that Bluetooth has been enabled.
*
* @param err zero on success or (negative) error code otherwise.
*/
typedef void (*bt_ready_cb_t)(int err);
/**
* @brief Enable Bluetooth
*
* Enable Bluetooth. Must be the called before any calls that
* require communication with the local Bluetooth hardware.
*
* When @kconfig{CONFIG_BT_SETTINGS} is enabled, the application must load the
* Bluetooth settings after this API call successfully completes before
* Bluetooth APIs can be used. Loading the settings before calling this function
* is insufficient. Bluetooth settings can be loaded with settings_load() or
* settings_load_subtree() with argument "bt". The latter selectively loads only
* Bluetooth settings and is recommended if settings_load() has been called
* earlier.
*
* @param cb Callback to notify completion or NULL to perform the
* enabling synchronously. The callback is called from the system workqueue.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_enable(bt_ready_cb_t cb);
/**
* @brief Disable Bluetooth
*
* Disable Bluetooth. Can't be called before bt_enable has completed.
*
* This API will clear all configured identities and keys that are not persistently
* stored with @kconfig{CONFIG_BT_SETTINGS}. These can be restored
* with settings_load() before reenabling the stack.
*
* This API does _not_ clear previously registered callbacks
* like @ref bt_le_scan_cb_register and @ref bt_conn_cb_register.
* That is, the application shall not re-register them when
* the Bluetooth subsystem is re-enabled later.
*
* Close and release HCI resources. Result is architecture dependent.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_disable(void);
/**
* @brief Check if Bluetooth is ready
*
* @return true when Bluetooth is ready, false otherwise
*/
bool bt_is_ready(void);
/**
* @brief Set Bluetooth Device Name
*
* Set Bluetooth GAP Device Name.
*
* When advertising with device name in the advertising data the name should
* be updated by calling @ref bt_le_adv_update_data or
* @ref bt_le_ext_adv_set_data.
*
* @note Requires @kconfig{CONFIG_BT_DEVICE_NAME_DYNAMIC}.
*
* @sa @kconfig{CONFIG_BT_DEVICE_NAME_MAX}.
*
* @param name New name
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_set_name(const char *name);
/**
* @brief Get Bluetooth Device Name
*
* Get Bluetooth GAP Device Name.
*
* @return Bluetooth Device Name
*/
const char *bt_get_name(void);
/**
* @brief Get local Bluetooth appearance
*
* Bluetooth Appearance is a description of the external appearance of a device
* in terms of an Appearance Value.
*
* @see path_to_url
*
* @returns Appearance Value of local Bluetooth host.
*/
uint16_t bt_get_appearance(void);
/**
* @brief Set local Bluetooth appearance
*
* Automatically preserves the new appearance across reboots if
* @kconfig{CONFIG_BT_SETTINGS} is enabled.
*
* This symbol is linkable if @kconfig{CONFIG_BT_DEVICE_APPEARANCE_DYNAMIC} is
* enabled.
*
* @param new_appearance Appearance Value
*
* @retval 0 Success.
* @retval other Persistent storage failed. Appearance was not updated.
*/
int bt_set_appearance(uint16_t new_appearance);
/**
* @brief Get the currently configured identities.
*
* Returns an array of the currently configured identity addresses. To
* make sure all available identities can be retrieved, the number of
* elements in the @a addrs array should be CONFIG_BT_ID_MAX. The identity
* identifier that some APIs expect (such as advertising parameters) is
* simply the index of the identity in the @a addrs array.
*
* If @a addrs is passed as NULL, then returned @a count contains the
* count of all available identities that can be retrieved with a
* subsequent call to this function with non-NULL @a addrs parameter.
*
* @note Deleted identities may show up as @ref BT_ADDR_LE_ANY in the returned
* array.
*
* @param addrs Array where to store the configured identities.
* @param count Should be initialized to the array size. Once the function
* returns it will contain the number of returned identities.
*/
void bt_id_get(bt_addr_le_t *addrs, size_t *count);
/**
* @brief Create a new identity.
*
* Create a new identity using the given address and IRK. This function can be
* called before calling bt_enable(). However, the new identity will only be
* stored persistently in flash when this API is used after bt_enable(). The
* reason is that the persistent settings are loaded after bt_enable() and would
* therefore cause potential conflicts with the stack blindly overwriting what's
* stored in flash. The identity will also not be written to flash in case a
* pre-defined address is provided, since in such a situation the app clearly
* has some place it got the address from and will be able to repeat the
* procedure on every power cycle, i.e. it would be redundant to also store the
* information in flash.
*
* Generating random static address or random IRK is not supported when calling
* this function before bt_enable().
*
* If the application wants to have the stack randomly generate identities
* and store them in flash for later recovery, the way to do it would be
* to first initialize the stack (using bt_enable), then call settings_load(),
* and after that check with bt_id_get() how many identities were recovered.
* If an insufficient amount of identities were recovered the app may then
* call bt_id_create() to create new ones.
*
* If supported by the HCI driver (indicated by setting
* @kconfig{CONFIG_BT_HCI_SET_PUBLIC_ADDR}), the first call to this function can be
* used to set the controller's public identity address. This call must happen
* before calling bt_enable(). Subsequent calls always add/generate random
* static addresses.
*
* @param addr Address to use for the new identity. If NULL or initialized
* to BT_ADDR_LE_ANY the stack will generate a new random
* static address for the identity and copy it to the given
* parameter upon return from this function (in case the
* parameter was non-NULL).
* @param irk Identity Resolving Key (16 bytes) to be used with this
* identity. If set to all zeroes or NULL, the stack will
* generate a random IRK for the identity and copy it back
* to the parameter upon return from this function (in case
* the parameter was non-NULL). If privacy
* @kconfig{CONFIG_BT_PRIVACY} is not enabled this parameter must
* be NULL.
*
* @return Identity identifier (>= 0) in case of success, or a negative
* error code on failure.
*/
int bt_id_create(bt_addr_le_t *addr, uint8_t *irk);
/**
* @brief Reset/reclaim an identity for reuse.
*
* The semantics of the @a addr and @a irk parameters of this function
* are the same as with bt_id_create(). The difference is the first
* @a id parameter that needs to be an existing identity (if it doesn't
* exist this function will return an error). When given an existing
* identity this function will disconnect any connections created using it,
* remove any pairing keys or other data associated with it, and then create
* a new identity in the same slot, based on the @a addr and @a irk
* parameters.
*
* @note the default identity (BT_ID_DEFAULT) cannot be reset, i.e. this
* API will return an error if asked to do that.
*
* @param id Existing identity identifier.
* @param addr Address to use for the new identity. If NULL or initialized
* to BT_ADDR_LE_ANY the stack will generate a new static
* random address for the identity and copy it to the given
* parameter upon return from this function (in case the
* parameter was non-NULL).
* @param irk Identity Resolving Key (16 bytes) to be used with this
* identity. If set to all zeroes or NULL, the stack will
* generate a random IRK for the identity and copy it back
* to the parameter upon return from this function (in case
* the parameter was non-NULL). If privacy
* @kconfig{CONFIG_BT_PRIVACY} is not enabled this parameter must
* be NULL.
*
* @return Identity identifier (>= 0) in case of success, or a negative
* error code on failure.
*/
int bt_id_reset(uint8_t id, bt_addr_le_t *addr, uint8_t *irk);
/**
* @brief Delete an identity.
*
* When given a valid identity this function will disconnect any connections
* created using it, remove any pairing keys or other data associated with
* it, and then flag is as deleted, so that it can not be used for any
* operations. To take back into use the slot the identity was occupying the
* bt_id_reset() API needs to be used.
*
* @note the default identity (BT_ID_DEFAULT) cannot be deleted, i.e. this
* API will return an error if asked to do that.
*
* @param id Existing identity identifier.
*
* @return 0 in case of success, or a negative error code on failure.
*/
int bt_id_delete(uint8_t id);
/**
* @brief Bluetooth data serialized size.
*
* Get the size of a serialized @ref bt_data given its data length.
*
* Size of 'AD Structure'->'Length' field, equal to 1.
* Size of 'AD Structure'->'Data'->'AD Type' field, equal to 1.
* Size of 'AD Structure'->'Data'->'AD Data' field, equal to data_len.
*
* See Core Specification Version 5.4 Vol. 3 Part C, 11, Figure 11.1.
*/
#define BT_DATA_SERIALIZED_SIZE(data_len) ((data_len) + 2)
/**
* @brief Bluetooth data.
*
* Description of different data types that can be encoded into
* advertising data. Used to form arrays that are passed to the
* bt_le_adv_start() function.
*/
struct bt_data {
uint8_t type;
uint8_t data_len;
const uint8_t *data;
};
/**
* @brief Helper to declare elements of bt_data arrays
*
* This macro is mainly for creating an array of struct bt_data
* elements which is then passed to e.g. @ref bt_le_adv_start().
*
* @param _type Type of advertising data field
* @param _data Pointer to the data field payload
* @param _data_len Number of bytes behind the _data pointer
*/
#define BT_DATA(_type, _data, _data_len) \
{ \
.type = (_type), \
.data_len = (_data_len), \
.data = (const uint8_t *)(_data), \
}
/**
* @brief Helper to declare elements of bt_data arrays
*
* This macro is mainly for creating an array of struct bt_data
* elements which is then passed to e.g. @ref bt_le_adv_start().
*
* @param _type Type of advertising data field
* @param _bytes Variable number of single-byte parameters
*/
#define BT_DATA_BYTES(_type, _bytes...) \
BT_DATA(_type, ((uint8_t []) { _bytes }), \
sizeof((uint8_t []) { _bytes }))
/**
* @brief Get the total size (in bytes) of a given set of @ref bt_data
* structures.
*
* @param[in] data Array of @ref bt_data structures.
* @param[in] data_count Number of @ref bt_data structures in @p data.
*
* @return Size of the concatenated data, built from the @ref bt_data structure
* set.
*/
size_t bt_data_get_len(const struct bt_data data[], size_t data_count);
/**
* @brief Serialize a @ref bt_data struct into an advertising structure (a flat
* byte array).
*
* The data are formatted according to the Bluetooth Core Specification v. 5.4,
* vol. 3, part C, 11.
*
* @param[in] input Single @ref bt_data structure to read from.
* @param[out] output Buffer large enough to store the advertising structure in
* @p input. The size of it must be at least the size of the
* `input->data_len + 2` (for the type and the length).
*
* @return Number of bytes written in @p output.
*/
size_t bt_data_serialize(const struct bt_data *input, uint8_t *output);
/** Advertising options */
enum {
/** Convenience value when no options are specified. */
BT_LE_ADV_OPT_NONE = 0,
/**
* @brief Advertise as connectable.
*
* Advertise as connectable. If not connectable then the type of
* advertising is determined by providing scan response data.
* The advertiser address is determined by the type of advertising
* and/or enabling privacy @kconfig{CONFIG_BT_PRIVACY}.
*/
BT_LE_ADV_OPT_CONNECTABLE = BIT(0),
/**
* @brief Advertise one time.
*
* Don't try to resume connectable advertising after a connection.
* This option is only meaningful when used together with
* BT_LE_ADV_OPT_CONNECTABLE. If set the advertising will be stopped
* when bt_le_adv_stop() is called or when an incoming (peripheral)
* connection happens. If this option is not set the stack will
* take care of keeping advertising enabled even as connections
* occur.
* If Advertising directed or the advertiser was started with
* @ref bt_le_ext_adv_start then this behavior is the default behavior
* and this flag has no effect.
*/
BT_LE_ADV_OPT_ONE_TIME = BIT(1),
/**
* @brief Advertise using identity address.
*
* Advertise using the identity address as the advertiser address.
* @warning This will compromise the privacy of the device, so care
* must be taken when using this option.
* @note The address used for advertising will not be the same as
* returned by @ref bt_le_oob_get_local, instead @ref bt_id_get
* should be used to get the LE address.
*/
BT_LE_ADV_OPT_USE_IDENTITY = BIT(2),
/**
* @deprecated This option will be removed in the near future, see
* path_to_url
*
* @brief Advertise using GAP device name.
*
* Include the GAP device name automatically when advertising.
* By default the GAP device name is put at the end of the scan
* response data.
* When advertising using @ref BT_LE_ADV_OPT_EXT_ADV and not
* @ref BT_LE_ADV_OPT_SCANNABLE then it will be put at the end of the
* advertising data.
* If the GAP device name does not fit into advertising data it will be
* converted to a shortened name if possible.
* @ref BT_LE_ADV_OPT_FORCE_NAME_IN_AD can be used to force the device
* name to appear in the advertising data of an advert with scan
* response data.
*
* The application can set the device name itself by including the
* following in the advertising data.
* @code
* BT_DATA(BT_DATA_NAME_COMPLETE, name, sizeof(name) - 1)
* @endcode
*/
BT_LE_ADV_OPT_USE_NAME = BIT(3),
/**
* @brief Low duty cycle directed advertising.
*
* Use low duty directed advertising mode, otherwise high duty mode
* will be used.
*/
BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY = BIT(4),
/**
* @brief Directed advertising to privacy-enabled peer.
*
* Enable use of Resolvable Private Address (RPA) as the target address
* in directed advertisements.
* This is required if the remote device is privacy-enabled and
* supports address resolution of the target address in directed
* advertisement.
* It is the responsibility of the application to check that the remote
* device supports address resolution of directed advertisements by
* reading its Central Address Resolution characteristic.
*/
BT_LE_ADV_OPT_DIR_ADDR_RPA = BIT(5),
/** Use filter accept list to filter devices that can request scan
* response data.
*/
BT_LE_ADV_OPT_FILTER_SCAN_REQ = BIT(6),
/** Use filter accept list to filter devices that can connect. */
BT_LE_ADV_OPT_FILTER_CONN = BIT(7),
/** Notify the application when a scan response data has been sent to an
* active scanner.
*/
BT_LE_ADV_OPT_NOTIFY_SCAN_REQ = BIT(8),
/**
* @brief Support scan response data.
*
* When used together with @ref BT_LE_ADV_OPT_EXT_ADV then this option
* cannot be used together with the @ref BT_LE_ADV_OPT_CONNECTABLE
* option.
* When used together with @ref BT_LE_ADV_OPT_EXT_ADV then scan
* response data must be set.
*/
BT_LE_ADV_OPT_SCANNABLE = BIT(9),
/**
* @brief Advertise with extended advertising.
*
* This options enables extended advertising in the advertising set.
* In extended advertising the advertising set will send a small header
* packet on the three primary advertising channels. This small header
* points to the advertising data packet that will be sent on one of
* the 37 secondary advertising channels.
* The advertiser will send primary advertising on LE 1M PHY, and
* secondary advertising on LE 2M PHY.
* Connections will be established on LE 2M PHY.
*
* Without this option the advertiser will send advertising data on the
* three primary advertising channels.
*
* @note Enabling this option requires extended advertising support in
* the peer devices scanning for advertisement packets.
*
* @note This cannot be used with bt_le_adv_start().
*/
BT_LE_ADV_OPT_EXT_ADV = BIT(10),
/**
* @brief Disable use of LE 2M PHY on the secondary advertising
* channel.
*
* Disabling the use of LE 2M PHY could be necessary if scanners don't
* support the LE 2M PHY.
* The advertiser will send primary advertising on LE 1M PHY, and
* secondary advertising on LE 1M PHY.
* Connections will be established on LE 1M PHY.
*
* @note Cannot be set if BT_LE_ADV_OPT_CODED is set.
*
* @note Requires @ref BT_LE_ADV_OPT_EXT_ADV.
*/
BT_LE_ADV_OPT_NO_2M = BIT(11),
/**
* @brief Advertise on the LE Coded PHY (Long Range).
*
* The advertiser will send both primary and secondary advertising
* on the LE Coded PHY. This gives the advertiser increased range with
* the trade-off of lower data rate and higher power consumption.
* Connections will be established on LE Coded PHY.
*
* @note Requires @ref BT_LE_ADV_OPT_EXT_ADV
*/
BT_LE_ADV_OPT_CODED = BIT(12),
/**
* @brief Advertise without a device address (identity or RPA).
*
* @note Requires @ref BT_LE_ADV_OPT_EXT_ADV
*/
BT_LE_ADV_OPT_ANONYMOUS = BIT(13),
/**
* @brief Advertise with transmit power.
*
* @note Requires @ref BT_LE_ADV_OPT_EXT_ADV
*/
BT_LE_ADV_OPT_USE_TX_POWER = BIT(14),
/** Disable advertising on channel index 37. */
BT_LE_ADV_OPT_DISABLE_CHAN_37 = BIT(15),
/** Disable advertising on channel index 38. */
BT_LE_ADV_OPT_DISABLE_CHAN_38 = BIT(16),
/** Disable advertising on channel index 39. */
BT_LE_ADV_OPT_DISABLE_CHAN_39 = BIT(17),
/**
* @deprecated This option will be removed in the near future, see
* path_to_url
*
* @brief Put GAP device name into advert data
*
* Will place the GAP device name into the advertising data rather than
* the scan response data.
*
* @note Requires @ref BT_LE_ADV_OPT_USE_NAME
*/
BT_LE_ADV_OPT_FORCE_NAME_IN_AD = BIT(18),
/**
* @brief Advertise using a Non-Resolvable Private Address.
*
* A new NRPA is set when updating the advertising parameters.
*
* This is an advanced feature; most users will want to enable
* @kconfig{CONFIG_BT_EXT_ADV} instead.
*
* @note Not implemented when @kconfig{CONFIG_BT_PRIVACY}.
*
* @note Mutually exclusive with BT_LE_ADV_OPT_USE_IDENTITY.
*/
BT_LE_ADV_OPT_USE_NRPA = BIT(19),
};
/** LE Advertising Parameters. */
struct bt_le_adv_param {
/**
* @brief Local identity.
*
* @note When extended advertising @kconfig{CONFIG_BT_EXT_ADV} is not
* enabled or not supported by the controller it is not possible
* to scan and advertise simultaneously using two different
* random addresses.
*/
uint8_t id;
/**
* @brief Advertising Set Identifier, valid range 0x00 - 0x0f.
*
* @note Requires @ref BT_LE_ADV_OPT_EXT_ADV
**/
uint8_t sid;
/**
* @brief Secondary channel maximum skip count.
*
* Maximum advertising events the advertiser can skip before it must
* send advertising data on the secondary advertising channel.
*
* @note Requires @ref BT_LE_ADV_OPT_EXT_ADV
*/
uint8_t secondary_max_skip;
/** Bit-field of advertising options */
uint32_t options;
/** Minimum Advertising Interval (N * 0.625 milliseconds)
* Minimum Advertising Interval shall be less than or equal to the
* Maximum Advertising Interval. The Minimum Advertising Interval and
* Maximum Advertising Interval should not be the same value (as stated
* in Bluetooth Core Spec 5.2, section 7.8.5)
* Range: 0x0020 to 0x4000
*/
uint32_t interval_min;
/** Maximum Advertising Interval (N * 0.625 milliseconds)
* Minimum Advertising Interval shall be less than or equal to the
* Maximum Advertising Interval. The Minimum Advertising Interval and
* Maximum Advertising Interval should not be the same value (as stated
* in Bluetooth Core Spec 5.2, section 7.8.5)
* Range: 0x0020 to 0x4000
*/
uint32_t interval_max;
/**
* @brief Directed advertising to peer
*
* When this parameter is set the advertiser will send directed
* advertising to the remote device.
*
* The advertising type will either be high duty cycle, or low duty
* cycle if the BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY option is enabled.
* When using @ref BT_LE_ADV_OPT_EXT_ADV then only low duty cycle is
* allowed.
*
* In case of connectable high duty cycle if the connection could not
* be established within the timeout the connected() callback will be
* called with the status set to @ref BT_HCI_ERR_ADV_TIMEOUT.
*/
const bt_addr_le_t *peer;
};
/** Periodic Advertising options */
enum {
/** Convenience value when no options are specified. */
BT_LE_PER_ADV_OPT_NONE = 0,
/**
* @brief Advertise with transmit power.
*
* @note Requires @ref BT_LE_ADV_OPT_EXT_ADV
*/
BT_LE_PER_ADV_OPT_USE_TX_POWER = BIT(1),
/**
* @brief Advertise with included AdvDataInfo (ADI).
*
* @note Requires @ref BT_LE_ADV_OPT_EXT_ADV
*/
BT_LE_PER_ADV_OPT_INCLUDE_ADI = BIT(2),
};
struct bt_le_per_adv_param {
/**
* @brief Minimum Periodic Advertising Interval (N * 1.25 ms)
*
* Shall be greater or equal to BT_GAP_PER_ADV_MIN_INTERVAL and
* less or equal to interval_max.
*/
uint16_t interval_min;
/**
* @brief Maximum Periodic Advertising Interval (N * 1.25 ms)
*
* Shall be less or equal to BT_GAP_PER_ADV_MAX_INTERVAL and
* greater or equal to interval_min.
*/
uint16_t interval_max;
/** Bit-field of periodic advertising options */
uint32_t options;
#if defined(CONFIG_BT_PER_ADV_RSP)
/**
* @brief Number of subevents
*
* If zero, the periodic advertiser will be a broadcaster, without responses.
*/
uint8_t num_subevents;
/**
* @brief Interval between subevents (N * 1.25 ms)
*
* Shall be between 7.5ms and 318.75 ms.
*/
uint8_t subevent_interval;
/**
* @brief Time between the advertising packet in a subevent and the
* first response slot (N * 1.25 ms)
*
*/
uint8_t response_slot_delay;
/**
* @brief Time between response slots (N * 0.125 ms)
*
* Shall be between 0.25 and 31.875 ms.
*/
uint8_t response_slot_spacing;
/**
* @brief Number of subevent response slots
*
* If zero, response_slot_delay and response_slot_spacing are ignored.
*/
uint8_t num_response_slots;
#endif /* CONFIG_BT_PER_ADV_RSP */
};
/**
* @brief Initialize advertising parameters
*
* @param _options Advertising Options
* @param _int_min Minimum advertising interval
* @param _int_max Maximum advertising interval
* @param _peer Peer address, set to NULL for undirected advertising or
* address of peer for directed advertising.
*/
#define BT_LE_ADV_PARAM_INIT(_options, _int_min, _int_max, _peer) \
{ \
.id = BT_ID_DEFAULT, \
.sid = 0, \
.secondary_max_skip = 0, \
.options = (_options), \
.interval_min = (_int_min), \
.interval_max = (_int_max), \
.peer = (_peer), \
}
/**
* @brief Helper to declare advertising parameters inline
*
* @param _options Advertising Options
* @param _int_min Minimum advertising interval
* @param _int_max Maximum advertising interval
* @param _peer Peer address, set to NULL for undirected advertising or
* address of peer for directed advertising.
*/
#define BT_LE_ADV_PARAM(_options, _int_min, _int_max, _peer) \
((const struct bt_le_adv_param[]) { \
BT_LE_ADV_PARAM_INIT(_options, _int_min, _int_max, _peer) \
})
#define BT_LE_ADV_CONN_DIR(_peer) BT_LE_ADV_PARAM(BT_LE_ADV_OPT_CONNECTABLE | \
BT_LE_ADV_OPT_ONE_TIME, 0, 0,\
_peer)
#define BT_LE_ADV_CONN BT_LE_ADV_PARAM(BT_LE_ADV_OPT_CONNECTABLE, \
BT_GAP_ADV_FAST_INT_MIN_2, \
BT_GAP_ADV_FAST_INT_MAX_2, NULL)
/** This is the recommended default for connectable advertisers.
*/
#define BT_LE_ADV_CONN_ONE_TIME \
BT_LE_ADV_PARAM(BT_LE_ADV_OPT_CONNECTABLE | BT_LE_ADV_OPT_ONE_TIME, \
BT_GAP_ADV_FAST_INT_MIN_2, BT_GAP_ADV_FAST_INT_MAX_2, NULL)
/**
* @deprecated This macro will be removed in the near future, see
* path_to_url
*/
#define BT_LE_ADV_CONN_NAME BT_LE_ADV_PARAM(BT_LE_ADV_OPT_CONNECTABLE | \
BT_LE_ADV_OPT_USE_NAME, \
BT_GAP_ADV_FAST_INT_MIN_2, \
BT_GAP_ADV_FAST_INT_MAX_2, NULL) \
__DEPRECATED_MACRO
/**
* @deprecated This macro will be removed in the near future, see
* path_to_url
*/
#define BT_LE_ADV_CONN_NAME_AD BT_LE_ADV_PARAM(BT_LE_ADV_OPT_CONNECTABLE | \
BT_LE_ADV_OPT_USE_NAME | \
BT_LE_ADV_OPT_FORCE_NAME_IN_AD, \
BT_GAP_ADV_FAST_INT_MIN_2, \
BT_GAP_ADV_FAST_INT_MAX_2, NULL) \
__DEPRECATED_MACRO
#define BT_LE_ADV_CONN_DIR_LOW_DUTY(_peer) \
BT_LE_ADV_PARAM(BT_LE_ADV_OPT_CONNECTABLE | BT_LE_ADV_OPT_ONE_TIME | \
BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY, \
BT_GAP_ADV_FAST_INT_MIN_2, BT_GAP_ADV_FAST_INT_MAX_2, \
_peer)
/** Non-connectable advertising with private address */
#define BT_LE_ADV_NCONN BT_LE_ADV_PARAM(0, BT_GAP_ADV_FAST_INT_MIN_2, \
BT_GAP_ADV_FAST_INT_MAX_2, NULL)
/**
* @deprecated This macro will be removed in the near future, see
* path_to_url
*
* Non-connectable advertising with @ref BT_LE_ADV_OPT_USE_NAME
*/
#define BT_LE_ADV_NCONN_NAME BT_LE_ADV_PARAM(BT_LE_ADV_OPT_USE_NAME, \
BT_GAP_ADV_FAST_INT_MIN_2, \
BT_GAP_ADV_FAST_INT_MAX_2, NULL) \
__DEPRECATED_MACRO
/** Non-connectable advertising with @ref BT_LE_ADV_OPT_USE_IDENTITY */
#define BT_LE_ADV_NCONN_IDENTITY BT_LE_ADV_PARAM(BT_LE_ADV_OPT_USE_IDENTITY, \
BT_GAP_ADV_FAST_INT_MIN_2, \
BT_GAP_ADV_FAST_INT_MAX_2, \
NULL)
/** Connectable extended advertising */
#define BT_LE_EXT_ADV_CONN BT_LE_ADV_PARAM(BT_LE_ADV_OPT_EXT_ADV | \
BT_LE_ADV_OPT_CONNECTABLE, \
BT_GAP_ADV_FAST_INT_MIN_2, \
BT_GAP_ADV_FAST_INT_MAX_2, \
NULL)
/**
* @deprecated This macro will be removed in the near future, see
* path_to_url
*
* Connectable extended advertising with @ref BT_LE_ADV_OPT_USE_NAME
*/
#define BT_LE_EXT_ADV_CONN_NAME BT_LE_ADV_PARAM(BT_LE_ADV_OPT_EXT_ADV | \
BT_LE_ADV_OPT_CONNECTABLE | \
BT_LE_ADV_OPT_USE_NAME, \
BT_GAP_ADV_FAST_INT_MIN_2, \
BT_GAP_ADV_FAST_INT_MAX_2, \
NULL) \
__DEPRECATED_MACRO
/** Scannable extended advertising */
#define BT_LE_EXT_ADV_SCAN BT_LE_ADV_PARAM(BT_LE_ADV_OPT_EXT_ADV | \
BT_LE_ADV_OPT_SCANNABLE, \
BT_GAP_ADV_FAST_INT_MIN_2, \
BT_GAP_ADV_FAST_INT_MAX_2, \
NULL)
/**
* @deprecated This macro will be removed in the near future, see
* path_to_url
*
* Scannable extended advertising with @ref BT_LE_ADV_OPT_USE_NAME
*/
#define BT_LE_EXT_ADV_SCAN_NAME BT_LE_ADV_PARAM(BT_LE_ADV_OPT_EXT_ADV | \
BT_LE_ADV_OPT_SCANNABLE | \
BT_LE_ADV_OPT_USE_NAME, \
BT_GAP_ADV_FAST_INT_MIN_2, \
BT_GAP_ADV_FAST_INT_MAX_2, \
NULL) \
__DEPRECATED_MACRO
/** Non-connectable extended advertising with private address */
#define BT_LE_EXT_ADV_NCONN BT_LE_ADV_PARAM(BT_LE_ADV_OPT_EXT_ADV, \
BT_GAP_ADV_FAST_INT_MIN_2, \
BT_GAP_ADV_FAST_INT_MAX_2, NULL)
/**
* @deprecated This macro will be removed in the near future, see
* path_to_url
*
* Non-connectable extended advertising with @ref BT_LE_ADV_OPT_USE_NAME
*/
#define BT_LE_EXT_ADV_NCONN_NAME BT_LE_ADV_PARAM(BT_LE_ADV_OPT_EXT_ADV | \
BT_LE_ADV_OPT_USE_NAME, \
BT_GAP_ADV_FAST_INT_MIN_2, \
BT_GAP_ADV_FAST_INT_MAX_2, \
NULL) \
__DEPRECATED_MACRO
/** Non-connectable extended advertising with @ref BT_LE_ADV_OPT_USE_IDENTITY */
#define BT_LE_EXT_ADV_NCONN_IDENTITY \
BT_LE_ADV_PARAM(BT_LE_ADV_OPT_EXT_ADV | \
BT_LE_ADV_OPT_USE_IDENTITY, \
BT_GAP_ADV_FAST_INT_MIN_2, \
BT_GAP_ADV_FAST_INT_MAX_2, NULL)
/** Non-connectable extended advertising on coded PHY with private address */
#define BT_LE_EXT_ADV_CODED_NCONN BT_LE_ADV_PARAM(BT_LE_ADV_OPT_EXT_ADV | \
BT_LE_ADV_OPT_CODED, \
BT_GAP_ADV_FAST_INT_MIN_2, \
BT_GAP_ADV_FAST_INT_MAX_2, \
NULL)
/**
* @deprecated This macro will be removed in the near future, see
* path_to_url
*
* Non-connectable extended advertising on coded PHY with
* @ref BT_LE_ADV_OPT_USE_NAME
*/
#define BT_LE_EXT_ADV_CODED_NCONN_NAME \
BT_LE_ADV_PARAM(BT_LE_ADV_OPT_EXT_ADV | BT_LE_ADV_OPT_CODED | \
BT_LE_ADV_OPT_USE_NAME, \
BT_GAP_ADV_FAST_INT_MIN_2, \
BT_GAP_ADV_FAST_INT_MAX_2, NULL) \
__DEPRECATED_MACRO
/** Non-connectable extended advertising on coded PHY with
* @ref BT_LE_ADV_OPT_USE_IDENTITY
*/
#define BT_LE_EXT_ADV_CODED_NCONN_IDENTITY \
BT_LE_ADV_PARAM(BT_LE_ADV_OPT_EXT_ADV | BT_LE_ADV_OPT_CODED | \
BT_LE_ADV_OPT_USE_IDENTITY, \
BT_GAP_ADV_FAST_INT_MIN_2, \
BT_GAP_ADV_FAST_INT_MAX_2, NULL)
/**
* Helper to initialize extended advertising start parameters inline
*
* @param _timeout Advertiser timeout
* @param _n_evts Number of advertising events
*/
#define BT_LE_EXT_ADV_START_PARAM_INIT(_timeout, _n_evts) \
{ \
.timeout = (_timeout), \
.num_events = (_n_evts), \
}
/**
* Helper to declare extended advertising start parameters inline
*
* @param _timeout Advertiser timeout
* @param _n_evts Number of advertising events
*/
#define BT_LE_EXT_ADV_START_PARAM(_timeout, _n_evts) \
((const struct bt_le_ext_adv_start_param[]) { \
BT_LE_EXT_ADV_START_PARAM_INIT((_timeout), (_n_evts)) \
})
#define BT_LE_EXT_ADV_START_DEFAULT BT_LE_EXT_ADV_START_PARAM(0, 0)
/**
* Helper to declare periodic advertising parameters inline
*
* @param _int_min Minimum periodic advertising interval
* @param _int_max Maximum periodic advertising interval
* @param _options Periodic advertising properties bitfield.
*/
#define BT_LE_PER_ADV_PARAM_INIT(_int_min, _int_max, _options) \
{ \
.interval_min = (_int_min), \
.interval_max = (_int_max), \
.options = (_options), \
}
/**
* Helper to declare periodic advertising parameters inline
*
* @param _int_min Minimum periodic advertising interval
* @param _int_max Maximum periodic advertising interval
* @param _options Periodic advertising properties bitfield.
*/
#define BT_LE_PER_ADV_PARAM(_int_min, _int_max, _options) \
((struct bt_le_per_adv_param[]) { \
BT_LE_PER_ADV_PARAM_INIT(_int_min, _int_max, _options) \
})
#define BT_LE_PER_ADV_DEFAULT BT_LE_PER_ADV_PARAM(BT_GAP_PER_ADV_SLOW_INT_MIN, \
BT_GAP_PER_ADV_SLOW_INT_MAX, \
BT_LE_PER_ADV_OPT_NONE)
/**
* @brief Start advertising
*
* Set advertisement data, scan response data, advertisement parameters
* and start advertising.
*
* When the advertisement parameter peer address has been set the advertising
* will be directed to the peer. In this case advertisement data and scan
* response data parameters are ignored. If the mode is high duty cycle
* the timeout will be @ref BT_GAP_ADV_HIGH_DUTY_CYCLE_MAX_TIMEOUT.
*
* This function cannot be used with @ref BT_LE_ADV_OPT_EXT_ADV in the @p param.options.
* For extended advertising, the bt_le_ext_adv_* functions must be used.
*
* @param param Advertising parameters.
* @param ad Data to be used in advertisement packets.
* @param ad_len Number of elements in ad
* @param sd Data to be used in scan response packets.
* @param sd_len Number of elements in sd
*
* @return Zero on success or (negative) error code otherwise.
* @return -ENOMEM No free connection objects available for connectable
* advertiser.
* @return -ECONNREFUSED When connectable advertising is requested and there
* is already maximum number of connections established
* in the controller.
* This error code is only guaranteed when using Zephyr
* controller, for other controllers code returned in
* this case may be -EIO.
*/
int bt_le_adv_start(const struct bt_le_adv_param *param,
const struct bt_data *ad, size_t ad_len,
const struct bt_data *sd, size_t sd_len);
/**
* @brief Update advertising
*
* Update advertisement and scan response data.
*
* @param ad Data to be used in advertisement packets.
* @param ad_len Number of elements in ad
* @param sd Data to be used in scan response packets.
* @param sd_len Number of elements in sd
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_le_adv_update_data(const struct bt_data *ad, size_t ad_len,
const struct bt_data *sd, size_t sd_len);
/**
* @brief Stop advertising
*
* Stops ongoing advertising.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_le_adv_stop(void);
/**
* @brief Create advertising set.
*
* Create a new advertising set and set advertising parameters.
* Advertising parameters can be updated with @ref bt_le_ext_adv_update_param.
*
* @param[in] param Advertising parameters.
* @param[in] cb Callback struct to notify about advertiser activity. Can be
* NULL. Must point to valid memory during the lifetime of the
* advertising set.
* @param[out] adv Valid advertising set object on success.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_le_ext_adv_create(const struct bt_le_adv_param *param,
const struct bt_le_ext_adv_cb *cb,
struct bt_le_ext_adv **adv);
struct bt_le_ext_adv_start_param {
/**
* @brief Advertiser timeout (N * 10 ms).
*
* Application will be notified by the advertiser sent callback.
* Set to zero for no timeout.
*
* When using high duty cycle directed connectable advertising then
* this parameters must be set to a non-zero value less than or equal
* to the maximum of @ref BT_GAP_ADV_HIGH_DUTY_CYCLE_MAX_TIMEOUT.
*
* If privacy @kconfig{CONFIG_BT_PRIVACY} is enabled then the timeout
* must be less than @kconfig{CONFIG_BT_RPA_TIMEOUT}.
*/
uint16_t timeout;
/**
* @brief Number of advertising events.
*
* Application will be notified by the advertiser sent callback.
* Set to zero for no limit.
*/
uint8_t num_events;
};
/**
* @brief Start advertising with the given advertising set
*
* If the advertiser is limited by either the timeout or number of advertising
* events the application will be notified by the advertiser sent callback once
* the limit is reached.
* If the advertiser is limited by both the timeout and the number of
* advertising events then the limit that is reached first will stop the
* advertiser.
*
* @param adv Advertising set object.
* @param param Advertise start parameters.
*/
int bt_le_ext_adv_start(struct bt_le_ext_adv *adv,
const struct bt_le_ext_adv_start_param *param);
/**
* @brief Stop advertising with the given advertising set
*
* Stop advertising with a specific advertising set. When using this function
* the advertising sent callback will not be called.
*
* @param adv Advertising set object.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_le_ext_adv_stop(struct bt_le_ext_adv *adv);
/**
* @brief Set an advertising set's advertising or scan response data.
*
* Set advertisement data or scan response data. If the advertising set is
* currently advertising then the advertising data will be updated in
* subsequent advertising events.
*
* When both @ref BT_LE_ADV_OPT_EXT_ADV and @ref BT_LE_ADV_OPT_SCANNABLE are
* enabled then advertising data is ignored.
* When @ref BT_LE_ADV_OPT_SCANNABLE is not enabled then scan response data is
* ignored.
*
* If the advertising set has been configured to send advertising data on the
* primary advertising channels then the maximum data length is
* @ref BT_GAP_ADV_MAX_ADV_DATA_LEN bytes.
* If the advertising set has been configured for extended advertising,
* then the maximum data length is defined by the controller with the maximum
* possible of @ref BT_GAP_ADV_MAX_EXT_ADV_DATA_LEN bytes.
*
* @note Not all scanners support extended data length advertising data.
*
* @note When updating the advertising data while advertising the advertising
* data and scan response data length must be smaller or equal to what
* can be fit in a single advertising packet. Otherwise the
* advertiser must be stopped.
*
* @param adv Advertising set object.
* @param ad Data to be used in advertisement packets.
* @param ad_len Number of elements in ad
* @param sd Data to be used in scan response packets.
* @param sd_len Number of elements in sd
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_le_ext_adv_set_data(struct bt_le_ext_adv *adv,
const struct bt_data *ad, size_t ad_len,
const struct bt_data *sd, size_t sd_len);
/**
* @brief Update advertising parameters.
*
* Update the advertising parameters. The function will return an error if the
* advertiser set is currently advertising. Stop the advertising set before
* calling this function.
*
* @note When changing the option @ref BT_LE_ADV_OPT_USE_NAME then
* @ref bt_le_ext_adv_set_data needs to be called in order to update the
* advertising data and scan response data.
*
* @param adv Advertising set object.
* @param param Advertising parameters.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_le_ext_adv_update_param(struct bt_le_ext_adv *adv,
const struct bt_le_adv_param *param);
/**
* @brief Delete advertising set.
*
* Delete advertising set. This will free up the advertising set and make it
* possible to create a new advertising set.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_le_ext_adv_delete(struct bt_le_ext_adv *adv);
/**
* @brief Get array index of an advertising set.
*
* This function is used to map bt_adv to index of an array of
* advertising sets. The array has CONFIG_BT_EXT_ADV_MAX_ADV_SET elements.
*
* @param adv Advertising set.
*
* @return Index of the advertising set object.
* The range of the returned value is 0..CONFIG_BT_EXT_ADV_MAX_ADV_SET-1
*/
uint8_t bt_le_ext_adv_get_index(struct bt_le_ext_adv *adv);
/** @brief Advertising set info structure. */
struct bt_le_ext_adv_info {
/* Local identity */
uint8_t id;
/** Currently selected Transmit Power (dBM). */
int8_t tx_power;
/** Current local advertising address used. */
const bt_addr_le_t *addr;
};
/**
* @brief Get advertising set info
*
* @param adv Advertising set object
* @param info Advertising set info object
*
* @return Zero on success or (negative) error code on failure.
*/
int bt_le_ext_adv_get_info(const struct bt_le_ext_adv *adv,
struct bt_le_ext_adv_info *info);
/**
* @typedef bt_le_scan_cb_t
* @brief Callback type for reporting LE scan results.
*
* A function of this type is given to the bt_le_scan_start() function
* and will be called for any discovered LE device.
*
* @param addr Advertiser LE address and type.
* @param rssi Strength of advertiser signal.
* @param adv_type Type of advertising response from advertiser.
* Uses the BT_GAP_ADV_TYPE_* values.
* @param buf Buffer containing advertiser data.
*/
typedef void bt_le_scan_cb_t(const bt_addr_le_t *addr, int8_t rssi,
uint8_t adv_type, struct net_buf_simple *buf);
/**
* @brief Set or update the periodic advertising parameters.
*
* The periodic advertising parameters can only be set or updated on an
* extended advertisement set which is neither scannable, connectable nor
* anonymous.
*
* @param adv Advertising set object.
* @param param Advertising parameters.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_le_per_adv_set_param(struct bt_le_ext_adv *adv,
const struct bt_le_per_adv_param *param);
/**
* @brief Set or update the periodic advertising data.
*
* The periodic advertisement data can only be set or updated on an
* extended advertisement set which is neither scannable, connectable nor
* anonymous.
*
* @param adv Advertising set object.
* @param ad Advertising data.
* @param ad_len Advertising data length.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_le_per_adv_set_data(const struct bt_le_ext_adv *adv,
const struct bt_data *ad, size_t ad_len);
struct bt_le_per_adv_subevent_data_params {
/** The subevent to set data for */
uint8_t subevent;
/** The first response slot to listen to */
uint8_t response_slot_start;
/** The number of response slots to listen to */
uint8_t response_slot_count;
/** The data to send */
const struct net_buf_simple *data;
};
/**
* @brief Set the periodic advertising with response subevent data.
*
* Set the data for one or more subevents of a Periodic Advertising with
* Responses Advertiser in reply data request.
*
* @pre There are @p num_subevents elements in @p params.
* @pre The controller has requested data for the subevents in @p params.
*
* @param adv The extended advertiser the PAwR train belongs to.
* @param num_subevents The number of subevents to set data for.
* @param params Subevent parameters.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_le_per_adv_set_subevent_data(const struct bt_le_ext_adv *adv, uint8_t num_subevents,
const struct bt_le_per_adv_subevent_data_params *params);
/**
* @brief Starts periodic advertising.
*
* Enabling the periodic advertising can be done independently of extended
* advertising, but both periodic advertising and extended advertising
* shall be enabled before any periodic advertising data is sent. The
* periodic advertising and extended advertising can be enabled in any order.
*
* Once periodic advertising has been enabled, it will continue advertising
* until @ref bt_le_per_adv_stop() has been called, or if the advertising set
* is deleted by @ref bt_le_ext_adv_delete(). Calling @ref bt_le_ext_adv_stop()
* will not stop the periodic advertising.
*
* @param adv Advertising set object.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_le_per_adv_start(struct bt_le_ext_adv *adv);
/**
* @brief Stops periodic advertising.
*
* Disabling the periodic advertising can be done independently of extended
* advertising. Disabling periodic advertising will not disable extended
* advertising.
*
* @param adv Advertising set object.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_le_per_adv_stop(struct bt_le_ext_adv *adv);
struct bt_le_per_adv_sync_synced_info {
/** Advertiser LE address and type. */
const bt_addr_le_t *addr;
/** Advertiser SID */
uint8_t sid;
/** Periodic advertising interval (N * 1.25 ms) */
uint16_t interval;
/** Advertiser PHY */
uint8_t phy;
/** True if receiving periodic advertisements, false otherwise. */
bool recv_enabled;
/**
* @brief Service Data provided by the peer when sync is transferred
*
* Will always be 0 when the sync is locally created.
*/
uint16_t service_data;
/**
* @brief Peer that transferred the periodic advertising sync
*
* Will always be 0 when the sync is locally created.
*
*/
struct bt_conn *conn;
#if defined(CONFIG_BT_PER_ADV_SYNC_RSP)
/** Number of subevents */
uint8_t num_subevents;
/** Subevent interval (N * 1.25 ms) */
uint8_t subevent_interval;
/** Response slot delay (N * 1.25 ms) */
uint8_t response_slot_delay;
/** Response slot spacing (N * 1.25 ms) */
uint8_t response_slot_spacing;
#endif /* CONFIG_BT_PER_ADV_SYNC_RSP */
};
struct bt_le_per_adv_sync_term_info {
/** Advertiser LE address and type. */
const bt_addr_le_t *addr;
/** Advertiser SID */
uint8_t sid;
/** Cause of periodic advertising termination */
uint8_t reason;
};
struct bt_le_per_adv_sync_recv_info {
/** Advertiser LE address and type. */
const bt_addr_le_t *addr;
/** Advertiser SID */
uint8_t sid;
/** The TX power of the advertisement. */
int8_t tx_power;
/** The RSSI of the advertisement excluding any CTE. */
int8_t rssi;
/** The Constant Tone Extension (CTE) of the advertisement (@ref bt_df_cte_type) */
uint8_t cte_type;
#if defined(CONFIG_BT_PER_ADV_SYNC_RSP)
/** The value of the event counter where the subevent indication was received. */
uint16_t periodic_event_counter;
/** The subevent where the subevent indication was received. */
uint8_t subevent;
#endif /* CONFIG_BT_PER_ADV_SYNC_RSP */
};
struct bt_le_per_adv_sync_state_info {
/** True if receiving periodic advertisements, false otherwise. */
bool recv_enabled;
};
struct bt_le_per_adv_sync_cb {
/**
* @brief The periodic advertising has been successfully synced.
*
* This callback notifies the application that the periodic advertising
* set has been successfully synced, and will now start to
* receive periodic advertising reports.
*
* @param sync The periodic advertising sync object.
* @param info Information about the sync event.
*/
void (*synced)(struct bt_le_per_adv_sync *sync,
struct bt_le_per_adv_sync_synced_info *info);
/**
* @brief The periodic advertising sync has been terminated.
*
* This callback notifies the application that the periodic advertising
* sync has been terminated, either by local request, remote request or
* because due to missing data, e.g. by being out of range or sync.
*
* @param sync The periodic advertising sync object.
*/
void (*term)(struct bt_le_per_adv_sync *sync,
const struct bt_le_per_adv_sync_term_info *info);
/**
* @brief Periodic advertising data received.
*
* This callback notifies the application of an periodic advertising
* report.
*
* @param sync The advertising set object.
* @param info Information about the periodic advertising event.
* @param buf Buffer containing the periodic advertising data.
* NULL if the controller failed to receive a subevent
* indication. Only happens if
* @kconfig{CONFIG_BT_PER_ADV_SYNC_RSP} is enabled.
*/
void (*recv)(struct bt_le_per_adv_sync *sync,
const struct bt_le_per_adv_sync_recv_info *info,
struct net_buf_simple *buf);
/**
* @brief The periodic advertising sync state has changed.
*
* This callback notifies the application about changes to the sync
* state. Initialize sync and termination is handled by their individual
* callbacks, and won't be notified here.
*
* @param sync The periodic advertising sync object.
* @param info Information about the state change.
*/
void (*state_changed)(struct bt_le_per_adv_sync *sync,
const struct bt_le_per_adv_sync_state_info *info);
/**
* @brief BIGInfo advertising report received.
*
* This callback notifies the application of a BIGInfo advertising report.
* This is received if the advertiser is broadcasting isochronous streams in a BIG.
* See iso.h for more information.
*
* @param sync The advertising set object.
* @param biginfo The BIGInfo report.
*/
void (*biginfo)(struct bt_le_per_adv_sync *sync, const struct bt_iso_biginfo *biginfo);
/**
* @brief Callback for IQ samples report collected when sampling
* CTE received with periodic advertising PDU.
*
* @param sync The periodic advertising sync object.
* @param info Information about the sync event.
*/
void (*cte_report_cb)(struct bt_le_per_adv_sync *sync,
struct bt_df_per_adv_sync_iq_samples_report const *info);
sys_snode_t node;
};
/** Periodic advertising sync options */
enum {
/** Convenience value when no options are specified. */
BT_LE_PER_ADV_SYNC_OPT_NONE = 0,
/**
* @brief Use the periodic advertising list to sync with advertiser
*
* When this option is set, the address and SID of the parameters
* are ignored.
*/
BT_LE_PER_ADV_SYNC_OPT_USE_PER_ADV_LIST = BIT(0),
/**
* @brief Disables periodic advertising reports
*
* No advertisement reports will be handled until enabled.
*/
BT_LE_PER_ADV_SYNC_OPT_REPORTING_INITIALLY_DISABLED = BIT(1),
/** Filter duplicate Periodic Advertising reports */
BT_LE_PER_ADV_SYNC_OPT_FILTER_DUPLICATE = BIT(2),
/** Sync with Angle of Arrival (AoA) constant tone extension */
BT_LE_PER_ADV_SYNC_OPT_DONT_SYNC_AOA = BIT(3),
/** Sync with Angle of Departure (AoD) 1 us constant tone extension */
BT_LE_PER_ADV_SYNC_OPT_DONT_SYNC_AOD_1US = BIT(4),
/** Sync with Angle of Departure (AoD) 2 us constant tone extension */
BT_LE_PER_ADV_SYNC_OPT_DONT_SYNC_AOD_2US = BIT(5),
/** Do not sync to packets without a constant tone extension */
BT_LE_PER_ADV_SYNC_OPT_SYNC_ONLY_CONST_TONE_EXT = BIT(6),
};
struct bt_le_per_adv_sync_param {
/**
* @brief Periodic Advertiser Address
*
* Only valid if not using the periodic advertising list
* (BT_LE_PER_ADV_SYNC_OPT_USE_PER_ADV_LIST)
*/
bt_addr_le_t addr;
/**
* @brief Advertiser SID
*
* Only valid if not using the periodic advertising list
* (BT_LE_PER_ADV_SYNC_OPT_USE_PER_ADV_LIST)
*/
uint8_t sid;
/** Bit-field of periodic advertising sync options. */
uint32_t options;
/**
* @brief Maximum event skip
*
* Maximum number of periodic advertising events that can be
* skipped after a successful receive.
* Range: 0x0000 to 0x01F3
*/
uint16_t skip;
/**
* @brief Synchronization timeout (N * 10 ms)
*
* Synchronization timeout for the periodic advertising sync.
* Range 0x000A to 0x4000 (100 ms to 163840 ms)
*/
uint16_t timeout;
};
/**
* @brief Get array index of an periodic advertising sync object.
*
* This function is get the index of an array of periodic advertising sync
* objects. The array has CONFIG_BT_PER_ADV_SYNC_MAX elements.
*
* @param per_adv_sync The periodic advertising sync object.
*
* @return Index of the periodic advertising sync object.
* The range of the returned value is 0..CONFIG_BT_PER_ADV_SYNC_MAX-1
*/
uint8_t bt_le_per_adv_sync_get_index(struct bt_le_per_adv_sync *per_adv_sync);
/**
* @brief Get a periodic advertising sync object from the array index.
*
* This function is to get the periodic advertising sync object from
* the array index.
* The array has CONFIG_BT_PER_ADV_SYNC_MAX elements.
*
* @param index The index of the periodic advertising sync object.
* The range of the index value is 0..CONFIG_BT_PER_ADV_SYNC_MAX-1
*
* @return The periodic advertising sync object of the array index or NULL if invalid index.
*/
struct bt_le_per_adv_sync *bt_le_per_adv_sync_lookup_index(uint8_t index);
/** @brief Advertising set info structure. */
struct bt_le_per_adv_sync_info {
/** Periodic Advertiser Address */
bt_addr_le_t addr;
/** Advertiser SID */
uint8_t sid;
/** Periodic advertising interval (N * 1.25 ms) */
uint16_t interval;
/** Advertiser PHY */
uint8_t phy;
};
/**
* @brief Get periodic adv sync information.
*
* @param per_adv_sync Periodic advertising sync object.
* @param info Periodic advertising sync info object
*
* @return Zero on success or (negative) error code on failure.
*/
int bt_le_per_adv_sync_get_info(struct bt_le_per_adv_sync *per_adv_sync,
struct bt_le_per_adv_sync_info *info);
/**
* @brief Look up an existing periodic advertising sync object by advertiser address.
*
* @param adv_addr Advertiser address.
* @param sid The advertising set ID.
*
* @return Periodic advertising sync object or NULL if not found.
*/
struct bt_le_per_adv_sync *bt_le_per_adv_sync_lookup_addr(const bt_addr_le_t *adv_addr,
uint8_t sid);
/**
* @brief Create a periodic advertising sync object.
*
* Create a periodic advertising sync object that can try to synchronize
* to periodic advertising reports from an advertiser. Scan shall either be
* disabled or extended scan shall be enabled.
*
* This function does not timeout, and will continue to look for an advertiser until it either
* finds it or bt_le_per_adv_sync_delete() is called. It is thus suggested to implement a timeout
* when using this, if it is expected to find the advertiser within a reasonable timeframe.
*
* @param[in] param Periodic advertising sync parameters.
* @param[out] out_sync Periodic advertising sync object on.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_le_per_adv_sync_create(const struct bt_le_per_adv_sync_param *param,
struct bt_le_per_adv_sync **out_sync);
/**
* @brief Delete periodic advertising sync.
*
* Delete the periodic advertising sync object. Can be called regardless of the
* state of the sync. If the syncing is currently syncing, the syncing is
* cancelled. If the sync has been established, it is terminated. The
* periodic advertising sync object will be invalidated afterwards.
*
* If the state of the sync object is syncing, then a new periodic advertising
* sync object may not be created until the controller has finished canceling
* this object.
*
* @param per_adv_sync The periodic advertising sync object.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_le_per_adv_sync_delete(struct bt_le_per_adv_sync *per_adv_sync);
/**
* @brief Register periodic advertising sync callbacks.
*
* Adds the callback structure to the list of callback structures for periodic
* advertising syncs.
*
* This callback will be called for all periodic advertising sync activity,
* such as synced, terminated and when data is received.
*
* @param cb Callback struct. Must point to memory that remains valid.
*
* @retval 0 Success.
* @retval -EEXIST if @p cb was already registered.
*/
int bt_le_per_adv_sync_cb_register(struct bt_le_per_adv_sync_cb *cb);
/**
* @brief Enables receiving periodic advertising reports for a sync.
*
* If the sync is already receiving the reports, -EALREADY is returned.
*
* @param per_adv_sync The periodic advertising sync object.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_le_per_adv_sync_recv_enable(struct bt_le_per_adv_sync *per_adv_sync);
/**
* @brief Disables receiving periodic advertising reports for a sync.
*
* If the sync report receiving is already disabled, -EALREADY is returned.
*
* @param per_adv_sync The periodic advertising sync object.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_le_per_adv_sync_recv_disable(struct bt_le_per_adv_sync *per_adv_sync);
/** Periodic Advertising Sync Transfer options */
enum {
/** Convenience value when no options are specified. */
BT_LE_PER_ADV_SYNC_TRANSFER_OPT_NONE = 0,
/**
* @brief No Angle of Arrival (AoA)
*
* Do not sync with Angle of Arrival (AoA) constant tone extension
**/
BT_LE_PER_ADV_SYNC_TRANSFER_OPT_SYNC_NO_AOA = BIT(0),
/**
* @brief No Angle of Departure (AoD) 1 us
*
* Do not sync with Angle of Departure (AoD) 1 us
* constant tone extension
*/
BT_LE_PER_ADV_SYNC_TRANSFER_OPT_SYNC_NO_AOD_1US = BIT(1),
/**
* @brief No Angle of Departure (AoD) 2
*
* Do not sync with Angle of Departure (AoD) 2 us
* constant tone extension
*/
BT_LE_PER_ADV_SYNC_TRANSFER_OPT_SYNC_NO_AOD_2US = BIT(2),
/** Only sync to packets with constant tone extension */
BT_LE_PER_ADV_SYNC_TRANSFER_OPT_SYNC_ONLY_CTE = BIT(3),
/**
* @brief Sync to received PAST packets but don't generate sync reports
*
* This option must not be set at the same time as
* @ref BT_LE_PER_ADV_SYNC_TRANSFER_OPT_FILTER_DUPLICATES.
*/
BT_LE_PER_ADV_SYNC_TRANSFER_OPT_REPORTING_INITIALLY_DISABLED = BIT(4),
/**
* @brief Sync to received PAST packets and generate sync reports with duplicate filtering
*
* This option must not be set at the same time as
* @ref BT_LE_PER_ADV_SYNC_TRANSFER_OPT_REPORTING_INITIALLY_DISABLED.
*/
BT_LE_PER_ADV_SYNC_TRANSFER_OPT_FILTER_DUPLICATES = BIT(5),
};
struct bt_le_per_adv_sync_transfer_param {
/**
* @brief Maximum event skip
*
* The number of periodic advertising packets that can be skipped
* after a successful receive.
*/
uint16_t skip;
/**
* @brief Synchronization timeout (N * 10 ms)
*
* Synchronization timeout for the periodic advertising sync.
* Range 0x000A to 0x4000 (100 ms to 163840 ms)
*/
uint16_t timeout;
/** Periodic Advertising Sync Transfer options */
uint32_t options;
};
/**
* @brief Transfer the periodic advertising sync information to a peer device.
*
* This will allow another device to quickly synchronize to the same periodic
* advertising train that this device is currently synced to.
*
* @param per_adv_sync The periodic advertising sync to transfer.
* @param conn The peer device that will receive the sync information.
* @param service_data Application service data provided to the remote host.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_le_per_adv_sync_transfer(const struct bt_le_per_adv_sync *per_adv_sync,
const struct bt_conn *conn,
uint16_t service_data);
/**
* @brief Transfer the information about a periodic advertising set.
*
* This will allow another device to quickly synchronize to periodic
* advertising set from this device.
*
* @param adv The periodic advertising set to transfer info of.
* @param conn The peer device that will receive the information.
* @param service_data Application service data provided to the remote host.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_le_per_adv_set_info_transfer(const struct bt_le_ext_adv *adv,
const struct bt_conn *conn,
uint16_t service_data);
/**
* @brief Subscribe to periodic advertising sync transfers (PASTs).
*
* Sets the parameters and allow other devices to transfer periodic advertising
* syncs.
*
* @param conn The connection to set the parameters for. If NULL default
* parameters for all connections will be set. Parameters set
* for specific connection will always have precedence.
* @param param The periodic advertising sync transfer parameters.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_le_per_adv_sync_transfer_subscribe(
const struct bt_conn *conn,
const struct bt_le_per_adv_sync_transfer_param *param);
/**
* @brief Unsubscribe from periodic advertising sync transfers (PASTs).
*
* Remove the parameters that allow other devices to transfer periodic
* advertising syncs.
*
* @param conn The connection to remove the parameters for. If NULL default
* parameters for all connections will be removed. Unsubscribing
* for a specific device, will still allow other devices to
* transfer periodic advertising syncs.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_le_per_adv_sync_transfer_unsubscribe(const struct bt_conn *conn);
/**
* @brief Add a device to the periodic advertising list.
*
* Add peer device LE address to the periodic advertising list. This will make
* it possibly to automatically create a periodic advertising sync to this
* device.
*
* @param addr Bluetooth LE identity address.
* @param sid The advertising set ID. This value is obtained from the
* @ref bt_le_scan_recv_info in the scan callback.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_le_per_adv_list_add(const bt_addr_le_t *addr, uint8_t sid);
/**
* @brief Remove a device from the periodic advertising list.
*
* Removes peer device LE address from the periodic advertising list.
*
* @param addr Bluetooth LE identity address.
* @param sid The advertising set ID. This value is obtained from the
* @ref bt_le_scan_recv_info in the scan callback.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_le_per_adv_list_remove(const bt_addr_le_t *addr, uint8_t sid);
/**
* @brief Clear the periodic advertising list.
*
* Clears the entire periodic advertising list.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_le_per_adv_list_clear(void);
enum {
/** Convenience value when no options are specified. */
BT_LE_SCAN_OPT_NONE = 0,
/** Filter duplicates. */
BT_LE_SCAN_OPT_FILTER_DUPLICATE = BIT(0),
/** Filter using filter accept list. */
BT_LE_SCAN_OPT_FILTER_ACCEPT_LIST = BIT(1),
/** Enable scan on coded PHY (Long Range).*/
BT_LE_SCAN_OPT_CODED = BIT(2),
/**
* @brief Disable scan on 1M phy.
*
* @note Requires @ref BT_LE_SCAN_OPT_CODED.
*/
BT_LE_SCAN_OPT_NO_1M = BIT(3),
};
#define BT_LE_SCAN_OPT_FILTER_WHITELIST __DEPRECATED_MACRO BT_LE_SCAN_OPT_FILTER_ACCEPT_LIST
enum {
/** Scan without requesting additional information from advertisers. */
BT_LE_SCAN_TYPE_PASSIVE = 0x00,
/**
* @brief Scan and request additional information from advertisers.
*
* Using this scan type will automatically send scan requests to all
* devices. Scan responses are received in the same manner and using the
* same callbacks as advertising reports.
*/
BT_LE_SCAN_TYPE_ACTIVE = 0x01,
};
/** LE scan parameters */
struct bt_le_scan_param {
/** Scan type (BT_LE_SCAN_TYPE_ACTIVE or BT_LE_SCAN_TYPE_PASSIVE) */
uint8_t type;
/** Bit-field of scanning options. */
uint32_t options;
/** Scan interval (N * 0.625 ms) */
uint16_t interval;
/** Scan window (N * 0.625 ms) */
uint16_t window;
/**
* @brief Scan timeout (N * 10 ms)
*
* Application will be notified by the scan timeout callback.
* Set zero to disable timeout.
*/
uint16_t timeout;
/**
* @brief Scan interval LE Coded PHY (N * 0.625 MS)
*
* Set zero to use same as LE 1M PHY scan interval.
*/
uint16_t interval_coded;
/**
* @brief Scan window LE Coded PHY (N * 0.625 MS)
*
* Set zero to use same as LE 1M PHY scan window.
*/
uint16_t window_coded;
};
/** LE advertisement and scan response packet information */
struct bt_le_scan_recv_info {
/**
* @brief Advertiser LE address and type.
*
* If advertiser is anonymous then this address will be
* @ref BT_ADDR_LE_ANY.
*/
const bt_addr_le_t *addr;
/** Advertising Set Identifier. */
uint8_t sid;
/** Strength of advertiser signal. */
int8_t rssi;
/** Transmit power of the advertiser. */
int8_t tx_power;
/**
* @brief Advertising packet type.
*
* Uses the BT_GAP_ADV_TYPE_* value.
*
* May indicate that this is a scan response if the type is
* @ref BT_GAP_ADV_TYPE_SCAN_RSP.
*/
uint8_t adv_type;
/**
* @brief Advertising packet properties bitfield.
*
* Uses the BT_GAP_ADV_PROP_* values.
* May indicate that this is a scan response if the value contains the
* @ref BT_GAP_ADV_PROP_SCAN_RESPONSE bit.
*
*/
uint16_t adv_props;
/**
* @brief Periodic advertising interval (N * 1.25 ms).
*
* If 0 there is no periodic advertising.
*/
uint16_t interval;
/** Primary advertising channel PHY. */
uint8_t primary_phy;
/** Secondary advertising channel PHY. */
uint8_t secondary_phy;
};
/** Listener context for (LE) scanning. */
struct bt_le_scan_cb {
/**
* @brief Advertisement packet and scan response received callback.
*
* @param info Advertiser packet and scan response information.
* @param buf Buffer containing advertiser data.
*/
void (*recv)(const struct bt_le_scan_recv_info *info,
struct net_buf_simple *buf);
/** @brief The scanner has stopped scanning after scan timeout. */
void (*timeout)(void);
sys_snode_t node;
};
/**
* @brief Initialize scan parameters
*
* @param _type Scan Type, BT_LE_SCAN_TYPE_ACTIVE or
* BT_LE_SCAN_TYPE_PASSIVE.
* @param _options Scan options
* @param _interval Scan Interval (N * 0.625 ms)
* @param _window Scan Window (N * 0.625 ms)
*/
#define BT_LE_SCAN_PARAM_INIT(_type, _options, _interval, _window) \
{ \
.type = (_type), \
.options = (_options), \
.interval = (_interval), \
.window = (_window), \
.timeout = 0, \
.interval_coded = 0, \
.window_coded = 0, \
}
/**
* @brief Helper to declare scan parameters inline
*
* @param _type Scan Type, BT_LE_SCAN_TYPE_ACTIVE or
* BT_LE_SCAN_TYPE_PASSIVE.
* @param _options Scan options
* @param _interval Scan Interval (N * 0.625 ms)
* @param _window Scan Window (N * 0.625 ms)
*/
#define BT_LE_SCAN_PARAM(_type, _options, _interval, _window) \
((struct bt_le_scan_param[]) { \
BT_LE_SCAN_PARAM_INIT(_type, _options, _interval, _window) \
})
/**
* @brief Helper macro to enable active scanning to discover new devices.
*/
#define BT_LE_SCAN_ACTIVE BT_LE_SCAN_PARAM(BT_LE_SCAN_TYPE_ACTIVE, \
BT_LE_SCAN_OPT_FILTER_DUPLICATE, \
BT_GAP_SCAN_FAST_INTERVAL, \
BT_GAP_SCAN_FAST_WINDOW)
/**
* @brief Helper macro to enable active scanning to discover new devices with window == interval.
*
* Continuous scanning should be used to maximize the chances of receiving advertising packets.
*/
#define BT_LE_SCAN_ACTIVE_CONTINUOUS BT_LE_SCAN_PARAM(BT_LE_SCAN_TYPE_ACTIVE, \
BT_LE_SCAN_OPT_FILTER_DUPLICATE, \
BT_GAP_SCAN_FAST_INTERVAL_MIN, \
BT_GAP_SCAN_FAST_WINDOW)
BUILD_ASSERT(BT_GAP_SCAN_FAST_WINDOW == BT_GAP_SCAN_FAST_INTERVAL_MIN,
"Continuous scanning is requested by setting window and interval equal.");
/**
* @brief Helper macro to enable passive scanning to discover new devices.
*
* This macro should be used if information required for device identification
* (e.g., UUID) are known to be placed in Advertising Data.
*/
#define BT_LE_SCAN_PASSIVE BT_LE_SCAN_PARAM(BT_LE_SCAN_TYPE_PASSIVE, \
BT_LE_SCAN_OPT_FILTER_DUPLICATE, \
BT_GAP_SCAN_FAST_INTERVAL, \
BT_GAP_SCAN_FAST_WINDOW)
/**
* @brief Helper macro to enable passive scanning to discover new devices with window==interval.
*
* This macro should be used if information required for device identification
* (e.g., UUID) are known to be placed in Advertising Data.
*/
#define BT_LE_SCAN_PASSIVE_CONTINUOUS BT_LE_SCAN_PARAM(BT_LE_SCAN_TYPE_PASSIVE, \
BT_LE_SCAN_OPT_FILTER_DUPLICATE, \
BT_GAP_SCAN_FAST_INTERVAL_MIN, \
BT_GAP_SCAN_FAST_WINDOW)
BUILD_ASSERT(BT_GAP_SCAN_FAST_WINDOW == BT_GAP_SCAN_FAST_INTERVAL_MIN,
"Continuous scanning is requested by setting window and interval equal.");
/**
* @brief Helper macro to enable active scanning to discover new devices.
* Include scanning on Coded PHY in addition to 1M PHY.
*/
#define BT_LE_SCAN_CODED_ACTIVE \
BT_LE_SCAN_PARAM(BT_LE_SCAN_TYPE_ACTIVE, \
BT_LE_SCAN_OPT_CODED | \
BT_LE_SCAN_OPT_FILTER_DUPLICATE, \
BT_GAP_SCAN_FAST_INTERVAL, \
BT_GAP_SCAN_FAST_WINDOW)
/**
* @brief Helper macro to enable passive scanning to discover new devices.
* Include scanning on Coded PHY in addition to 1M PHY.
*
* This macro should be used if information required for device identification
* (e.g., UUID) are known to be placed in Advertising Data.
*/
#define BT_LE_SCAN_CODED_PASSIVE \
BT_LE_SCAN_PARAM(BT_LE_SCAN_TYPE_PASSIVE, \
BT_LE_SCAN_OPT_CODED | \
BT_LE_SCAN_OPT_FILTER_DUPLICATE, \
BT_GAP_SCAN_FAST_INTERVAL, \
BT_GAP_SCAN_FAST_WINDOW)
/**
* @brief Start (LE) scanning
*
* Start LE scanning with given parameters and provide results through
* the specified callback.
*
* @note The LE scanner by default does not use the Identity Address of the
* local device when @kconfig{CONFIG_BT_PRIVACY} is disabled. This is to
* prevent the active scanner from disclosing the identity information
* when requesting additional information from advertisers.
* In order to enable directed advertiser reports then
* @kconfig{CONFIG_BT_SCAN_WITH_IDENTITY} must be enabled.
*
* @note Setting the `param.timeout` parameter is not supported when
* @kconfig{CONFIG_BT_PRIVACY} is enabled, when the param.type is @ref
* BT_LE_SCAN_TYPE_ACTIVE. Supplying a non-zero timeout will result in an
* -EINVAL error code.
*
* @param param Scan parameters.
* @param cb Callback to notify scan results. May be NULL if callback
* registration through @ref bt_le_scan_cb_register is preferred.
*
* @return Zero on success or error code otherwise, positive in case of
* protocol error or negative (POSIX) in case of stack internal error.
* @retval -EBUSY if the scanner is already being started in a different thread.
*/
int bt_le_scan_start(const struct bt_le_scan_param *param, bt_le_scan_cb_t cb);
/**
* @brief Stop (LE) scanning.
*
* Stops ongoing LE scanning.
*
* @return Zero on success or error code otherwise, positive in case of
* protocol error or negative (POSIX) in case of stack internal error.
*/
int bt_le_scan_stop(void);
/**
* @brief Register scanner packet callbacks.
*
* Adds the callback structure to the list of callback structures that monitors
* scanner activity.
*
* This callback will be called for all scanner activity, regardless of what
* API was used to start the scanner.
*
* @param cb Callback struct. Must point to memory that remains valid.
*
* @retval 0 Success.
* @retval -EEXIST if @p cb was already registered.
*/
int bt_le_scan_cb_register(struct bt_le_scan_cb *cb);
/**
* @brief Unregister scanner packet callbacks.
*
* Remove the callback structure from the list of scanner callbacks.
*
* @param cb Callback struct. Must point to memory that remains valid.
*/
void bt_le_scan_cb_unregister(struct bt_le_scan_cb *cb);
/**
* @brief Add device (LE) to filter accept list.
*
* Add peer device LE address to the filter accept list.
*
* @note The filter accept list cannot be modified when an LE role is using
* the filter accept list, i.e advertiser or scanner using a filter accept list
* or automatic connecting to devices using filter accept list.
*
* @param addr Bluetooth LE identity address.
*
* @return Zero on success or error code otherwise, positive in case of
* protocol error or negative (POSIX) in case of stack internal error.
*/
int bt_le_filter_accept_list_add(const bt_addr_le_t *addr);
/**
* @brief Remove device (LE) from filter accept list.
*
* Remove peer device LE address from the filter accept list.
*
* @note The filter accept list cannot be modified when an LE role is using
* the filter accept list, i.e advertiser or scanner using a filter accept list
* or automatic connecting to devices using filter accept list.
*
* @param addr Bluetooth LE identity address.
*
* @return Zero on success or error code otherwise, positive in case of
* protocol error or negative (POSIX) in case of stack internal error.
*/
int bt_le_filter_accept_list_remove(const bt_addr_le_t *addr);
/**
* @brief Clear filter accept list.
*
* Clear all devices from the filter accept list.
*
* @note The filter accept list cannot be modified when an LE role is using
* the filter accept list, i.e advertiser or scanner using a filter accept
* list or automatic connecting to devices using filter accept list.
*
* @return Zero on success or error code otherwise, positive in case of
* protocol error or negative (POSIX) in case of stack internal error.
*/
int bt_le_filter_accept_list_clear(void);
/**
* @brief Set (LE) channel map.
*
* @param chan_map Channel map.
*
* @return Zero on success or error code otherwise, positive in case of
* protocol error or negative (POSIX) in case of stack internal error.
*/
int bt_le_set_chan_map(uint8_t chan_map[5]);
/**
* @brief Set the Resolvable Private Address timeout in runtime
*
* The new RPA timeout value will be used for the next RPA rotation
* and all subsequent rotations until another override is scheduled
* with this API.
*
* Initially, the if @kconfig{CONFIG_BT_RPA_TIMEOUT} is used as the
* RPA timeout.
*
* This symbol is linkable if @kconfig{CONFIG_BT_RPA_TIMEOUT_DYNAMIC}
* is enabled.
*
* @param new_rpa_timeout Resolvable Private Address timeout in seconds
*
* @retval 0 Success.
* @retval -EINVAL RPA timeout value is invalid. Valid range is 1s - 3600s.
*/
int bt_le_set_rpa_timeout(uint16_t new_rpa_timeout);
/**
* @brief Helper for parsing advertising (or EIR or OOB) data.
*
* A helper for parsing the basic data types used for Extended Inquiry
* Response (EIR), Advertising Data (AD), and OOB data blocks. The most
* common scenario is to call this helper on the advertising data
* received in the callback that was given to bt_le_scan_start().
*
* @warning This helper function will consume `ad` when parsing. The user should
* make a copy if the original data is to be used afterwards
*
* @param ad Advertising data as given to the bt_le_scan_cb_t callback.
* @param func Callback function which will be called for each element
* that's found in the data. The callback should return
* true to continue parsing, or false to stop parsing.
* @param user_data User data to be passed to the callback.
*/
void bt_data_parse(struct net_buf_simple *ad,
bool (*func)(struct bt_data *data, void *user_data),
void *user_data);
/** LE Secure Connections pairing Out of Band data. */
struct bt_le_oob_sc_data {
/** Random Number. */
uint8_t r[16];
/** Confirm Value. */
uint8_t c[16];
};
/** LE Out of Band information. */
struct bt_le_oob {
/** LE address. If privacy is enabled this is a Resolvable Private
* Address.
*/
bt_addr_le_t addr;
/** LE Secure Connections pairing Out of Band data. */
struct bt_le_oob_sc_data le_sc_data;
};
/**
* @brief Get local LE Out of Band (OOB) information.
*
* This function allows to get local information that are useful for
* Out of Band pairing or connection creation.
*
* If privacy @kconfig{CONFIG_BT_PRIVACY} is enabled this will result in
* generating new Resolvable Private Address (RPA) that is valid for
* @kconfig{CONFIG_BT_RPA_TIMEOUT} seconds. This address will be used for
* advertising started by @ref bt_le_adv_start, active scanning and
* connection creation.
*
* @note If privacy is enabled the RPA cannot be refreshed in the following
* cases:
* - Creating a connection in progress, wait for the connected callback.
* In addition when extended advertising @kconfig{CONFIG_BT_EXT_ADV} is
* not enabled or not supported by the controller:
* - Advertiser is enabled using a Random Static Identity Address for a
* different local identity.
* - The local identity conflicts with the local identity used by other
* roles.
*
* @param[in] id Local identity, in most cases BT_ID_DEFAULT.
* @param[out] oob LE OOB information
*
* @return Zero on success or error code otherwise, positive in case of
* protocol error or negative (POSIX) in case of stack internal error.
*/
int bt_le_oob_get_local(uint8_t id, struct bt_le_oob *oob);
/**
* @brief Get local LE Out of Band (OOB) information.
*
* This function allows to get local information that are useful for
* Out of Band pairing or connection creation.
*
* If privacy @kconfig{CONFIG_BT_PRIVACY} is enabled this will result in
* generating new Resolvable Private Address (RPA) that is valid for
* @kconfig{CONFIG_BT_RPA_TIMEOUT} seconds. This address will be used by the
* advertising set.
*
* @note When generating OOB information for multiple advertising set all
* OOB information needs to be generated at the same time.
*
* @note If privacy is enabled the RPA cannot be refreshed in the following
* cases:
* - Creating a connection in progress, wait for the connected callback.
*
* @param[in] adv The advertising set object
* @param[out] oob LE OOB information
*
* @return Zero on success or error code otherwise, positive in case
* of protocol error or negative (POSIX) in case of stack internal error.
*/
int bt_le_ext_adv_oob_get_local(struct bt_le_ext_adv *adv,
struct bt_le_oob *oob);
/** @brief BR/EDR discovery result structure */
struct bt_br_discovery_result {
/** private */
uint8_t _priv[4];
/** Remote device address */
bt_addr_t addr;
/** RSSI from inquiry */
int8_t rssi;
/** Class of Device */
uint8_t cod[3];
/** Extended Inquiry Response */
uint8_t eir[240];
};
/**
* @typedef bt_br_discovery_cb_t
* @brief Callback type for reporting BR/EDR discovery (inquiry)
* results.
*
* A callback of this type is given to the bt_br_discovery_start()
* function and will be called at the end of the discovery with
* information about found devices populated in the results array.
*
* @param results Storage used for discovery results
* @param count Number of valid discovery results.
*/
typedef void bt_br_discovery_cb_t(struct bt_br_discovery_result *results,
size_t count);
/** BR/EDR discovery parameters */
struct bt_br_discovery_param {
/** Maximum length of the discovery in units of 1.28 seconds.
* Valid range is 0x01 - 0x30.
*/
uint8_t length;
/** True if limited discovery procedure is to be used. */
bool limited;
};
/**
* @brief Start BR/EDR discovery
*
* Start BR/EDR discovery (inquiry) and provide results through the specified
* callback. When bt_br_discovery_cb_t is called it indicates that discovery
* has completed. If more inquiry results were received during session than
* fits in provided result storage, only ones with highest RSSI will be
* reported.
*
* @param param Discovery parameters.
* @param results Storage for discovery results.
* @param count Number of results in storage. Valid range: 1-255.
* @param cb Callback to notify discovery results.
*
* @return Zero on success or error code otherwise, positive in case
* of protocol error or negative (POSIX) in case of stack internal error
*/
int bt_br_discovery_start(const struct bt_br_discovery_param *param,
struct bt_br_discovery_result *results, size_t count,
bt_br_discovery_cb_t cb);
/**
* @brief Stop BR/EDR discovery.
*
* Stops ongoing BR/EDR discovery. If discovery was stopped by this call
* results won't be reported
*
* @return Zero on success or error code otherwise, positive in case of
* protocol error or negative (POSIX) in case of stack internal error.
*/
int bt_br_discovery_stop(void);
struct bt_br_oob {
/** BR/EDR address. */
bt_addr_t addr;
};
/**
* @brief Get BR/EDR local Out Of Band information
*
* This function allows to get local controller information that are useful
* for Out Of Band pairing or connection creation process.
*
* @param oob Out Of Band information
*/
int bt_br_oob_get_local(struct bt_br_oob *oob);
/**
* @brief Enable/disable set controller in discoverable state.
*
* Allows make local controller to listen on INQUIRY SCAN channel and responds
* to devices making general inquiry. To enable this state it's mandatory
* to first be in connectable state.
*
* @param enable Value allowing/disallowing controller to become discoverable.
*
* @return Negative if fail set to requested state or requested state has been
* already set. Zero if done successfully.
*/
int bt_br_set_discoverable(bool enable);
/**
* @brief Enable/disable set controller in connectable state.
*
* Allows make local controller to be connectable. It means the controller
* start listen to devices requests on PAGE SCAN channel. If disabled also
* resets discoverability if was set.
*
* @param enable Value allowing/disallowing controller to be connectable.
*
* @return Negative if fail set to requested state or requested state has been
* already set. Zero if done successfully.
*/
int bt_br_set_connectable(bool enable);
/**
* @brief Clear pairing information.
*
* @param id Local identity (mostly just BT_ID_DEFAULT).
* @param addr Remote address, NULL or BT_ADDR_LE_ANY to clear all remote
* devices.
*
* @return 0 on success or negative error value on failure.
*/
int bt_unpair(uint8_t id, const bt_addr_le_t *addr);
/** Information about a bond with a remote device. */
struct bt_bond_info {
/** Address of the remote device. */
bt_addr_le_t addr;
};
/**
* @brief Iterate through all existing bonds.
*
* @param id Local identity (mostly just BT_ID_DEFAULT).
* @param func Function to call for each bond.
* @param user_data Data to pass to the callback function.
*/
void bt_foreach_bond(uint8_t id, void (*func)(const struct bt_bond_info *info,
void *user_data),
void *user_data);
/** @brief Configure vendor data path
*
* Request the Controller to configure the data transport path in a given direction between
* the Controller and the Host.
*
* @param dir Direction to be configured, BT_HCI_DATAPATH_DIR_HOST_TO_CTLR or
* BT_HCI_DATAPATH_DIR_CTLR_TO_HOST
* @param id Vendor specific logical transport channel ID, range
* [BT_HCI_DATAPATH_ID_VS..BT_HCI_DATAPATH_ID_VS_END]
* @param vs_config_len Length of additional vendor specific configuration data
* @param vs_config Pointer to additional vendor specific configuration data
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_configure_data_path(uint8_t dir, uint8_t id, uint8_t vs_config_len,
const uint8_t *vs_config);
struct bt_le_per_adv_sync_subevent_params {
/** @brief Periodic Advertising Properties.
*
* Bit 6 is include TxPower, all others RFU.
*
*/
uint16_t properties;
/** Number of subevents to sync to */
uint8_t num_subevents;
/** @brief The subevent(s) to synchronize with
*
* The array must have @ref num_subevents elements.
*
*/
uint8_t *subevents;
};
/** @brief Synchronize with a subset of subevents
*
* Until this command is issued, the subevent(s) the controller is synchronized
* to is unspecified.
*
* @param per_adv_sync The periodic advertising sync object.
* @param params Parameters.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_le_per_adv_sync_subevent(struct bt_le_per_adv_sync *per_adv_sync,
struct bt_le_per_adv_sync_subevent_params *params);
struct bt_le_per_adv_response_params {
/** @brief The periodic event counter of the request the response is sent to.
*
* @ref bt_le_per_adv_sync_recv_info
*
* @note The response can be sent up to one periodic interval after
* the request was received.
*
*/
uint16_t request_event;
/** @brief The subevent counter of the request the response is sent to.
*
* @ref bt_le_per_adv_sync_recv_info
*
*/
uint8_t request_subevent;
/** The subevent the response shall be sent in */
uint8_t response_subevent;
/** The response slot the response shall be sent in */
uint8_t response_slot;
};
/**
* @brief Set the data for a response slot in a specific subevent of the PAwR.
*
* This function is called by the application to set the response data.
* The data for a response slot shall be transmitted only once.
*
* @param per_adv_sync The periodic advertising sync object.
* @param params Parameters.
* @param data The response data to send.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_le_per_adv_set_response_data(struct bt_le_per_adv_sync *per_adv_sync,
const struct bt_le_per_adv_response_params *params,
const struct net_buf_simple *data);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
/**
* @}
*/
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_BLUETOOTH_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/bluetooth.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 21,404 |
```objective-c
/** @file
* @brief Bluetooth UUID handling
*/
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_UUID_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_UUID_H_
/**
* @brief UUIDs
* @defgroup bt_uuid UUIDs
* @ingroup bluetooth
* @{
*/
#include <stdint.h>
#include <zephyr/sys/util.h>
#include <zephyr/bluetooth/byteorder.h>
#ifdef __cplusplus
extern "C" {
#endif
/** @brief Bluetooth UUID types */
enum {
/** UUID type 16-bit. */
BT_UUID_TYPE_16,
/** UUID type 32-bit. */
BT_UUID_TYPE_32,
/** UUID type 128-bit. */
BT_UUID_TYPE_128,
};
/** Size in octets of a 16-bit UUID */
#define BT_UUID_SIZE_16 2
/** Size in octets of a 32-bit UUID */
#define BT_UUID_SIZE_32 4
/** Size in octets of a 128-bit UUID */
#define BT_UUID_SIZE_128 16
/** @brief This is a 'tentative' type and should be used as a pointer only */
struct bt_uuid {
uint8_t type;
};
struct bt_uuid_16 {
/** UUID generic type. */
struct bt_uuid uuid;
/** UUID value, 16-bit in host endianness. */
uint16_t val;
};
struct bt_uuid_32 {
/** UUID generic type. */
struct bt_uuid uuid;
/** UUID value, 32-bit in host endianness. */
uint32_t val;
};
struct bt_uuid_128 {
/** UUID generic type. */
struct bt_uuid uuid;
/** UUID value, 128-bit in little-endian format. */
uint8_t val[BT_UUID_SIZE_128];
};
/** @brief Initialize a 16-bit UUID.
*
* @param value 16-bit UUID value in host endianness.
*/
#define BT_UUID_INIT_16(value) \
{ \
.uuid = { BT_UUID_TYPE_16 }, \
.val = (value), \
}
/** @brief Initialize a 32-bit UUID.
*
* @param value 32-bit UUID value in host endianness.
*/
#define BT_UUID_INIT_32(value) \
{ \
.uuid = { BT_UUID_TYPE_32 }, \
.val = (value), \
}
/** @brief Initialize a 128-bit UUID.
*
* @param value 128-bit UUID array values in little-endian format.
* Can be combined with @ref BT_UUID_128_ENCODE to initialize a
* UUID from the readable form of UUIDs.
*/
#define BT_UUID_INIT_128(value...) \
{ \
.uuid = { BT_UUID_TYPE_128 }, \
.val = { value }, \
}
/** @brief Helper to declare a 16-bit UUID inline.
*
* @param value 16-bit UUID value in host endianness.
*
* @return Pointer to a generic UUID.
*/
#define BT_UUID_DECLARE_16(value) \
((const struct bt_uuid *) ((const struct bt_uuid_16[]) {BT_UUID_INIT_16(value)}))
/** @brief Helper to declare a 32-bit UUID inline.
*
* @param value 32-bit UUID value in host endianness.
*
* @return Pointer to a generic UUID.
*/
#define BT_UUID_DECLARE_32(value) \
((const struct bt_uuid *) ((const struct bt_uuid_32[]) {BT_UUID_INIT_32(value)}))
/** @brief Helper to declare a 128-bit UUID inline.
*
* @param value 128-bit UUID array values in little-endian format.
* Can be combined with @ref BT_UUID_128_ENCODE to declare a
* UUID from the readable form of UUIDs.
*
* @return Pointer to a generic UUID.
*/
#define BT_UUID_DECLARE_128(value...) \
((const struct bt_uuid *) ((const struct bt_uuid_128[]) {BT_UUID_INIT_128(value)}))
/** Helper macro to access the 16-bit UUID from a generic UUID. */
#define BT_UUID_16(__u) CONTAINER_OF(__u, struct bt_uuid_16, uuid)
/** Helper macro to access the 32-bit UUID from a generic UUID. */
#define BT_UUID_32(__u) CONTAINER_OF(__u, struct bt_uuid_32, uuid)
/** Helper macro to access the 128-bit UUID from a generic UUID. */
#define BT_UUID_128(__u) CONTAINER_OF(__u, struct bt_uuid_128, uuid)
/** @brief Encode 128 bit UUID into array values in little-endian format.
*
* Helper macro to initialize a 128-bit UUID array value from the readable form
* of UUIDs, or encode 128-bit UUID values into advertising data
* Can be combined with BT_UUID_DECLARE_128 to declare a 128-bit UUID.
*
* Example of how to declare the UUID `6E400001-B5A3-F393-E0A9-E50E24DCCA9E`
*
* @code
* BT_UUID_DECLARE_128(
* BT_UUID_128_ENCODE(0x6E400001, 0xB5A3, 0xF393, 0xE0A9, 0xE50E24DCCA9E))
* @endcode
*
* Example of how to encode the UUID `6E400001-B5A3-F393-E0A9-E50E24DCCA9E`
* into advertising data.
*
* @code
* BT_DATA_BYTES(BT_DATA_UUID128_ALL,
* BT_UUID_128_ENCODE(0x6E400001, 0xB5A3, 0xF393, 0xE0A9, 0xE50E24DCCA9E))
* @endcode
*
* Just replace the hyphen by the comma and add `0x` prefixes.
*
* @param w32 First part of the UUID (32 bits)
* @param w1 Second part of the UUID (16 bits)
* @param w2 Third part of the UUID (16 bits)
* @param w3 Fourth part of the UUID (16 bits)
* @param w48 Fifth part of the UUID (48 bits)
*
* @return The comma separated values for UUID 128 initializer that
* may be used directly as an argument for
* @ref BT_UUID_INIT_128 or @ref BT_UUID_DECLARE_128
*/
#define BT_UUID_128_ENCODE(w32, w1, w2, w3, w48) \
BT_BYTES_LIST_LE48(w48),\
BT_BYTES_LIST_LE16(w3), \
BT_BYTES_LIST_LE16(w2), \
BT_BYTES_LIST_LE16(w1), \
BT_BYTES_LIST_LE32(w32)
/** @brief Encode 16-bit UUID into array values in little-endian format.
*
* Helper macro to encode 16-bit UUID values into advertising data.
*
* Example of how to encode the UUID `0x180a` into advertising data.
*
* @code
* BT_DATA_BYTES(BT_DATA_UUID16_ALL, BT_UUID_16_ENCODE(0x180a))
* @endcode
*
* @param w16 UUID value (16-bits)
*
* @return The comma separated values for UUID 16 value that
* may be used directly as an argument for @ref BT_DATA_BYTES.
*/
#define BT_UUID_16_ENCODE(w16) BT_BYTES_LIST_LE16(w16)
/** @brief Encode 32-bit UUID into array values in little-endian format.
*
* Helper macro to encode 32-bit UUID values into advertising data.
*
* Example of how to encode the UUID `0x180a01af` into advertising data.
*
* @code
* BT_DATA_BYTES(BT_DATA_UUID32_ALL, BT_UUID_32_ENCODE(0x180a01af))
* @endcode
*
* @param w32 UUID value (32-bits)
*
* @return The comma separated values for UUID 32 value that
* may be used directly as an argument for @ref BT_DATA_BYTES.
*/
#define BT_UUID_32_ENCODE(w32) BT_BYTES_LIST_LE32(w32)
/**
* @brief Recommended length of user string buffer for Bluetooth UUID.
*
* @details The recommended length guarantee the output of UUID
* conversion will not lose valuable information about the UUID being
* processed. If the length of the UUID is known the string can be shorter.
*/
#define BT_UUID_STR_LEN 37
/**
* @brief Generic Access UUID value
*/
#define BT_UUID_GAP_VAL 0x1800
/**
* @brief Generic Access
*/
#define BT_UUID_GAP \
BT_UUID_DECLARE_16(BT_UUID_GAP_VAL)
/**
* @brief Generic attribute UUID value
*/
#define BT_UUID_GATT_VAL 0x1801
/**
* @brief Generic Attribute
*/
#define BT_UUID_GATT \
BT_UUID_DECLARE_16(BT_UUID_GATT_VAL)
/**
* @brief Immediate Alert Service UUID value
*/
#define BT_UUID_IAS_VAL 0x1802
/**
* @brief Immediate Alert Service
*/
#define BT_UUID_IAS \
BT_UUID_DECLARE_16(BT_UUID_IAS_VAL)
/**
* @brief Link Loss Service UUID value
*/
#define BT_UUID_LLS_VAL 0x1803
/**
* @brief Link Loss Service
*/
#define BT_UUID_LLS \
BT_UUID_DECLARE_16(BT_UUID_LLS_VAL)
/**
* @brief Tx Power Service UUID value
*/
#define BT_UUID_TPS_VAL 0x1804
/**
* @brief Tx Power Service
*/
#define BT_UUID_TPS \
BT_UUID_DECLARE_16(BT_UUID_TPS_VAL)
/**
* @brief Current Time Service UUID value
*/
#define BT_UUID_CTS_VAL 0x1805
/**
* @brief Current Time Service
*/
#define BT_UUID_CTS \
BT_UUID_DECLARE_16(BT_UUID_CTS_VAL)
/**
* @brief Reference Time Update Service UUID value
*/
#define BT_UUID_RTUS_VAL 0x1806
/**
* @brief Reference Time Update Service
*/
#define BT_UUID_RTUS \
BT_UUID_DECLARE_16(BT_UUID_RTUS_VAL)
/**
* @brief Next DST Change Service UUID value
*/
#define BT_UUID_NDSTS_VAL 0x1807
/**
* @brief Next DST Change Service
*/
#define BT_UUID_NDSTS \
BT_UUID_DECLARE_16(BT_UUID_NDSTS_VAL)
/**
* @brief Glucose Service UUID value
*/
#define BT_UUID_GS_VAL 0x1808
/**
* @brief Glucose Service
*/
#define BT_UUID_GS \
BT_UUID_DECLARE_16(BT_UUID_GS_VAL)
/**
* @brief Health Thermometer Service UUID value
*/
#define BT_UUID_HTS_VAL 0x1809
/**
* @brief Health Thermometer Service
*/
#define BT_UUID_HTS \
BT_UUID_DECLARE_16(BT_UUID_HTS_VAL)
/**
* @brief Device Information Service UUID value
*/
#define BT_UUID_DIS_VAL 0x180a
/**
* @brief Device Information Service
*/
#define BT_UUID_DIS \
BT_UUID_DECLARE_16(BT_UUID_DIS_VAL)
/**
* @brief Network Availability Service UUID value
*/
#define BT_UUID_NAS_VAL 0x180b
/**
* @brief Network Availability Service
*/
#define BT_UUID_NAS \
BT_UUID_DECLARE_16(BT_UUID_NAS_VAL)
/**
* @brief Watchdog Service UUID value
*/
#define BT_UUID_WDS_VAL 0x180c
/**
* @brief Watchdog Service
*/
#define BT_UUID_WDS \
BT_UUID_DECLARE_16(BT_UUID_WDS_VAL)
/**
* @brief Heart Rate Service UUID value
*/
#define BT_UUID_HRS_VAL 0x180d
/**
* @brief Heart Rate Service
*/
#define BT_UUID_HRS \
BT_UUID_DECLARE_16(BT_UUID_HRS_VAL)
/**
* @brief Phone Alert Service UUID value
*/
#define BT_UUID_PAS_VAL 0x180e
/**
* @brief Phone Alert Service
*/
#define BT_UUID_PAS \
BT_UUID_DECLARE_16(BT_UUID_PAS_VAL)
/**
* @brief Battery Service UUID value
*/
#define BT_UUID_BAS_VAL 0x180f
/**
* @brief Battery Service
*/
#define BT_UUID_BAS \
BT_UUID_DECLARE_16(BT_UUID_BAS_VAL)
/**
* @brief Blood Pressure Service UUID value
*/
#define BT_UUID_BPS_VAL 0x1810
/**
* @brief Blood Pressure Service
*/
#define BT_UUID_BPS \
BT_UUID_DECLARE_16(BT_UUID_BPS_VAL)
/**
* @brief Alert Notification Service UUID value
*/
#define BT_UUID_ANS_VAL 0x1811
/**
* @brief Alert Notification Service
*/
#define BT_UUID_ANS \
BT_UUID_DECLARE_16(BT_UUID_ANS_VAL)
/**
* @brief HID Service UUID value
*/
#define BT_UUID_HIDS_VAL 0x1812
/**
* @brief HID Service
*/
#define BT_UUID_HIDS \
BT_UUID_DECLARE_16(BT_UUID_HIDS_VAL)
/**
* @brief Scan Parameters Service UUID value
*/
#define BT_UUID_SPS_VAL 0x1813
/**
* @brief Scan Parameters Service
*/
#define BT_UUID_SPS \
BT_UUID_DECLARE_16(BT_UUID_SPS_VAL)
/**
* @brief Running Speed and Cadence Service UUID value
*/
#define BT_UUID_RSCS_VAL 0x1814
/**
* @brief Running Speed and Cadence Service
*/
#define BT_UUID_RSCS \
BT_UUID_DECLARE_16(BT_UUID_RSCS_VAL)
/**
* @brief Automation IO Service UUID value
*/
#define BT_UUID_AIOS_VAL 0x1815
/**
* @brief Automation IO Service
*/
#define BT_UUID_AIOS \
BT_UUID_DECLARE_16(BT_UUID_AIOS_VAL)
/**
* @brief Cycling Speed and Cadence Service UUID value
*/
#define BT_UUID_CSC_VAL 0x1816
/**
* @brief Cycling Speed and Cadence Service
*/
#define BT_UUID_CSC \
BT_UUID_DECLARE_16(BT_UUID_CSC_VAL)
/**
* @brief Cycling Power Service UUID value
*/
#define BT_UUID_CPS_VAL 0x1818
/**
* @brief Cycling Power Service
*/
#define BT_UUID_CPS \
BT_UUID_DECLARE_16(BT_UUID_CPS_VAL)
/**
* @brief Location and Navigation Service UUID value
*/
#define BT_UUID_LNS_VAL 0x1819
/**
* @brief Location and Navigation Service
*/
#define BT_UUID_LNS \
BT_UUID_DECLARE_16(BT_UUID_LNS_VAL)
/**
* @brief Environmental Sensing Service UUID value
*/
#define BT_UUID_ESS_VAL 0x181a
/**
* @brief Environmental Sensing Service
*/
#define BT_UUID_ESS \
BT_UUID_DECLARE_16(BT_UUID_ESS_VAL)
/**
* @brief Body Composition Service UUID value
*/
#define BT_UUID_BCS_VAL 0x181b
/**
* @brief Body Composition Service
*/
#define BT_UUID_BCS \
BT_UUID_DECLARE_16(BT_UUID_BCS_VAL)
/**
* @brief User Data Service UUID value
*/
#define BT_UUID_UDS_VAL 0x181c
/**
* @brief User Data Service
*/
#define BT_UUID_UDS \
BT_UUID_DECLARE_16(BT_UUID_UDS_VAL)
/**
* @brief Weight Scale Service UUID value
*/
#define BT_UUID_WSS_VAL 0x181d
/**
* @brief Weight Scale Service
*/
#define BT_UUID_WSS \
BT_UUID_DECLARE_16(BT_UUID_WSS_VAL)
/**
* @brief Bond Management Service UUID value
*/
#define BT_UUID_BMS_VAL 0x181e
/**
* @brief Bond Management Service
*/
#define BT_UUID_BMS \
BT_UUID_DECLARE_16(BT_UUID_BMS_VAL)
/**
* @brief Continuous Glucose Monitoring Service UUID value
*/
#define BT_UUID_CGMS_VAL 0x181f
/**
* @brief Continuous Glucose Monitoring Service
*/
#define BT_UUID_CGMS \
BT_UUID_DECLARE_16(BT_UUID_CGMS_VAL)
/**
* @brief IP Support Service UUID value
*/
#define BT_UUID_IPSS_VAL 0x1820
/**
* @brief IP Support Service
*/
#define BT_UUID_IPSS \
BT_UUID_DECLARE_16(BT_UUID_IPSS_VAL)
/**
* @brief Indoor Positioning Service UUID value
*/
#define BT_UUID_IPS_VAL 0x1821
/**
* @brief Indoor Positioning Service
*/
#define BT_UUID_IPS \
BT_UUID_DECLARE_16(BT_UUID_IPS_VAL)
/**
* @brief Pulse Oximeter Service UUID value
*/
#define BT_UUID_POS_VAL 0x1822
/**
* @brief Pulse Oximeter Service
*/
#define BT_UUID_POS \
BT_UUID_DECLARE_16(BT_UUID_POS_VAL)
/**
* @brief HTTP Proxy Service UUID value
*/
#define BT_UUID_HPS_VAL 0x1823
/**
* @brief HTTP Proxy Service
*/
#define BT_UUID_HPS \
BT_UUID_DECLARE_16(BT_UUID_HPS_VAL)
/**
* @brief Transport Discovery Service UUID value
*/
#define BT_UUID_TDS_VAL 0x1824
/**
* @brief Transport Discovery Service
*/
#define BT_UUID_TDS \
BT_UUID_DECLARE_16(BT_UUID_TDS_VAL)
/**
* @brief Object Transfer Service UUID value
*/
#define BT_UUID_OTS_VAL 0x1825
/**
* @brief Object Transfer Service
*/
#define BT_UUID_OTS \
BT_UUID_DECLARE_16(BT_UUID_OTS_VAL)
/**
* @brief Fitness Machine Service UUID value
*/
#define BT_UUID_FMS_VAL 0x1826
/**
* @brief Fitness Machine Service
*/
#define BT_UUID_FMS \
BT_UUID_DECLARE_16(BT_UUID_FMS_VAL)
/**
* @brief Mesh Provisioning Service UUID value
*/
#define BT_UUID_MESH_PROV_VAL 0x1827
/**
* @brief Mesh Provisioning Service
*/
#define BT_UUID_MESH_PROV \
BT_UUID_DECLARE_16(BT_UUID_MESH_PROV_VAL)
/**
* @brief Mesh Proxy Service UUID value
*/
#define BT_UUID_MESH_PROXY_VAL 0x1828
/**
* @brief Mesh Proxy Service
*/
#define BT_UUID_MESH_PROXY \
BT_UUID_DECLARE_16(BT_UUID_MESH_PROXY_VAL)
/**
* @brief Proxy Solicitation UUID value
*/
#define BT_UUID_MESH_PROXY_SOLICITATION_VAL 0x1859
/**
* @brief Reconnection Configuration Service UUID value
*/
#define BT_UUID_RCSRV_VAL 0x1829
/**
* @brief Reconnection Configuration Service
*/
#define BT_UUID_RCSRV \
BT_UUID_DECLARE_16(BT_UUID_RCSRV_VAL)
/**
* @brief Insulin Delivery Service UUID value
*/
#define BT_UUID_IDS_VAL 0x183a
/**
* @brief Insulin Delivery Service
*/
#define BT_UUID_IDS \
BT_UUID_DECLARE_16(BT_UUID_IDS_VAL)
/**
* @brief Binary Sensor Service UUID value
*/
#define BT_UUID_BSS_VAL 0x183b
/**
* @brief Binary Sensor Service
*/
#define BT_UUID_BSS \
BT_UUID_DECLARE_16(BT_UUID_BSS_VAL)
/**
* @brief Emergency Configuration Service UUID value
*/
#define BT_UUID_ECS_VAL 0x183c
/**
* @brief Emergency Configuration Service
*/
#define BT_UUID_ECS \
BT_UUID_DECLARE_16(BT_UUID_ECS_VAL)
/**
* @brief Authorization Control Service UUID value
*/
#define BT_UUID_ACLS_VAL 0x183d
/**
* @brief Authorization Control Service
*/
#define BT_UUID_ACLS \
BT_UUID_DECLARE_16(BT_UUID_ACLS_VAL)
/**
* @brief Physical Activity Monitor Service UUID value
*/
#define BT_UUID_PAMS_VAL 0x183e
/**
* @brief Physical Activity Monitor Service
*/
#define BT_UUID_PAMS \
BT_UUID_DECLARE_16(BT_UUID_PAMS_VAL)
/**
* @brief Audio Input Control Service UUID value
*/
#define BT_UUID_AICS_VAL 0x1843
/**
* @brief Audio Input Control Service
*/
#define BT_UUID_AICS \
BT_UUID_DECLARE_16(BT_UUID_AICS_VAL)
/**
* @brief Volume Control Service UUID value
*/
#define BT_UUID_VCS_VAL 0x1844
/**
* @brief Volume Control Service
*/
#define BT_UUID_VCS \
BT_UUID_DECLARE_16(BT_UUID_VCS_VAL)
/**
* @brief Volume Offset Control Service UUID value
*/
#define BT_UUID_VOCS_VAL 0x1845
/**
* @brief Volume Offset Control Service
*/
#define BT_UUID_VOCS \
BT_UUID_DECLARE_16(BT_UUID_VOCS_VAL)
/**
* @brief Coordinated Set Identification Service UUID value
*/
#define BT_UUID_CSIS_VAL 0x1846
/**
* @brief Coordinated Set Identification Service
*/
#define BT_UUID_CSIS \
BT_UUID_DECLARE_16(BT_UUID_CSIS_VAL)
/**
* @brief Device Time Service UUID value
*/
#define BT_UUID_DTS_VAL 0x1847
/**
* @brief Device Time Service
*/
#define BT_UUID_DTS \
BT_UUID_DECLARE_16(BT_UUID_DTS_VAL)
/**
* @brief Media Control Service UUID value
*/
#define BT_UUID_MCS_VAL 0x1848
/**
* @brief Media Control Service
*/
#define BT_UUID_MCS \
BT_UUID_DECLARE_16(BT_UUID_MCS_VAL)
/**
* @brief Generic Media Control Service UUID value
*/
#define BT_UUID_GMCS_VAL 0x1849
/**
* @brief Generic Media Control Service
*/
#define BT_UUID_GMCS \
BT_UUID_DECLARE_16(BT_UUID_GMCS_VAL)
/**
* @brief Constant Tone Extension Service UUID value
*/
#define BT_UUID_CTES_VAL 0x184a
/**
* @brief Constant Tone Extension Service
*/
#define BT_UUID_CTES \
BT_UUID_DECLARE_16(BT_UUID_CTES_VAL)
/**
* @brief Telephone Bearer Service UUID value
*/
#define BT_UUID_TBS_VAL 0x184b
/**
* @brief Telephone Bearer Service
*/
#define BT_UUID_TBS \
BT_UUID_DECLARE_16(BT_UUID_TBS_VAL)
/**
* @brief Generic Telephone Bearer Service UUID value
*/
#define BT_UUID_GTBS_VAL 0x184c
/**
* @brief Generic Telephone Bearer Service
*/
#define BT_UUID_GTBS \
BT_UUID_DECLARE_16(BT_UUID_GTBS_VAL)
/**
* @brief Microphone Control Service UUID value
*/
#define BT_UUID_MICS_VAL 0x184d
/**
* @brief Microphone Control Service
*/
#define BT_UUID_MICS \
BT_UUID_DECLARE_16(BT_UUID_MICS_VAL)
/**
* @brief Audio Stream Control Service UUID value
*/
#define BT_UUID_ASCS_VAL 0x184e
/**
* @brief Audio Stream Control Service
*/
#define BT_UUID_ASCS \
BT_UUID_DECLARE_16(BT_UUID_ASCS_VAL)
/**
* @brief Broadcast Audio Scan Service UUID value
*/
#define BT_UUID_BASS_VAL 0x184f
/**
* @brief Broadcast Audio Scan Service
*/
#define BT_UUID_BASS \
BT_UUID_DECLARE_16(BT_UUID_BASS_VAL)
/**
* @brief Published Audio Capabilities Service UUID value
*/
#define BT_UUID_PACS_VAL 0x1850
/**
* @brief Published Audio Capabilities Service
*/
#define BT_UUID_PACS \
BT_UUID_DECLARE_16(BT_UUID_PACS_VAL)
/**
* @brief Basic Audio Announcement Service UUID value
*/
#define BT_UUID_BASIC_AUDIO_VAL 0x1851
/**
* @brief Basic Audio Announcement Service
*/
#define BT_UUID_BASIC_AUDIO \
BT_UUID_DECLARE_16(BT_UUID_BASIC_AUDIO_VAL)
/**
* @brief Broadcast Audio Announcement Service UUID value
*/
#define BT_UUID_BROADCAST_AUDIO_VAL 0x1852
/**
* @brief Broadcast Audio Announcement Service
*/
#define BT_UUID_BROADCAST_AUDIO \
BT_UUID_DECLARE_16(BT_UUID_BROADCAST_AUDIO_VAL)
/**
* @brief Common Audio Service UUID value
*/
#define BT_UUID_CAS_VAL 0x1853
/**
* @brief Common Audio Service
*/
#define BT_UUID_CAS \
BT_UUID_DECLARE_16(BT_UUID_CAS_VAL)
/**
* @brief Hearing Access Service UUID value
*/
#define BT_UUID_HAS_VAL 0x1854
/**
* @brief Hearing Access Service
*/
#define BT_UUID_HAS \
BT_UUID_DECLARE_16(BT_UUID_HAS_VAL)
/**
* @brief Telephony and Media Audio Service UUID value
*/
#define BT_UUID_TMAS_VAL 0x1855
/**
* @brief Telephony and Media Audio Service
*/
#define BT_UUID_TMAS \
BT_UUID_DECLARE_16(BT_UUID_TMAS_VAL)
/**
* @brief Public Broadcast Announcement Service UUID value
*/
#define BT_UUID_PBA_VAL 0x1856
/**
* @brief Public Broadcast Announcement Service
*/
#define BT_UUID_PBA \
BT_UUID_DECLARE_16(BT_UUID_PBA_VAL)
/**
* @brief GATT Primary Service UUID value
*/
#define BT_UUID_GATT_PRIMARY_VAL 0x2800
/**
* @brief GATT Primary Service
*/
#define BT_UUID_GATT_PRIMARY \
BT_UUID_DECLARE_16(BT_UUID_GATT_PRIMARY_VAL)
/**
* @brief GATT Secondary Service UUID value
*/
#define BT_UUID_GATT_SECONDARY_VAL 0x2801
/**
* @brief GATT Secondary Service
*/
#define BT_UUID_GATT_SECONDARY \
BT_UUID_DECLARE_16(BT_UUID_GATT_SECONDARY_VAL)
/**
* @brief GATT Include Service UUID value
*/
#define BT_UUID_GATT_INCLUDE_VAL 0x2802
/**
* @brief GATT Include Service
*/
#define BT_UUID_GATT_INCLUDE \
BT_UUID_DECLARE_16(BT_UUID_GATT_INCLUDE_VAL)
/**
* @brief GATT Characteristic UUID value
*/
#define BT_UUID_GATT_CHRC_VAL 0x2803
/**
* @brief GATT Characteristic
*/
#define BT_UUID_GATT_CHRC \
BT_UUID_DECLARE_16(BT_UUID_GATT_CHRC_VAL)
/**
* @brief GATT Characteristic Extended Properties UUID value
*/
#define BT_UUID_GATT_CEP_VAL 0x2900
/**
* @brief GATT Characteristic Extended Properties
*/
#define BT_UUID_GATT_CEP \
BT_UUID_DECLARE_16(BT_UUID_GATT_CEP_VAL)
/**
* @brief GATT Characteristic User Description UUID value
*/
#define BT_UUID_GATT_CUD_VAL 0x2901
/**
* @brief GATT Characteristic User Description
*/
#define BT_UUID_GATT_CUD \
BT_UUID_DECLARE_16(BT_UUID_GATT_CUD_VAL)
/**
* @brief GATT Client Characteristic Configuration UUID value
*/
#define BT_UUID_GATT_CCC_VAL 0x2902
/**
* @brief GATT Client Characteristic Configuration
*/
#define BT_UUID_GATT_CCC \
BT_UUID_DECLARE_16(BT_UUID_GATT_CCC_VAL)
/**
* @brief GATT Server Characteristic Configuration UUID value
*/
#define BT_UUID_GATT_SCC_VAL 0x2903
/**
* @brief GATT Server Characteristic Configuration
*/
#define BT_UUID_GATT_SCC \
BT_UUID_DECLARE_16(BT_UUID_GATT_SCC_VAL)
/**
* @brief GATT Characteristic Presentation Format UUID value
*/
#define BT_UUID_GATT_CPF_VAL 0x2904
/**
* @brief GATT Characteristic Presentation Format
*/
#define BT_UUID_GATT_CPF \
BT_UUID_DECLARE_16(BT_UUID_GATT_CPF_VAL)
/**
* @brief GATT Characteristic Aggregated Format UUID value
*/
#define BT_UUID_GATT_CAF_VAL 0x2905
/**
* @brief GATT Characteristic Aggregated Format
*/
#define BT_UUID_GATT_CAF \
BT_UUID_DECLARE_16(BT_UUID_GATT_CAF_VAL)
/**
* @brief Valid Range Descriptor UUID value
*/
#define BT_UUID_VALID_RANGE_VAL 0x2906
/**
* @brief Valid Range Descriptor
*/
#define BT_UUID_VALID_RANGE \
BT_UUID_DECLARE_16(BT_UUID_VALID_RANGE_VAL)
/**
* @brief HID External Report Descriptor UUID value
*/
#define BT_UUID_HIDS_EXT_REPORT_VAL 0x2907
/**
* @brief HID External Report Descriptor
*/
#define BT_UUID_HIDS_EXT_REPORT \
BT_UUID_DECLARE_16(BT_UUID_HIDS_EXT_REPORT_VAL)
/**
* @brief HID Report Reference Descriptor UUID value
*/
#define BT_UUID_HIDS_REPORT_REF_VAL 0x2908
/**
* @brief HID Report Reference Descriptor
*/
#define BT_UUID_HIDS_REPORT_REF \
BT_UUID_DECLARE_16(BT_UUID_HIDS_REPORT_REF_VAL)
/**
* @brief Value Trigger Setting Descriptor UUID value
*/
#define BT_UUID_VAL_TRIGGER_SETTING_VAL 0x290a
/**
* @brief Value Trigger Setting Descriptor
*/
#define BT_UUID_VAL_TRIGGER_SETTING \
BT_UUID_DECLARE_16(BT_UUID_VAL_TRIGGER_SETTING_VAL)
/**
* @brief Environmental Sensing Configuration Descriptor UUID value
*/
#define BT_UUID_ES_CONFIGURATION_VAL 0x290b
/**
* @brief Environmental Sensing Configuration Descriptor
*/
#define BT_UUID_ES_CONFIGURATION \
BT_UUID_DECLARE_16(BT_UUID_ES_CONFIGURATION_VAL)
/**
* @brief Environmental Sensing Measurement Descriptor UUID value
*/
#define BT_UUID_ES_MEASUREMENT_VAL 0x290c
/**
* @brief Environmental Sensing Measurement Descriptor
*/
#define BT_UUID_ES_MEASUREMENT \
BT_UUID_DECLARE_16(BT_UUID_ES_MEASUREMENT_VAL)
/**
* @brief Environmental Sensing Trigger Setting Descriptor UUID value
*/
#define BT_UUID_ES_TRIGGER_SETTING_VAL 0x290d
/**
* @brief Environmental Sensing Trigger Setting Descriptor
*/
#define BT_UUID_ES_TRIGGER_SETTING \
BT_UUID_DECLARE_16(BT_UUID_ES_TRIGGER_SETTING_VAL)
/**
* @brief Time Trigger Setting Descriptor UUID value
*/
#define BT_UUID_TM_TRIGGER_SETTING_VAL 0x290e
/**
* @brief Time Trigger Setting Descriptor
*/
#define BT_UUID_TM_TRIGGER_SETTING \
BT_UUID_DECLARE_16(BT_UUID_TM_TRIGGER_SETTING_VAL)
/**
* @brief GAP Characteristic Device Name UUID value
*/
#define BT_UUID_GAP_DEVICE_NAME_VAL 0x2a00
/**
* @brief GAP Characteristic Device Name
*/
#define BT_UUID_GAP_DEVICE_NAME \
BT_UUID_DECLARE_16(BT_UUID_GAP_DEVICE_NAME_VAL)
/**
* @brief GAP Characteristic Appearance UUID value
*/
#define BT_UUID_GAP_APPEARANCE_VAL 0x2a01
/**
* @brief GAP Characteristic Appearance
*/
#define BT_UUID_GAP_APPEARANCE \
BT_UUID_DECLARE_16(BT_UUID_GAP_APPEARANCE_VAL)
/**
* @brief GAP Characteristic Peripheral Privacy Flag UUID value
*/
#define BT_UUID_GAP_PPF_VAL 0x2a02
/**
* @brief GAP Characteristic Peripheral Privacy Flag
*/
#define BT_UUID_GAP_PPF \
BT_UUID_DECLARE_16(BT_UUID_GAP_PPF_VAL)
/**
* @brief GAP Characteristic Reconnection Address UUID value
*/
#define BT_UUID_GAP_RA_VAL 0x2a03
/**
* @brief GAP Characteristic Reconnection Address
*/
#define BT_UUID_GAP_RA \
BT_UUID_DECLARE_16(BT_UUID_GAP_RA_VAL)
/**
* @brief GAP Characteristic Peripheral Preferred Connection Parameters UUID
* value
*/
#define BT_UUID_GAP_PPCP_VAL 0x2a04
/**
* @brief GAP Characteristic Peripheral Preferred Connection Parameters
*/
#define BT_UUID_GAP_PPCP \
BT_UUID_DECLARE_16(BT_UUID_GAP_PPCP_VAL)
/**
* @brief GATT Characteristic Service Changed UUID value
*/
#define BT_UUID_GATT_SC_VAL 0x2a05
/**
* @brief GATT Characteristic Service Changed
*/
#define BT_UUID_GATT_SC \
BT_UUID_DECLARE_16(BT_UUID_GATT_SC_VAL)
/**
* @brief GATT Characteristic Alert Level UUID value
*/
#define BT_UUID_ALERT_LEVEL_VAL 0x2a06
/**
* @brief GATT Characteristic Alert Level
*/
#define BT_UUID_ALERT_LEVEL \
BT_UUID_DECLARE_16(BT_UUID_ALERT_LEVEL_VAL)
/**
* @brief TPS Characteristic Tx Power Level UUID value
*/
#define BT_UUID_TPS_TX_POWER_LEVEL_VAL 0x2a07
/**
* @brief TPS Characteristic Tx Power Level
*/
#define BT_UUID_TPS_TX_POWER_LEVEL \
BT_UUID_DECLARE_16(BT_UUID_TPS_TX_POWER_LEVEL_VAL)
/**
* @brief GATT Characteristic Date Time UUID value
*/
#define BT_UUID_GATT_DT_VAL 0x2a08
/**
* @brief GATT Characteristic Date Time
*/
#define BT_UUID_GATT_DT \
BT_UUID_DECLARE_16(BT_UUID_GATT_DT_VAL)
/**
* @brief GATT Characteristic Day of Week UUID value
*/
#define BT_UUID_GATT_DW_VAL 0x2a09
/**
* @brief GATT Characteristic Day of Week
*/
#define BT_UUID_GATT_DW \
BT_UUID_DECLARE_16(BT_UUID_GATT_DW_VAL)
/**
* @brief GATT Characteristic Day Date Time UUID value
*/
#define BT_UUID_GATT_DDT_VAL 0x2a0a
/**
* @brief GATT Characteristic Day Date Time
*/
#define BT_UUID_GATT_DDT \
BT_UUID_DECLARE_16(BT_UUID_GATT_DDT_VAL)
/**
* @brief GATT Characteristic Exact Time 256 UUID value
*/
#define BT_UUID_GATT_ET256_VAL 0x2a0c
/**
* @brief GATT Characteristic Exact Time 256
*/
#define BT_UUID_GATT_ET256 \
BT_UUID_DECLARE_16(BT_UUID_GATT_ET256_VAL)
/**
* @brief GATT Characteristic DST Offset UUID value
*/
#define BT_UUID_GATT_DST_VAL 0x2a0d
/**
* @brief GATT Characteristic DST Offset
*/
#define BT_UUID_GATT_DST \
BT_UUID_DECLARE_16(BT_UUID_GATT_DST_VAL)
/**
* @brief GATT Characteristic Time Zone UUID value
*/
#define BT_UUID_GATT_TZ_VAL 0x2a0e
/**
* @brief GATT Characteristic Time Zone
*/
#define BT_UUID_GATT_TZ \
BT_UUID_DECLARE_16(BT_UUID_GATT_TZ_VAL)
/**
* @brief GATT Characteristic Local Time Information UUID value
*/
#define BT_UUID_GATT_LTI_VAL 0x2a0f
/**
* @brief GATT Characteristic Local Time Information
*/
#define BT_UUID_GATT_LTI \
BT_UUID_DECLARE_16(BT_UUID_GATT_LTI_VAL)
/**
* @brief GATT Characteristic Time with DST UUID value
*/
#define BT_UUID_GATT_TDST_VAL 0x2a11
/**
* @brief GATT Characteristic Time with DST
*/
#define BT_UUID_GATT_TDST \
BT_UUID_DECLARE_16(BT_UUID_GATT_TDST_VAL)
/**
* @brief GATT Characteristic Time Accuracy UUID value
*/
#define BT_UUID_GATT_TA_VAL 0x2a12
/**
* @brief GATT Characteristic Time Accuracy
*/
#define BT_UUID_GATT_TA \
BT_UUID_DECLARE_16(BT_UUID_GATT_TA_VAL)
/**
* @brief GATT Characteristic Time Source UUID value
*/
#define BT_UUID_GATT_TS_VAL 0x2a13
/**
* @brief GATT Characteristic Time Source
*/
#define BT_UUID_GATT_TS \
BT_UUID_DECLARE_16(BT_UUID_GATT_TS_VAL)
/**
* @brief GATT Characteristic Reference Time Information UUID value
*/
#define BT_UUID_GATT_RTI_VAL 0x2a14
/**
* @brief GATT Characteristic Reference Time Information
*/
#define BT_UUID_GATT_RTI \
BT_UUID_DECLARE_16(BT_UUID_GATT_RTI_VAL)
/**
* @brief GATT Characteristic Time Update Control Point UUID value
*/
#define BT_UUID_GATT_TUCP_VAL 0x2a16
/**
* @brief GATT Characteristic Time Update Control Point
*/
#define BT_UUID_GATT_TUCP \
BT_UUID_DECLARE_16(BT_UUID_GATT_TUCP_VAL)
/**
* @brief GATT Characteristic Time Update State UUID value
*/
#define BT_UUID_GATT_TUS_VAL 0x2a17
/**
* @brief GATT Characteristic Time Update State
*/
#define BT_UUID_GATT_TUS \
BT_UUID_DECLARE_16(BT_UUID_GATT_TUS_VAL)
/**
* @brief GATT Characteristic Glucose Measurement UUID value
*/
#define BT_UUID_GATT_GM_VAL 0x2a18
/**
* @brief GATT Characteristic Glucose Measurement
*/
#define BT_UUID_GATT_GM \
BT_UUID_DECLARE_16(BT_UUID_GATT_GM_VAL)
/**
* @brief BAS Characteristic Battery Level UUID value
*/
#define BT_UUID_BAS_BATTERY_LEVEL_VAL 0x2a19
/**
* @brief BAS Characteristic Battery Level
*/
#define BT_UUID_BAS_BATTERY_LEVEL \
BT_UUID_DECLARE_16(BT_UUID_BAS_BATTERY_LEVEL_VAL)
/**
* @brief BAS Characteristic Battery Power State UUID value
*/
#define BT_UUID_BAS_BATTERY_POWER_STATE_VAL 0x2a1a
/**
* @brief BAS Characteristic Battery Power State
*/
#define BT_UUID_BAS_BATTERY_POWER_STATE \
BT_UUID_DECLARE_16(BT_UUID_BAS_BATTERY_POWER_STATE_VAL)
/**
* @brief BAS Characteristic Battery Level StateUUID value
*/
#define BT_UUID_BAS_BATTERY_LEVEL_STATE_VAL 0x2a1b
/**
* @brief BAS Characteristic Battery Level State
*/
#define BT_UUID_BAS_BATTERY_LEVEL_STATE \
BT_UUID_DECLARE_16(BT_UUID_BAS_BATTERY_LEVEL_STATE_VAL)
/**
* @brief HTS Characteristic Temperature Measurement UUID value
*/
#define BT_UUID_HTS_MEASUREMENT_VAL 0x2a1c
/**
* @brief HTS Characteristic Temperature Measurement Value
*/
#define BT_UUID_HTS_MEASUREMENT \
BT_UUID_DECLARE_16(BT_UUID_HTS_MEASUREMENT_VAL)
/**
* @brief HTS Characteristic Temperature Type UUID value
*/
#define BT_UUID_HTS_TEMP_TYP_VAL 0x2a1d
/**
* @brief HTS Characteristic Temperature Type
*/
#define BT_UUID_HTS_TEMP_TYP \
BT_UUID_DECLARE_16(BT_UUID_HTS_TEMP_TYP_VAL)
/**
* @brief HTS Characteristic Intermediate Temperature UUID value
*/
#define BT_UUID_HTS_TEMP_INT_VAL 0x2a1e
/**
* @brief HTS Characteristic Intermediate Temperature
*/
#define BT_UUID_HTS_TEMP_INT \
BT_UUID_DECLARE_16(BT_UUID_HTS_TEMP_INT_VAL)
/**
* @brief HTS Characteristic Temperature Celsius UUID value
*/
#define BT_UUID_HTS_TEMP_C_VAL 0x2a1f
/**
* @brief HTS Characteristic Temperature Celsius
*/
#define BT_UUID_HTS_TEMP_C \
BT_UUID_DECLARE_16(BT_UUID_HTS_TEMP_C_VAL)
/**
* @brief HTS Characteristic Temperature Fahrenheit UUID value
*/
#define BT_UUID_HTS_TEMP_F_VAL 0x2a20
/**
* @brief HTS Characteristic Temperature Fahrenheit
*/
#define BT_UUID_HTS_TEMP_F \
BT_UUID_DECLARE_16(BT_UUID_HTS_TEMP_F_VAL)
/**
* @brief HTS Characteristic Measurement Interval UUID value
*/
#define BT_UUID_HTS_INTERVAL_VAL 0x2a21
/**
* @brief HTS Characteristic Measurement Interval
*/
#define BT_UUID_HTS_INTERVAL \
BT_UUID_DECLARE_16(BT_UUID_HTS_INTERVAL_VAL)
/**
* @brief HID Characteristic Boot Keyboard Input Report UUID value
*/
#define BT_UUID_HIDS_BOOT_KB_IN_REPORT_VAL 0x2a22
/**
* @brief HID Characteristic Boot Keyboard Input Report
*/
#define BT_UUID_HIDS_BOOT_KB_IN_REPORT \
BT_UUID_DECLARE_16(BT_UUID_HIDS_BOOT_KB_IN_REPORT_VAL)
/**
* @brief DIS Characteristic System ID UUID value
*/
#define BT_UUID_DIS_SYSTEM_ID_VAL 0x2a23
/**
* @brief DIS Characteristic System ID
*/
#define BT_UUID_DIS_SYSTEM_ID \
BT_UUID_DECLARE_16(BT_UUID_DIS_SYSTEM_ID_VAL)
/**
* @brief DIS Characteristic Model Number String UUID value
*/
#define BT_UUID_DIS_MODEL_NUMBER_VAL 0x2a24
/**
* @brief DIS Characteristic Model Number String
*/
#define BT_UUID_DIS_MODEL_NUMBER \
BT_UUID_DECLARE_16(BT_UUID_DIS_MODEL_NUMBER_VAL)
/**
* @brief DIS Characteristic Serial Number String UUID value
*/
#define BT_UUID_DIS_SERIAL_NUMBER_VAL 0x2a25
/**
* @brief DIS Characteristic Serial Number String
*/
#define BT_UUID_DIS_SERIAL_NUMBER \
BT_UUID_DECLARE_16(BT_UUID_DIS_SERIAL_NUMBER_VAL)
/**
* @brief DIS Characteristic Firmware Revision String UUID value
*/
#define BT_UUID_DIS_FIRMWARE_REVISION_VAL 0x2a26
/**
* @brief DIS Characteristic Firmware Revision String
*/
#define BT_UUID_DIS_FIRMWARE_REVISION \
BT_UUID_DECLARE_16(BT_UUID_DIS_FIRMWARE_REVISION_VAL)
/**
* @brief DIS Characteristic Hardware Revision String UUID value
*/
#define BT_UUID_DIS_HARDWARE_REVISION_VAL 0x2a27
/**
* @brief DIS Characteristic Hardware Revision String
*/
#define BT_UUID_DIS_HARDWARE_REVISION \
BT_UUID_DECLARE_16(BT_UUID_DIS_HARDWARE_REVISION_VAL)
/**
* @brief DIS Characteristic Software Revision String UUID value
*/
#define BT_UUID_DIS_SOFTWARE_REVISION_VAL 0x2a28
/**
* @brief DIS Characteristic Software Revision String
*/
#define BT_UUID_DIS_SOFTWARE_REVISION \
BT_UUID_DECLARE_16(BT_UUID_DIS_SOFTWARE_REVISION_VAL)
/**
* @brief DIS Characteristic Manufacturer Name String UUID Value
*/
#define BT_UUID_DIS_MANUFACTURER_NAME_VAL 0x2a29
/**
* @brief DIS Characteristic Manufacturer Name String
*/
#define BT_UUID_DIS_MANUFACTURER_NAME \
BT_UUID_DECLARE_16(BT_UUID_DIS_MANUFACTURER_NAME_VAL)
/**
* @brief GATT Characteristic IEEE Regulatory Certification Data List UUID Value
*/
#define BT_UUID_GATT_IEEE_RCDL_VAL 0x2a2a
/**
* @brief GATT Characteristic IEEE Regulatory Certification Data List
*/
#define BT_UUID_GATT_IEEE_RCDL \
BT_UUID_DECLARE_16(BT_UUID_GATT_IEEE_RCDL_VAL)
/**
* @brief CTS Characteristic Current Time UUID value
*/
#define BT_UUID_CTS_CURRENT_TIME_VAL 0x2a2b
/**
* @brief CTS Characteristic Current Time
*/
#define BT_UUID_CTS_CURRENT_TIME \
BT_UUID_DECLARE_16(BT_UUID_CTS_CURRENT_TIME_VAL)
/**
* @brief Magnetic Declination Characteristic UUID value
*/
#define BT_UUID_MAGN_DECLINATION_VAL 0x2a2c
/**
* @brief Magnetic Declination Characteristic
*/
#define BT_UUID_MAGN_DECLINATION \
BT_UUID_DECLARE_16(BT_UUID_MAGN_DECLINATION_VAL)
/**
* @brief GATT Characteristic Legacy Latitude UUID Value
*/
#define BT_UUID_GATT_LLAT_VAL 0x2a2d
/**
* @brief GATT Characteristic Legacy Latitude
*/
#define BT_UUID_GATT_LLAT \
BT_UUID_DECLARE_16(BT_UUID_GATT_LLAT_VAL)
/**
* @brief GATT Characteristic Legacy Longitude UUID Value
*/
#define BT_UUID_GATT_LLON_VAL 0x2a2e
/**
* @brief GATT Characteristic Legacy Longitude
*/
#define BT_UUID_GATT_LLON \
BT_UUID_DECLARE_16(BT_UUID_GATT_LLON_VAL)
/**
* @brief GATT Characteristic Position 2D UUID Value
*/
#define BT_UUID_GATT_POS_2D_VAL 0x2a2f
/**
* @brief GATT Characteristic Position 2D
*/
#define BT_UUID_GATT_POS_2D \
BT_UUID_DECLARE_16(BT_UUID_GATT_POS_2D_VAL)
/**
* @brief GATT Characteristic Position 3D UUID Value
*/
#define BT_UUID_GATT_POS_3D_VAL 0x2a30
/**
* @brief GATT Characteristic Position 3D
*/
#define BT_UUID_GATT_POS_3D \
BT_UUID_DECLARE_16(BT_UUID_GATT_POS_3D_VAL)
/**
* @brief GATT Characteristic Scan Refresh UUID Value
*/
#define BT_UUID_GATT_SR_VAL 0x2a31
/**
* @brief GATT Characteristic Scan Refresh
*/
#define BT_UUID_GATT_SR \
BT_UUID_DECLARE_16(BT_UUID_GATT_SR_VAL)
/**
* @brief HID Boot Keyboard Output Report Characteristic UUID value
*/
#define BT_UUID_HIDS_BOOT_KB_OUT_REPORT_VAL 0x2a32
/**
* @brief HID Boot Keyboard Output Report Characteristic
*/
#define BT_UUID_HIDS_BOOT_KB_OUT_REPORT \
BT_UUID_DECLARE_16(BT_UUID_HIDS_BOOT_KB_OUT_REPORT_VAL)
/**
* @brief HID Boot Mouse Input Report Characteristic UUID value
*/
#define BT_UUID_HIDS_BOOT_MOUSE_IN_REPORT_VAL 0x2a33
/**
* @brief HID Boot Mouse Input Report Characteristic
*/
#define BT_UUID_HIDS_BOOT_MOUSE_IN_REPORT \
BT_UUID_DECLARE_16(BT_UUID_HIDS_BOOT_MOUSE_IN_REPORT_VAL)
/**
* @brief GATT Characteristic Glucose Measurement Context UUID Value
*/
#define BT_UUID_GATT_GMC_VAL 0x2a34
/**
* @brief GATT Characteristic Glucose Measurement Context
*/
#define BT_UUID_GATT_GMC \
BT_UUID_DECLARE_16(BT_UUID_GATT_GMC_VAL)
/**
* @brief GATT Characteristic Blood Pressure Measurement UUID Value
*/
#define BT_UUID_GATT_BPM_VAL 0x2a35
/**
* @brief GATT Characteristic Blood Pressure Measurement
*/
#define BT_UUID_GATT_BPM \
BT_UUID_DECLARE_16(BT_UUID_GATT_BPM_VAL)
/**
* @brief GATT Characteristic Intermediate Cuff Pressure UUID Value
*/
#define BT_UUID_GATT_ICP_VAL 0x2a36
/**
* @brief GATT Characteristic Intermediate Cuff Pressure
*/
#define BT_UUID_GATT_ICP \
BT_UUID_DECLARE_16(BT_UUID_GATT_ICP_VAL)
/**
* @brief HRS Characteristic Measurement Interval UUID value
*/
#define BT_UUID_HRS_MEASUREMENT_VAL 0x2a37
/**
* @brief HRS Characteristic Measurement Interval
*/
#define BT_UUID_HRS_MEASUREMENT \
BT_UUID_DECLARE_16(BT_UUID_HRS_MEASUREMENT_VAL)
/**
* @brief HRS Characteristic Body Sensor Location
*/
#define BT_UUID_HRS_BODY_SENSOR_VAL 0x2a38
/**
* @brief HRS Characteristic Control Point
*/
#define BT_UUID_HRS_BODY_SENSOR \
BT_UUID_DECLARE_16(BT_UUID_HRS_BODY_SENSOR_VAL)
/**
* @brief HRS Characteristic Control Point UUID value
*/
#define BT_UUID_HRS_CONTROL_POINT_VAL 0x2a39
/**
* @brief HRS Characteristic Control Point
*/
#define BT_UUID_HRS_CONTROL_POINT \
BT_UUID_DECLARE_16(BT_UUID_HRS_CONTROL_POINT_VAL)
/**
* @brief GATT Characteristic Removable UUID Value
*/
#define BT_UUID_GATT_REM_VAL 0x2a3a
/**
* @brief GATT Characteristic Removable
*/
#define BT_UUID_GATT_REM \
BT_UUID_DECLARE_16(BT_UUID_GATT_REM_VAL)
/**
* @brief GATT Characteristic Service Required UUID Value
*/
#define BT_UUID_GATT_SRVREQ_VAL 0x2a3b
/**
* @brief GATT Characteristic Service Required
*/
#define BT_UUID_GATT_SRVREQ \
BT_UUID_DECLARE_16(BT_UUID_GATT_SRVREQ_VAL)
/**
* @brief GATT Characteristic Scientific Temperature in Celsius UUID Value
*/
#define BT_UUID_GATT_SC_TEMP_C_VAL 0x2a3c
/**
* @brief GATT Characteristic Scientific Temperature in Celsius
*/
#define BT_UUID_GATT_SC_TEMP_C \
BT_UUID_DECLARE_16(BT_UUID_GATT_SC_TEMP_C_VAL)
/**
* @brief GATT Characteristic String UUID Value
*/
#define BT_UUID_GATT_STRING_VAL 0x2a3d
/**
* @brief GATT Characteristic String
*/
#define BT_UUID_GATT_STRING \
BT_UUID_DECLARE_16(BT_UUID_GATT_STRING_VAL)
/**
* @brief GATT Characteristic Network Availability UUID Value
*/
#define BT_UUID_GATT_NETA_VAL 0x2a3e
/**
* @brief GATT Characteristic Network Availability
*/
#define BT_UUID_GATT_NETA \
BT_UUID_DECLARE_16(BT_UUID_GATT_NETA_VAL)
/**
* @brief GATT Characteristic Alert Status UUID Value
*/
#define BT_UUID_GATT_ALRTS_VAL 0x2a3f
/**
* @brief GATT Characteristic Alert Status
*/
#define BT_UUID_GATT_ALRTS \
BT_UUID_DECLARE_16(BT_UUID_GATT_ALRTS_VAL)
/**
* @brief GATT Characteristic Ringer Control Point UUID Value
*/
#define BT_UUID_GATT_RCP_VAL 0x2a40
/**
* @brief GATT Characteristic Ringer Control Point
*/
#define BT_UUID_GATT_RCP \
BT_UUID_DECLARE_16(BT_UUID_GATT_RCP_VAL)
/**
* @brief GATT Characteristic Ringer Setting UUID Value
*/
#define BT_UUID_GATT_RS_VAL 0x2a41
/**
* @brief GATT Characteristic Ringer Setting
*/
#define BT_UUID_GATT_RS \
BT_UUID_DECLARE_16(BT_UUID_GATT_RS_VAL)
/**
* @brief GATT Characteristic Alert Category ID Bit Mask UUID Value
*/
#define BT_UUID_GATT_ALRTCID_MASK_VAL 0x2a42
/**
* @brief GATT Characteristic Alert Category ID Bit Mask
*/
#define BT_UUID_GATT_ALRTCID_MASK \
BT_UUID_DECLARE_16(BT_UUID_GATT_ALRTCID_MASK_VAL)
/**
* @brief GATT Characteristic Alert Category ID UUID Value
*/
#define BT_UUID_GATT_ALRTCID_VAL 0x2a43
/**
* @brief GATT Characteristic Alert Category ID
*/
#define BT_UUID_GATT_ALRTCID \
BT_UUID_DECLARE_16(BT_UUID_GATT_ALRTCID_VAL)
/**
* @brief GATT Characteristic Alert Notification Control Point Value
*/
#define BT_UUID_GATT_ALRTNCP_VAL 0x2a44
/**
* @brief GATT Characteristic Alert Notification Control Point
*/
#define BT_UUID_GATT_ALRTNCP \
BT_UUID_DECLARE_16(BT_UUID_GATT_ALRTNCP_VAL)
/**
* @brief GATT Characteristic Unread Alert Status UUID Value
*/
#define BT_UUID_GATT_UALRTS_VAL 0x2a45
/**
* @brief GATT Characteristic Unread Alert Status
*/
#define BT_UUID_GATT_UALRTS \
BT_UUID_DECLARE_16(BT_UUID_GATT_UALRTS_VAL)
/**
* @brief GATT Characteristic New Alert UUID Value
*/
#define BT_UUID_GATT_NALRT_VAL 0x2a46
/**
* @brief GATT Characteristic New Alert
*/
#define BT_UUID_GATT_NALRT \
BT_UUID_DECLARE_16(BT_UUID_GATT_NALRT_VAL)
/**
* @brief GATT Characteristic Supported New Alert Category UUID Value
*/
#define BT_UUID_GATT_SNALRTC_VAL 0x2a47
/**
* @brief GATT Characteristic Supported New Alert Category
*/
#define BT_UUID_GATT_SNALRTC \
BT_UUID_DECLARE_16(BT_UUID_GATT_SNALRTC_VAL)
/**
* @brief GATT Characteristic Supported Unread Alert Category UUID Value
*/
#define BT_UUID_GATT_SUALRTC_VAL 0x2a48
/**
* @brief GATT Characteristic Supported Unread Alert Category
*/
#define BT_UUID_GATT_SUALRTC \
BT_UUID_DECLARE_16(BT_UUID_GATT_SUALRTC_VAL)
/**
* @brief GATT Characteristic Blood Pressure Feature UUID Value
*/
#define BT_UUID_GATT_BPF_VAL 0x2a49
/**
* @brief GATT Characteristic Blood Pressure Feature
*/
#define BT_UUID_GATT_BPF \
BT_UUID_DECLARE_16(BT_UUID_GATT_BPF_VAL)
/**
* @brief HID Information Characteristic UUID value
*/
#define BT_UUID_HIDS_INFO_VAL 0x2a4a
/**
* @brief HID Information Characteristic
*/
#define BT_UUID_HIDS_INFO \
BT_UUID_DECLARE_16(BT_UUID_HIDS_INFO_VAL)
/**
* @brief HID Report Map Characteristic UUID value
*/
#define BT_UUID_HIDS_REPORT_MAP_VAL 0x2a4b
/**
* @brief HID Report Map Characteristic
*/
#define BT_UUID_HIDS_REPORT_MAP \
BT_UUID_DECLARE_16(BT_UUID_HIDS_REPORT_MAP_VAL)
/**
* @brief HID Control Point Characteristic UUID value
*/
#define BT_UUID_HIDS_CTRL_POINT_VAL 0x2a4c
/**
* @brief HID Control Point Characteristic
*/
#define BT_UUID_HIDS_CTRL_POINT \
BT_UUID_DECLARE_16(BT_UUID_HIDS_CTRL_POINT_VAL)
/**
* @brief HID Report Characteristic UUID value
*/
#define BT_UUID_HIDS_REPORT_VAL 0x2a4d
/**
* @brief HID Report Characteristic
*/
#define BT_UUID_HIDS_REPORT \
BT_UUID_DECLARE_16(BT_UUID_HIDS_REPORT_VAL)
/**
* @brief HID Protocol Mode Characteristic UUID value
*/
#define BT_UUID_HIDS_PROTOCOL_MODE_VAL 0x2a4e
/**
* @brief HID Protocol Mode Characteristic
*/
#define BT_UUID_HIDS_PROTOCOL_MODE \
BT_UUID_DECLARE_16(BT_UUID_HIDS_PROTOCOL_MODE_VAL)
/**
* @brief GATT Characteristic Scan Interval Windows UUID Value
*/
#define BT_UUID_GATT_SIW_VAL 0x2a4f
/**
* @brief GATT Characteristic Scan Interval Windows
*/
#define BT_UUID_GATT_SIW \
BT_UUID_DECLARE_16(BT_UUID_GATT_SIW_VAL)
/**
* @brief DIS Characteristic PnP ID UUID value
*/
#define BT_UUID_DIS_PNP_ID_VAL 0x2a50
/**
* @brief DIS Characteristic PnP ID
*/
#define BT_UUID_DIS_PNP_ID \
BT_UUID_DECLARE_16(BT_UUID_DIS_PNP_ID_VAL)
/**
* @brief GATT Characteristic Glucose Feature UUID Value
*/
#define BT_UUID_GATT_GF_VAL 0x2a51
/**
* @brief GATT Characteristic Glucose Feature
*/
#define BT_UUID_GATT_GF \
BT_UUID_DECLARE_16(BT_UUID_GATT_GF_VAL)
/**
* @brief Record Access Control Point Characteristic value
*/
#define BT_UUID_RECORD_ACCESS_CONTROL_POINT_VAL 0x2a52
/**
* @brief Record Access Control Point
*/
#define BT_UUID_RECORD_ACCESS_CONTROL_POINT \
BT_UUID_DECLARE_16(BT_UUID_RECORD_ACCESS_CONTROL_POINT_VAL)
/**
* @brief RSC Measurement Characteristic UUID value
*/
#define BT_UUID_RSC_MEASUREMENT_VAL 0x2a53
/**
* @brief RSC Measurement Characteristic
*/
#define BT_UUID_RSC_MEASUREMENT \
BT_UUID_DECLARE_16(BT_UUID_RSC_MEASUREMENT_VAL)
/**
* @brief RSC Feature Characteristic UUID value
*/
#define BT_UUID_RSC_FEATURE_VAL 0x2a54
/**
* @brief RSC Feature Characteristic
*/
#define BT_UUID_RSC_FEATURE \
BT_UUID_DECLARE_16(BT_UUID_RSC_FEATURE_VAL)
/**
* @brief SC Control Point Characteristic UUID value
*/
#define BT_UUID_SC_CONTROL_POINT_VAL 0x2a55
/**
* @brief SC Control Point Characteristic
*/
#define BT_UUID_SC_CONTROL_POINT \
BT_UUID_DECLARE_16(BT_UUID_SC_CONTROL_POINT_VAL)
/**
* @brief GATT Characteristic Digital Input UUID Value
*/
#define BT_UUID_GATT_DI_VAL 0x2a56
/**
* @brief GATT Characteristic Digital Input
*/
#define BT_UUID_GATT_DI \
BT_UUID_DECLARE_16(BT_UUID_GATT_DI_VAL)
/**
* @brief GATT Characteristic Digital Output UUID Value
*/
#define BT_UUID_GATT_DO_VAL 0x2a57
/**
* @brief GATT Characteristic Digital Output
*/
#define BT_UUID_GATT_DO \
BT_UUID_DECLARE_16(BT_UUID_GATT_DO_VAL)
/**
* @brief GATT Characteristic Analog Input UUID Value
*/
#define BT_UUID_GATT_AI_VAL 0x2a58
/**
* @brief GATT Characteristic Analog Input
*/
#define BT_UUID_GATT_AI \
BT_UUID_DECLARE_16(BT_UUID_GATT_AI_VAL)
/**
* @brief GATT Characteristic Analog Output UUID Value
*/
#define BT_UUID_GATT_AO_VAL 0x2a59
/**
* @brief GATT Characteristic Analog Output
*/
#define BT_UUID_GATT_AO \
BT_UUID_DECLARE_16(BT_UUID_GATT_AO_VAL)
/**
* @brief GATT Characteristic Aggregate UUID Value
*/
#define BT_UUID_GATT_AGGR_VAL 0x2a5a
/**
* @brief GATT Characteristic Aggregate
*/
#define BT_UUID_GATT_AGGR \
BT_UUID_DECLARE_16(BT_UUID_GATT_AGGR_VAL)
/**
* @brief CSC Measurement Characteristic UUID value
*/
#define BT_UUID_CSC_MEASUREMENT_VAL 0x2a5b
/**
* @brief CSC Measurement Characteristic
*/
#define BT_UUID_CSC_MEASUREMENT \
BT_UUID_DECLARE_16(BT_UUID_CSC_MEASUREMENT_VAL)
/**
* @brief CSC Feature Characteristic UUID value
*/
#define BT_UUID_CSC_FEATURE_VAL 0x2a5c
/**
* @brief CSC Feature Characteristic
*/
#define BT_UUID_CSC_FEATURE \
BT_UUID_DECLARE_16(BT_UUID_CSC_FEATURE_VAL)
/**
* @brief Sensor Location Characteristic UUID value
*/
#define BT_UUID_SENSOR_LOCATION_VAL 0x2a5d
/**
* @brief Sensor Location Characteristic
*/
#define BT_UUID_SENSOR_LOCATION \
BT_UUID_DECLARE_16(BT_UUID_SENSOR_LOCATION_VAL)
/**
* @brief GATT Characteristic PLX Spot-Check Measurement UUID Value
*/
#define BT_UUID_GATT_PLX_SCM_VAL 0x2a5e
/**
* @brief GATT Characteristic PLX Spot-Check Measurement
*/
#define BT_UUID_GATT_PLX_SCM \
BT_UUID_DECLARE_16(BT_UUID_GATT_PLX_SCM_VAL)
/**
* @brief GATT Characteristic PLX Continuous Measurement UUID Value
*/
#define BT_UUID_GATT_PLX_CM_VAL 0x2a5f
/**
* @brief GATT Characteristic PLX Continuous Measurement
*/
#define BT_UUID_GATT_PLX_CM \
BT_UUID_DECLARE_16(BT_UUID_GATT_PLX_CM_VAL)
/**
* @brief GATT Characteristic PLX Features UUID Value
*/
#define BT_UUID_GATT_PLX_F_VAL 0x2a60
/**
* @brief GATT Characteristic PLX Features
*/
#define BT_UUID_GATT_PLX_F \
BT_UUID_DECLARE_16(BT_UUID_GATT_PLX_F_VAL)
/**
* @brief GATT Characteristic Pulse Oximetry Pulastile Event UUID Value
*/
#define BT_UUID_GATT_POPE_VAL 0x2a61
/**
* @brief GATT Characteristic Pulse Oximetry Pulsatile Event
*/
#define BT_UUID_GATT_POPE \
BT_UUID_DECLARE_16(BT_UUID_GATT_POPE_VAL)
/**
* @brief GATT Characteristic Pulse Oximetry Control Point UUID Value
*/
#define BT_UUID_GATT_POCP_VAL 0x2a62
/**
* @brief GATT Characteristic Pulse Oximetry Control Point
*/
#define BT_UUID_GATT_POCP \
BT_UUID_DECLARE_16(BT_UUID_GATT_POCP_VAL)
/**
* @brief GATT Characteristic Cycling Power Measurement UUID Value
*/
#define BT_UUID_GATT_CPS_CPM_VAL 0x2a63
/**
* @brief GATT Characteristic Cycling Power Measurement
*/
#define BT_UUID_GATT_CPS_CPM \
BT_UUID_DECLARE_16(BT_UUID_GATT_CPS_CPM_VAL)
/**
* @brief GATT Characteristic Cycling Power Vector UUID Value
*/
#define BT_UUID_GATT_CPS_CPV_VAL 0x2a64
/**
* @brief GATT Characteristic Cycling Power Vector
*/
#define BT_UUID_GATT_CPS_CPV \
BT_UUID_DECLARE_16(BT_UUID_GATT_CPS_CPV_VAL)
/**
* @brief GATT Characteristic Cycling Power Feature UUID Value
*/
#define BT_UUID_GATT_CPS_CPF_VAL 0x2a65
/**
* @brief GATT Characteristic Cycling Power Feature
*/
#define BT_UUID_GATT_CPS_CPF \
BT_UUID_DECLARE_16(BT_UUID_GATT_CPS_CPF_VAL)
/**
* @brief GATT Characteristic Cycling Power Control Point UUID Value
*/
#define BT_UUID_GATT_CPS_CPCP_VAL 0x2a66
/**
* @brief GATT Characteristic Cycling Power Control Point
*/
#define BT_UUID_GATT_CPS_CPCP \
BT_UUID_DECLARE_16(BT_UUID_GATT_CPS_CPCP_VAL)
/**
* @brief GATT Characteristic Location and Speed UUID Value
*/
#define BT_UUID_GATT_LOC_SPD_VAL 0x2a67
/**
* @brief GATT Characteristic Location and Speed
*/
#define BT_UUID_GATT_LOC_SPD \
BT_UUID_DECLARE_16(BT_UUID_GATT_LOC_SPD_VAL)
/**
* @brief GATT Characteristic Navigation UUID Value
*/
#define BT_UUID_GATT_NAV_VAL 0x2a68
/**
* @brief GATT Characteristic Navigation
*/
#define BT_UUID_GATT_NAV \
BT_UUID_DECLARE_16(BT_UUID_GATT_NAV_VAL)
/**
* @brief GATT Characteristic Position Quality UUID Value
*/
#define BT_UUID_GATT_PQ_VAL 0x2a69
/**
* @brief GATT Characteristic Position Quality
*/
#define BT_UUID_GATT_PQ \
BT_UUID_DECLARE_16(BT_UUID_GATT_PQ_VAL)
/**
* @brief GATT Characteristic LN Feature UUID Value
*/
#define BT_UUID_GATT_LNF_VAL 0x2a6a
/**
* @brief GATT Characteristic LN Feature
*/
#define BT_UUID_GATT_LNF \
BT_UUID_DECLARE_16(BT_UUID_GATT_LNF_VAL)
/**
* @brief GATT Characteristic LN Control Point UUID Value
*/
#define BT_UUID_GATT_LNCP_VAL 0x2a6b
/**
* @brief GATT Characteristic LN Control Point
*/
#define BT_UUID_GATT_LNCP \
BT_UUID_DECLARE_16(BT_UUID_GATT_LNCP_VAL)
/**
* @brief Elevation Characteristic UUID value
*/
#define BT_UUID_ELEVATION_VAL 0x2a6c
/**
* @brief Elevation Characteristic
*/
#define BT_UUID_ELEVATION \
BT_UUID_DECLARE_16(BT_UUID_ELEVATION_VAL)
/**
* @brief Pressure Characteristic UUID value
*/
#define BT_UUID_PRESSURE_VAL 0x2a6d
/**
* @brief Pressure Characteristic
*/
#define BT_UUID_PRESSURE \
BT_UUID_DECLARE_16(BT_UUID_PRESSURE_VAL)
/**
* @brief Temperature Characteristic UUID value
*/
#define BT_UUID_TEMPERATURE_VAL 0x2a6e
/**
* @brief Temperature Characteristic
*/
#define BT_UUID_TEMPERATURE \
BT_UUID_DECLARE_16(BT_UUID_TEMPERATURE_VAL)
/**
* @brief Humidity Characteristic UUID value
*/
#define BT_UUID_HUMIDITY_VAL 0x2a6f
/**
* @brief Humidity Characteristic
*/
#define BT_UUID_HUMIDITY \
BT_UUID_DECLARE_16(BT_UUID_HUMIDITY_VAL)
/**
* @brief True Wind Speed Characteristic UUID value
*/
#define BT_UUID_TRUE_WIND_SPEED_VAL 0x2a70
/**
* @brief True Wind Speed Characteristic
*/
#define BT_UUID_TRUE_WIND_SPEED \
BT_UUID_DECLARE_16(BT_UUID_TRUE_WIND_SPEED_VAL)
/**
* @brief True Wind Direction Characteristic UUID value
*/
#define BT_UUID_TRUE_WIND_DIR_VAL 0x2a71
/**
* @brief True Wind Direction Characteristic
*/
#define BT_UUID_TRUE_WIND_DIR \
BT_UUID_DECLARE_16(BT_UUID_TRUE_WIND_DIR_VAL)
/**
* @brief Apparent Wind Speed Characteristic UUID value
*/
#define BT_UUID_APPARENT_WIND_SPEED_VAL 0x2a72
/**
* @brief Apparent Wind Speed Characteristic
*/
#define BT_UUID_APPARENT_WIND_SPEED \
BT_UUID_DECLARE_16(BT_UUID_APPARENT_WIND_SPEED_VAL)
/**
* @brief Apparent Wind Direction Characteristic UUID value
*/
#define BT_UUID_APPARENT_WIND_DIR_VAL 0x2a73
/**
* @brief Apparent Wind Direction Characteristic
*/
#define BT_UUID_APPARENT_WIND_DIR \
BT_UUID_DECLARE_16(BT_UUID_APPARENT_WIND_DIR_VAL)
/**
* @brief Gust Factor Characteristic UUID value
*/
#define BT_UUID_GUST_FACTOR_VAL 0x2a74
/**
* @brief Gust Factor Characteristic
*/
#define BT_UUID_GUST_FACTOR \
BT_UUID_DECLARE_16(BT_UUID_GUST_FACTOR_VAL)
/**
* @brief Pollen Concentration Characteristic UUID value
*/
#define BT_UUID_POLLEN_CONCENTRATION_VAL 0x2a75
/**
* @brief Pollen Concentration Characteristic
*/
#define BT_UUID_POLLEN_CONCENTRATION \
BT_UUID_DECLARE_16(BT_UUID_POLLEN_CONCENTRATION_VAL)
/**
* @brief UV Index Characteristic UUID value
*/
#define BT_UUID_UV_INDEX_VAL 0x2a76
/**
* @brief UV Index Characteristic
*/
#define BT_UUID_UV_INDEX \
BT_UUID_DECLARE_16(BT_UUID_UV_INDEX_VAL)
/**
* @brief Irradiance Characteristic UUID value
*/
#define BT_UUID_IRRADIANCE_VAL 0x2a77
/**
* @brief Irradiance Characteristic
*/
#define BT_UUID_IRRADIANCE \
BT_UUID_DECLARE_16(BT_UUID_IRRADIANCE_VAL)
/**
* @brief Rainfall Characteristic UUID value
*/
#define BT_UUID_RAINFALL_VAL 0x2a78
/**
* @brief Rainfall Characteristic
*/
#define BT_UUID_RAINFALL \
BT_UUID_DECLARE_16(BT_UUID_RAINFALL_VAL)
/**
* @brief Wind Chill Characteristic UUID value
*/
#define BT_UUID_WIND_CHILL_VAL 0x2a79
/**
* @brief Wind Chill Characteristic
*/
#define BT_UUID_WIND_CHILL \
BT_UUID_DECLARE_16(BT_UUID_WIND_CHILL_VAL)
/**
* @brief Heat Index Characteristic UUID value
*/
#define BT_UUID_HEAT_INDEX_VAL 0x2a7a
/**
* @brief Heat Index Characteristic
*/
#define BT_UUID_HEAT_INDEX \
BT_UUID_DECLARE_16(BT_UUID_HEAT_INDEX_VAL)
/**
* @brief Dew Point Characteristic UUID value
*/
#define BT_UUID_DEW_POINT_VAL 0x2a7b
/**
* @brief Dew Point Characteristic
*/
#define BT_UUID_DEW_POINT \
BT_UUID_DECLARE_16(BT_UUID_DEW_POINT_VAL)
/**
* @brief GATT Characteristic Trend UUID Value
*/
#define BT_UUID_GATT_TREND_VAL 0x2a7c
/**
* @brief GATT Characteristic Trend
*/
#define BT_UUID_GATT_TREND \
BT_UUID_DECLARE_16(BT_UUID_GATT_TREND_VAL)
/**
* @brief Descriptor Value Changed Characteristic UUID value
*/
#define BT_UUID_DESC_VALUE_CHANGED_VAL 0x2a7d
/**
* @brief Descriptor Value Changed Characteristic
*/
#define BT_UUID_DESC_VALUE_CHANGED \
BT_UUID_DECLARE_16(BT_UUID_DESC_VALUE_CHANGED_VAL)
/**
* @brief GATT Characteristic Aerobic Heart Rate Low Limit UUID Value
*/
#define BT_UUID_GATT_AEHRLL_VAL 0x2a7e
/**
* @brief GATT Characteristic Aerobic Heart Rate Lower Limit
*/
#define BT_UUID_GATT_AEHRLL \
BT_UUID_DECLARE_16(BT_UUID_GATT_AEHRLL_VAL)
/**
* @brief GATT Characteristic Aerobic Threshold UUID Value
*/
#define BT_UUID_GATT_AETHR_VAL 0x2a7f
/**
* @brief GATT Characteristic Aerobic Threshold
*/
#define BT_UUID_GATT_AETHR \
BT_UUID_DECLARE_16(BT_UUID_GATT_AETHR_VAL)
/**
* @brief GATT Characteristic Age UUID Value
*/
#define BT_UUID_GATT_AGE_VAL 0x2a80
/**
* @brief GATT Characteristic Age
*/
#define BT_UUID_GATT_AGE \
BT_UUID_DECLARE_16(BT_UUID_GATT_AGE_VAL)
/**
* @brief GATT Characteristic Anaerobic Heart Rate Lower Limit UUID Value
*/
#define BT_UUID_GATT_ANHRLL_VAL 0x2a81
/**
* @brief GATT Characteristic Anaerobic Heart Rate Lower Limit
*/
#define BT_UUID_GATT_ANHRLL \
BT_UUID_DECLARE_16(BT_UUID_GATT_ANHRLL_VAL)
/**
* @brief GATT Characteristic Anaerobic Heart Rate Upper Limit UUID Value
*/
#define BT_UUID_GATT_ANHRUL_VAL 0x2a82
/**
* @brief GATT Characteristic Anaerobic Heart Rate Upper Limit
*/
#define BT_UUID_GATT_ANHRUL \
BT_UUID_DECLARE_16(BT_UUID_GATT_ANHRUL_VAL)
/**
* @brief GATT Characteristic Anaerobic Threshold UUID Value
*/
#define BT_UUID_GATT_ANTHR_VAL 0x2a83
/**
* @brief GATT Characteristic Anaerobic Threshold
*/
#define BT_UUID_GATT_ANTHR \
BT_UUID_DECLARE_16(BT_UUID_GATT_ANTHR_VAL)
/**
* @brief GATT Characteristic Aerobic Heart Rate Upper Limit UUID Value
*/
#define BT_UUID_GATT_AEHRUL_VAL 0x2a84
/**
* @brief GATT Characteristic Aerobic Heart Rate Upper Limit
*/
#define BT_UUID_GATT_AEHRUL \
BT_UUID_DECLARE_16(BT_UUID_GATT_AEHRUL_VAL)
/**
* @brief GATT Characteristic Date of Birth UUID Value
*/
#define BT_UUID_GATT_DATE_BIRTH_VAL 0x2a85
/**
* @brief GATT Characteristic Date of Birth
*/
#define BT_UUID_GATT_DATE_BIRTH \
BT_UUID_DECLARE_16(BT_UUID_GATT_DATE_BIRTH_VAL)
/**
* @brief GATT Characteristic Date of Threshold Assessment UUID Value
*/
#define BT_UUID_GATT_DATE_THRASS_VAL 0x2a86
/**
* @brief GATT Characteristic Date of Threshold Assessment
*/
#define BT_UUID_GATT_DATE_THRASS \
BT_UUID_DECLARE_16(BT_UUID_GATT_DATE_THRASS_VAL)
/**
* @brief GATT Characteristic Email Address UUID Value
*/
#define BT_UUID_GATT_EMAIL_VAL 0x2a87
/**
* @brief GATT Characteristic Email Address
*/
#define BT_UUID_GATT_EMAIL \
BT_UUID_DECLARE_16(BT_UUID_GATT_EMAIL_VAL)
/**
* @brief GATT Characteristic Fat Burn Heart Rate Lower Limit UUID Value
*/
#define BT_UUID_GATT_FBHRLL_VAL 0x2a88
/**
* @brief GATT Characteristic Fat Burn Heart Rate Lower Limit
*/
#define BT_UUID_GATT_FBHRLL \
BT_UUID_DECLARE_16(BT_UUID_GATT_FBHRLL_VAL)
/**
* @brief GATT Characteristic Fat Burn Heart Rate Upper Limit UUID Value
*/
#define BT_UUID_GATT_FBHRUL_VAL 0x2a89
/**
* @brief GATT Characteristic Fat Burn Heart Rate Upper Limit
*/
#define BT_UUID_GATT_FBHRUL \
BT_UUID_DECLARE_16(BT_UUID_GATT_FBHRUL_VAL)
/**
* @brief GATT Characteristic First Name UUID Value
*/
#define BT_UUID_GATT_FIRST_NAME_VAL 0x2a8a
/**
* @brief GATT Characteristic First Name
*/
#define BT_UUID_GATT_FIRST_NAME \
BT_UUID_DECLARE_16(BT_UUID_GATT_FIRST_NAME_VAL)
/**
* @brief GATT Characteristic Five Zone Heart Rate Limits UUID Value
*/
#define BT_UUID_GATT_5ZHRL_VAL 0x2a8b
/**
* @brief GATT Characteristic Five Zone Heart Rate Limits
*/
#define BT_UUID_GATT_5ZHRL \
BT_UUID_DECLARE_16(BT_UUID_GATT_5ZHRL_VAL)
/**
* @brief GATT Characteristic Gender UUID Value
*/
#define BT_UUID_GATT_GENDER_VAL 0x2a8c
/**
* @brief GATT Characteristic Gender
*/
#define BT_UUID_GATT_GENDER \
BT_UUID_DECLARE_16(BT_UUID_GATT_GENDER_VAL)
/**
* @brief GATT Characteristic Heart Rate Max UUID Value
*/
#define BT_UUID_GATT_HR_MAX_VAL 0x2a8d
/**
* @brief GATT Characteristic Heart Rate Max
*/
#define BT_UUID_GATT_HR_MAX \
BT_UUID_DECLARE_16(BT_UUID_GATT_HR_MAX_VAL)
/**
* @brief GATT Characteristic Height UUID Value
*/
#define BT_UUID_GATT_HEIGHT_VAL 0x2a8e
/**
* @brief GATT Characteristic Height
*/
#define BT_UUID_GATT_HEIGHT \
BT_UUID_DECLARE_16(BT_UUID_GATT_HEIGHT_VAL)
/**
* @brief GATT Characteristic Hip Circumference UUID Value
*/
#define BT_UUID_GATT_HC_VAL 0x2a8f
/**
* @brief GATT Characteristic Hip Circumference
*/
#define BT_UUID_GATT_HC \
BT_UUID_DECLARE_16(BT_UUID_GATT_HC_VAL)
/**
* @brief GATT Characteristic Last Name UUID Value
*/
#define BT_UUID_GATT_LAST_NAME_VAL 0x2a90
/**
* @brief GATT Characteristic Last Name
*/
#define BT_UUID_GATT_LAST_NAME \
BT_UUID_DECLARE_16(BT_UUID_GATT_LAST_NAME_VAL)
/**
* @brief GATT Characteristic Maximum Recommended Heart Rate> UUID Value
*/
#define BT_UUID_GATT_MRHR_VAL 0x2a91
/**
* @brief GATT Characteristic Maximum Recommended Heart Rate
*/
#define BT_UUID_GATT_MRHR \
BT_UUID_DECLARE_16(BT_UUID_GATT_MRHR_VAL)
/**
* @brief GATT Characteristic Resting Heart Rate UUID Value
*/
#define BT_UUID_GATT_RHR_VAL 0x2a92
/**
* @brief GATT Characteristic Resting Heart Rate
*/
#define BT_UUID_GATT_RHR \
BT_UUID_DECLARE_16(BT_UUID_GATT_RHR_VAL)
/**
* @brief GATT Characteristic Sport Type for Aerobic and Anaerobic Thresholds UUID Value
*/
#define BT_UUID_GATT_AEANTHR_VAL 0x2a93
/**
* @brief GATT Characteristic Sport Type for Aerobic and Anaerobic Threshold
*/
#define BT_UUID_GATT_AEANTHR \
BT_UUID_DECLARE_16(BT_UUID_GATT_AEANTHR_VAL)
/**
* @brief GATT Characteristic Three Zone Heart Rate Limits UUID Value
*/
#define BT_UUID_GATT_3ZHRL_VAL 0x2a94
/**
* @brief GATT Characteristic Three Zone Heart Rate Limits
*/
#define BT_UUID_GATT_3ZHRL \
BT_UUID_DECLARE_16(BT_UUID_GATT_3ZHRL_VAL)
/**
* @brief GATT Characteristic Two Zone Heart Rate Limits UUID Value
*/
#define BT_UUID_GATT_2ZHRL_VAL 0x2a95
/**
* @brief GATT Characteristic Two Zone Heart Rate Limits
*/
#define BT_UUID_GATT_2ZHRL \
BT_UUID_DECLARE_16(BT_UUID_GATT_2ZHRL_VAL)
/**
* @brief GATT Characteristic VO2 Max UUID Value
*/
#define BT_UUID_GATT_VO2_MAX_VAL 0x2a96
/**
* @brief GATT Characteristic VO2 Max
*/
#define BT_UUID_GATT_VO2_MAX \
BT_UUID_DECLARE_16(BT_UUID_GATT_VO2_MAX_VAL)
/**
* @brief GATT Characteristic Waist Circumference UUID Value
*/
#define BT_UUID_GATT_WC_VAL 0x2a97
/**
* @brief GATT Characteristic Waist Circumference
*/
#define BT_UUID_GATT_WC \
BT_UUID_DECLARE_16(BT_UUID_GATT_WC_VAL)
/**
* @brief GATT Characteristic Weight UUID Value
*/
#define BT_UUID_GATT_WEIGHT_VAL 0x2a98
/**
* @brief GATT Characteristic Weight
*/
#define BT_UUID_GATT_WEIGHT \
BT_UUID_DECLARE_16(BT_UUID_GATT_WEIGHT_VAL)
/**
* @brief GATT Characteristic Database Change Increment UUID Value
*/
#define BT_UUID_GATT_DBCHINC_VAL 0x2a99
/**
* @brief GATT Characteristic Database Change Increment
*/
#define BT_UUID_GATT_DBCHINC \
BT_UUID_DECLARE_16(BT_UUID_GATT_DBCHINC_VAL)
/**
* @brief GATT Characteristic User Index UUID Value
*/
#define BT_UUID_GATT_USRIDX_VAL 0x2a9a
/**
* @brief GATT Characteristic User Index
*/
#define BT_UUID_GATT_USRIDX \
BT_UUID_DECLARE_16(BT_UUID_GATT_USRIDX_VAL)
/**
* @brief GATT Characteristic Body Composition Feature UUID Value
*/
#define BT_UUID_GATT_BCF_VAL 0x2a9b
/**
* @brief GATT Characteristic Body Composition Feature
*/
#define BT_UUID_GATT_BCF \
BT_UUID_DECLARE_16(BT_UUID_GATT_BCF_VAL)
/**
* @brief GATT Characteristic Body Composition Measurement UUID Value
*/
#define BT_UUID_GATT_BCM_VAL 0x2a9c
/**
* @brief GATT Characteristic Body Composition Measurement
*/
#define BT_UUID_GATT_BCM \
BT_UUID_DECLARE_16(BT_UUID_GATT_BCM_VAL)
/**
* @brief GATT Characteristic Weight Measurement UUID Value
*/
#define BT_UUID_GATT_WM_VAL 0x2a9d
/**
* @brief GATT Characteristic Weight Measurement
*/
#define BT_UUID_GATT_WM \
BT_UUID_DECLARE_16(BT_UUID_GATT_WM_VAL)
/**
* @brief GATT Characteristic Weight Scale Feature UUID Value
*/
#define BT_UUID_GATT_WSF_VAL 0x2a9e
/**
* @brief GATT Characteristic Weight Scale Feature
*/
#define BT_UUID_GATT_WSF \
BT_UUID_DECLARE_16(BT_UUID_GATT_WSF_VAL)
/**
* @brief GATT Characteristic User Control Point UUID Value
*/
#define BT_UUID_GATT_USRCP_VAL 0x2a9f
/**
* @brief GATT Characteristic User Control Point
*/
#define BT_UUID_GATT_USRCP \
BT_UUID_DECLARE_16(BT_UUID_GATT_USRCP_VAL)
/**
* @brief Magnetic Flux Density - 2D Characteristic UUID value
*/
#define BT_UUID_MAGN_FLUX_DENSITY_2D_VAL 0x2aa0
/**
* @brief Magnetic Flux Density - 2D Characteristic
*/
#define BT_UUID_MAGN_FLUX_DENSITY_2D \
BT_UUID_DECLARE_16(BT_UUID_MAGN_FLUX_DENSITY_2D_VAL)
/**
* @brief Magnetic Flux Density - 3D Characteristic UUID value
*/
#define BT_UUID_MAGN_FLUX_DENSITY_3D_VAL 0x2aa1
/**
* @brief Magnetic Flux Density - 3D Characteristic
*/
#define BT_UUID_MAGN_FLUX_DENSITY_3D \
BT_UUID_DECLARE_16(BT_UUID_MAGN_FLUX_DENSITY_3D_VAL)
/**
* @brief GATT Characteristic Language UUID Value
*/
#define BT_UUID_GATT_LANG_VAL 0x2aa2
/**
* @brief GATT Characteristic Language
*/
#define BT_UUID_GATT_LANG \
BT_UUID_DECLARE_16(BT_UUID_GATT_LANG_VAL)
/**
* @brief Barometric Pressure Trend Characteristic UUID value
*/
#define BT_UUID_BAR_PRESSURE_TREND_VAL 0x2aa3
/**
* @brief Barometric Pressure Trend Characteristic
*/
#define BT_UUID_BAR_PRESSURE_TREND \
BT_UUID_DECLARE_16(BT_UUID_BAR_PRESSURE_TREND_VAL)
/**
* @brief Bond Management Control Point UUID value
*/
#define BT_UUID_BMS_CONTROL_POINT_VAL 0x2aa4
/**
* @brief Bond Management Control Point
*/
#define BT_UUID_BMS_CONTROL_POINT \
BT_UUID_DECLARE_16(BT_UUID_BMS_CONTROL_POINT_VAL)
/**
* @brief Bond Management Feature UUID value
*/
#define BT_UUID_BMS_FEATURE_VAL 0x2aa5
/**
* @brief Bond Management Feature
*/
#define BT_UUID_BMS_FEATURE \
BT_UUID_DECLARE_16(BT_UUID_BMS_FEATURE_VAL)
/**
* @brief Central Address Resolution Characteristic UUID value
*/
#define BT_UUID_CENTRAL_ADDR_RES_VAL 0x2aa6
/**
* @brief Central Address Resolution Characteristic
*/
#define BT_UUID_CENTRAL_ADDR_RES \
BT_UUID_DECLARE_16(BT_UUID_CENTRAL_ADDR_RES_VAL)
/**
* @brief CGM Measurement Characteristic value
*/
#define BT_UUID_CGM_MEASUREMENT_VAL 0x2aa7
/**
* @brief CGM Measurement Characteristic
*/
#define BT_UUID_CGM_MEASUREMENT \
BT_UUID_DECLARE_16(BT_UUID_CGM_MEASUREMENT_VAL)
/**
* @brief CGM Feature Characteristic value
*/
#define BT_UUID_CGM_FEATURE_VAL 0x2aa8
/**
* @brief CGM Feature Characteristic
*/
#define BT_UUID_CGM_FEATURE \
BT_UUID_DECLARE_16(BT_UUID_CGM_FEATURE_VAL)
/**
* @brief CGM Status Characteristic value
*/
#define BT_UUID_CGM_STATUS_VAL 0x2aa9
/**
* @brief CGM Status Characteristic
*/
#define BT_UUID_CGM_STATUS \
BT_UUID_DECLARE_16(BT_UUID_CGM_STATUS_VAL)
/**
* @brief CGM Session Start Time Characteristic value
*/
#define BT_UUID_CGM_SESSION_START_TIME_VAL 0x2aaa
/**
* @brief CGM Session Start Time
*/
#define BT_UUID_CGM_SESSION_START_TIME \
BT_UUID_DECLARE_16(BT_UUID_CGM_SESSION_START_TIME_VAL)
/**
* @brief CGM Session Run Time Characteristic value
*/
#define BT_UUID_CGM_SESSION_RUN_TIME_VAL 0x2aab
/**
* @brief CGM Session Run Time
*/
#define BT_UUID_CGM_SESSION_RUN_TIME \
BT_UUID_DECLARE_16(BT_UUID_CGM_SESSION_RUN_TIME_VAL)
/**
* @brief CGM Specific Ops Control Point Characteristic value
*/
#define BT_UUID_CGM_SPECIFIC_OPS_CONTROL_POINT_VAL 0x2aac
/**
* @brief CGM Specific Ops Control Point
*/
#define BT_UUID_CGM_SPECIFIC_OPS_CONTROL_POINT \
BT_UUID_DECLARE_16(BT_UUID_CGM_SPECIFIC_OPS_CONTROL_POINT_VAL)
/**
* @brief GATT Characteristic Indoor Positioning Configuration UUID Value
*/
#define BT_UUID_GATT_IPC_VAL 0x2aad
/**
* @brief GATT Characteristic Indoor Positioning Configuration
*/
#define BT_UUID_GATT_IPC \
BT_UUID_DECLARE_16(BT_UUID_GATT_IPC_VAL)
/**
* @brief GATT Characteristic Latitude UUID Value
*/
#define BT_UUID_GATT_LAT_VAL 0x2aae
/**
* @brief GATT Characteristic Latitude
*/
#define BT_UUID_GATT_LAT \
BT_UUID_DECLARE_16(BT_UUID_GATT_LAT_VAL)
/**
* @brief GATT Characteristic Longitude UUID Value
*/
#define BT_UUID_GATT_LON_VAL 0x2aaf
/**
* @brief GATT Characteristic Longitude
*/
#define BT_UUID_GATT_LON \
BT_UUID_DECLARE_16(BT_UUID_GATT_LON_VAL)
/**
* @brief GATT Characteristic Local North Coordinate UUID Value
*/
#define BT_UUID_GATT_LNCOORD_VAL 0x2ab0
/**
* @brief GATT Characteristic Local North Coordinate
*/
#define BT_UUID_GATT_LNCOORD \
BT_UUID_DECLARE_16(BT_UUID_GATT_LNCOORD_VAL)
/**
* @brief GATT Characteristic Local East Coordinate UUID Value
*/
#define BT_UUID_GATT_LECOORD_VAL 0x2ab1
/**
* @brief GATT Characteristic Local East Coordinate
*/
#define BT_UUID_GATT_LECOORD \
BT_UUID_DECLARE_16(BT_UUID_GATT_LECOORD_VAL)
/**
* @brief GATT Characteristic Floor Number UUID Value
*/
#define BT_UUID_GATT_FN_VAL 0x2ab2
/**
* @brief GATT Characteristic Floor Number
*/
#define BT_UUID_GATT_FN \
BT_UUID_DECLARE_16(BT_UUID_GATT_FN_VAL)
/**
* @brief GATT Characteristic Altitude UUID Value
*/
#define BT_UUID_GATT_ALT_VAL 0x2ab3
/**
* @brief GATT Characteristic Altitude
*/
#define BT_UUID_GATT_ALT \
BT_UUID_DECLARE_16(BT_UUID_GATT_ALT_VAL)
/**
* @brief GATT Characteristic Uncertainty UUID Value
*/
#define BT_UUID_GATT_UNCERTAINTY_VAL 0x2ab4
/**
* @brief GATT Characteristic Uncertainty
*/
#define BT_UUID_GATT_UNCERTAINTY \
BT_UUID_DECLARE_16(BT_UUID_GATT_UNCERTAINTY_VAL)
/**
* @brief GATT Characteristic Location Name UUID Value
*/
#define BT_UUID_GATT_LOC_NAME_VAL 0x2ab5
/**
* @brief GATT Characteristic Location Name
*/
#define BT_UUID_GATT_LOC_NAME \
BT_UUID_DECLARE_16(BT_UUID_GATT_LOC_NAME_VAL)
/**
* @brief URI UUID value
*/
#define BT_UUID_URI_VAL 0x2ab6
/**
* @brief URI
*/
#define BT_UUID_URI \
BT_UUID_DECLARE_16(BT_UUID_URI_VAL)
/**
* @brief HTTP Headers UUID value
*/
#define BT_UUID_HTTP_HEADERS_VAL 0x2ab7
/**
* @brief HTTP Headers
*/
#define BT_UUID_HTTP_HEADERS \
BT_UUID_DECLARE_16(BT_UUID_HTTP_HEADERS_VAL)
/**
* @brief HTTP Status Code UUID value
*/
#define BT_UUID_HTTP_STATUS_CODE_VAL 0x2ab8
/**
* @brief HTTP Status Code
*/
#define BT_UUID_HTTP_STATUS_CODE \
BT_UUID_DECLARE_16(BT_UUID_HTTP_STATUS_CODE_VAL)
/**
* @brief HTTP Entity Body UUID value
*/
#define BT_UUID_HTTP_ENTITY_BODY_VAL 0x2ab9
/**
* @brief HTTP Entity Body
*/
#define BT_UUID_HTTP_ENTITY_BODY \
BT_UUID_DECLARE_16(BT_UUID_HTTP_ENTITY_BODY_VAL)
/**
* @brief HTTP Control Point UUID value
*/
#define BT_UUID_HTTP_CONTROL_POINT_VAL 0x2aba
/**
* @brief HTTP Control Point
*/
#define BT_UUID_HTTP_CONTROL_POINT \
BT_UUID_DECLARE_16(BT_UUID_HTTP_CONTROL_POINT_VAL)
/**
* @brief HTTPS Security UUID value
*/
#define BT_UUID_HTTPS_SECURITY_VAL 0x2abb
/**
* @brief HTTPS Security
*/
#define BT_UUID_HTTPS_SECURITY \
BT_UUID_DECLARE_16(BT_UUID_HTTPS_SECURITY_VAL)
/**
* @brief GATT Characteristic TDS Control Point UUID Value
*/
#define BT_UUID_GATT_TDS_CP_VAL 0x2abc
/**
* @brief GATT Characteristic TDS Control Point
*/
#define BT_UUID_GATT_TDS_CP \
BT_UUID_DECLARE_16(BT_UUID_GATT_TDS_CP_VAL)
/**
* @brief OTS Feature Characteristic UUID value
*/
#define BT_UUID_OTS_FEATURE_VAL 0x2abd
/**
* @brief OTS Feature Characteristic
*/
#define BT_UUID_OTS_FEATURE \
BT_UUID_DECLARE_16(BT_UUID_OTS_FEATURE_VAL)
/**
* @brief OTS Object Name Characteristic UUID value
*/
#define BT_UUID_OTS_NAME_VAL 0x2abe
/**
* @brief OTS Object Name Characteristic
*/
#define BT_UUID_OTS_NAME \
BT_UUID_DECLARE_16(BT_UUID_OTS_NAME_VAL)
/**
* @brief OTS Object Type Characteristic UUID value
*/
#define BT_UUID_OTS_TYPE_VAL 0x2abf
/**
* @brief OTS Object Type Characteristic
*/
#define BT_UUID_OTS_TYPE \
BT_UUID_DECLARE_16(BT_UUID_OTS_TYPE_VAL)
/**
* @brief OTS Object Size Characteristic UUID value
*/
#define BT_UUID_OTS_SIZE_VAL 0x2ac0
/**
* @brief OTS Object Size Characteristic
*/
#define BT_UUID_OTS_SIZE \
BT_UUID_DECLARE_16(BT_UUID_OTS_SIZE_VAL)
/**
* @brief OTS Object First-Created Characteristic UUID value
*/
#define BT_UUID_OTS_FIRST_CREATED_VAL 0x2ac1
/**
* @brief OTS Object First-Created Characteristic
*/
#define BT_UUID_OTS_FIRST_CREATED \
BT_UUID_DECLARE_16(BT_UUID_OTS_FIRST_CREATED_VAL)
/**
* @brief OTS Object Last-Modified Characteristic UUI value
*/
#define BT_UUID_OTS_LAST_MODIFIED_VAL 0x2ac2
/**
* @brief OTS Object Last-Modified Characteristic
*/
#define BT_UUID_OTS_LAST_MODIFIED \
BT_UUID_DECLARE_16(BT_UUID_OTS_LAST_MODIFIED_VAL)
/**
* @brief OTS Object ID Characteristic UUID value
*/
#define BT_UUID_OTS_ID_VAL 0x2ac3
/**
* @brief OTS Object ID Characteristic
*/
#define BT_UUID_OTS_ID \
BT_UUID_DECLARE_16(BT_UUID_OTS_ID_VAL)
/**
* @brief OTS Object Properties Characteristic UUID value
*/
#define BT_UUID_OTS_PROPERTIES_VAL 0x2ac4
/**
* @brief OTS Object Properties Characteristic
*/
#define BT_UUID_OTS_PROPERTIES \
BT_UUID_DECLARE_16(BT_UUID_OTS_PROPERTIES_VAL)
/**
* @brief OTS Object Action Control Point Characteristic UUID value
*/
#define BT_UUID_OTS_ACTION_CP_VAL 0x2ac5
/**
* @brief OTS Object Action Control Point Characteristic
*/
#define BT_UUID_OTS_ACTION_CP \
BT_UUID_DECLARE_16(BT_UUID_OTS_ACTION_CP_VAL)
/**
* @brief OTS Object List Control Point Characteristic UUID value
*/
#define BT_UUID_OTS_LIST_CP_VAL 0x2ac6
/**
* @brief OTS Object List Control Point Characteristic
*/
#define BT_UUID_OTS_LIST_CP \
BT_UUID_DECLARE_16(BT_UUID_OTS_LIST_CP_VAL)
/**
* @brief OTS Object List Filter Characteristic UUID value
*/
#define BT_UUID_OTS_LIST_FILTER_VAL 0x2ac7
/**
* @brief OTS Object List Filter Characteristic
*/
#define BT_UUID_OTS_LIST_FILTER \
BT_UUID_DECLARE_16(BT_UUID_OTS_LIST_FILTER_VAL)
/**
* @brief OTS Object Changed Characteristic UUID value
*/
#define BT_UUID_OTS_CHANGED_VAL 0x2ac8
/**
* @brief OTS Object Changed Characteristic
*/
#define BT_UUID_OTS_CHANGED \
BT_UUID_DECLARE_16(BT_UUID_OTS_CHANGED_VAL)
/**
* @brief GATT Characteristic Resolvable Private Address Only UUID Value
*/
#define BT_UUID_GATT_RPAO_VAL 0x2ac9
/**
* @brief GATT Characteristic Resolvable Private Address Only
*/
#define BT_UUID_GATT_RPAO \
BT_UUID_DECLARE_16(BT_UUID_GATT_RPAO_VAL)
/**
* @brief OTS Unspecified Object Type UUID value
*/
#define BT_UUID_OTS_TYPE_UNSPECIFIED_VAL 0x2aca
/**
* @brief OTS Unspecified Object Type
*/
#define BT_UUID_OTS_TYPE_UNSPECIFIED \
BT_UUID_DECLARE_16(BT_UUID_OTS_TYPE_UNSPECIFIED_VAL)
/**
* @brief OTS Directory Listing UUID value
*/
#define BT_UUID_OTS_DIRECTORY_LISTING_VAL 0x2acb
/**
* @brief OTS Directory Listing
*/
#define BT_UUID_OTS_DIRECTORY_LISTING \
BT_UUID_DECLARE_16(BT_UUID_OTS_DIRECTORY_LISTING_VAL)
/**
* @brief GATT Characteristic Fitness Machine Feature UUID Value
*/
#define BT_UUID_GATT_FMF_VAL 0x2acc
/**
* @brief GATT Characteristic Fitness Machine Feature
*/
#define BT_UUID_GATT_FMF \
BT_UUID_DECLARE_16(BT_UUID_GATT_FMF_VAL)
/**
* @brief GATT Characteristic Treadmill Data UUID Value
*/
#define BT_UUID_GATT_TD_VAL 0x2acd
/**
* @brief GATT Characteristic Treadmill Data
*/
#define BT_UUID_GATT_TD \
BT_UUID_DECLARE_16(BT_UUID_GATT_TD_VAL)
/**
* @brief GATT Characteristic Cross Trainer Data UUID Value
*/
#define BT_UUID_GATT_CTD_VAL 0x2ace
/**
* @brief GATT Characteristic Cross Trainer Data
*/
#define BT_UUID_GATT_CTD \
BT_UUID_DECLARE_16(BT_UUID_GATT_CTD_VAL)
/**
* @brief GATT Characteristic Step Climber Data UUID Value
*/
#define BT_UUID_GATT_STPCD_VAL 0x2acf
/**
* @brief GATT Characteristic Step Climber Data
*/
#define BT_UUID_GATT_STPCD \
BT_UUID_DECLARE_16(BT_UUID_GATT_STPCD_VAL)
/**
* @brief GATT Characteristic Stair Climber Data UUID Value
*/
#define BT_UUID_GATT_STRCD_VAL 0x2ad0
/**
* @brief GATT Characteristic Stair Climber Data
*/
#define BT_UUID_GATT_STRCD \
BT_UUID_DECLARE_16(BT_UUID_GATT_STRCD_VAL)
/**
* @brief GATT Characteristic Rower Data UUID Value
*/
#define BT_UUID_GATT_RD_VAL 0x2ad1
/**
* @brief GATT Characteristic Rower Data
*/
#define BT_UUID_GATT_RD \
BT_UUID_DECLARE_16(BT_UUID_GATT_RD_VAL)
/**
* @brief GATT Characteristic Indoor Bike Data UUID Value
*/
#define BT_UUID_GATT_IBD_VAL 0x2ad2
/**
* @brief GATT Characteristic Indoor Bike Data
*/
#define BT_UUID_GATT_IBD \
BT_UUID_DECLARE_16(BT_UUID_GATT_IBD_VAL)
/**
* @brief GATT Characteristic Training Status UUID Value
*/
#define BT_UUID_GATT_TRSTAT_VAL 0x2ad3
/**
* @brief GATT Characteristic Training Status
*/
#define BT_UUID_GATT_TRSTAT \
BT_UUID_DECLARE_16(BT_UUID_GATT_TRSTAT_VAL)
/**
* @brief GATT Characteristic Supported Speed Range UUID Value
*/
#define BT_UUID_GATT_SSR_VAL 0x2ad4
/**
* @brief GATT Characteristic Supported Speed Range
*/
#define BT_UUID_GATT_SSR \
BT_UUID_DECLARE_16(BT_UUID_GATT_SSR_VAL)
/**
* @brief GATT Characteristic Supported Inclination Range UUID Value
*/
#define BT_UUID_GATT_SIR_VAL 0x2ad5
/**
* @brief GATT Characteristic Supported Inclination Range
*/
#define BT_UUID_GATT_SIR \
BT_UUID_DECLARE_16(BT_UUID_GATT_SIR_VAL)
/**
* @brief GATT Characteristic Supported Resistance Level Range UUID Value
*/
#define BT_UUID_GATT_SRLR_VAL 0x2ad6
/**
* @brief GATT Characteristic Supported Resistance Level Range
*/
#define BT_UUID_GATT_SRLR \
BT_UUID_DECLARE_16(BT_UUID_GATT_SRLR_VAL)
/**
* @brief GATT Characteristic Supported Heart Rate Range UUID Value
*/
#define BT_UUID_GATT_SHRR_VAL 0x2ad7
/**
* @brief GATT Characteristic Supported Heart Rate Range
*/
#define BT_UUID_GATT_SHRR \
BT_UUID_DECLARE_16(BT_UUID_GATT_SHRR_VAL)
/**
* @brief GATT Characteristic Supported Power Range UUID Value
*/
#define BT_UUID_GATT_SPR_VAL 0x2ad8
/**
* @brief GATT Characteristic Supported Power Range
*/
#define BT_UUID_GATT_SPR \
BT_UUID_DECLARE_16(BT_UUID_GATT_SPR_VAL)
/**
* @brief GATT Characteristic Fitness Machine Control Point UUID Value
*/
#define BT_UUID_GATT_FMCP_VAL 0x2ad9
/**
* @brief GATT Characteristic Fitness Machine Control Point
*/
#define BT_UUID_GATT_FMCP \
BT_UUID_DECLARE_16(BT_UUID_GATT_FMCP_VAL)
/**
* @brief GATT Characteristic Fitness Machine Status UUID Value
*/
#define BT_UUID_GATT_FMS_VAL 0x2ada
/**
* @brief GATT Characteristic Fitness Machine Status
*/
#define BT_UUID_GATT_FMS \
BT_UUID_DECLARE_16(BT_UUID_GATT_FMS_VAL)
/**
* @brief Mesh Provisioning Data In UUID value
*/
#define BT_UUID_MESH_PROV_DATA_IN_VAL 0x2adb
/**
* @brief Mesh Provisioning Data In
*/
#define BT_UUID_MESH_PROV_DATA_IN \
BT_UUID_DECLARE_16(BT_UUID_MESH_PROV_DATA_IN_VAL)
/**
* @brief Mesh Provisioning Data Out UUID value
*/
#define BT_UUID_MESH_PROV_DATA_OUT_VAL 0x2adc
/**
* @brief Mesh Provisioning Data Out
*/
#define BT_UUID_MESH_PROV_DATA_OUT \
BT_UUID_DECLARE_16(BT_UUID_MESH_PROV_DATA_OUT_VAL)
/**
* @brief Mesh Proxy Data In UUID value
*/
#define BT_UUID_MESH_PROXY_DATA_IN_VAL 0x2add
/**
* @brief Mesh Proxy Data In
*/
#define BT_UUID_MESH_PROXY_DATA_IN \
BT_UUID_DECLARE_16(BT_UUID_MESH_PROXY_DATA_IN_VAL)
/**
* @brief Mesh Proxy Data Out UUID value
*/
#define BT_UUID_MESH_PROXY_DATA_OUT_VAL 0x2ade
/**
* @brief Mesh Proxy Data Out
*/
#define BT_UUID_MESH_PROXY_DATA_OUT \
BT_UUID_DECLARE_16(BT_UUID_MESH_PROXY_DATA_OUT_VAL)
/**
* @brief GATT Characteristic New Number Needed UUID Value
*/
#define BT_UUID_GATT_NNN_VAL 0x2adf
/**
* @brief GATT Characteristic New Number Needed
*/
#define BT_UUID_GATT_NNN \
BT_UUID_DECLARE_16(BT_UUID_GATT_NNN_VAL)
/**
* @brief GATT Characteristic Average Current UUID Value
*/
#define BT_UUID_GATT_AC_VAL 0x2ae0
/**
* @brief GATT Characteristic Average Current
*/
#define BT_UUID_GATT_AC \
BT_UUID_DECLARE_16(BT_UUID_GATT_AC_VAL)
/**
* @brief GATT Characteristic Average Voltage UUID Value
*/
#define BT_UUID_GATT_AV_VAL 0x2ae1
/**
* @brief GATT Characteristic Average Voltage
*/
#define BT_UUID_GATT_AV \
BT_UUID_DECLARE_16(BT_UUID_GATT_AV_VAL)
/**
* @brief GATT Characteristic Boolean UUID Value
*/
#define BT_UUID_GATT_BOOLEAN_VAL 0x2ae2
/**
* @brief GATT Characteristic Boolean
*/
#define BT_UUID_GATT_BOOLEAN \
BT_UUID_DECLARE_16(BT_UUID_GATT_BOOLEAN_VAL)
/**
* @brief GATT Characteristic Chromatic Distance From Planckian UUID Value
*/
#define BT_UUID_GATT_CRDFP_VAL 0x2ae3
/**
* @brief GATT Characteristic Chromatic Distance From Planckian
*/
#define BT_UUID_GATT_CRDFP \
BT_UUID_DECLARE_16(BT_UUID_GATT_CRDFP_VAL)
/**
* @brief GATT Characteristic Chromaticity Coordinates UUID Value
*/
#define BT_UUID_GATT_CRCOORDS_VAL 0x2ae4
/**
* @brief GATT Characteristic Chromaticity Coordinates
*/
#define BT_UUID_GATT_CRCOORDS \
BT_UUID_DECLARE_16(BT_UUID_GATT_CRCOORDS_VAL)
/**
* @brief GATT Characteristic Chromaticity In CCT And Duv Values UUID Value
*/
#define BT_UUID_GATT_CRCCT_VAL 0x2ae5
/**
* @brief GATT Characteristic Chromaticity In CCT And Duv Values
*/
#define BT_UUID_GATT_CRCCT \
BT_UUID_DECLARE_16(BT_UUID_GATT_CRCCT_VAL)
/**
* @brief GATT Characteristic Chromaticity Tolerance UUID Value
*/
#define BT_UUID_GATT_CRT_VAL 0x2ae6
/**
* @brief GATT Characteristic Chromaticity Tolerance
*/
#define BT_UUID_GATT_CRT \
BT_UUID_DECLARE_16(BT_UUID_GATT_CRT_VAL)
/**
* @brief GATT Characteristic CIE 13.3-1995 Color Rendering Index UUID Value
*/
#define BT_UUID_GATT_CIEIDX_VAL 0x2ae7
/**
* @brief GATT Characteristic CIE 13.3-1995 Color Rendering Index
*/
#define BT_UUID_GATT_CIEIDX \
BT_UUID_DECLARE_16(BT_UUID_GATT_CIEIDX_VAL)
/**
* @brief GATT Characteristic Coefficient UUID Value
*/
#define BT_UUID_GATT_COEFFICIENT_VAL 0x2ae8
/**
* @brief GATT Characteristic Coefficient
*/
#define BT_UUID_GATT_COEFFICIENT \
BT_UUID_DECLARE_16(BT_UUID_GATT_COEFFICIENT_VAL)
/**
* @brief GATT Characteristic Correlated Color Temperature UUID Value
*/
#define BT_UUID_GATT_CCTEMP_VAL 0x2ae9
/**
* @brief GATT Characteristic Correlated Color Temperature
*/
#define BT_UUID_GATT_CCTEMP \
BT_UUID_DECLARE_16(BT_UUID_GATT_CCTEMP_VAL)
/**
* @brief GATT Characteristic Count 16 UUID Value
*/
#define BT_UUID_GATT_COUNT16_VAL 0x2aea
/**
* @brief GATT Characteristic Count 16
*/
#define BT_UUID_GATT_COUNT16 \
BT_UUID_DECLARE_16(BT_UUID_GATT_COUNT16_VAL)
/**
* @brief GATT Characteristic Count 24 UUID Value
*/
#define BT_UUID_GATT_COUNT24_VAL 0x2aeb
/**
* @brief GATT Characteristic Count 24
*/
#define BT_UUID_GATT_COUNT24 \
BT_UUID_DECLARE_16(BT_UUID_GATT_COUNT24_VAL)
/**
* @brief GATT Characteristic Country Code UUID Value
*/
#define BT_UUID_GATT_CNTRCODE_VAL 0x2aec
/**
* @brief GATT Characteristic Country Code
*/
#define BT_UUID_GATT_CNTRCODE \
BT_UUID_DECLARE_16(BT_UUID_GATT_CNTRCODE_VAL)
/**
* @brief GATT Characteristic Date UTC UUID Value
*/
#define BT_UUID_GATT_DATEUTC_VAL 0x2aed
/**
* @brief GATT Characteristic Date UTC
*/
#define BT_UUID_GATT_DATEUTC \
BT_UUID_DECLARE_16(BT_UUID_GATT_DATEUTC_VAL)
/**
* @brief GATT Characteristic Electric Current UUID Value
*/
#define BT_UUID_GATT_EC_VAL 0x2aee
/**
* @brief GATT Characteristic Electric Current
*/
#define BT_UUID_GATT_EC \
BT_UUID_DECLARE_16(BT_UUID_GATT_EC_VAL)
/**
* @brief GATT Characteristic Electric Current Range UUID Value
*/
#define BT_UUID_GATT_ECR_VAL 0x2aef
/**
* @brief GATT Characteristic Electric Current Range
*/
#define BT_UUID_GATT_ECR \
BT_UUID_DECLARE_16(BT_UUID_GATT_ECR_VAL)
/**
* @brief GATT Characteristic Electric Current Specification UUID Value
*/
#define BT_UUID_GATT_ECSPEC_VAL 0x2af0
/**
* @brief GATT Characteristic Electric Current Specification
*/
#define BT_UUID_GATT_ECSPEC \
BT_UUID_DECLARE_16(BT_UUID_GATT_ECSPEC_VAL)
/**
* @brief GATT Characteristic Electric Current Statistics UUID Value
*/
#define BT_UUID_GATT_ECSTAT_VAL 0x2af1
/**
* @brief GATT Characteristic Electric Current Statistics
*/
#define BT_UUID_GATT_ECSTAT \
BT_UUID_DECLARE_16(BT_UUID_GATT_ECSTAT_VAL)
/**
* @brief GATT Characteristic Energy UUID Value
*/
#define BT_UUID_GATT_ENERGY_VAL 0x2af2
/**
* @brief GATT Characteristic Energy
*/
#define BT_UUID_GATT_ENERGY \
BT_UUID_DECLARE_16(BT_UUID_GATT_ENERGY_VAL)
/**
* @brief GATT Characteristic Energy In A Period Of Day UUID Value
*/
#define BT_UUID_GATT_EPOD_VAL 0x2af3
/**
* @brief GATT Characteristic Energy In A Period Of Day
*/
#define BT_UUID_GATT_EPOD \
BT_UUID_DECLARE_16(BT_UUID_GATT_EPOD_VAL)
/**
* @brief GATT Characteristic Event Statistics UUID Value
*/
#define BT_UUID_GATT_EVTSTAT_VAL 0x2af4
/**
* @brief GATT Characteristic Event Statistics
*/
#define BT_UUID_GATT_EVTSTAT \
BT_UUID_DECLARE_16(BT_UUID_GATT_EVTSTAT_VAL)
/**
* @brief GATT Characteristic Fixed String 16 UUID Value
*/
#define BT_UUID_GATT_FSTR16_VAL 0x2af5
/**
* @brief GATT Characteristic Fixed String 16
*/
#define BT_UUID_GATT_FSTR16 \
BT_UUID_DECLARE_16(BT_UUID_GATT_FSTR16_VAL)
/**
* @brief GATT Characteristic Fixed String 24 UUID Value
*/
#define BT_UUID_GATT_FSTR24_VAL 0x2af6
/**
* @brief GATT Characteristic Fixed String 24
*/
#define BT_UUID_GATT_FSTR24 \
BT_UUID_DECLARE_16(BT_UUID_GATT_FSTR24_VAL)
/**
* @brief GATT Characteristic Fixed String 36 UUID Value
*/
#define BT_UUID_GATT_FSTR36_VAL 0x2af7
/**
* @brief GATT Characteristic Fixed String 36
*/
#define BT_UUID_GATT_FSTR36 \
BT_UUID_DECLARE_16(BT_UUID_GATT_FSTR36_VAL)
/**
* @brief GATT Characteristic Fixed String 8 UUID Value
*/
#define BT_UUID_GATT_FSTR8_VAL 0x2af8
/**
* @brief GATT Characteristic Fixed String 8
*/
#define BT_UUID_GATT_FSTR8 \
BT_UUID_DECLARE_16(BT_UUID_GATT_FSTR8_VAL)
/**
* @brief GATT Characteristic Generic Level UUID Value
*/
#define BT_UUID_GATT_GENLVL_VAL 0x2af9
/**
* @brief GATT Characteristic Generic Level
*/
#define BT_UUID_GATT_GENLVL \
BT_UUID_DECLARE_16(BT_UUID_GATT_GENLVL_VAL)
/**
* @brief GATT Characteristic Global Trade Item Number UUID Value
*/
#define BT_UUID_GATT_GTIN_VAL 0x2afa
/**
* @brief GATT Characteristic Global Trade Item Number
*/
#define BT_UUID_GATT_GTIN \
BT_UUID_DECLARE_16(BT_UUID_GATT_GTIN_VAL)
/**
* @brief GATT Characteristic Illuminance UUID Value
*/
#define BT_UUID_GATT_ILLUM_VAL 0x2afb
/**
* @brief GATT Characteristic Illuminance
*/
#define BT_UUID_GATT_ILLUM \
BT_UUID_DECLARE_16(BT_UUID_GATT_ILLUM_VAL)
/**
* @brief GATT Characteristic Luminous Efficacy UUID Value
*/
#define BT_UUID_GATT_LUMEFF_VAL 0x2afc
/**
* @brief GATT Characteristic Luminous Efficacy
*/
#define BT_UUID_GATT_LUMEFF \
BT_UUID_DECLARE_16(BT_UUID_GATT_LUMEFF_VAL)
/**
* @brief GATT Characteristic Luminous Energy UUID Value
*/
#define BT_UUID_GATT_LUMNRG_VAL 0x2afd
/**
* @brief GATT Characteristic Luminous Energy
*/
#define BT_UUID_GATT_LUMNRG \
BT_UUID_DECLARE_16(BT_UUID_GATT_LUMNRG_VAL)
/**
* @brief GATT Characteristic Luminous Exposure UUID Value
*/
#define BT_UUID_GATT_LUMEXP_VAL 0x2afe
/**
* @brief GATT Characteristic Luminous Exposure
*/
#define BT_UUID_GATT_LUMEXP \
BT_UUID_DECLARE_16(BT_UUID_GATT_LUMEXP_VAL)
/**
* @brief GATT Characteristic Luminous Flux UUID Value
*/
#define BT_UUID_GATT_LUMFLX_VAL 0x2aff
/**
* @brief GATT Characteristic Luminous Flux
*/
#define BT_UUID_GATT_LUMFLX \
BT_UUID_DECLARE_16(BT_UUID_GATT_LUMFLX_VAL)
/**
* @brief GATT Characteristic Luminous Flux Range UUID Value
*/
#define BT_UUID_GATT_LUMFLXR_VAL 0x2b00
/**
* @brief GATT Characteristic Luminous Flux Range
*/
#define BT_UUID_GATT_LUMFLXR \
BT_UUID_DECLARE_16(BT_UUID_GATT_LUMFLXR_VAL)
/**
* @brief GATT Characteristic Luminous Intensity UUID Value
*/
#define BT_UUID_GATT_LUMINT_VAL 0x2b01
/**
* @brief GATT Characteristic Luminous Intensity
*/
#define BT_UUID_GATT_LUMINT \
BT_UUID_DECLARE_16(BT_UUID_GATT_LUMINT_VAL)
/**
* @brief GATT Characteristic Mass Flow UUID Value
*/
#define BT_UUID_GATT_MASSFLOW_VAL 0x2b02
/**
* @brief GATT Characteristic Mass Flow
*/
#define BT_UUID_GATT_MASSFLOW \
BT_UUID_DECLARE_16(BT_UUID_GATT_MASSFLOW_VAL)
/**
* @brief GATT Characteristic Perceived Lightness UUID Value
*/
#define BT_UUID_GATT_PERLGHT_VAL 0x2b03
/**
* @brief GATT Characteristic Perceived Lightness
*/
#define BT_UUID_GATT_PERLGHT \
BT_UUID_DECLARE_16(BT_UUID_GATT_PERLGHT_VAL)
/**
* @brief GATT Characteristic Percentage 8 UUID Value
*/
#define BT_UUID_GATT_PER8_VAL 0x2b04
/**
* @brief GATT Characteristic Percentage 8
*/
#define BT_UUID_GATT_PER8 \
BT_UUID_DECLARE_16(BT_UUID_GATT_PER8_VAL)
/**
* @brief GATT Characteristic Power UUID Value
*/
#define BT_UUID_GATT_PWR_VAL 0x2b05
/**
* @brief GATT Characteristic Power
*/
#define BT_UUID_GATT_PWR \
BT_UUID_DECLARE_16(BT_UUID_GATT_PWR_VAL)
/**
* @brief GATT Characteristic Power Specification UUID Value
*/
#define BT_UUID_GATT_PWRSPEC_VAL 0x2b06
/**
* @brief GATT Characteristic Power Specification
*/
#define BT_UUID_GATT_PWRSPEC \
BT_UUID_DECLARE_16(BT_UUID_GATT_PWRSPEC_VAL)
/**
* @brief GATT Characteristic Relative Runtime In A Current Range UUID Value
*/
#define BT_UUID_GATT_RRICR_VAL 0x2b07
/**
* @brief GATT Characteristic Relative Runtime In A Current Range
*/
#define BT_UUID_GATT_RRICR \
BT_UUID_DECLARE_16(BT_UUID_GATT_RRICR_VAL)
/**
* @brief GATT Characteristic Relative Runtime In A Generic Level Range UUID Value
*/
#define BT_UUID_GATT_RRIGLR_VAL 0x2b08
/**
* @brief GATT Characteristic Relative Runtime In A Generic Level Range
*/
#define BT_UUID_GATT_RRIGLR \
BT_UUID_DECLARE_16(BT_UUID_GATT_RRIGLR_VAL)
/**
* @brief GATT Characteristic Relative Value In A Voltage Range UUID Value
*/
#define BT_UUID_GATT_RVIVR_VAL 0x2b09
/**
* @brief GATT Characteristic Relative Value In A Voltage Range
*/
#define BT_UUID_GATT_RVIVR \
BT_UUID_DECLARE_16(BT_UUID_GATT_RVIVR_VAL)
/**
* @brief GATT Characteristic Relative Value In A Illuminance Range UUID Value
*/
#define BT_UUID_GATT_RVIIR_VAL 0x2b0a
/**
* @brief GATT Characteristic Relative Value In A Illuminance Range
*/
#define BT_UUID_GATT_RVIIR \
BT_UUID_DECLARE_16(BT_UUID_GATT_RVIIR_VAL)
/**
* @brief GATT Characteristic Relative Value In A Period Of Day UUID Value
*/
#define BT_UUID_GATT_RVIPOD_VAL 0x2b0b
/**
* @brief GATT Characteristic Relative Value In A Period Of Day
*/
#define BT_UUID_GATT_RVIPOD \
BT_UUID_DECLARE_16(BT_UUID_GATT_RVIPOD_VAL)
/**
* @brief GATT Characteristic Relative Value In A Temperature Range UUID Value
*/
#define BT_UUID_GATT_RVITR_VAL 0x2b0c
/**
* @brief GATT Characteristic Relative Value In A Temperature Range
*/
#define BT_UUID_GATT_RVITR \
BT_UUID_DECLARE_16(BT_UUID_GATT_RVITR_VAL)
/**
* @brief GATT Characteristic Temperature 8 UUID Value
*/
#define BT_UUID_GATT_TEMP8_VAL 0x2b0d
/**
* @brief GATT Characteristic Temperature 8
*/
#define BT_UUID_GATT_TEMP8 \
BT_UUID_DECLARE_16(BT_UUID_GATT_TEMP8_VAL)
/**
* @brief GATT Characteristic Temperature 8 In A Period Of Day UUID Value
*/
#define BT_UUID_GATT_TEMP8_IPOD_VAL 0x2b0e
/**
* @brief GATT Characteristic Temperature 8 In A Period Of Day
*/
#define BT_UUID_GATT_TEMP8_IPOD \
BT_UUID_DECLARE_16(BT_UUID_GATT_TEMP8_IPOD_VAL)
/**
* @brief GATT Characteristic Temperature 8 Statistics UUID Value
*/
#define BT_UUID_GATT_TEMP8_STAT_VAL 0x2b0f
/**
* @brief GATT Characteristic Temperature 8 Statistics
*/
#define BT_UUID_GATT_TEMP8_STAT \
BT_UUID_DECLARE_16(BT_UUID_GATT_TEMP8_STAT_VAL)
/**
* @brief GATT Characteristic Temperature Range UUID Value
*/
#define BT_UUID_GATT_TEMP_RNG_VAL 0x2b10
/**
* @brief GATT Characteristic Temperature Range
*/
#define BT_UUID_GATT_TEMP_RNG \
BT_UUID_DECLARE_16(BT_UUID_GATT_TEMP_RNG_VAL)
/**
* @brief GATT Characteristic Temperature Statistics UUID Value
*/
#define BT_UUID_GATT_TEMP_STAT_VAL 0x2b11
/**
* @brief GATT Characteristic Temperature Statistics
*/
#define BT_UUID_GATT_TEMP_STAT \
BT_UUID_DECLARE_16(BT_UUID_GATT_TEMP_STAT_VAL)
/**
* @brief GATT Characteristic Time Decihour 8 UUID Value
*/
#define BT_UUID_GATT_TIM_DC8_VAL 0x2b12
/**
* @brief GATT Characteristic Time Decihour 8
*/
#define BT_UUID_GATT_TIM_DC8 \
BT_UUID_DECLARE_16(BT_UUID_GATT_TIM_DC8_VAL)
/**
* @brief GATT Characteristic Time Exponential 8 UUID Value
*/
#define BT_UUID_GATT_TIM_EXP8_VAL 0x2b13
/**
* @brief GATT Characteristic Time Exponential 8
*/
#define BT_UUID_GATT_TIM_EXP8 \
BT_UUID_DECLARE_16(BT_UUID_GATT_TIM_EXP8_VAL)
/**
* @brief GATT Characteristic Time Hour 24 UUID Value
*/
#define BT_UUID_GATT_TIM_H24_VAL 0x2b14
/**
* @brief GATT Characteristic Time Hour 24
*/
#define BT_UUID_GATT_TIM_H24 \
BT_UUID_DECLARE_16(BT_UUID_GATT_TIM_H24_VAL)
/**
* @brief GATT Characteristic Time Millisecond 24 UUID Value
*/
#define BT_UUID_GATT_TIM_MS24_VAL 0x2b15
/**
* @brief GATT Characteristic Time Millisecond 24
*/
#define BT_UUID_GATT_TIM_MS24 \
BT_UUID_DECLARE_16(BT_UUID_GATT_TIM_MS24_VAL)
/**
* @brief GATT Characteristic Time Second 16 UUID Value
*/
#define BT_UUID_GATT_TIM_S16_VAL 0x2b16
/**
* @brief GATT Characteristic Time Second 16
*/
#define BT_UUID_GATT_TIM_S16 \
BT_UUID_DECLARE_16(BT_UUID_GATT_TIM_S16_VAL)
/**
* @brief GATT Characteristic Time Second 8 UUID Value
*/
#define BT_UUID_GATT_TIM_S8_VAL 0x2b17
/**
* @brief GATT Characteristic Time Second 8
*/
#define BT_UUID_GATT_TIM_S8 \
BT_UUID_DECLARE_16(BT_UUID_GATT_TIM_S8_VAL)
/**
* @brief GATT Characteristic Voltage UUID Value
*/
#define BT_UUID_GATT_V_VAL 0x2b18
/**
* @brief GATT Characteristic Voltage
*/
#define BT_UUID_GATT_V \
BT_UUID_DECLARE_16(BT_UUID_GATT_V_VAL)
/**
* @brief GATT Characteristic Voltage Specification UUID Value
*/
#define BT_UUID_GATT_V_SPEC_VAL 0x2b19
/**
* @brief GATT Characteristic Voltage Specification
*/
#define BT_UUID_GATT_V_SPEC \
BT_UUID_DECLARE_16(BT_UUID_GATT_V_SPEC_VAL)
/**
* @brief GATT Characteristic Voltage Statistics UUID Value
*/
#define BT_UUID_GATT_V_STAT_VAL 0x2b1a
/**
* @brief GATT Characteristic Voltage Statistics
*/
#define BT_UUID_GATT_V_STAT \
BT_UUID_DECLARE_16(BT_UUID_GATT_V_STAT_VAL)
/**
* @brief GATT Characteristic Volume Flow UUID Value
*/
#define BT_UUID_GATT_VOLF_VAL 0x2b1b
/**
* @brief GATT Characteristic Volume Flow
*/
#define BT_UUID_GATT_VOLF \
BT_UUID_DECLARE_16(BT_UUID_GATT_VOLF_VAL)
/**
* @brief GATT Characteristic Chromaticity Coordinate (not Coordinates) UUID Value
*/
#define BT_UUID_GATT_CRCOORD_VAL 0x2b1c
/**
* @brief GATT Characteristic Chromaticity Coordinate (not Coordinates)
*/
#define BT_UUID_GATT_CRCOORD \
BT_UUID_DECLARE_16(BT_UUID_GATT_CRCOORD_VAL)
/**
* @brief GATT Characteristic RC Feature UUID Value
*/
#define BT_UUID_GATT_RCF_VAL 0x2b1d
/**
* @brief GATT Characteristic RC Feature
*/
#define BT_UUID_GATT_RCF \
BT_UUID_DECLARE_16(BT_UUID_GATT_RCF_VAL)
/**
* @brief GATT Characteristic RC Settings UUID Value
*/
#define BT_UUID_GATT_RCSET_VAL 0x2b1e
/**
* @brief GATT Characteristic RC Settings
*/
#define BT_UUID_GATT_RCSET \
BT_UUID_DECLARE_16(BT_UUID_GATT_RCSET_VAL)
/**
* @brief GATT Characteristic Reconnection Configuration Control Point UUID Value
*/
#define BT_UUID_GATT_RCCP_VAL 0x2b1f
/**
* @brief GATT Characteristic Reconnection Configuration Control Point
*/
#define BT_UUID_GATT_RCCP \
BT_UUID_DECLARE_16(BT_UUID_GATT_RCCP_VAL)
/**
* @brief GATT Characteristic IDD Status Changed UUID Value
*/
#define BT_UUID_GATT_IDD_SC_VAL 0x2b20
/**
* @brief GATT Characteristic IDD Status Changed
*/
#define BT_UUID_GATT_IDD_SC \
BT_UUID_DECLARE_16(BT_UUID_GATT_IDD_SC_VAL)
/**
* @brief GATT Characteristic IDD Status UUID Value
*/
#define BT_UUID_GATT_IDD_S_VAL 0x2b21
/**
* @brief GATT Characteristic IDD Status
*/
#define BT_UUID_GATT_IDD_S \
BT_UUID_DECLARE_16(BT_UUID_GATT_IDD_S_VAL)
/**
* @brief GATT Characteristic IDD Annunciation Status UUID Value
*/
#define BT_UUID_GATT_IDD_AS_VAL 0x2b22
/**
* @brief GATT Characteristic IDD Annunciation Status
*/
#define BT_UUID_GATT_IDD_AS \
BT_UUID_DECLARE_16(BT_UUID_GATT_IDD_AS_VAL)
/**
* @brief GATT Characteristic IDD Features UUID Value
*/
#define BT_UUID_GATT_IDD_F_VAL 0x2b23
/**
* @brief GATT Characteristic IDD Features
*/
#define BT_UUID_GATT_IDD_F \
BT_UUID_DECLARE_16(BT_UUID_GATT_IDD_F_VAL)
/**
* @brief GATT Characteristic IDD Status Reader Control Point UUID Value
*/
#define BT_UUID_GATT_IDD_SRCP_VAL 0x2b24
/**
* @brief GATT Characteristic IDD Status Reader Control Point
*/
#define BT_UUID_GATT_IDD_SRCP \
BT_UUID_DECLARE_16(BT_UUID_GATT_IDD_SRCP_VAL)
/**
* @brief GATT Characteristic IDD Command Control Point UUID Value
*/
#define BT_UUID_GATT_IDD_CCP_VAL 0x2b25
/**
* @brief GATT Characteristic IDD Command Control Point
*/
#define BT_UUID_GATT_IDD_CCP \
BT_UUID_DECLARE_16(BT_UUID_GATT_IDD_CCP_VAL)
/**
* @brief GATT Characteristic IDD Command Data UUID Value
*/
#define BT_UUID_GATT_IDD_CD_VAL 0x2b26
/**
* @brief GATT Characteristic IDD Command Data
*/
#define BT_UUID_GATT_IDD_CD \
BT_UUID_DECLARE_16(BT_UUID_GATT_IDD_CD_VAL)
/**
* @brief GATT Characteristic IDD Record Access Control Point UUID Value
*/
#define BT_UUID_GATT_IDD_RACP_VAL 0x2b27
/**
* @brief GATT Characteristic IDD Record Access Control Point
*/
#define BT_UUID_GATT_IDD_RACP \
BT_UUID_DECLARE_16(BT_UUID_GATT_IDD_RACP_VAL)
/**
* @brief GATT Characteristic IDD History Data UUID Value
*/
#define BT_UUID_GATT_IDD_HD_VAL 0x2b28
/**
* @brief GATT Characteristic IDD History Data
*/
#define BT_UUID_GATT_IDD_HD \
BT_UUID_DECLARE_16(BT_UUID_GATT_IDD_HD_VAL)
/**
* @brief GATT Characteristic Client Supported Features UUID value
*/
#define BT_UUID_GATT_CLIENT_FEATURES_VAL 0x2b29
/**
* @brief GATT Characteristic Client Supported Features
*/
#define BT_UUID_GATT_CLIENT_FEATURES \
BT_UUID_DECLARE_16(BT_UUID_GATT_CLIENT_FEATURES_VAL)
/**
* @brief GATT Characteristic Database Hash UUID value
*/
#define BT_UUID_GATT_DB_HASH_VAL 0x2b2a
/**
* @brief GATT Characteristic Database Hash
*/
#define BT_UUID_GATT_DB_HASH \
BT_UUID_DECLARE_16(BT_UUID_GATT_DB_HASH_VAL)
/**
* @brief GATT Characteristic BSS Control Point UUID Value
*/
#define BT_UUID_GATT_BSS_CP_VAL 0x2b2b
/**
* @brief GATT Characteristic BSS Control Point
*/
#define BT_UUID_GATT_BSS_CP \
BT_UUID_DECLARE_16(BT_UUID_GATT_BSS_CP_VAL)
/**
* @brief GATT Characteristic BSS Response UUID Value
*/
#define BT_UUID_GATT_BSS_R_VAL 0x2b2c
/**
* @brief GATT Characteristic BSS Response
*/
#define BT_UUID_GATT_BSS_R \
BT_UUID_DECLARE_16(BT_UUID_GATT_BSS_R_VAL)
/**
* @brief GATT Characteristic Emergency ID UUID Value
*/
#define BT_UUID_GATT_EMG_ID_VAL 0x2b2d
/**
* @brief GATT Characteristic Emergency ID
*/
#define BT_UUID_GATT_EMG_ID \
BT_UUID_DECLARE_16(BT_UUID_GATT_EMG_ID_VAL)
/**
* @brief GATT Characteristic Emergency Text UUID Value
*/
#define BT_UUID_GATT_EMG_TXT_VAL 0x2b2e
/**
* @brief GATT Characteristic Emergency Text
*/
#define BT_UUID_GATT_EMG_TXT \
BT_UUID_DECLARE_16(BT_UUID_GATT_EMG_TXT_VAL)
/**
* @brief GATT Characteristic ACS Status UUID Value
*/
#define BT_UUID_GATT_ACS_S_VAL 0x2b2f
/**
* @brief GATT Characteristic ACS Status
*/
#define BT_UUID_GATT_ACS_S \
BT_UUID_DECLARE_16(BT_UUID_GATT_ACS_S_VAL)
/**
* @brief GATT Characteristic ACS Data In UUID Value
*/
#define BT_UUID_GATT_ACS_DI_VAL 0x2b30
/**
* @brief GATT Characteristic ACS Data In
*/
#define BT_UUID_GATT_ACS_DI \
BT_UUID_DECLARE_16(BT_UUID_GATT_ACS_DI_VAL)
/**
* @brief GATT Characteristic ACS Data Out Notify UUID Value
*/
#define BT_UUID_GATT_ACS_DON_VAL 0x2b31
/**
* @brief GATT Characteristic ACS Data Out Notify
*/
#define BT_UUID_GATT_ACS_DON \
BT_UUID_DECLARE_16(BT_UUID_GATT_ACS_DON_VAL)
/**
* @brief GATT Characteristic ACS Data Out Indicate UUID Value
*/
#define BT_UUID_GATT_ACS_DOI_VAL 0x2b32
/**
* @brief GATT Characteristic ACS Data Out Indicate
*/
#define BT_UUID_GATT_ACS_DOI \
BT_UUID_DECLARE_16(BT_UUID_GATT_ACS_DOI_VAL)
/**
* @brief GATT Characteristic ACS Control Point UUID Value
*/
#define BT_UUID_GATT_ACS_CP_VAL 0x2b33
/**
* @brief GATT Characteristic ACS Control Point
*/
#define BT_UUID_GATT_ACS_CP \
BT_UUID_DECLARE_16(BT_UUID_GATT_ACS_CP_VAL)
/**
* @brief GATT Characteristic Enhanced Blood Pressure Measurement UUID Value
*/
#define BT_UUID_GATT_EBPM_VAL 0x2b34
/**
* @brief GATT Characteristic Enhanced Blood Pressure Measurement
*/
#define BT_UUID_GATT_EBPM \
BT_UUID_DECLARE_16(BT_UUID_GATT_EBPM_VAL)
/**
* @brief GATT Characteristic Enhanced Intermediate Cuff Pressure UUID Value
*/
#define BT_UUID_GATT_EICP_VAL 0x2b35
/**
* @brief GATT Characteristic Enhanced Intermediate Cuff Pressure
*/
#define BT_UUID_GATT_EICP \
BT_UUID_DECLARE_16(BT_UUID_GATT_EICP_VAL)
/**
* @brief GATT Characteristic Blood Pressure Record UUID Value
*/
#define BT_UUID_GATT_BPR_VAL 0x2b36
/**
* @brief GATT Characteristic Blood Pressure Record
*/
#define BT_UUID_GATT_BPR \
BT_UUID_DECLARE_16(BT_UUID_GATT_BPR_VAL)
/**
* @brief GATT Characteristic Registered User UUID Value
*/
#define BT_UUID_GATT_RU_VAL 0x2b37
/**
* @brief GATT Characteristic Registered User
*/
#define BT_UUID_GATT_RU \
BT_UUID_DECLARE_16(BT_UUID_GATT_RU_VAL)
/**
* @brief GATT Characteristic BR-EDR Handover Data UUID Value
*/
#define BT_UUID_GATT_BR_EDR_HD_VAL 0x2b38
/**
* @brief GATT Characteristic BR-EDR Handover Data
*/
#define BT_UUID_GATT_BR_EDR_HD \
BT_UUID_DECLARE_16(BT_UUID_GATT_BR_EDR_HD_VAL)
/**
* @brief GATT Characteristic Bluetooth SIG Data UUID Value
*/
#define BT_UUID_GATT_BT_SIG_D_VAL 0x2b39
/**
* @brief GATT Characteristic Bluetooth SIG Data
*/
#define BT_UUID_GATT_BT_SIG_D \
BT_UUID_DECLARE_16(BT_UUID_GATT_BT_SIG_D_VAL)
/**
* @brief GATT Characteristic Server Supported Features UUID value
*/
#define BT_UUID_GATT_SERVER_FEATURES_VAL 0x2b3a
/**
* @brief GATT Characteristic Server Supported Features
*/
#define BT_UUID_GATT_SERVER_FEATURES \
BT_UUID_DECLARE_16(BT_UUID_GATT_SERVER_FEATURES_VAL)
/**
* @brief GATT Characteristic Physical Activity Monitor Features UUID Value
*/
#define BT_UUID_GATT_PHY_AMF_VAL 0x2b3b
/**
* @brief GATT Characteristic Physical Activity Monitor Features
*/
#define BT_UUID_GATT_PHY_AMF \
BT_UUID_DECLARE_16(BT_UUID_GATT_PHY_AMF_VAL)
/**
* @brief GATT Characteristic General Activity Instantaneous Data UUID Value
*/
#define BT_UUID_GATT_GEN_AID_VAL 0x2b3c
/**
* @brief GATT Characteristic General Activity Instantaneous Data
*/
#define BT_UUID_GATT_GEN_AID \
BT_UUID_DECLARE_16(BT_UUID_GATT_GEN_AID_VAL)
/**
* @brief GATT Characteristic General Activity Summary Data UUID Value
*/
#define BT_UUID_GATT_GEN_ASD_VAL 0x2b3d
/**
* @brief GATT Characteristic General Activity Summary Data
*/
#define BT_UUID_GATT_GEN_ASD \
BT_UUID_DECLARE_16(BT_UUID_GATT_GEN_ASD_VAL)
/**
* @brief GATT Characteristic CardioRespiratory Activity Instantaneous Data UUID Value
*/
#define BT_UUID_GATT_CR_AID_VAL 0x2b3e
/**
* @brief GATT Characteristic CardioRespiratory Activity Instantaneous Data
*/
#define BT_UUID_GATT_CR_AID \
BT_UUID_DECLARE_16(BT_UUID_GATT_CR_AID_VAL)
/**
* @brief GATT Characteristic CardioRespiratory Activity Summary Data UUID Value
*/
#define BT_UUID_GATT_CR_ASD_VAL 0x2b3f
/**
* @brief GATT Characteristic CardioRespiratory Activity Summary Data
*/
#define BT_UUID_GATT_CR_ASD \
BT_UUID_DECLARE_16(BT_UUID_GATT_CR_ASD_VAL)
/**
* @brief GATT Characteristic Step Counter Activity Summary Data UUID Value
*/
#define BT_UUID_GATT_SC_ASD_VAL 0x2b40
/**
* @brief GATT Characteristic Step Counter Activity Summary Data
*/
#define BT_UUID_GATT_SC_ASD \
BT_UUID_DECLARE_16(BT_UUID_GATT_SC_ASD_VAL)
/**
* @brief GATT Characteristic Sleep Activity Instantaneous Data UUID Value
*/
#define BT_UUID_GATT_SLP_AID_VAL 0x2b41
/**
* @brief GATT Characteristic Sleep Activity Instantaneous Data
*/
#define BT_UUID_GATT_SLP_AID \
BT_UUID_DECLARE_16(BT_UUID_GATT_SLP_AID_VAL)
/**
* @brief GATT Characteristic Sleep Activity Summary Data UUID Value
*/
#define BT_UUID_GATT_SLP_ASD_VAL 0x2b42
/**
* @brief GATT Characteristic Sleep Activity Summary Data
*/
#define BT_UUID_GATT_SLP_ASD \
BT_UUID_DECLARE_16(BT_UUID_GATT_SLP_ASD_VAL)
/**
* @brief GATT Characteristic Physical Activity Monitor Control Point UUID Value
*/
#define BT_UUID_GATT_PHY_AMCP_VAL 0x2b43
/**
* @brief GATT Characteristic Physical Activity Monitor Control Point
*/
#define BT_UUID_GATT_PHY_AMCP \
BT_UUID_DECLARE_16(BT_UUID_GATT_PHY_AMCP_VAL)
/**
* @brief GATT Characteristic Activity Current Session UUID Value
*/
#define BT_UUID_GATT_ACS_VAL 0x2b44
/**
* @brief GATT Characteristic Activity Current Session
*/
#define BT_UUID_GATT_ACS \
BT_UUID_DECLARE_16(BT_UUID_GATT_ACS_VAL)
/**
* @brief GATT Characteristic Physical Activity Session Descriptor UUID Value
*/
#define BT_UUID_GATT_PHY_ASDESC_VAL 0x2b45
/**
* @brief GATT Characteristic Physical Activity Session Descriptor
*/
#define BT_UUID_GATT_PHY_ASDESC \
BT_UUID_DECLARE_16(BT_UUID_GATT_PHY_ASDESC_VAL)
/**
* @brief GATT Characteristic Preferred Units UUID Value
*/
#define BT_UUID_GATT_PREF_U_VAL 0x2b46
/**
* @brief GATT Characteristic Preferred Units
*/
#define BT_UUID_GATT_PREF_U \
BT_UUID_DECLARE_16(BT_UUID_GATT_PREF_U_VAL)
/**
* @brief GATT Characteristic High Resolution Height UUID Value
*/
#define BT_UUID_GATT_HRES_H_VAL 0x2b47
/**
* @brief GATT Characteristic High Resolution Height
*/
#define BT_UUID_GATT_HRES_H \
BT_UUID_DECLARE_16(BT_UUID_GATT_HRES_H_VAL)
/**
* @brief GATT Characteristic Middle Name UUID Value
*/
#define BT_UUID_GATT_MID_NAME_VAL 0x2b48
/**
* @brief GATT Characteristic Middle Name
*/
#define BT_UUID_GATT_MID_NAME \
BT_UUID_DECLARE_16(BT_UUID_GATT_MID_NAME_VAL)
/**
* @brief GATT Characteristic Stride Length UUID Value
*/
#define BT_UUID_GATT_STRDLEN_VAL 0x2b49
/**
* @brief GATT Characteristic Stride Length
*/
#define BT_UUID_GATT_STRDLEN \
BT_UUID_DECLARE_16(BT_UUID_GATT_STRDLEN_VAL)
/**
* @brief GATT Characteristic Handedness UUID Value
*/
#define BT_UUID_GATT_HANDEDNESS_VAL 0x2b4a
/**
* @brief GATT Characteristic Handedness
*/
#define BT_UUID_GATT_HANDEDNESS \
BT_UUID_DECLARE_16(BT_UUID_GATT_HANDEDNESS_VAL)
/**
* @brief GATT Characteristic Device Wearing Position UUID Value
*/
#define BT_UUID_GATT_DEVICE_WP_VAL 0x2b4b
/**
* @brief GATT Characteristic Device Wearing Position
*/
#define BT_UUID_GATT_DEVICE_WP \
BT_UUID_DECLARE_16(BT_UUID_GATT_DEVICE_WP_VAL)
/**
* @brief GATT Characteristic Four Zone Heart Rate Limit UUID Value
*/
#define BT_UUID_GATT_4ZHRL_VAL 0x2b4c
/**
* @brief GATT Characteristic Four Zone Heart Rate Limit
*/
#define BT_UUID_GATT_4ZHRL \
BT_UUID_DECLARE_16(BT_UUID_GATT_4ZHRL_VAL)
/**
* @brief GATT Characteristic High Intensity Exercise Threshold UUID Value
*/
#define BT_UUID_GATT_HIET_VAL 0x2b4d
/**
* @brief GATT Characteristic High Intensity Exercise Threshold
*/
#define BT_UUID_GATT_HIET \
BT_UUID_DECLARE_16(BT_UUID_GATT_HIET_VAL)
/**
* @brief GATT Characteristic Activity Goal UUID Value
*/
#define BT_UUID_GATT_AG_VAL 0x2b4e
/**
* @brief GATT Characteristic Activity Goal
*/
#define BT_UUID_GATT_AG \
BT_UUID_DECLARE_16(BT_UUID_GATT_AG_VAL)
/**
* @brief GATT Characteristic Sedentary Interval Notification UUID Value
*/
#define BT_UUID_GATT_SIN_VAL 0x2b4f
/**
* @brief GATT Characteristic Sedentary Interval Notification
*/
#define BT_UUID_GATT_SIN \
BT_UUID_DECLARE_16(BT_UUID_GATT_SIN_VAL)
/**
* @brief GATT Characteristic Caloric Intake UUID Value
*/
#define BT_UUID_GATT_CI_VAL 0x2b50
/**
* @brief GATT Characteristic Caloric Intake
*/
#define BT_UUID_GATT_CI \
BT_UUID_DECLARE_16(BT_UUID_GATT_CI_VAL)
/**
* @brief GATT Characteristic TMAP Role UUID Value
*/
#define BT_UUID_GATT_TMAPR_VAL 0x2b51
/**
* @brief GATT Characteristic TMAP Role
*/
#define BT_UUID_GATT_TMAPR \
BT_UUID_DECLARE_16(BT_UUID_GATT_TMAPR_VAL)
/**
* @brief Audio Input Control Service State value
*/
#define BT_UUID_AICS_STATE_VAL 0x2b77
/**
* @brief Audio Input Control Service State
*/
#define BT_UUID_AICS_STATE \
BT_UUID_DECLARE_16(BT_UUID_AICS_STATE_VAL)
/**
* @brief Audio Input Control Service Gain Settings Properties value
*/
#define BT_UUID_AICS_GAIN_SETTINGS_VAL 0x2b78
/**
* @brief Audio Input Control Service Gain Settings Properties
*/
#define BT_UUID_AICS_GAIN_SETTINGS \
BT_UUID_DECLARE_16(BT_UUID_AICS_GAIN_SETTINGS_VAL)
/**
* @brief Audio Input Control Service Input Type value
*/
#define BT_UUID_AICS_INPUT_TYPE_VAL 0x2b79
/**
* @brief Audio Input Control Service Input Type
*/
#define BT_UUID_AICS_INPUT_TYPE \
BT_UUID_DECLARE_16(BT_UUID_AICS_INPUT_TYPE_VAL)
/**
* @brief Audio Input Control Service Input Status value
*/
#define BT_UUID_AICS_INPUT_STATUS_VAL 0x2b7a
/**
* @brief Audio Input Control Service Input Status
*/
#define BT_UUID_AICS_INPUT_STATUS \
BT_UUID_DECLARE_16(BT_UUID_AICS_INPUT_STATUS_VAL)
/**
* @brief Audio Input Control Service Control Point value
*/
#define BT_UUID_AICS_CONTROL_VAL 0x2b7b
/**
* @brief Audio Input Control Service Control Point
*/
#define BT_UUID_AICS_CONTROL \
BT_UUID_DECLARE_16(BT_UUID_AICS_CONTROL_VAL)
/**
* @brief Audio Input Control Service Input Description value
*/
#define BT_UUID_AICS_DESCRIPTION_VAL 0x2b7c
/**
* @brief Audio Input Control Service Input Description
*/
#define BT_UUID_AICS_DESCRIPTION \
BT_UUID_DECLARE_16(BT_UUID_AICS_DESCRIPTION_VAL)
/**
* @brief Volume Control Setting value
*/
#define BT_UUID_VCS_STATE_VAL 0x2b7d
/**
* @brief Volume Control Setting
*/
#define BT_UUID_VCS_STATE \
BT_UUID_DECLARE_16(BT_UUID_VCS_STATE_VAL)
/**
* @brief Volume Control Control point value
*/
#define BT_UUID_VCS_CONTROL_VAL 0x2b7e
/**
* @brief Volume Control Control point
*/
#define BT_UUID_VCS_CONTROL \
BT_UUID_DECLARE_16(BT_UUID_VCS_CONTROL_VAL)
/**
* @brief Volume Control Flags value
*/
#define BT_UUID_VCS_FLAGS_VAL 0x2b7f
/**
* @brief Volume Control Flags
*/
#define BT_UUID_VCS_FLAGS \
BT_UUID_DECLARE_16(BT_UUID_VCS_FLAGS_VAL)
/**
* @brief Volume Offset State value
*/
#define BT_UUID_VOCS_STATE_VAL 0x2b80
/**
* @brief Volume Offset State
*/
#define BT_UUID_VOCS_STATE \
BT_UUID_DECLARE_16(BT_UUID_VOCS_STATE_VAL)
/**
* @brief Audio Location value
*/
#define BT_UUID_VOCS_LOCATION_VAL 0x2b81
/**
* @brief Audio Location
*/
#define BT_UUID_VOCS_LOCATION \
BT_UUID_DECLARE_16(BT_UUID_VOCS_LOCATION_VAL)
/**
* @brief Volume Offset Control Point value
*/
#define BT_UUID_VOCS_CONTROL_VAL 0x2b82
/**
* @brief Volume Offset Control Point
*/
#define BT_UUID_VOCS_CONTROL \
BT_UUID_DECLARE_16(BT_UUID_VOCS_CONTROL_VAL)
/**
* @brief Volume Offset Audio Output Description value
*/
#define BT_UUID_VOCS_DESCRIPTION_VAL 0x2b83
/**
* @brief Volume Offset Audio Output Description
*/
#define BT_UUID_VOCS_DESCRIPTION \
BT_UUID_DECLARE_16(BT_UUID_VOCS_DESCRIPTION_VAL)
/**
* @brief Set Identity Resolving Key value
*/
#define BT_UUID_CSIS_SIRK_VAL 0x2b84
/**
* @brief Set Identity Resolving Key
*/
#define BT_UUID_CSIS_SIRK BT_UUID_DECLARE_16(BT_UUID_CSIS_SIRK_VAL)
/**
* @brief Set size value
*/
#define BT_UUID_CSIS_SET_SIZE_VAL 0x2b85
/**
* @brief Set size
*/
#define BT_UUID_CSIS_SET_SIZE \
BT_UUID_DECLARE_16(BT_UUID_CSIS_SET_SIZE_VAL)
/**
* @brief Set lock value
*/
#define BT_UUID_CSIS_SET_LOCK_VAL 0x2b86
/**
* @brief Set lock
*/
#define BT_UUID_CSIS_SET_LOCK \
BT_UUID_DECLARE_16(BT_UUID_CSIS_SET_LOCK_VAL)
/**
* @brief Rank value
*/
#define BT_UUID_CSIS_RANK_VAL 0x2b87
/**
* @brief Rank
*/
#define BT_UUID_CSIS_RANK \
BT_UUID_DECLARE_16(BT_UUID_CSIS_RANK_VAL)
/**
* @brief GATT Characteristic Encrypted Data Key Material UUID Value
*/
#define BT_UUID_GATT_EDKM_VAL 0x2b88
/**
* @brief GATT Characteristic Encrypted Data Key Material
*/
#define BT_UUID_GATT_EDKM \
BT_UUID_DECLARE_16(BT_UUID_GATT_EDKM_VAL)
/**
* @brief GATT Characteristic Apparent Energy 32 UUID Value
*/
#define BT_UUID_GATT_AE32_VAL 0x2b89
/**
* @brief GATT Characteristic Apparent Energy 32
*/
#define BT_UUID_GATT_AE32 \
BT_UUID_DECLARE_16(BT_UUID_GATT_AE32_VAL)
/**
* @brief GATT Characteristic Apparent Power UUID Value
*/
#define BT_UUID_GATT_AP_VAL 0x2b8a
/**
* @brief GATT Characteristic Apparent Power
*/
#define BT_UUID_GATT_AP \
BT_UUID_DECLARE_16(BT_UUID_GATT_AP_VAL)
/**
* @brief GATT Characteristic CO2 Concentration UUID Value
*/
#define BT_UUID_GATT_CO2CONC_VAL 0x2b8c
/**
* @brief GATT Characteristic CO2 Concentration
*/
#define BT_UUID_GATT_CO2CONC \
BT_UUID_DECLARE_16(BT_UUID_GATT_CO2CONC_VAL)
/**
* @brief GATT Characteristic Cosine of the Angle UUID Value
*/
#define BT_UUID_GATT_COS_VAL 0x2b8d
/**
* @brief GATT Characteristic Cosine of the Angle
*/
#define BT_UUID_GATT_COS \
BT_UUID_DECLARE_16(BT_UUID_GATT_COS_VAL)
/**
* @brief GATT Characteristic Device Time Feature UUID Value
*/
#define BT_UUID_GATT_DEVTF_VAL 0x2b8e
/**
* @brief GATT Characteristic Device Time Feature
*/
#define BT_UUID_GATT_DEVTF \
BT_UUID_DECLARE_16(BT_UUID_GATT_DEVTF_VAL)
/**
* @brief GATT Characteristic Device Time Parameters UUID Value
*/
#define BT_UUID_GATT_DEVTP_VAL 0x2b8f
/**
* @brief GATT Characteristic Device Time Parameters
*/
#define BT_UUID_GATT_DEVTP \
BT_UUID_DECLARE_16(BT_UUID_GATT_DEVTP_VAL)
/**
* @brief GATT Characteristic Device Time UUID Value
*/
#define BT_UUID_GATT_DEVT_VAL 0x2b90
/**
* @brief GATT Characteristic String
*/
#define BT_UUID_GATT_DEVT \
BT_UUID_DECLARE_16(BT_UUID_GATT_DEVT_VAL)
/**
* @brief GATT Characteristic Device Time Control Point UUID Value
*/
#define BT_UUID_GATT_DEVTCP_VAL 0x2b91
/**
* @brief GATT Characteristic Device Time Control Point
*/
#define BT_UUID_GATT_DEVTCP \
BT_UUID_DECLARE_16(BT_UUID_GATT_DEVTCP_VAL)
/**
* @brief GATT Characteristic Time Change Log Data UUID Value
*/
#define BT_UUID_GATT_TCLD_VAL 0x2b92
/**
* @brief GATT Characteristic Time Change Log Data
*/
#define BT_UUID_GATT_TCLD \
BT_UUID_DECLARE_16(BT_UUID_GATT_TCLD_VAL)
/**
* @brief Media player name value
*/
#define BT_UUID_MCS_PLAYER_NAME_VAL 0x2b93
/**
* @brief Media player name
*/
#define BT_UUID_MCS_PLAYER_NAME \
BT_UUID_DECLARE_16(BT_UUID_MCS_PLAYER_NAME_VAL)
/**
* @brief Media Icon Object ID value
*/
#define BT_UUID_MCS_ICON_OBJ_ID_VAL 0x2b94
/**
* @brief Media Icon Object ID
*/
#define BT_UUID_MCS_ICON_OBJ_ID \
BT_UUID_DECLARE_16(BT_UUID_MCS_ICON_OBJ_ID_VAL)
/**
* @brief Media Icon URL value
*/
#define BT_UUID_MCS_ICON_URL_VAL 0x2b95
/**
* @brief Media Icon URL
*/
#define BT_UUID_MCS_ICON_URL \
BT_UUID_DECLARE_16(BT_UUID_MCS_ICON_URL_VAL)
/**
* @brief Track Changed value
*/
#define BT_UUID_MCS_TRACK_CHANGED_VAL 0x2b96
/**
* @brief Track Changed
*/
#define BT_UUID_MCS_TRACK_CHANGED \
BT_UUID_DECLARE_16(BT_UUID_MCS_TRACK_CHANGED_VAL)
/**
* @brief Track Title value
*/
#define BT_UUID_MCS_TRACK_TITLE_VAL 0x2b97
/**
* @brief Track Title
*/
#define BT_UUID_MCS_TRACK_TITLE \
BT_UUID_DECLARE_16(BT_UUID_MCS_TRACK_TITLE_VAL)
/**
* @brief Track Duration value
*/
#define BT_UUID_MCS_TRACK_DURATION_VAL 0x2b98
/**
* @brief Track Duration
*/
#define BT_UUID_MCS_TRACK_DURATION \
BT_UUID_DECLARE_16(BT_UUID_MCS_TRACK_DURATION_VAL)
/**
* @brief Track Position value
*/
#define BT_UUID_MCS_TRACK_POSITION_VAL 0x2b99
/**
* @brief Track Position
*/
#define BT_UUID_MCS_TRACK_POSITION \
BT_UUID_DECLARE_16(BT_UUID_MCS_TRACK_POSITION_VAL)
/**
* @brief Playback Speed value
*/
#define BT_UUID_MCS_PLAYBACK_SPEED_VAL 0x2b9a
/**
* @brief Playback Speed
*/
#define BT_UUID_MCS_PLAYBACK_SPEED \
BT_UUID_DECLARE_16(BT_UUID_MCS_PLAYBACK_SPEED_VAL)
/**
* @brief Seeking Speed value
*/
#define BT_UUID_MCS_SEEKING_SPEED_VAL 0x2b9b
/**
* @brief Seeking Speed
*/
#define BT_UUID_MCS_SEEKING_SPEED \
BT_UUID_DECLARE_16(BT_UUID_MCS_SEEKING_SPEED_VAL)
/**
* @brief Track Segments Object ID value
*/
#define BT_UUID_MCS_TRACK_SEGMENTS_OBJ_ID_VAL 0x2b9c
/**
* @brief Track Segments Object ID
*/
#define BT_UUID_MCS_TRACK_SEGMENTS_OBJ_ID \
BT_UUID_DECLARE_16(BT_UUID_MCS_TRACK_SEGMENTS_OBJ_ID_VAL)
/**
* @brief Current Track Object ID value
*/
#define BT_UUID_MCS_CURRENT_TRACK_OBJ_ID_VAL 0x2b9d
/**
* @brief Current Track Object ID
*/
#define BT_UUID_MCS_CURRENT_TRACK_OBJ_ID \
BT_UUID_DECLARE_16(BT_UUID_MCS_CURRENT_TRACK_OBJ_ID_VAL)
/**
* @brief Next Track Object ID value
*/
#define BT_UUID_MCS_NEXT_TRACK_OBJ_ID_VAL 0x2b9e
/**
* @brief Next Track Object ID
*/
#define BT_UUID_MCS_NEXT_TRACK_OBJ_ID \
BT_UUID_DECLARE_16(BT_UUID_MCS_NEXT_TRACK_OBJ_ID_VAL)
/**
* @brief Parent Group Object ID value
*/
#define BT_UUID_MCS_PARENT_GROUP_OBJ_ID_VAL 0x2b9f
/**
* @brief Parent Group Object ID
*/
#define BT_UUID_MCS_PARENT_GROUP_OBJ_ID \
BT_UUID_DECLARE_16(BT_UUID_MCS_PARENT_GROUP_OBJ_ID_VAL)
/**
* @brief Group Object ID value
*/
#define BT_UUID_MCS_CURRENT_GROUP_OBJ_ID_VAL 0x2ba0
/**
* @brief Group Object ID
*/
#define BT_UUID_MCS_CURRENT_GROUP_OBJ_ID \
BT_UUID_DECLARE_16(BT_UUID_MCS_CURRENT_GROUP_OBJ_ID_VAL)
/**
* @brief Playing Order value
*/
#define BT_UUID_MCS_PLAYING_ORDER_VAL 0x2ba1
/**
* @brief Playing Order
*/
#define BT_UUID_MCS_PLAYING_ORDER \
BT_UUID_DECLARE_16(BT_UUID_MCS_PLAYING_ORDER_VAL)
/**
* @brief Playing Orders supported value
*/
#define BT_UUID_MCS_PLAYING_ORDERS_VAL 0x2ba2
/**
* @brief Playing Orders supported
*/
#define BT_UUID_MCS_PLAYING_ORDERS \
BT_UUID_DECLARE_16(BT_UUID_MCS_PLAYING_ORDERS_VAL)
/**
* @brief Media State value
*/
#define BT_UUID_MCS_MEDIA_STATE_VAL 0x2ba3
/**
* @brief Media State
*/
#define BT_UUID_MCS_MEDIA_STATE \
BT_UUID_DECLARE_16(BT_UUID_MCS_MEDIA_STATE_VAL)
/**
* @brief Media Control Point value
*/
#define BT_UUID_MCS_MEDIA_CONTROL_POINT_VAL 0x2ba4
/**
* @brief Media Control Point
*/
#define BT_UUID_MCS_MEDIA_CONTROL_POINT \
BT_UUID_DECLARE_16(BT_UUID_MCS_MEDIA_CONTROL_POINT_VAL)
/**
* @brief Media control opcodes supported value
*/
#define BT_UUID_MCS_MEDIA_CONTROL_OPCODES_VAL 0x2ba5
/**
* @brief Media control opcodes supported
*/
#define BT_UUID_MCS_MEDIA_CONTROL_OPCODES \
BT_UUID_DECLARE_16(BT_UUID_MCS_MEDIA_CONTROL_OPCODES_VAL)
/**
* @brief Search result object ID value
*/
#define BT_UUID_MCS_SEARCH_RESULTS_OBJ_ID_VAL 0x2ba6
/**
* @brief Search result object ID
*/
#define BT_UUID_MCS_SEARCH_RESULTS_OBJ_ID \
BT_UUID_DECLARE_16(BT_UUID_MCS_SEARCH_RESULTS_OBJ_ID_VAL)
/**
* @brief Search control point value
*/
#define BT_UUID_MCS_SEARCH_CONTROL_POINT_VAL 0x2ba7
/**
* @brief Search control point
*/
#define BT_UUID_MCS_SEARCH_CONTROL_POINT \
BT_UUID_DECLARE_16(BT_UUID_MCS_SEARCH_CONTROL_POINT_VAL)
/**
* @brief GATT Characteristic Energy 32 UUID Value
*/
#define BT_UUID_GATT_E32_VAL 0x2ba8
/**
* @brief GATT Characteristic Energy 32
*/
#define BT_UUID_GATT_E32 \
BT_UUID_DECLARE_16(BT_UUID_GATT_E32_VAL)
/**
* @brief Media Player Icon Object Type value
*/
#define BT_UUID_OTS_TYPE_MPL_ICON_VAL 0x2ba9
/**
* @brief Media Player Icon Object Type
*/
#define BT_UUID_OTS_TYPE_MPL_ICON \
BT_UUID_DECLARE_16(BT_UUID_OTS_TYPE_MPL_ICON_VAL)
/**
* @brief Track Segments Object Type value
*/
#define BT_UUID_OTS_TYPE_TRACK_SEGMENT_VAL 0x2baa
/**
* @brief Track Segments Object Type
*/
#define BT_UUID_OTS_TYPE_TRACK_SEGMENT \
BT_UUID_DECLARE_16(BT_UUID_OTS_TYPE_TRACK_SEGMENT_VAL)
/**
* @brief Track Object Type value
*/
#define BT_UUID_OTS_TYPE_TRACK_VAL 0x2bab
/**
* @brief Track Object Type
*/
#define BT_UUID_OTS_TYPE_TRACK \
BT_UUID_DECLARE_16(BT_UUID_OTS_TYPE_TRACK_VAL)
/**
* @brief Group Object Type value
*/
#define BT_UUID_OTS_TYPE_GROUP_VAL 0x2bac
/**
* @brief Group Object Type
*/
#define BT_UUID_OTS_TYPE_GROUP \
BT_UUID_DECLARE_16(BT_UUID_OTS_TYPE_GROUP_VAL)
/**
* @brief GATT Characteristic Constant Tone Extension Enable UUID Value
*/
#define BT_UUID_GATT_CTEE_VAL 0x2bad
/**
* @brief GATT Characteristic Constant Tone Extension Enable
*/
#define BT_UUID_GATT_CTEE \
BT_UUID_DECLARE_16(BT_UUID_GATT_CTEE_VAL)
/**
* @brief GATT Characteristic Advertising Constant Tone Extension Minimum Length UUID Value
*/
#define BT_UUID_GATT_ACTEML_VAL 0x2bae
/**
* @brief GATT Characteristic Advertising Constant Tone Extension Minimum Length
*/
#define BT_UUID_GATT_ACTEML \
BT_UUID_DECLARE_16(BT_UUID_GATT_ACTEML_VAL)
/**
* @brief GATT Characteristic Advertising Constant Tone Extension Minimum Transmit Count UUID Value
*/
#define BT_UUID_GATT_ACTEMTC_VAL 0x2baf
/**
* @brief GATT Characteristic Advertising Constant Tone Extension Minimum Transmit Count
*/
#define BT_UUID_GATT_ACTEMTC \
BT_UUID_DECLARE_16(BT_UUID_GATT_ACTEMTC_VAL)
/**
* @brief GATT Characteristic Advertising Constant Tone Extension Transmit Duration UUID Value
*/
#define BT_UUID_GATT_ACTETD_VAL 0x2bb0
/**
* @brief GATT Characteristic Advertising Constant Tone Extension Transmit Duration
*/
#define BT_UUID_GATT_ACTETD \
BT_UUID_DECLARE_16(BT_UUID_GATT_ACTETD_VAL)
/**
* @brief GATT Characteristic Advertising Constant Tone Extension Interval UUID Value
*/
#define BT_UUID_GATT_ACTEI_VAL 0x2bb1
/**
* @brief GATT Characteristic Advertising Constant Tone Extension Interval
*/
#define BT_UUID_GATT_ACTEI \
BT_UUID_DECLARE_16(BT_UUID_GATT_ACTEI_VAL)
/**
* @brief GATT Characteristic Advertising Constant Tone Extension PHY UUID Value
*/
#define BT_UUID_GATT_ACTEP_VAL 0x2bb2
/**
* @brief GATT Characteristic Advertising Constant Tone Extension PHY
*/
#define BT_UUID_GATT_ACTEP \
BT_UUID_DECLARE_16(BT_UUID_GATT_ACTEP_VAL)
/**
* @brief Bearer Provider Name value
*/
#define BT_UUID_TBS_PROVIDER_NAME_VAL 0x2bb3
/**
* @brief Bearer Provider Name
*/
#define BT_UUID_TBS_PROVIDER_NAME \
BT_UUID_DECLARE_16(BT_UUID_TBS_PROVIDER_NAME_VAL)
/**
* @brief Bearer UCI value
*/
#define BT_UUID_TBS_UCI_VAL 0x2bb4
/**
* @brief Bearer UCI
*/
#define BT_UUID_TBS_UCI \
BT_UUID_DECLARE_16(BT_UUID_TBS_UCI_VAL)
/**
* @brief Bearer Technology value
*/
#define BT_UUID_TBS_TECHNOLOGY_VAL 0x2bb5
/**
* @brief Bearer Technology
*/
#define BT_UUID_TBS_TECHNOLOGY \
BT_UUID_DECLARE_16(BT_UUID_TBS_TECHNOLOGY_VAL)
/**
* @brief Bearer URI Prefixes Supported List value
*/
#define BT_UUID_TBS_URI_LIST_VAL 0x2bb6
/**
* @brief Bearer URI Prefixes Supported List
*/
#define BT_UUID_TBS_URI_LIST \
BT_UUID_DECLARE_16(BT_UUID_TBS_URI_LIST_VAL)
/**
* @brief Bearer Signal Strength value
*/
#define BT_UUID_TBS_SIGNAL_STRENGTH_VAL 0x2bb7
/**
* @brief Bearer Signal Strength
*/
#define BT_UUID_TBS_SIGNAL_STRENGTH \
BT_UUID_DECLARE_16(BT_UUID_TBS_SIGNAL_STRENGTH_VAL)
/**
* @brief Bearer Signal Strength Reporting Interval value
*/
#define BT_UUID_TBS_SIGNAL_INTERVAL_VAL 0x2bb8
/**
* @brief Bearer Signal Strength Reporting Interval
*/
#define BT_UUID_TBS_SIGNAL_INTERVAL \
BT_UUID_DECLARE_16(BT_UUID_TBS_SIGNAL_INTERVAL_VAL)
/**
* @brief Bearer List Current Calls value
*/
#define BT_UUID_TBS_LIST_CURRENT_CALLS_VAL 0x2bb9
/**
* @brief Bearer List Current Calls
*/
#define BT_UUID_TBS_LIST_CURRENT_CALLS \
BT_UUID_DECLARE_16(BT_UUID_TBS_LIST_CURRENT_CALLS_VAL)
/**
* @brief Content Control ID value
*/
#define BT_UUID_CCID_VAL 0x2bba
/**
* @brief Content Control ID
*/
#define BT_UUID_CCID \
BT_UUID_DECLARE_16(BT_UUID_CCID_VAL)
/**
* @brief Status flags value
*/
#define BT_UUID_TBS_STATUS_FLAGS_VAL 0x2bbb
/**
* @brief Status flags
*/
#define BT_UUID_TBS_STATUS_FLAGS \
BT_UUID_DECLARE_16(BT_UUID_TBS_STATUS_FLAGS_VAL)
/**
* @brief Incoming Call Target Caller ID value
*/
#define BT_UUID_TBS_INCOMING_URI_VAL 0x2bbc
/**
* @brief Incoming Call Target Caller ID
*/
#define BT_UUID_TBS_INCOMING_URI \
BT_UUID_DECLARE_16(BT_UUID_TBS_INCOMING_URI_VAL)
/**
* @brief Call State value
*/
#define BT_UUID_TBS_CALL_STATE_VAL 0x2bbd
/**
* @brief Call State
*/
#define BT_UUID_TBS_CALL_STATE \
BT_UUID_DECLARE_16(BT_UUID_TBS_CALL_STATE_VAL)
/**
* @brief Call Control Point value
*/
#define BT_UUID_TBS_CALL_CONTROL_POINT_VAL 0x2bbe
/**
* @brief Call Control Point
*/
#define BT_UUID_TBS_CALL_CONTROL_POINT \
BT_UUID_DECLARE_16(BT_UUID_TBS_CALL_CONTROL_POINT_VAL)
/**
* @brief Optional Opcodes value
*/
#define BT_UUID_TBS_OPTIONAL_OPCODES_VAL 0x2bbf
/**
* @brief Optional Opcodes
*/
#define BT_UUID_TBS_OPTIONAL_OPCODES \
BT_UUID_DECLARE_16(BT_UUID_TBS_OPTIONAL_OPCODES_VAL)
/** BT_UUID_TBS_TERMINATE_REASON_VAL
* @brief Terminate reason value
*/
#define BT_UUID_TBS_TERMINATE_REASON_VAL 0x2bc0
/** BT_UUID_TBS_TERMINATE_REASON
* @brief Terminate reason
*/
#define BT_UUID_TBS_TERMINATE_REASON \
BT_UUID_DECLARE_16(BT_UUID_TBS_TERMINATE_REASON_VAL)
/**
* @brief Incoming Call value
*/
#define BT_UUID_TBS_INCOMING_CALL_VAL 0x2bc1
/**
* @brief Incoming Call
*/
#define BT_UUID_TBS_INCOMING_CALL \
BT_UUID_DECLARE_16(BT_UUID_TBS_INCOMING_CALL_VAL)
/**
* @brief Incoming Call Friendly name value
*/
#define BT_UUID_TBS_FRIENDLY_NAME_VAL 0x2bc2
/**
* @brief Incoming Call Friendly name
*/
#define BT_UUID_TBS_FRIENDLY_NAME \
BT_UUID_DECLARE_16(BT_UUID_TBS_FRIENDLY_NAME_VAL)
/**
* @brief Microphone Control Service Mute value
*/
#define BT_UUID_MICS_MUTE_VAL 0x2bc3
/**
* @brief Microphone Control Service Mute
*/
#define BT_UUID_MICS_MUTE \
BT_UUID_DECLARE_16(BT_UUID_MICS_MUTE_VAL)
/**
* @brief Audio Stream Endpoint Sink Characteristic value
*/
#define BT_UUID_ASCS_ASE_SNK_VAL 0x2bc4
/**
* @brief Audio Stream Endpoint Sink Characteristic
*/
#define BT_UUID_ASCS_ASE_SNK \
BT_UUID_DECLARE_16(BT_UUID_ASCS_ASE_SNK_VAL)
/**
* @brief Audio Stream Endpoint Source Characteristic value
*/
#define BT_UUID_ASCS_ASE_SRC_VAL 0x2bc5
/**
* @brief Audio Stream Endpoint Source Characteristic
*/
#define BT_UUID_ASCS_ASE_SRC \
BT_UUID_DECLARE_16(BT_UUID_ASCS_ASE_SRC_VAL)
/**
* @brief Audio Stream Endpoint Control Point Characteristic value
*/
#define BT_UUID_ASCS_ASE_CP_VAL 0x2bc6
/**
* @brief Audio Stream Endpoint Control Point Characteristic
*/
#define BT_UUID_ASCS_ASE_CP \
BT_UUID_DECLARE_16(BT_UUID_ASCS_ASE_CP_VAL)
/**
* @brief Broadcast Audio Scan Service Scan State value
*/
#define BT_UUID_BASS_CONTROL_POINT_VAL 0x2bc7
/**
* @brief Broadcast Audio Scan Service Scan State
*/
#define BT_UUID_BASS_CONTROL_POINT \
BT_UUID_DECLARE_16(BT_UUID_BASS_CONTROL_POINT_VAL)
/**
* @brief Broadcast Audio Scan Service Receive State value
*/
#define BT_UUID_BASS_RECV_STATE_VAL 0x2bc8
/**
* @brief Broadcast Audio Scan Service Receive State
*/
#define BT_UUID_BASS_RECV_STATE \
BT_UUID_DECLARE_16(BT_UUID_BASS_RECV_STATE_VAL)
/**
* @brief Sink PAC Characteristic value
*/
#define BT_UUID_PACS_SNK_VAL 0x2bc9
/**
* @brief Sink PAC Characteristic
*/
#define BT_UUID_PACS_SNK \
BT_UUID_DECLARE_16(BT_UUID_PACS_SNK_VAL)
/**
* @brief Sink PAC Locations Characteristic value
*/
#define BT_UUID_PACS_SNK_LOC_VAL 0x2bca
/**
* @brief Sink PAC Locations Characteristic
*/
#define BT_UUID_PACS_SNK_LOC \
BT_UUID_DECLARE_16(BT_UUID_PACS_SNK_LOC_VAL)
/**
* @brief Source PAC Characteristic value
*/
#define BT_UUID_PACS_SRC_VAL 0x2bcb
/**
* @brief Source PAC Characteristic
*/
#define BT_UUID_PACS_SRC \
BT_UUID_DECLARE_16(BT_UUID_PACS_SRC_VAL)
/**
* @brief Source PAC Locations Characteristic value
*/
#define BT_UUID_PACS_SRC_LOC_VAL 0x2bcc
/**
* @brief Source PAC Locations Characteristic
*/
#define BT_UUID_PACS_SRC_LOC \
BT_UUID_DECLARE_16(BT_UUID_PACS_SRC_LOC_VAL)
/**
* @brief Available Audio Contexts Characteristic value
*/
#define BT_UUID_PACS_AVAILABLE_CONTEXT_VAL 0x2bcd
/**
* @brief Available Audio Contexts Characteristic
*/
#define BT_UUID_PACS_AVAILABLE_CONTEXT \
BT_UUID_DECLARE_16(BT_UUID_PACS_AVAILABLE_CONTEXT_VAL)
/**
* @brief Supported Audio Context Characteristic value
*/
#define BT_UUID_PACS_SUPPORTED_CONTEXT_VAL 0x2bce
/**
* @brief Supported Audio Context Characteristic
*/
#define BT_UUID_PACS_SUPPORTED_CONTEXT \
BT_UUID_DECLARE_16(BT_UUID_PACS_SUPPORTED_CONTEXT_VAL)
/**
* @brief GATT Characteristic Ammonia Concentration UUID Value
*/
#define BT_UUID_GATT_NH4CONC_VAL 0x2bcf
/**
* @brief GATT Characteristic Ammonia Concentration
*/
#define BT_UUID_GATT_NH4CONC \
BT_UUID_DECLARE_16(BT_UUID_GATT_NH4CONC_VAL)
/**
* @brief GATT Characteristic Carbon Monoxide Concentration UUID Value
*/
#define BT_UUID_GATT_COCONC_VAL 0x2bd0
/**
* @brief GATT Characteristic Carbon Monoxide Concentration
*/
#define BT_UUID_GATT_COCONC \
BT_UUID_DECLARE_16(BT_UUID_GATT_COCONC_VAL)
/**
* @brief GATT Characteristic Methane Concentration UUID Value
*/
#define BT_UUID_GATT_CH4CONC_VAL 0x2bd1
/**
* @brief GATT Characteristic Methane Concentration
*/
#define BT_UUID_GATT_CH4CONC \
BT_UUID_DECLARE_16(BT_UUID_GATT_CH4CONC_VAL)
/**
* @brief GATT Characteristic Nitrogen Dioxide Concentration UUID Value
*/
#define BT_UUID_GATT_NO2CONC_VAL 0x2bd2
/**
* @brief GATT Characteristic Nitrogen Dioxide Concentration
*/
#define BT_UUID_GATT_NO2CONC \
BT_UUID_DECLARE_16(BT_UUID_GATT_NO2CONC_VAL)
/**
* @brief GATT Characteristic Non-Methane Volatile Organic Compounds Concentration UUID Value
*/
#define BT_UUID_GATT_NONCH4CONC_VAL 0x2bd3
/**
* @brief GATT Characteristic Non-Methane Volatile Organic Compounds Concentration
*/
#define BT_UUID_GATT_NONCH4CONC \
BT_UUID_DECLARE_16(BT_UUID_GATT_NONCH4CONC_VAL)
/**
* @brief GATT Characteristic Ozone Concentration UUID Value
*/
#define BT_UUID_GATT_O3CONC_VAL 0x2bd4
/**
* @brief GATT Characteristic Ozone Concentration
*/
#define BT_UUID_GATT_O3CONC \
BT_UUID_DECLARE_16(BT_UUID_GATT_O3CONC_VAL)
/**
* @brief GATT Characteristic Particulate Matter - PM1 Concentration UUID Value
*/
#define BT_UUID_GATT_PM1CONC_VAL 0x2bd5
/**
* @brief GATT Characteristic Particulate Matter - PM1 Concentration
*/
#define BT_UUID_GATT_PM1CONC \
BT_UUID_DECLARE_16(BT_UUID_GATT_PM1CONC_VAL)
/**
* @brief GATT Characteristic Particulate Matter - PM2.5 Concentration UUID Value
*/
#define BT_UUID_GATT_PM25CONC_VAL 0x2bd6
/**
* @brief GATT Characteristic Particulate Matter - PM2.5 Concentration
*/
#define BT_UUID_GATT_PM25CONC \
BT_UUID_DECLARE_16(BT_UUID_GATT_PM25CONC_VAL)
/**
* @brief GATT Characteristic Particulate Matter - PM10 Concentration UUID Value
*/
#define BT_UUID_GATT_PM10CONC_VAL 0x2bd7
/**
* @brief GATT Characteristic Particulate Matter - PM10 Concentration
*/
#define BT_UUID_GATT_PM10CONC \
BT_UUID_DECLARE_16(BT_UUID_GATT_PM10CONC_VAL)
/**
* @brief GATT Characteristic Sulfur Dioxide Concentration UUID Value
*/
#define BT_UUID_GATT_SO2CONC_VAL 0x2bd8
/**
* @brief GATT Characteristic Sulfur Dioxide Concentration
*/
#define BT_UUID_GATT_SO2CONC \
BT_UUID_DECLARE_16(BT_UUID_GATT_SO2CONC_VAL)
/**
* @brief GATT Characteristic Sulfur Hexafluoride Concentration UUID Value
*/
#define BT_UUID_GATT_SF6CONC_VAL 0x2bd9
/**
* @brief GATT Characteristic Sulfur Hexafluoride Concentration
*/
#define BT_UUID_GATT_SF6CONC \
BT_UUID_DECLARE_16(BT_UUID_GATT_SF6CONC_VAL)
/**
* @brief Hearing Aid Features Characteristic value
*/
#define BT_UUID_HAS_HEARING_AID_FEATURES_VAL 0x2bda
/**
* @brief Hearing Aid Features Characteristic
*/
#define BT_UUID_HAS_HEARING_AID_FEATURES \
BT_UUID_DECLARE_16(BT_UUID_HAS_HEARING_AID_FEATURES_VAL)
/**
* @brief Hearing Aid Preset Control Point Characteristic value
*/
#define BT_UUID_HAS_PRESET_CONTROL_POINT_VAL 0x2bdb
/**
* @brief Hearing Aid Preset Control Point Characteristic
*/
#define BT_UUID_HAS_PRESET_CONTROL_POINT \
BT_UUID_DECLARE_16(BT_UUID_HAS_PRESET_CONTROL_POINT_VAL)
/**
* @brief Active Preset Index Characteristic value
*/
#define BT_UUID_HAS_ACTIVE_PRESET_INDEX_VAL 0x2bdc
/**
* @brief Active Preset Index Characteristic
*/
#define BT_UUID_HAS_ACTIVE_PRESET_INDEX \
BT_UUID_DECLARE_16(BT_UUID_HAS_ACTIVE_PRESET_INDEX_VAL)
/**
* @brief GATT Characteristic Fixed String 64 UUID Value
*/
#define BT_UUID_GATT_FSTR64_VAL 0x2bde
/**
* @brief GATT Characteristic Fixed String 64
*/
#define BT_UUID_GATT_FSTR64 \
BT_UUID_DECLARE_16(BT_UUID_GATT_FSTR64_VAL)
/**
* @brief GATT Characteristic High Temperature UUID Value
*/
#define BT_UUID_GATT_HITEMP_VAL 0x2bdf
/**
* @brief GATT Characteristic High Temperature
*/
#define BT_UUID_GATT_HITEMP \
BT_UUID_DECLARE_16(BT_UUID_GATT_HITEMP_VAL)
/**
* @brief GATT Characteristic High Voltage UUID Value
*/
#define BT_UUID_GATT_HV_VAL 0x2be0
/**
* @brief GATT Characteristic High Voltage
*/
#define BT_UUID_GATT_HV \
BT_UUID_DECLARE_16(BT_UUID_GATT_HV_VAL)
/**
* @brief GATT Characteristic Light Distribution UUID Value
*/
#define BT_UUID_GATT_LD_VAL 0x2be1
/**
* @brief GATT Characteristic Light Distribution
*/
#define BT_UUID_GATT_LD \
BT_UUID_DECLARE_16(BT_UUID_GATT_LD_VAL)
/**
* @brief GATT Characteristic Light Output UUID Value
*/
#define BT_UUID_GATT_LO_VAL 0x2be2
/**
* @brief GATT Characteristic Light Output
*/
#define BT_UUID_GATT_LO \
BT_UUID_DECLARE_16(BT_UUID_GATT_LO_VAL)
/**
* @brief GATT Characteristic Light Source Type UUID Value
*/
#define BT_UUID_GATT_LST_VAL 0x2be3
/**
* @brief GATT Characteristic Light Source Type
*/
#define BT_UUID_GATT_LST \
BT_UUID_DECLARE_16(BT_UUID_GATT_LST_VAL)
/**
* @brief GATT Characteristic Noise UUID Value
*/
#define BT_UUID_GATT_NOISE_VAL 0x2be4
/**
* @brief GATT Characteristic Noise
*/
#define BT_UUID_GATT_NOISE \
BT_UUID_DECLARE_16(BT_UUID_GATT_NOISE_VAL)
/**
* @brief GATT Characteristic Relative Runtime in a Correlated Color Temperature Range UUID Value
*/
#define BT_UUID_GATT_RRCCTP_VAL 0x2be5
/**
* @brief GATT Characteristic Relative Runtime in a Correlated Color Temperature Range
*/
#define BT_UUID_GATT_RRCCTR \
BT_UUID_DECLARE_16(BT_UUID_GATT_RRCCTR_VAL)
/**
* @brief GATT Characteristic Time Second 32 UUID Value
*/
#define BT_UUID_GATT_TIM_S32_VAL 0x2be6
/**
* @brief GATT Characteristic Time Second 32
*/
#define BT_UUID_GATT_TIM_S32 \
BT_UUID_DECLARE_16(BT_UUID_GATT_TIM_S32_VAL)
/**
* @brief GATT Characteristic VOC Concentration UUID Value
*/
#define BT_UUID_GATT_VOCCONC_VAL 0x2be7
/**
* @brief GATT Characteristic VOC Concentration
*/
#define BT_UUID_GATT_VOCCONC \
BT_UUID_DECLARE_16(BT_UUID_GATT_VOCCONC_VAL)
/**
* @brief GATT Characteristic Voltage Frequency UUID Value
*/
#define BT_UUID_GATT_VF_VAL 0x2be8
/**
* @brief GATT Characteristic Voltage Frequency
*/
#define BT_UUID_GATT_VF \
BT_UUID_DECLARE_16(BT_UUID_GATT_VF_VAL)
/**
* @brief BAS Characteristic Battery Critical Status UUID Value
*/
#define BT_UUID_BAS_BATTERY_CRIT_STATUS_VAL 0x2be9
/**
* @brief BAS Characteristic Battery Critical Status
*/
#define BT_UUID_BAS_BATTERY_CRIT_STATUS \
BT_UUID_DECLARE_16(BT_UUID_BAS_BATTERY_CRIT_STATUS_VAL)
/**
* @brief BAS Characteristic Battery Health Status UUID Value
*/
#define BT_UUID_BAS_BATTERY_HEALTH_STATUS_VAL 0x2bea
/**
* @brief BAS Characteristic Battery Health Status
*/
#define BT_UUID_BAS_BATTERY_HEALTH_STATUS \
BT_UUID_DECLARE_16(BT_UUID_BAS_BATTERY_HEALTH_STATUS_VAL)
/**
* @brief BAS Characteristic Battery Health Information UUID Value
*/
#define BT_UUID_BAS_BATTERY_HEALTH_INF_VAL 0x2beb
/**
* @brief BAS Characteristic Battery Health Information
*/
#define BT_UUID_BAS_BATTERY_HEALTH_INF \
BT_UUID_DECLARE_16(BT_UUID_BAS_BATTERY_HEALTH_INF_VAL)
/**
* @brief BAS Characteristic Battery Information UUID Value
*/
#define BT_UUID_BAS_BATTERY_INF_VAL 0x2bec
/**
* @brief BAS Characteristic Battery Information
*/
#define BT_UUID_BAS_BATTERY_INF \
BT_UUID_DECLARE_16(BT_UUID_BAS_BATTERY_INF_VAL)
/**
* @brief BAS Characteristic Battery Level Status UUID Value
*/
#define BT_UUID_BAS_BATTERY_LEVEL_STATUS_VAL 0x2bed
/**
* @brief BAS Characteristic Battery Level Status
*/
#define BT_UUID_BAS_BATTERY_LEVEL_STATUS \
BT_UUID_DECLARE_16(BT_UUID_BAS_BATTERY_LEVEL_STATUS_VAL)
/**
* @brief BAS Characteristic Battery Time Status UUID Value
*/
#define BT_UUID_BAS_BATTERY_TIME_STATUS_VAL 0x2bee
/**
* @brief BAS Characteristic Battery Time Status
*/
#define BT_UUID_BAS_BATTERY_TIME_STATUS \
BT_UUID_DECLARE_16(BT_UUID_BAS_BATTERY_TIME_STATUS_VAL)
/**
* @brief GATT Characteristic Estimated Service Date UUID Value
*/
#define BT_UUID_GATT_ESD_VAL 0x2bef
/**
* @brief GATT Characteristic Estimated Service Date
*/
#define BT_UUID_GATT_ESD \
BT_UUID_DECLARE_16(BT_UUID_GATT_ESD_VAL)
/**
* @brief BAS Characteristic Battery Energy Status UUID Value
*/
#define BT_UUID_BAS_BATTERY_ENERGY_STATUS_VAL 0x2bf0
/**
* @brief BAS Characteristic Battery Energy Status
*/
#define BT_UUID_BAS_BATTERY_ENERGY_STATUS \
BT_UUID_DECLARE_16(BT_UUID_BAS_BATTERY_ENERGY_STATUS_VAL)
/**
* @brief GATT Characteristic LE GATT Security Levels UUID Value
*/
#define BT_UUID_GATT_SL_VAL 0x2bf5
/**
* @brief GATT Characteristic LE GATT Security Levels
*/
#define BT_UUID_GATT_SL \
BT_UUID_DECLARE_16(BT_UUID_GATT_SL_VAL)
/**
* @brief Gaming Service UUID value
*/
#define BT_UUID_GMAS_VAL 0x1858
/**
* @brief Common Audio Service
*/
#define BT_UUID_GMAS BT_UUID_DECLARE_16(BT_UUID_GMAS_VAL)
/**
* @brief Gaming Audio Profile Role UUID value
*/
#define BT_UUID_GMAP_ROLE_VAL 0x2C00
/**
* @brief Gaming Audio Profile Role
*/
#define BT_UUID_GMAP_ROLE BT_UUID_DECLARE_16(BT_UUID_GMAP_ROLE_VAL)
/**
* @brief Gaming Audio Profile Unicast Game Gateway Features UUID value
*/
#define BT_UUID_GMAP_UGG_FEAT_VAL 0x2C01
/**
* @brief Gaming Audio Profile Unicast Game Gateway Features
*/
#define BT_UUID_GMAP_UGG_FEAT BT_UUID_DECLARE_16(BT_UUID_GMAP_UGG_FEAT_VAL)
/**
* @brief Gaming Audio Profile Unicast Game Terminal Features UUID value
*/
#define BT_UUID_GMAP_UGT_FEAT_VAL 0x2C02
/**
* @brief Gaming Audio Profile Unicast Game Terminal Features
*/
#define BT_UUID_GMAP_UGT_FEAT BT_UUID_DECLARE_16(BT_UUID_GMAP_UGT_FEAT_VAL)
/**
* @brief Gaming Audio Profile Broadcast Game Sender Features UUID value
*/
#define BT_UUID_GMAP_BGS_FEAT_VAL 0x2C03
/**
* @brief Gaming Audio Profile Broadcast Game Sender Features
*/
#define BT_UUID_GMAP_BGS_FEAT BT_UUID_DECLARE_16(BT_UUID_GMAP_BGS_FEAT_VAL)
/**
* @brief Gaming Audio Profile Broadcast Game Receiver Features UUID value
*/
#define BT_UUID_GMAP_BGR_FEAT_VAL 0x2C04
/**
* @brief Gaming Audio Profile Broadcast Game Receiver Features
*/
#define BT_UUID_GMAP_BGR_FEAT BT_UUID_DECLARE_16(BT_UUID_GMAP_BGR_FEAT_VAL)
/*
* Protocol UUIDs
*/
#define BT_UUID_SDP_VAL 0x0001
#define BT_UUID_SDP BT_UUID_DECLARE_16(BT_UUID_SDP_VAL)
#define BT_UUID_UDP_VAL 0x0002
#define BT_UUID_UDP BT_UUID_DECLARE_16(BT_UUID_UDP_VAL)
#define BT_UUID_RFCOMM_VAL 0x0003
#define BT_UUID_RFCOMM BT_UUID_DECLARE_16(BT_UUID_RFCOMM_VAL)
#define BT_UUID_TCP_VAL 0x0004
#define BT_UUID_TCP BT_UUID_DECLARE_16(BT_UUID_TCP_VAL)
#define BT_UUID_TCS_BIN_VAL 0x0005
#define BT_UUID_TCS_BIN BT_UUID_DECLARE_16(BT_UUID_TCS_BIN_VAL)
#define BT_UUID_TCS_AT_VAL 0x0006
#define BT_UUID_TCS_AT BT_UUID_DECLARE_16(BT_UUID_TCS_AT_VAL)
#define BT_UUID_ATT_VAL 0x0007
#define BT_UUID_ATT BT_UUID_DECLARE_16(BT_UUID_ATT_VAL)
#define BT_UUID_OBEX_VAL 0x0008
#define BT_UUID_OBEX BT_UUID_DECLARE_16(BT_UUID_OBEX_VAL)
#define BT_UUID_IP_VAL 0x0009
#define BT_UUID_IP BT_UUID_DECLARE_16(BT_UUID_IP_VAL)
#define BT_UUID_FTP_VAL 0x000a
#define BT_UUID_FTP BT_UUID_DECLARE_16(BT_UUID_FTP_VAL)
#define BT_UUID_HTTP_VAL 0x000c
#define BT_UUID_HTTP BT_UUID_DECLARE_16(BT_UUID_HTTP_VAL)
#define BT_UUID_WSP_VAL 0x000e
#define BT_UUID_WSP BT_UUID_DECLARE_16(BT_UUID_WSP_VAL)
#define BT_UUID_BNEP_VAL 0x000f
#define BT_UUID_BNEP BT_UUID_DECLARE_16(BT_UUID_BNEP_VAL)
#define BT_UUID_UPNP_VAL 0x0010
#define BT_UUID_UPNP BT_UUID_DECLARE_16(BT_UUID_UPNP_VAL)
#define BT_UUID_HIDP_VAL 0x0011
#define BT_UUID_HIDP BT_UUID_DECLARE_16(BT_UUID_HIDP_VAL)
#define BT_UUID_HCRP_CTRL_VAL 0x0012
#define BT_UUID_HCRP_CTRL BT_UUID_DECLARE_16(BT_UUID_HCRP_CTRL_VAL)
#define BT_UUID_HCRP_DATA_VAL 0x0014
#define BT_UUID_HCRP_DATA BT_UUID_DECLARE_16(BT_UUID_HCRP_DATA_VAL)
#define BT_UUID_HCRP_NOTE_VAL 0x0016
#define BT_UUID_HCRP_NOTE BT_UUID_DECLARE_16(BT_UUID_HCRP_NOTE_VAL)
#define BT_UUID_AVCTP_VAL 0x0017
#define BT_UUID_AVCTP BT_UUID_DECLARE_16(BT_UUID_AVCTP_VAL)
#define BT_UUID_AVDTP_VAL 0x0019
#define BT_UUID_AVDTP BT_UUID_DECLARE_16(BT_UUID_AVDTP_VAL)
#define BT_UUID_CMTP_VAL 0x001b
#define BT_UUID_CMTP BT_UUID_DECLARE_16(BT_UUID_CMTP_VAL)
#define BT_UUID_UDI_VAL 0x001d
#define BT_UUID_UDI BT_UUID_DECLARE_16(BT_UUID_UDI_VAL)
#define BT_UUID_MCAP_CTRL_VAL 0x001e
#define BT_UUID_MCAP_CTRL BT_UUID_DECLARE_16(BT_UUID_MCAP_CTRL_VAL)
#define BT_UUID_MCAP_DATA_VAL 0x001f
#define BT_UUID_MCAP_DATA BT_UUID_DECLARE_16(BT_UUID_MCAP_DATA_VAL)
#define BT_UUID_L2CAP_VAL 0x0100
#define BT_UUID_L2CAP BT_UUID_DECLARE_16(BT_UUID_L2CAP_VAL)
/** @brief Compare Bluetooth UUIDs.
*
* Compares 2 Bluetooth UUIDs, if the types are different both UUIDs are
* first converted to 128 bits format before comparing.
*
* @param u1 First Bluetooth UUID to compare
* @param u2 Second Bluetooth UUID to compare
*
* @return negative value if @a u1 < @a u2, 0 if @a u1 == @a u2, else positive
*/
int bt_uuid_cmp(const struct bt_uuid *u1, const struct bt_uuid *u2);
/** @brief Create a bt_uuid from a little-endian data buffer.
*
* Create a bt_uuid from a little-endian data buffer. The data_len parameter
* is used to determine whether the UUID is in 16, 32 or 128 bit format
* (length 2, 4 or 16). Note: 32 bit format is not allowed over the air.
*
* @param uuid Pointer to the bt_uuid variable
* @param data pointer to UUID stored in little-endian data buffer
* @param data_len length of the UUID in the data buffer
*
* @return true if the data was valid and the UUID was successfully created.
*/
bool bt_uuid_create(struct bt_uuid *uuid, const uint8_t *data, uint8_t data_len);
/** @brief Convert Bluetooth UUID to string.
*
* Converts Bluetooth UUID to string.
* UUID can be in any format, 16-bit, 32-bit or 128-bit.
*
* @param uuid Bluetooth UUID
* @param str pointer where to put converted string
* @param len length of str
*/
void bt_uuid_to_str(const struct bt_uuid *uuid, char *str, size_t len);
#ifdef __cplusplus
}
#endif
/**
* @}
*/
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_UUID_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/uuid.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 39,486 |
```objective-c
/** @file
* @brief Bluetooth HCI RAW channel handling
*/
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_HCI_RAW_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_HCI_RAW_H_
/**
* @brief HCI RAW channel
* @defgroup hci_raw HCI RAW channel
* @ingroup bluetooth
* @{
*/
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/** @brief Send packet to the Bluetooth controller
*
* Send packet to the Bluetooth controller. Caller needs to
* implement netbuf pool.
*
* @param buf netbuf packet to be send
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_send(struct net_buf *buf);
enum {
/** Passthrough mode
*
* While in this mode the buffers are passed as is between the stack
* and the driver.
*/
BT_HCI_RAW_MODE_PASSTHROUGH = 0x00,
/** H:4 mode
*
* While in this mode H:4 headers will added into the buffers
* according to the buffer type when coming from the stack and will be
* removed and used to set the buffer type.
*/
BT_HCI_RAW_MODE_H4 = 0x01,
};
/** @brief Set Bluetooth RAW channel mode
*
* Set access mode of Bluetooth RAW channel.
*
* @param mode Access mode.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_hci_raw_set_mode(uint8_t mode);
/** @brief Get Bluetooth RAW channel mode
*
* Get access mode of Bluetooth RAW channel.
*
* @return Access mode.
*/
uint8_t bt_hci_raw_get_mode(void);
#define BT_HCI_ERR_EXT_HANDLED 0xff
/** Helper macro to define a command extension
*
* @param _op Opcode of the command.
* @param _min_len Minimal length of the command.
* @param _func Handler function to be called.
*/
#define BT_HCI_RAW_CMD_EXT(_op, _min_len, _func) \
{ \
.op = _op, \
.min_len = _min_len, \
.func = _func, \
}
struct bt_hci_raw_cmd_ext {
/** Opcode of the command */
uint16_t op;
/** Minimal length of the command */
size_t min_len;
/** Handler function.
*
* Handler function to be called when a command is intercepted.
*
* @param buf Buffer containing the command.
*
* @return HCI Status code or BT_HCI_ERR_EXT_HANDLED if command has
* been handled already and a response has been sent as oppose to
* BT_HCI_ERR_SUCCESS which just indicates that the command can be
* sent to the controller to be processed.
*/
uint8_t (*func)(struct net_buf *buf);
};
/** @brief Register Bluetooth RAW command extension table
*
* Register Bluetooth RAW channel command extension table, opcodes in this
* table are intercepted to sent to the handler function.
*
* @param cmds Pointer to the command extension table.
* @param size Size of the command extension table.
*/
void bt_hci_raw_cmd_ext_register(struct bt_hci_raw_cmd_ext *cmds, size_t size);
/** @brief Enable Bluetooth RAW channel:
*
* Enable Bluetooth RAW HCI channel.
*
* @param rx_queue netbuf queue where HCI packets received from the Bluetooth
* controller are to be queued. The queue is defined in the caller while
* the available buffers pools are handled in the stack.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_enable_raw(struct k_fifo *rx_queue);
#ifdef __cplusplus
}
#endif
/**
* @}
*/
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_HCI_RAW_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/hci_raw.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 846 |
```objective-c
/** @file
* @brief Bluetooth subsystem crypto APIs.
*/
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_CRYPTO_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_CRYPTO_H_
/**
* @brief Cryptography
* @defgroup bt_crypto Cryptography
* @ingroup bluetooth
* @{
*/
#include <stdbool.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/** @brief Generate random data.
*
* A random number generation helper which utilizes the Bluetooth
* controller's own RNG.
*
* @param buf Buffer to insert the random data
* @param len Length of random data to generate
*
* @return Zero on success or error code otherwise, positive in case
* of protocol error or negative (POSIX) in case of stack internal error
*/
int bt_rand(void *buf, size_t len);
/** @brief AES encrypt little-endian data.
*
* An AES encrypt helper is used to request the Bluetooth controller's own
* hardware to encrypt the plaintext using the key and returns the encrypted
* data.
*
* @param key 128 bit LS byte first key for the encryption of the plaintext
* @param plaintext 128 bit LS byte first plaintext data block to be encrypted
* @param enc_data 128 bit LS byte first encrypted data block
*
* @return Zero on success or error code otherwise.
*/
int bt_encrypt_le(const uint8_t key[16], const uint8_t plaintext[16],
uint8_t enc_data[16]);
/** @brief AES encrypt big-endian data.
*
* An AES encrypt helper is used to request the Bluetooth controller's own
* hardware to encrypt the plaintext using the key and returns the encrypted
* data.
*
* @param key 128 bit MS byte first key for the encryption of the plaintext
* @param plaintext 128 bit MS byte first plaintext data block to be encrypted
* @param enc_data 128 bit MS byte first encrypted data block
*
* @return Zero on success or error code otherwise.
*/
int bt_encrypt_be(const uint8_t key[16], const uint8_t plaintext[16],
uint8_t enc_data[16]);
/** @brief Decrypt big-endian data with AES-CCM.
*
* Decrypts and authorizes @c enc_data with AES-CCM, as described in
* path_to_url
*
* Assumes that the MIC follows directly after the encrypted data.
*
* @param key 128 bit MS byte first key
* @param nonce 13 byte MS byte first nonce
* @param enc_data Encrypted data
* @param len Length of the encrypted data
* @param aad Additional authenticated data
* @param aad_len Additional authenticated data length
* @param plaintext Plaintext buffer to place result in
* @param mic_size Size of the trailing MIC (in bytes)
*
* @retval 0 Successfully decrypted the data.
* @retval -EINVAL Invalid parameters.
* @retval -EBADMSG Authentication failed.
*/
int bt_ccm_decrypt(const uint8_t key[16], uint8_t nonce[13], const uint8_t *enc_data,
size_t len, const uint8_t *aad, size_t aad_len,
uint8_t *plaintext, size_t mic_size);
/** @brief Encrypt big-endian data with AES-CCM.
*
* Encrypts and generates a MIC from @c plaintext with AES-CCM, as described in
* path_to_url
*
* Places the MIC directly after the encrypted data.
*
* @param key 128 bit MS byte first key
* @param nonce 13 byte MS byte first nonce
* @param plaintext Plaintext buffer to encrypt
* @param len Length of the encrypted data
* @param aad Additional authenticated data
* @param aad_len Additional authenticated data length
* @param enc_data Buffer to place encrypted data in
* @param mic_size Size of the trailing MIC (in bytes)
*
* @retval 0 Successfully encrypted the data.
* @retval -EINVAL Invalid parameters.
*/
int bt_ccm_encrypt(const uint8_t key[16], uint8_t nonce[13],
const uint8_t *plaintext, size_t len, const uint8_t *aad,
size_t aad_len, uint8_t *enc_data, size_t mic_size);
#ifdef __cplusplus
}
#endif
/**
* @}
*/
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_CRYPTO_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/crypto.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 998 |
```objective-c
/* hci_vs.h - Bluetooth Host Control Interface Vendor Specific definitions */
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_HCI_VS_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_HCI_VS_H_
#include <stdint.h>
#include <zephyr/bluetooth/hci.h>
#ifdef __cplusplus
extern "C" {
#endif
#define BT_VS_CMD_BIT_VERSION 0
#define BT_VS_CMD_BIT_SUP_CMD 1
#define BT_VS_CMD_BIT_SUP_FEAT 2
#define BT_VS_CMD_BIT_SET_EVT_MASK 3
#define BT_VS_CMD_BIT_RESET 4
#define BT_VS_CMD_BIT_WRITE_BDADDR 5
#define BT_VS_CMD_BIT_SET_TRACE_ENABLE 6
#define BT_VS_CMD_BIT_READ_BUILD_INFO 7
#define BT_VS_CMD_BIT_READ_STATIC_ADDRS 8
#define BT_VS_CMD_BIT_READ_KEY_ROOTS 9
#define BT_VS_CMD_BIT_READ_CHIP_TEMP 10
#define BT_VS_CMD_BIT_READ_HOST_STACK_CMD 11
#define BT_VS_CMD_BIT_SET_SCAN_REP_ENABLE 12
#define BT_VS_CMD_BIT_WRITE_TX_POWER 13
#define BT_VS_CMD_BIT_READ_TX_POWER 14
#define BT_VS_CMD_SUP_FEAT(cmd) BT_LE_FEAT_TEST(cmd, \
BT_VS_CMD_BIT_SUP_FEAT)
#define BT_VS_CMD_READ_STATIC_ADDRS(cmd) BT_LE_FEAT_TEST(cmd, \
BT_VS_CMD_BIT_READ_STATIC_ADDRS)
#define BT_VS_CMD_READ_KEY_ROOTS(cmd) BT_LE_FEAT_TEST(cmd, \
BT_VS_CMD_BIT_READ_KEY_ROOTS)
#define BT_HCI_VS_HW_PLAT_INTEL 0x0001
#define BT_HCI_VS_HW_PLAT_NORDIC 0x0002
#define BT_HCI_VS_HW_PLAT_NXP 0x0003
#define BT_HCI_VS_HW_VAR_NORDIC_NRF51X 0x0001
#define BT_HCI_VS_HW_VAR_NORDIC_NRF52X 0x0002
#define BT_HCI_VS_HW_VAR_NORDIC_NRF53X 0x0003
#define BT_HCI_VS_HW_VAR_NORDIC_NRF54HX 0x0004
#define BT_HCI_VS_HW_VAR_NORDIC_NRF54LX 0x0005
#define BT_HCI_VS_FW_VAR_STANDARD_CTLR 0x0001
#define BT_HCI_VS_FW_VAR_VS_CTLR 0x0002
#define BT_HCI_VS_FW_VAR_FW_LOADER 0x0003
#define BT_HCI_VS_FW_VAR_RESCUE_IMG 0x0004
#define BT_HCI_OP_VS_READ_VERSION_INFO BT_OP(BT_OGF_VS, 0x0001)
struct bt_hci_rp_vs_read_version_info {
uint8_t status;
uint16_t hw_platform;
uint16_t hw_variant;
uint8_t fw_variant;
uint8_t fw_version;
uint16_t fw_revision;
uint32_t fw_build;
} __packed;
#define BT_HCI_OP_VS_READ_SUPPORTED_COMMANDS BT_OP(BT_OGF_VS, 0x0002)
struct bt_hci_rp_vs_read_supported_commands {
uint8_t status;
uint8_t commands[64];
} __packed;
#define BT_HCI_OP_VS_READ_SUPPORTED_FEATURES BT_OP(BT_OGF_VS, 0x0003)
struct bt_hci_rp_vs_read_supported_features {
uint8_t status;
uint8_t features[8];
} __packed;
#define BT_HCI_OP_VS_SET_EVENT_MASK BT_OP(BT_OGF_VS, 0x0004)
struct bt_hci_cp_vs_set_event_mask {
uint8_t event_mask[8];
} __packed;
#define BT_HCI_VS_RESET_SOFT 0x00
#define BT_HCI_VS_RESET_HARD 0x01
#define BT_HCI_OP_VS_RESET BT_OP(BT_OGF_VS, 0x0005)
struct bt_hci_cp_vs_reset {
uint8_t type;
} __packed;
#define BT_HCI_OP_VS_WRITE_BD_ADDR BT_OP(BT_OGF_VS, 0x0006)
struct bt_hci_cp_vs_write_bd_addr {
bt_addr_t bdaddr;
} __packed;
#define BT_HCI_VS_TRACE_DISABLED 0x00
#define BT_HCI_VS_TRACE_ENABLED 0x01
#define BT_HCI_VS_TRACE_HCI_EVTS 0x00
#define BT_HCI_VS_TRACE_VDC 0x01
#define BT_HCI_OP_VS_SET_TRACE_ENABLE BT_OP(BT_OGF_VS, 0x0007)
struct bt_hci_cp_vs_set_trace_enable {
uint8_t enable;
uint8_t type;
} __packed;
#define BT_HCI_OP_VS_READ_BUILD_INFO BT_OP(BT_OGF_VS, 0x0008)
struct bt_hci_rp_vs_read_build_info {
uint8_t status;
uint8_t info[0];
} __packed;
struct bt_hci_vs_static_addr {
bt_addr_t bdaddr;
uint8_t ir[16];
} __packed;
#define BT_HCI_OP_VS_READ_STATIC_ADDRS BT_OP(BT_OGF_VS, 0x0009)
struct bt_hci_rp_vs_read_static_addrs {
uint8_t status;
uint8_t num_addrs;
struct bt_hci_vs_static_addr a[0];
} __packed;
#define BT_HCI_OP_VS_READ_KEY_HIERARCHY_ROOTS BT_OP(BT_OGF_VS, 0x000a)
struct bt_hci_rp_vs_read_key_hierarchy_roots {
uint8_t status;
uint8_t ir[16];
uint8_t er[16];
} __packed;
#define BT_HCI_OP_VS_READ_CHIP_TEMP BT_OP(BT_OGF_VS, 0x000b)
struct bt_hci_rp_vs_read_chip_temp {
uint8_t status;
int8_t temps;
} __packed;
struct bt_hci_vs_cmd {
uint16_t vendor_id;
uint16_t opcode_base;
} __packed;
#define BT_HCI_VS_VID_ANDROID 0x0001
#define BT_HCI_VS_VID_MICROSOFT 0x0002
#define BT_HCI_OP_VS_READ_HOST_STACK_CMDS BT_OP(BT_OGF_VS, 0x000c)
struct bt_hci_rp_vs_read_host_stack_cmds {
uint8_t status;
uint8_t num_cmds;
struct bt_hci_vs_cmd c[0];
} __packed;
#define BT_HCI_VS_SCAN_REQ_REPORTS_DISABLED 0x00
#define BT_HCI_VS_SCAN_REQ_REPORTS_ENABLED 0x01
#define BT_HCI_OP_VS_SET_SCAN_REQ_REPORTS BT_OP(BT_OGF_VS, 0x000d)
struct bt_hci_cp_vs_set_scan_req_reports {
uint8_t enable;
} __packed;
#define BT_HCI_VS_LL_HANDLE_TYPE_ADV 0x00
#define BT_HCI_VS_LL_HANDLE_TYPE_SCAN 0x01
#define BT_HCI_VS_LL_HANDLE_TYPE_CONN 0x02
#define BT_HCI_VS_LL_TX_POWER_LEVEL_NO_PREF 0x7F
#define BT_HCI_OP_VS_WRITE_TX_POWER_LEVEL BT_OP(BT_OGF_VS, 0x000e)
struct bt_hci_cp_vs_write_tx_power_level {
uint8_t handle_type;
uint16_t handle;
int8_t tx_power_level;
} __packed;
struct bt_hci_rp_vs_write_tx_power_level {
uint8_t status;
uint8_t handle_type;
uint16_t handle;
int8_t selected_tx_power;
} __packed;
#define BT_HCI_OP_VS_READ_TX_POWER_LEVEL BT_OP(BT_OGF_VS, 0x000f)
struct bt_hci_cp_vs_read_tx_power_level {
uint8_t handle_type;
uint16_t handle;
} __packed;
struct bt_hci_rp_vs_read_tx_power_level {
uint8_t status;
uint8_t handle_type;
uint16_t handle;
int8_t tx_power_level;
} __packed;
#define BT_HCI_OP_VS_READ_USB_TRANSPORT_MODE BT_OP(BT_OGF_VS, 0x0010)
struct bt_hci_rp_vs_read_usb_transport_mode {
uint8_t status;
uint8_t num_supported_modes;
uint8_t supported_mode[0];
} __packed;
#define BT_HCI_VS_USB_H2_MODE 0x00
#define BT_HCI_VS_USB_H4_MODE 0x01
#define BT_HCI_OP_VS_SET_USB_TRANSPORT_MODE BT_OP(BT_OGF_VS, 0x0011)
struct bt_hci_cp_vs_set_usb_transport_mode {
uint8_t mode;
} __packed;
#define BT_HCI_OP_VS_SET_MIN_NUM_USED_CHANS BT_OP(BT_OGF_VS, 0x0012)
struct bt_hci_cp_vs_set_min_num_used_chans {
uint16_t handle;
uint8_t phys;
uint8_t min_used_chans;
} __packed;
/* Events */
struct bt_hci_evt_vs {
uint8_t subevent;
} __packed;
#define BT_HCI_EVT_VS_FATAL_ERROR 0x02
#define BT_HCI_EVT_VS_ERROR_DATA_TYPE_STACK_FRAME 0x01
#define BT_HCI_EVT_VS_ERROR_DATA_TYPE_CTRL_ASSERT 0x02
#define BT_HCI_EVT_VS_ERROR_DATA_TYPE_TRACE 0x03
struct bt_hci_vs_fata_error_cpu_data_cortex_m {
uint32_t a1;
uint32_t a2;
uint32_t a3;
uint32_t a4;
uint32_t ip;
uint32_t lr;
uint32_t xpsr;
} __packed;
#define BT_HCI_EVT_VS_ERROR_CPU_TYPE_CORTEX_M 0x01
struct bt_hci_vs_fatal_error_stack_frame {
uint32_t reason;
uint8_t cpu_type;
uint8_t cpu_data[0];
} __packed;
struct bt_hci_evt_vs_fatal_error_trace_data {
uint64_t pc;
uint8_t err_info[0];
} __packed;
struct bt_hci_evt_vs_fatal_error {
uint8_t type;
uint8_t data[0];
} __packed;
#define BT_HCI_VS_TRACE_LMP_TX 0x01
#define BT_HCI_VS_TRACE_LMP_RX 0x02
#define BT_HCI_VS_TRACE_LLCP_TX 0x03
#define BT_HCI_VS_TRACE_LLCP_RX 0x04
#define BT_HCI_VS_TRACE_LE_CONN_IND 0x05
#define BT_HCI_EVT_VS_TRACE_INFO 0x03
struct bt_hci_evt_vs_trace_info {
uint8_t type;
uint8_t data[0];
} __packed;
#define BT_HCI_EVT_VS_SCAN_REQ_RX 0x04
struct bt_hci_evt_vs_scan_req_rx {
bt_addr_le_t addr;
int8_t rssi;
} __packed;
struct bt_hci_le_iq_sample16 {
int16_t i;
int16_t q;
} __packed;
#define BT_HCI_EVT_VS_LE_CONNECTIONLESS_IQ_REPORT 0x5
#define BT_HCI_VS_LE_CTE_REPORT_NO_VALID_SAMPLE 0x8000
struct bt_hci_evt_vs_le_connectionless_iq_report {
uint16_t sync_handle;
uint8_t chan_idx;
int16_t rssi;
uint8_t rssi_ant_id;
uint8_t cte_type;
uint8_t slot_durations;
uint8_t packet_status;
uint16_t per_evt_counter;
uint8_t sample_count;
struct bt_hci_le_iq_sample16 sample[0];
} __packed;
#define BT_HCI_EVT_VS_LE_CONNECTION_IQ_REPORT 0x6
struct bt_hci_evt_vs_le_connection_iq_report {
uint16_t conn_handle;
uint8_t rx_phy;
uint8_t data_chan_idx;
int16_t rssi;
uint8_t rssi_ant_id;
uint8_t cte_type;
uint8_t slot_durations;
uint8_t packet_status;
uint16_t conn_evt_counter;
uint8_t sample_count;
struct bt_hci_le_iq_sample16 sample[0];
} __packed;
/* Event mask bits */
#define BT_EVT_MASK_VS_FATAL_ERROR BT_EVT_BIT(1)
#define BT_EVT_MASK_VS_TRACE_INFO BT_EVT_BIT(2)
#define BT_EVT_MASK_VS_SCAN_REQ_RX BT_EVT_BIT(3)
#define BT_EVT_MASK_VS_LE_CONNECTIONLESS_IQ_REPORT BT_EVT_BIT(4)
#define BT_EVT_MASK_VS_LE_CONNECTION_IQ_REPORT BT_EVT_BIT(5)
#define DEFAULT_VS_EVT_MASK \
BT_EVT_MASK_VS_FATAL_ERROR | BT_EVT_MASK_VS_TRACE_INFO | BT_EVT_MASK_VS_SCAN_REQ_RX | \
BT_EVT_MASK_VS_LE_CONNECTIONLESS_IQ_REPORT | \
BT_EVT_MASK_VS_LE_CONNECTION_IQ_REPORT
/* Mesh HCI commands */
#define BT_HCI_MESH_REVISION 0x01
#define BT_HCI_OP_VS_MESH BT_OP(BT_OGF_VS, 0x0042)
#define BT_HCI_MESH_EVT_PREFIX 0xF0
struct bt_hci_cp_mesh {
uint8_t opcode;
} __packed;
#define BT_HCI_OC_MESH_GET_OPTS 0x00
struct bt_hci_rp_mesh_get_opts {
uint8_t status;
uint8_t opcode;
uint8_t revision;
uint8_t ch_map;
int8_t min_tx_power;
int8_t max_tx_power;
uint8_t max_scan_filter;
uint8_t max_filter_pattern;
uint8_t max_adv_slot;
uint8_t max_tx_window;
uint8_t evt_prefix_len;
uint8_t evt_prefix;
} __packed;
#define BT_HCI_MESH_PATTERN_LEN_MAX 0x0f
#define BT_HCI_OC_MESH_SET_SCAN_FILTER 0x01
struct bt_hci_mesh_pattern {
uint8_t pattern_len;
uint8_t pattern[0];
} __packed;
struct bt_hci_cp_mesh_set_scan_filter {
uint8_t scan_filter;
uint8_t filter_dup;
uint8_t num_patterns;
struct bt_hci_mesh_pattern patterns[0];
} __packed;
struct bt_hci_rp_mesh_set_scan_filter {
uint8_t status;
uint8_t opcode;
uint8_t scan_filter;
} __packed;
#define BT_HCI_OC_MESH_ADVERTISE 0x02
struct bt_hci_cp_mesh_advertise {
uint8_t adv_slot;
uint8_t own_addr_type;
bt_addr_t random_addr;
uint8_t ch_map;
int8_t tx_power;
uint8_t min_tx_delay;
uint8_t max_tx_delay;
uint8_t retx_count;
uint8_t retx_interval;
uint8_t scan_delay;
uint16_t scan_duration;
uint8_t scan_filter;
uint8_t data_len;
uint8_t data[31];
} __packed;
struct bt_hci_rp_mesh_advertise {
uint8_t status;
uint8_t opcode;
uint8_t adv_slot;
} __packed;
#define BT_HCI_OC_MESH_ADVERTISE_TIMED 0x03
struct bt_hci_cp_mesh_advertise_timed {
uint8_t adv_slot;
uint8_t own_addr_type;
bt_addr_t random_addr;
uint8_t ch_map;
int8_t tx_power;
uint8_t retx_count;
uint8_t retx_interval;
uint32_t instant;
uint16_t tx_delay;
uint16_t tx_window;
uint8_t data_len;
uint8_t data[31];
} __packed;
struct bt_hci_rp_mesh_advertise_timed {
uint8_t status;
uint8_t opcode;
uint8_t adv_slot;
} __packed;
#define BT_HCI_OC_MESH_ADVERTISE_CANCEL 0x04
struct bt_hci_cp_mesh_advertise_cancel {
uint8_t adv_slot;
} __packed;
struct bt_hci_rp_mesh_advertise_cancel {
uint8_t status;
uint8_t opcode;
uint8_t adv_slot;
} __packed;
#define BT_HCI_OC_MESH_SET_SCANNING 0x05
struct bt_hci_cp_mesh_set_scanning {
uint8_t enable;
uint8_t ch_map;
uint8_t scan_filter;
} __packed;
struct bt_hci_rp_mesh_set_scanning {
uint8_t status;
uint8_t opcode;
} __packed;
/* Events */
struct bt_hci_evt_mesh {
uint8_t prefix;
uint8_t subevent;
} __packed;
#define BT_HCI_EVT_MESH_ADV_COMPLETE 0x00
struct bt_hci_evt_mesh_adv_complete {
uint8_t adv_slot;
} __packed;
#define BT_HCI_EVT_MESH_SCANNING_REPORT 0x01
struct bt_hci_evt_mesh_scan_report {
bt_addr_le_t addr;
uint8_t chan;
int8_t rssi;
uint32_t instant;
uint8_t data_len;
uint8_t data[0];
} __packed;
struct bt_hci_evt_mesh_scanning_report {
uint8_t num_reports;
struct bt_hci_evt_mesh_scan_report reports[0];
} __packed;
struct net_buf *hci_vs_err_stack_frame(unsigned int reason, const struct arch_esf *esf);
struct net_buf *hci_vs_err_trace(const char *file, uint32_t line, uint64_t pc);
struct net_buf *hci_vs_err_assert(const char *file, uint32_t line);
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_HCI_VS_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/hci_vs.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 3,894 |
```objective-c
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_OTS_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_OTS_H_
/**
* @brief Object Transfer Service (OTS)
* @defgroup bt_ots Object Transfer Service (OTS)
* @ingroup bluetooth
* @{
*
* [Experimental] Users should note that the APIs can change
* as a part of ongoing development.
*/
#include <stdbool.h>
#include <stdint.h>
#include <sys/types.h>
#include <zephyr/sys/byteorder.h>
#include <zephyr/sys/util.h>
#include <zephyr/sys/crc.h>
#include <zephyr/bluetooth/conn.h>
#include <zephyr/bluetooth/uuid.h>
#include <zephyr/bluetooth/gatt.h>
#ifdef __cplusplus
extern "C" {
#endif
/** @brief Size of OTS object ID (in bytes). */
#define BT_OTS_OBJ_ID_SIZE 6
/** @brief Minimum allowed value for object ID (except ID for directory listing) */
#define BT_OTS_OBJ_ID_MIN 0x000000000100ULL
/** @brief Maximum allowed value for object ID (except ID for directory listing) */
#define BT_OTS_OBJ_ID_MAX 0xFFFFFFFFFFFFULL
/** @brief ID of the Directory Listing Object */
#define OTS_OBJ_ID_DIR_LIST 0x000000000000ULL
/** @brief Mask for OTS object IDs, preserving the 48 bits */
#define BT_OTS_OBJ_ID_MASK BIT64_MASK(48)
/** @brief Length of OTS object ID string (in bytes). */
#define BT_OTS_OBJ_ID_STR_LEN 15
/** @brief Type of an OTS object. */
struct bt_ots_obj_type {
union {
/* Used to indicate UUID type */
struct bt_uuid uuid;
/* 16-bit UUID value */
struct bt_uuid_16 uuid_16;
/* 128-bit UUID value */
struct bt_uuid_128 uuid_128;
};
};
/** @brief Properties of an OTS object. */
enum {
/** Bit 0 Deletion of this object is permitted */
BT_OTS_OBJ_PROP_DELETE = 0,
/** Bit 1 Execution of this object is permitted */
BT_OTS_OBJ_PROP_EXECUTE = 1,
/** Bit 2 Reading this object is permitted */
BT_OTS_OBJ_PROP_READ = 2,
/** Bit 3 Writing data to this object is permitted */
BT_OTS_OBJ_PROP_WRITE = 3,
/** @brief Bit 4 Appending data to this object is permitted.
*
* Appending data increases its Allocated Size.
*/
BT_OTS_OBJ_PROP_APPEND = 4,
/** Bit 5 Truncation of this object is permitted */
BT_OTS_OBJ_PROP_TRUNCATE = 5,
/** @brief Bit 6 Patching this object is permitted
*
* Patching this object overwrites some of
* the object's existing contents.
*/
BT_OTS_OBJ_PROP_PATCH = 6,
/** Bit 7 This object is a marked object */
BT_OTS_OBJ_PROP_MARKED = 7,
};
/** @brief Set @ref BT_OTS_OBJ_PROP_DELETE property.
*
* @param prop Object properties.
*/
#define BT_OTS_OBJ_SET_PROP_DELETE(prop) \
WRITE_BIT(prop, BT_OTS_OBJ_PROP_DELETE, 1)
/** @brief Set @ref BT_OTS_OBJ_PROP_EXECUTE property.
*
* @param prop Object properties.
*/
#define BT_OTS_OBJ_SET_PROP_EXECUTE(prop) \
WRITE_BIT(prop, BT_OTS_OBJ_PROP_EXECUTE, 1)
/** @brief Set @ref BT_OTS_OBJ_PROP_READ property.
*
* @param prop Object properties.
*/
#define BT_OTS_OBJ_SET_PROP_READ(prop) \
WRITE_BIT(prop, BT_OTS_OBJ_PROP_READ, 1)
/** @brief Set @ref BT_OTS_OBJ_PROP_WRITE property.
*
* @param prop Object properties.
*/
#define BT_OTS_OBJ_SET_PROP_WRITE(prop) \
WRITE_BIT(prop, BT_OTS_OBJ_PROP_WRITE, 1)
/** @brief Set @ref BT_OTS_OBJ_PROP_APPEND property.
*
* @param prop Object properties.
*/
#define BT_OTS_OBJ_SET_PROP_APPEND(prop) \
WRITE_BIT(prop, BT_OTS_OBJ_PROP_APPEND, 1)
/** @brief Set @ref BT_OTS_OBJ_PROP_TRUNCATE property.
*
* @param prop Object properties.
*/
#define BT_OTS_OBJ_SET_PROP_TRUNCATE(prop) \
WRITE_BIT(prop, BT_OTS_OBJ_PROP_TRUNCATE, 1)
/** @brief Set @ref BT_OTS_OBJ_PROP_PATCH property.
*
* @param prop Object properties.
*/
#define BT_OTS_OBJ_SET_PROP_PATCH(prop) \
WRITE_BIT(prop, BT_OTS_OBJ_PROP_PATCH, 1)
/** @brief Set @ref BT_OTS_OBJ_SET_PROP_MARKED property.
*
* @param prop Object properties.
*/
#define BT_OTS_OBJ_SET_PROP_MARKED(prop) \
WRITE_BIT(prop, BT_OTS_OBJ_PROP_MARKED, 1)
/** @brief Get @ref BT_OTS_OBJ_PROP_DELETE property.
*
* @param prop Object properties.
*/
#define BT_OTS_OBJ_GET_PROP_DELETE(prop) \
((prop) & BIT(BT_OTS_OBJ_PROP_DELETE))
/** @brief Get @ref BT_OTS_OBJ_PROP_EXECUTE property.
*
* @param prop Object properties.
*/
#define BT_OTS_OBJ_GET_PROP_EXECUTE(prop) \
((prop) & BIT(BT_OTS_OBJ_PROP_EXECUTE))
/** @brief Get @ref BT_OTS_OBJ_PROP_READ property.
*
* @param prop Object properties.
*/
#define BT_OTS_OBJ_GET_PROP_READ(prop) \
((prop) & BIT(BT_OTS_OBJ_PROP_READ))
/** @brief Get @ref BT_OTS_OBJ_PROP_WRITE property.
*
* @param prop Object properties.
*/
#define BT_OTS_OBJ_GET_PROP_WRITE(prop) \
((prop) & BIT(BT_OTS_OBJ_PROP_WRITE))
/** @brief Get @ref BT_OTS_OBJ_PROP_APPEND property.
*
* @param prop Object properties.
*/
#define BT_OTS_OBJ_GET_PROP_APPEND(prop) \
((prop) & BIT(BT_OTS_OBJ_PROP_APPEND))
/** @brief Get @ref BT_OTS_OBJ_PROP_TRUNCATE property.
*
* @param prop Object properties.
*/
#define BT_OTS_OBJ_GET_PROP_TRUNCATE(prop) \
((prop) & BIT(BT_OTS_OBJ_PROP_TRUNCATE))
/** @brief Get @ref BT_OTS_OBJ_PROP_PATCH property.
*
* @param prop Object properties.
*/
#define BT_OTS_OBJ_GET_PROP_PATCH(prop) \
((prop) & BIT(BT_OTS_OBJ_PROP_PATCH))
/** @brief Get @ref BT_OTS_OBJ_PROP_MARKED property.
*
* @param prop Object properties.
*/
#define BT_OTS_OBJ_GET_PROP_MARKED(prop) \
((prop) & BIT(BT_OTS_OBJ_PROP_MARKED))
/** @brief Descriptor for OTS Object Size parameter. */
struct bt_ots_obj_size {
/** @brief Current Size */
uint32_t cur;
/** @brief Allocated Size */
uint32_t alloc;
} __packed;
/** @brief Object Action Control Point Feature bits. */
enum {
/** Bit 0 OACP Create Op Code Supported */
BT_OTS_OACP_FEAT_CREATE = 0,
/** Bit 1 OACP Delete Op Code Supported */
BT_OTS_OACP_FEAT_DELETE = 1,
/** Bit 2 OACP Calculate Checksum Op Code Supported */
BT_OTS_OACP_FEAT_CHECKSUM = 2,
/** Bit 3 OACP Execute Op Code Supported */
BT_OTS_OACP_FEAT_EXECUTE = 3,
/** Bit 4 OACP Read Op Code Supported */
BT_OTS_OACP_FEAT_READ = 4,
/** Bit 5 OACP Write Op Code Supported */
BT_OTS_OACP_FEAT_WRITE = 5,
/** Bit 6 Appending Additional Data to Objects Supported */
BT_OTS_OACP_FEAT_APPEND = 6,
/** Bit 7 Truncation of Objects Supported */
BT_OTS_OACP_FEAT_TRUNCATE = 7,
/** Bit 8 Patching of Objects Supported */
BT_OTS_OACP_FEAT_PATCH = 8,
/** Bit 9 OACP Abort Op Code Supported */
BT_OTS_OACP_FEAT_ABORT = 9,
};
/*
* @enum bt_ots_oacp_write_op_mode
* @brief Mode Parameter for OACP Write Op Code.
*/
enum bt_ots_oacp_write_op_mode {
BT_OTS_OACP_WRITE_OP_MODE_NONE = 0,
BT_OTS_OACP_WRITE_OP_MODE_TRUNCATE = BIT(1),
};
/** @brief Set @ref BT_OTS_OACP_SET_FEAT_CREATE feature.
*
* @param feat OTS features.
*/
#define BT_OTS_OACP_SET_FEAT_CREATE(feat) \
WRITE_BIT(feat, BT_OTS_OACP_FEAT_CREATE, 1)
/** @brief Set @ref BT_OTS_OACP_FEAT_DELETE feature.
*
* @param feat OTS features.
*/
#define BT_OTS_OACP_SET_FEAT_DELETE(feat) \
WRITE_BIT(feat, BT_OTS_OACP_FEAT_DELETE, 1)
/** @brief Set @ref BT_OTS_OACP_FEAT_CHECKSUM feature.
*
* @param feat OTS features.
*/
#define BT_OTS_OACP_SET_FEAT_CHECKSUM(feat) \
WRITE_BIT(feat, BT_OTS_OACP_FEAT_CHECKSUM, 1)
/** @brief Set @ref BT_OTS_OACP_FEAT_EXECUTE feature.
*
* @param feat OTS features.
*/
#define BT_OTS_OACP_SET_FEAT_EXECUTE(feat) \
WRITE_BIT(feat, BT_OTS_OACP_FEAT_EXECUTE, 1)
/** @brief Set @ref BT_OTS_OACP_FEAT_READ feature.
*
* @param feat OTS features.
*/
#define BT_OTS_OACP_SET_FEAT_READ(feat) \
WRITE_BIT(feat, BT_OTS_OACP_FEAT_READ, 1)
/** @brief Set @ref BT_OTS_OACP_FEAT_WRITE feature.
*
* @param feat OTS features.
*/
#define BT_OTS_OACP_SET_FEAT_WRITE(feat) \
WRITE_BIT(feat, BT_OTS_OACP_FEAT_WRITE, 1)
/** @brief Set @ref BT_OTS_OACP_FEAT_APPEND feature.
*
* @param feat OTS features.
*/
#define BT_OTS_OACP_SET_FEAT_APPEND(feat) \
WRITE_BIT(feat, BT_OTS_OACP_FEAT_APPEND, 1)
/** @brief Set @ref BT_OTS_OACP_FEAT_TRUNCATE feature.
*
* @param feat OTS features.
*/
#define BT_OTS_OACP_SET_FEAT_TRUNCATE(feat) \
WRITE_BIT(feat, BT_OTS_OACP_FEAT_TRUNCATE, 1)
/** @brief Set @ref BT_OTS_OACP_FEAT_PATCH feature.
*
* @param feat OTS features.
*/
#define BT_OTS_OACP_SET_FEAT_PATCH(feat) \
WRITE_BIT(feat, BT_OTS_OACP_FEAT_PATCH, 1)
/** @brief Set @ref BT_OTS_OACP_FEAT_ABORT feature.
*
* @param feat OTS features.
*/
#define BT_OTS_OACP_SET_FEAT_ABORT(feat) \
WRITE_BIT(feat, BT_OTS_OACP_FEAT_ABORT, 1)
/** @brief Get @ref BT_OTS_OACP_FEAT_CREATE feature.
*
* @param feat OTS features.
*/
#define BT_OTS_OACP_GET_FEAT_CREATE(feat) \
((feat) & BIT(BT_OTS_OACP_FEAT_CREATE))
/** @brief Get @ref BT_OTS_OACP_FEAT_DELETE feature.
*
* @param feat OTS features.
*/
#define BT_OTS_OACP_GET_FEAT_DELETE(feat) \
((feat) & BIT(BT_OTS_OACP_FEAT_DELETE))
/** @brief Get @ref BT_OTS_OACP_FEAT_CHECKSUM feature.
*
* @param feat OTS features.
*/
#define BT_OTS_OACP_GET_FEAT_CHECKSUM(feat) \
((feat) & BIT(BT_OTS_OACP_FEAT_CHECKSUM))
/** @brief Get @ref BT_OTS_OACP_FEAT_EXECUTE feature.
*
* @param feat OTS features.
*/
#define BT_OTS_OACP_GET_FEAT_EXECUTE(feat) \
((feat) & BIT(BT_OTS_OACP_FEAT_EXECUTE))
/** @brief Get @ref BT_OTS_OACP_FEAT_READ feature.
*
* @param feat OTS features.
*/
#define BT_OTS_OACP_GET_FEAT_READ(feat) \
((feat) & BIT(BT_OTS_OACP_FEAT_READ))
/** @brief Get @ref BT_OTS_OACP_FEAT_WRITE feature.
*
* @param feat OTS features.
*/
#define BT_OTS_OACP_GET_FEAT_WRITE(feat) \
((feat) & BIT(BT_OTS_OACP_FEAT_WRITE))
/** @brief Get @ref BT_OTS_OACP_FEAT_APPEND feature.
*
* @param feat OTS features.
*/
#define BT_OTS_OACP_GET_FEAT_APPEND(feat) \
((feat) & BIT(BT_OTS_OACP_FEAT_APPEND))
/** @brief Get @ref BT_OTS_OACP_FEAT_TRUNCATE feature.
*
* @param feat OTS features.
*/
#define BT_OTS_OACP_GET_FEAT_TRUNCATE(feat) \
((feat) & BIT(BT_OTS_OACP_FEAT_TRUNCATE))
/** @brief Get @ref BT_OTS_OACP_FEAT_PATCH feature.
*
* @param feat OTS features.
*/
#define BT_OTS_OACP_GET_FEAT_PATCH(feat) \
((feat) & BIT(BT_OTS_OACP_FEAT_PATCH))
/** @brief Get @ref BT_OTS_OACP_FEAT_ABORT feature.
*
* @param feat OTS features.
*/
#define BT_OTS_OACP_GET_FEAT_ABORT(feat) \
((feat) & BIT(BT_OTS_OACP_FEAT_ABORT))
/** @brief Object List Control Point Feature bits. */
enum {
/** Bit 0 OLCP Go To Op Code Supported */
BT_OTS_OLCP_FEAT_GO_TO = 0,
/** Bit 1 OLCP Order Op Code Supported */
BT_OTS_OLCP_FEAT_ORDER = 1,
/** Bit 2 OLCP Request Number of Objects Op Code Supported */
BT_OTS_OLCP_FEAT_NUM_REQ = 2,
/** Bit 3 OLCP Clear Marking Op Code Supported*/
BT_OTS_OLCP_FEAT_CLEAR = 3,
};
/** @brief Set @ref BT_OTS_OLCP_FEAT_GO_TO feature.
*
* @param feat OTS features.
*/
#define BT_OTS_OLCP_SET_FEAT_GO_TO(feat) \
WRITE_BIT(feat, BT_OTS_OLCP_FEAT_GO_TO, 1)
/** @brief Set @ref BT_OTS_OLCP_FEAT_ORDER feature.
*
* @param feat OTS features.
*/
#define BT_OTS_OLCP_SET_FEAT_ORDER(feat) \
WRITE_BIT(feat, BT_OTS_OLCP_FEAT_ORDER, 1)
/** @brief Set @ref BT_OTS_OLCP_FEAT_NUM_REQ feature.
*
* @param feat OTS features.
*/
#define BT_OTS_OLCP_SET_FEAT_NUM_REQ(feat) \
WRITE_BIT(feat, BT_OTS_OLCP_FEAT_NUM_REQ, 1)
/** @brief Set @ref BT_OTS_OLCP_FEAT_CLEAR feature.
*
* @param feat OTS features.
*/
#define BT_OTS_OLCP_SET_FEAT_CLEAR(feat) \
WRITE_BIT(feat, BT_OTS_OLCP_FEAT_CLEAR, 1)
/** @brief Get @ref BT_OTS_OLCP_GET_FEAT_GO_TO feature.
*
* @param feat OTS features.
*/
#define BT_OTS_OLCP_GET_FEAT_GO_TO(feat) \
((feat) & BIT(BT_OTS_OLCP_FEAT_GO_TO))
/** @brief Get @ref BT_OTS_OLCP_GET_FEAT_ORDER feature.
*
* @param feat OTS features.
*/
#define BT_OTS_OLCP_GET_FEAT_ORDER(feat) \
((feat) & BIT(BT_OTS_OLCP_FEAT_ORDER))
/** @brief Get @ref BT_OTS_OLCP_GET_FEAT_NUM_REQ feature.
*
* @param feat OTS features.
*/
#define BT_OTS_OLCP_GET_FEAT_NUM_REQ(feat) \
((feat) & BIT(BT_OTS_OLCP_FEAT_NUM_REQ))
/** @brief Get @ref BT_OTS_OLCP_GET_FEAT_CLEAR feature.
*
* @param feat OTS features.
*/
#define BT_OTS_OLCP_GET_FEAT_CLEAR(feat) \
((feat) & BIT(BT_OTS_OLCP_FEAT_CLEAR))
/**@brief Features of the OTS. */
struct bt_ots_feat {
/* OACP Features */
uint32_t oacp;
/* OLCP Features */
uint32_t olcp;
} __packed;
/** @brief Object metadata request bit field values */
enum {
/** @brief Request object name */
BT_OTS_METADATA_REQ_NAME = BIT(0),
/** @brief Request object type */
BT_OTS_METADATA_REQ_TYPE = BIT(1),
/** @brief Request object size */
BT_OTS_METADATA_REQ_SIZE = BIT(2),
/** @brief Request object first created time */
BT_OTS_METADATA_REQ_CREATED = BIT(3),
/** @brief Request object last modified time */
BT_OTS_METADATA_REQ_MODIFIED = BIT(4),
/** @brief Request object ID */
BT_OTS_METADATA_REQ_ID = BIT(5),
/** @brief Request object properties */
BT_OTS_METADATA_REQ_PROPS = BIT(6),
/** @brief Request all object metadata */
BT_OTS_METADATA_REQ_ALL = 0x7F,
};
/** @brief Date and Time structure */
struct bt_ots_date_time {
uint16_t year;
uint8_t month;
uint8_t day;
uint8_t hours;
uint8_t minutes;
uint8_t seconds;
};
#define BT_OTS_DATE_TIME_FIELD_SIZE 7
/** @brief Metadata of an OTS object
*
* Used by the server as a descriptor for OTS object initialization.
* Used by the client to present object metadata to the application.
*/
struct bt_ots_obj_metadata {
#if defined(CONFIG_BT_OTS)
/** @brief Object Name */
char *name;
#endif /* CONFIG_BT_OTS */
#if defined(CONFIG_BT_OTS_CLIENT)
/* TODO: Unify client/server name */
/** @brief Object name (client) */
char name_c[CONFIG_BT_OTS_OBJ_MAX_NAME_LEN + 1];
#endif /* CONFIG_BT_OTS_CLIENT */
/** @brief Object Type */
struct bt_ots_obj_type type;
/** @brief Object Size */
struct bt_ots_obj_size size;
#if defined(CONFIG_BT_OTS_CLIENT)
/** @brief Object first created time */
struct bt_ots_date_time first_created;
/** @brief Object last modified time */
struct bt_ots_date_time modified;
/** @brief Object ID */
uint64_t id;
#endif /* CONFIG_BT_OTS_CLIENT */
/** @brief Object Properties */
uint32_t props;
};
/** @brief Opaque OTS instance. */
struct bt_ots;
/** @brief Descriptor for OTS object addition */
struct bt_ots_obj_add_param {
/** @brief Object size to allocate */
uint32_t size;
/** @brief Object type */
struct bt_ots_obj_type type;
};
/** @brief Descriptor for OTS created object.
*
* Descriptor for OTS object created by the application. This descriptor is
* returned by @ref bt_ots_cb.obj_created callback which contains further
* documentation on distinguishing between server and client object creation.
*/
struct bt_ots_obj_created_desc {
/** @brief Object name
*
* The object name as a NULL terminated string.
*
* When the server creates a new object the name
* shall be > 0 and <= BT_OTS_OBJ_MAX_NAME_LEN
* When the client creates a new object the name
* shall be an empty string
*/
char *name;
/** @brief Object size
*
* @ref bt_ots_obj_size.alloc shall be >= @ref bt_ots_obj_add_param.size
*
* When the server creates a new object @ref bt_ots_obj_size.cur
* shall be <= @ref bt_ots_obj_add_param.size
* When the client creates a new object @ref bt_ots_obj_size.cur
* shall be 0
*/
struct bt_ots_obj_size size;
/** @brief Object properties */
uint32_t props;
};
/** @brief OTS callback structure. */
struct bt_ots_cb {
/** @brief Object created callback
*
* This callback is called whenever a new object is created.
* Application can reject this request by returning an error
* when it does not have necessary resources to hold this new
* object. This callback is also triggered when the server
* creates a new object with bt_ots_obj_add() API.
*
* @param ots OTS instance.
* @param conn The connection that is requesting object creation or
* NULL if object is created by bt_ots_obj_add().
* @param id Object ID.
* @param add_param Object creation requested parameters.
* @param created_desc Created object descriptor that shall be filled by the
* receiver of this callback.
*
* @return 0 in case of success or negative value in case of error.
* @return -ENOTSUP if object type is not supported
* @return -ENOMEM if no available space for new object.
* @return -EINVAL if an invalid parameter is provided
* @return other negative values are treated as a generic operation failure
*/
int (*obj_created)(struct bt_ots *ots, struct bt_conn *conn, uint64_t id,
const struct bt_ots_obj_add_param *add_param,
struct bt_ots_obj_created_desc *created_desc);
/** @brief Object deleted callback
*
* This callback is called whenever an object is deleted. It is
* also triggered when the server deletes an object with
* bt_ots_obj_delete() API.
*
* @param ots OTS instance.
* @param conn The connection that deleted the object or NULL if
* this request came from the server.
* @param id Object ID.
*
* @retval When an error is indicated by using a negative value, the
* object delete procedure is aborted and a corresponding failed
* status is returned to the client.
* @return 0 in case of success.
* @return -EBUSY if the object is locked. This is generally not expected
* to be returned by the application as the OTS layer tracks object
* accesses. An object locked status is returned to the client.
* @return Other negative values in case of error. A generic operation
* failed status is returned to the client.
*/
int (*obj_deleted)(struct bt_ots *ots, struct bt_conn *conn,
uint64_t id);
/** @brief Object selected callback
*
* This callback is called on successful object selection.
*
* @param ots OTS instance.
* @param conn The connection that selected new object.
* @param id Object ID.
*/
void (*obj_selected)(struct bt_ots *ots, struct bt_conn *conn,
uint64_t id);
/** @brief Object read callback
*
* This callback is called multiple times during the Object read
* operation. OTS module will keep requesting successive Object
* fragments from the application until the read operation is
* completed. The end of read operation is indicated by NULL data
* parameter.
*
* @param ots OTS instance.
* @param conn The connection that read object.
* @param id Object ID.
* @param data In: NULL once the read operations is completed.
* Out: Next chunk of data to be sent.
* @param len Remaining length requested by the client.
* @param offset Object data offset.
*
* @return Data length to be sent via data parameter. This value
* shall be smaller or equal to the len parameter.
* @return Negative value in case of an error.
*/
ssize_t (*obj_read)(struct bt_ots *ots, struct bt_conn *conn,
uint64_t id, void **data, size_t len,
off_t offset);
/** @brief Object write callback
*
* This callback is called multiple times during the Object write
* operation. OTS module will keep providing successive Object
* fragments to the application until the write operation is
* completed. The offset and length of each write fragment is
* validated by the OTS module to be within the allocated size
* of the object. The remaining length indicates data length
* remaining to be written and will decrease each write iteration
* until it reaches 0 in the last write fragment.
*
* @param ots OTS instance.
* @param conn The connection that wrote object.
* @param id Object ID.
* @param data Next chunk of data to be written.
* @param len Length of the current chunk of data in the buffer.
* @param offset Object data offset.
* @param rem Remaining length in the write operation.
*
* @return Number of bytes written in case of success, if the number
* of bytes written does not match len, -EIO is returned to
* the L2CAP layer.
* @return A negative value in case of an error.
* @return -EINPROGRESS has a special meaning and is unsupported at
* the moment. It should not be returned.
*/
ssize_t (*obj_write)(struct bt_ots *ots, struct bt_conn *conn, uint64_t id,
const void *data, size_t len, off_t offset,
size_t rem);
/** @brief Object name written callback
*
* This callback is called when the object name is written.
* This is a notification to the application that the object name
* will be updated by the OTS service implementation.
*
* @param ots OTS instance.
* @param conn The connection that wrote object name.
* @param id Object ID.
* @param cur_name Current object name.
* @param new_name New object name.
*/
void (*obj_name_written)(struct bt_ots *ots, struct bt_conn *conn,
uint64_t id, const char *cur_name, const char *new_name);
/** @brief Object Calculate checksum callback
*
* This callback is called when the OACP Calculate Checksum procedure is performed.
* Because object data is opaque to OTS, the application is the only one who
* knows where data is and should return pointer of actual object data.
*
* @param[in] ots OTS instance.
* @param[in] conn The connection that wrote object.
* @param[in] id Object ID.
* @param[in] offset The first octet of the object contents need to be calculated.
* @param[in] len The length number of octets object name.
* @param[out] data Pointer of actual object data.
*
* @return 0 to accept, or any negative value to reject.
*/
int (*obj_cal_checksum)(struct bt_ots *ots, struct bt_conn *conn, uint64_t id,
off_t offset, size_t len, void **data);
};
/** @brief Descriptor for OTS initialization. */
struct bt_ots_init_param {
/* OTS features */
struct bt_ots_feat features;
/* Callbacks */
struct bt_ots_cb *cb;
};
/** @brief Add an object to the OTS instance.
*
* This function adds an object to the OTS database. When the
* object is being added, a callback obj_created() is called
* to notify the user about a new object ID.
*
* @param ots OTS instance.
* @param param Object addition parameters.
*
* @return ID of created object in case of success.
* @return negative value in case of error.
*/
int bt_ots_obj_add(struct bt_ots *ots, const struct bt_ots_obj_add_param *param);
/** @brief Delete an object from the OTS instance.
*
* This function deletes an object from the OTS database. When the
* object is deleted a callback obj_deleted() is called
* to notify the user about this event. At this point, it is possible
* to free allocated buffer for object data.
*
* @param ots OTS instance.
* @param id ID of the object to be deleted (uint48).
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_ots_obj_delete(struct bt_ots *ots, uint64_t id);
/** @brief Get the service declaration attribute.
*
* This function is enabled for CONFIG_BT_OTS_SECONDARY_SVC configuration.
* The first service attribute can be included in any other GATT service.
*
* @param ots OTS instance.
*
* @return The first OTS attribute instance.
*/
void *bt_ots_svc_decl_get(struct bt_ots *ots);
/** @brief Initialize the OTS instance.
*
* @param ots OTS instance.
* @param ots_init OTS initialization descriptor.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_ots_init(struct bt_ots *ots, struct bt_ots_init_param *ots_init);
/** @brief Get a free instance of OTS from the pool.
*
* @return OTS instance in case of success or NULL in case of error.
*/
struct bt_ots *bt_ots_free_instance_get(void);
#define BT_OTS_STOP 0
#define BT_OTS_CONTINUE 1
/* TODO: Merge server and client instance as opaque type */
/** @brief OTS client instance */
struct bt_ots_client {
uint16_t start_handle;
uint16_t end_handle;
uint16_t feature_handle;
uint16_t obj_name_handle;
uint16_t obj_type_handle;
uint16_t obj_size_handle;
uint16_t obj_properties_handle;
uint16_t obj_created_handle;
uint16_t obj_modified_handle;
uint16_t obj_id_handle;
uint16_t oacp_handle;
uint16_t olcp_handle;
struct bt_gatt_subscribe_params oacp_sub_params;
struct bt_gatt_discover_params oacp_sub_disc_params;
struct bt_gatt_subscribe_params olcp_sub_params;
struct bt_gatt_discover_params olcp_sub_disc_params;
struct bt_gatt_write_params write_params;
struct bt_gatt_read_params read_proc;
struct bt_ots_client_cb *cb;
struct bt_ots_feat features;
struct bt_ots_obj_metadata cur_object;
};
/** OTS client callback structure */
struct bt_ots_client_cb {
/** @brief Callback function when a new object is selected.
*
* Called when the a new object is selected and the current
* object has changed. The `cur_object` in `ots_inst` will
* have been reset, and metadata should be read again with
* bt_ots_client_read_object_metadata().
*
* @param ots_inst Pointer to the OTC instance.
* @param conn The connection to the peer device.
* @param err Error code (bt_ots_olcp_res_code).
*/
void (*obj_selected)(struct bt_ots_client *ots_inst,
struct bt_conn *conn, int err);
/** @brief Callback function for the data of the selected
* object.
*
* Called when the data of the selected object are read using
* bt_ots_client_read_object_data().
*
* @param ots_inst Pointer to the OTC instance.
* @param conn The connection to the peer device.
* @param offset Offset of the received data.
* @param len Length of the received data.
* @param data_p Pointer to the received data.
* @param is_complete Indicate if the whole object has been received.
*
* @return int BT_OTS_STOP or BT_OTS_CONTINUE. BT_OTS_STOP can
* be used to stop reading.
*/
int (*obj_data_read)(struct bt_ots_client *ots_inst,
struct bt_conn *conn, uint32_t offset,
uint32_t len, uint8_t *data_p, bool is_complete);
/** @brief Callback function for metadata of the selected object.
*
* Called when metadata of the selected object are read using
* bt_ots_client_read_object_metadata().
* Not all of the metadata may have been initialized.
*
* @param ots_inst Pointer to the OTC instance.
* @param conn The connection to the peer device.
* @param err Error value. 0 on success,
* GATT error or ERRNO on fail.
* @param metadata_read Bitfield of the metadata that was
* successfully read.
*/
void (*obj_metadata_read)(struct bt_ots_client *ots_inst,
struct bt_conn *conn, int err,
uint8_t metadata_read);
/** @brief Callback function for the data of the write object.
*
* Called when the data of the selected object is written using
* bt_ots_client_write_object_data().
*
* @param ots_inst Pointer to the OTC instance.
* @param conn The connection to the peer device.
* @param len Length of the written data.
*/
void (*obj_data_written)(struct bt_ots_client *ots_inst,
struct bt_conn *conn, size_t len);
/** @brief Callback function when checksum indication is received.
*
* Called when the oacp_ind_handler received response of
* OP BT_GATT_OTS_OACP_PROC_CHECKSUM_CALC.
*
* @param ots_inst Pointer to the OTC instance.
* @param conn The connection to the peer device.
* @param err Error code (bt_gatt_ots_oacp_res_code).
* @param checksum Checksum if error code is BT_GATT_OTS_OACP_RES_SUCCESS,
* otherwise 0.
*/
void (*obj_checksum_calculated)(struct bt_ots_client *ots_inst, struct bt_conn *conn,
int err, uint32_t checksum);
};
/** @brief Register an Object Transfer Service Instance.
*
* Register an Object Transfer Service instance discovered on the peer.
* Call this function when an OTS instance is discovered
* (discovery is to be handled by the higher layer).
*
* @param[in] ots_inst Discovered OTS instance.
*
* @return int 0 if success, ERRNO on failure.
*/
int bt_ots_client_register(struct bt_ots_client *ots_inst);
/** @brief Unregister an Object Transfer Service Instance.
*
* Unregister an Object Transfer Service instance when disconnect from the peer.
* Call this function when an ACL using OTS instance is disconnected.
*
* @param[in] index Index of OTS instance.
*
* @return int 0 if success, ERRNO on failure.
*/
int bt_ots_client_unregister(uint8_t index);
/** @brief OTS Indicate Handler function.
*
* Set this function as callback for indicate handler when discovering OTS.
*
* @param conn Connection object. May be NULL, indicating that the
* peer is being unpaired.
* @param params Subscription parameters.
* @param data Attribute value data. If NULL then subscription was
* removed.
* @param length Attribute value length.
*/
uint8_t bt_ots_client_indicate_handler(struct bt_conn *conn,
struct bt_gatt_subscribe_params *params,
const void *data, uint16_t length);
/** @brief Read the OTS feature characteristic.
*
* @param otc_inst Pointer to the OTC instance.
* @param conn Pointer to the connection object.
*
* @return int 0 if success, ERRNO on failure.
*/
int bt_ots_client_read_feature(struct bt_ots_client *otc_inst,
struct bt_conn *conn);
/** @brief Select an object by its Object ID.
*
* @param otc_inst Pointer to the OTC instance.
* @param conn Pointer to the connection object.
* @param obj_id Object's ID.
*
* @return int 0 if success, ERRNO on failure.
*/
int bt_ots_client_select_id(struct bt_ots_client *otc_inst,
struct bt_conn *conn,
uint64_t obj_id);
/** @brief Select the first object.
*
* @param otc_inst Pointer to the OTC instance.
* @param conn Pointer to the connection object.
*
* @return int 0 if success, ERRNO on failure.
*/
int bt_ots_client_select_first(struct bt_ots_client *otc_inst,
struct bt_conn *conn);
/** @brief Select the last object.
*
* @param otc_inst Pointer to the OTC instance.
* @param conn Pointer to the connection object.
*
* @return int 0 if success, ERRNO on failure.
*/
int bt_ots_client_select_last(struct bt_ots_client *otc_inst,
struct bt_conn *conn);
/** @brief Select the next object.
*
* @param otc_inst Pointer to the OTC instance.
* @param conn Pointer to the connection object.
*
* @return int 0 if success, ERRNO on failure.
*/
int bt_ots_client_select_next(struct bt_ots_client *otc_inst,
struct bt_conn *conn);
/** @brief Select the previous object.
*
* @param otc_inst Pointer to the OTC instance.
* @param conn Pointer to the connection object.
*
* @return int 0 if success, ERRNO on failure.
*/
int bt_ots_client_select_prev(struct bt_ots_client *otc_inst,
struct bt_conn *conn);
/** @brief Read the metadata of the current object.
*
* The metadata are returned in the obj_metadata_read() callback.
*
* @param otc_inst Pointer to the OTC instance.
* @param conn Pointer to the connection object.
* @param metadata Bitfield (`BT_OTS_METADATA_REQ_*`) of the metadata
* to read.
*
* @return int 0 if success, ERRNO on failure.
*/
int bt_ots_client_read_object_metadata(struct bt_ots_client *otc_inst,
struct bt_conn *conn,
uint8_t metadata);
/** @brief Read the data of the current selected object.
*
* This will trigger an OACP read operation for the current size of the object
* with a 0 offset and then expect receiving the content via the L2CAP CoC.
*
* The data of the object are returned in the obj_data_read() callback.
*
* @param otc_inst Pointer to the OTC instance.
* @param conn Pointer to the connection object.
*
* @return int 0 if success, ERRNO on failure.
*/
int bt_ots_client_read_object_data(struct bt_ots_client *otc_inst,
struct bt_conn *conn);
/** @brief Write the data of the current selected object.
*
* This will trigger an OACP write operation for the current object
* with a specified offset and then expect transferring the content via the L2CAP CoC.
*
* The length of the data written to object is returned in the obj_data_written() callback.
*
* @param otc_inst Pointer to the OTC instance.
* @param conn Pointer to the connection object.
* @param buf Pointer to the data buffer to be written.
* @param len Size of data.
* @param offset Offset to write, usually 0.
* @param mode Mode Parameter for OACP Write Op Code. See @ref bt_ots_oacp_write_op_mode.
*
* @return int 0 if success, ERRNO on failure.
*/
int bt_ots_client_write_object_data(struct bt_ots_client *otc_inst, struct bt_conn *conn,
const void *buf, size_t len, off_t offset,
enum bt_ots_oacp_write_op_mode mode);
/** @brief Get the checksum of the current selected object.
*
* This will trigger an OACP calculate checksum operation for the current object
* with a specified offset and length.
*
* The checksum goes to OACP IND and obj_checksum_calculated() callback.
*
* @param otc_inst Pointer to the OTC instance.
* @param conn Pointer to the connection object.
* @param offset Offset to calculate, usually 0.
* @param len Len of data to calculate checksum for. May be less than the current object's
* size, but shall not be larger.
*
* @return int 0 if success, ERRNO on failure.
*/
int bt_ots_client_get_object_checksum(struct bt_ots_client *otc_inst, struct bt_conn *conn,
off_t offset, size_t len);
/** @brief Directory listing object metadata callback
*
* If a directory listing is decoded using bt_ots_client_decode_dirlisting(),
* this callback will be called for each object in the directory listing.
*
* @param meta The metadata of the decoded object
*
* @return int BT_OTS_STOP or BT_OTS_CONTINUE. BT_OTS_STOP can be used to
* stop the decoding.
*/
typedef int (*bt_ots_client_dirlisting_cb)(struct bt_ots_obj_metadata *meta);
/** @brief Decode Directory Listing object into object metadata.
*
* If the Directory Listing object contains multiple objects, then the
* callback will be called for each of them.
*
* @param data The data received for the directory listing object.
* @param length Length of the data.
* @param cb The callback that will be called for each object.
*/
int bt_ots_client_decode_dirlisting(uint8_t *data, uint16_t length,
bt_ots_client_dirlisting_cb cb);
/** @brief Converts binary OTS Object ID to string.
*
* @param obj_id Object ID.
* @param str Address of user buffer with enough room to store
* formatted string containing binary Object ID.
* @param len Length of data to be copied to user string buffer.
* Refer to BT_OTS_OBJ_ID_STR_LEN about
* recommended value.
*
* @return Number of successfully formatted bytes from binary ID.
*/
static inline int bt_ots_obj_id_to_str(uint64_t obj_id, char *str, size_t len)
{
uint8_t id[6];
sys_put_le48(obj_id, id);
return snprintk(str, len, "0x%02X%02X%02X%02X%02X%02X",
id[5], id[4], id[3], id[2], id[1], id[0]);
}
/** @brief Displays one or more object metadata as text with LOG_INF.
*
* @param metadata Pointer to the first (or only) metadata in an array.
* @param count Number of metadata objects to display information of.
*/
void bt_ots_metadata_display(struct bt_ots_obj_metadata *metadata,
uint16_t count);
/**
* @brief Generate IEEE conform CRC32 checksum.
*
* To abstract IEEE implementation to service layer.
*
* @param data Pointer to data on which the CRC should be calculated.
* @param len Data length.
*
* @return CRC32 value.
*
*/
#if defined(CONFIG_BT_OTS_OACP_CHECKSUM_SUPPORT)
static inline uint32_t bt_ots_client_calc_checksum(const uint8_t *data, size_t len)
{
return crc32_ieee(data, len);
}
#endif
#ifdef __cplusplus
}
#endif
/**
* @}
*/
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_OTS_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/services/ots.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 9,866 |
```objective-c
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_BAS_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_BAS_H_
/**
* @brief Battery Service (BAS)
* @defgroup bt_bas Battery Service (BAS)
* @ingroup bluetooth
* @{
*
* [Experimental] Users should note that the APIs can change
* as a part of ongoing development.
*/
#include <stdint.h>
#include <zephyr/sys/util.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Battery Level Status Characteristic flags.
*
* Enumeration for the flags indicating the presence
* of various fields in the Battery Level Status characteristic.
*/
enum bt_bas_bls_flags {
/** Bit indicating that the Battery Level Status identifier is present. */
BT_BAS_BLS_FLAG_IDENTIFIER_PRESENT = BIT(0),
/** Bit indicating that the Battery Level is present. */
BT_BAS_BLS_FLAG_BATTERY_LEVEL_PRESENT = BIT(1),
/** Bit indicating that additional status information is present. */
BT_BAS_BLS_FLAG_ADDITIONAL_STATUS_PRESENT = BIT(2),
};
/** @brief Battery Present Status
*
* Enumeration for the presence of the battery.
*/
enum bt_bas_bls_battery_present {
/** Battery is not present. */
BT_BAS_BLS_BATTERY_NOT_PRESENT = 0,
/** Battery is present. */
BT_BAS_BLS_BATTERY_PRESENT = 1
};
/** @brief Wired External Power Source Status
*
* Enumeration for the status of the wired external power source.
*/
enum bt_bas_bls_wired_power_source {
/** Wired external power source is not connected. */
BT_BAS_BLS_WIRED_POWER_NOT_CONNECTED = 0,
/** Wired external power source is connected. */
BT_BAS_BLS_WIRED_POWER_CONNECTED = 1,
/** Wired external power source status is unknown. */
BT_BAS_BLS_WIRED_POWER_UNKNOWN = 2
};
/** @brief Wireless External Power Source Status
*
* Enumeration for the status of the wireless external power source.
*/
enum bt_bas_bls_wireless_power_source {
/** Wireless external power source is not connected. */
BT_BAS_BLS_WIRELESS_POWER_NOT_CONNECTED = 0,
/** Wireless external power source is connected. */
BT_BAS_BLS_WIRELESS_POWER_CONNECTED = 1,
/** Wireless external power source status is unknown. */
BT_BAS_BLS_WIRELESS_POWER_UNKNOWN = 2
};
/** @brief Battery Charge State
*
* Enumeration for the charge state of the battery.
*/
enum bt_bas_bls_battery_charge_state {
/** Battery charge state is unknown. */
BT_BAS_BLS_CHARGE_STATE_UNKNOWN = 0,
/** Battery is currently charging. */
BT_BAS_BLS_CHARGE_STATE_CHARGING = 1,
/** Battery is discharging actively. */
BT_BAS_BLS_CHARGE_STATE_DISCHARGING_ACTIVE = 2,
/** Battery is discharging but inactive. */
BT_BAS_BLS_CHARGE_STATE_DISCHARGING_INACTIVE = 3
};
/** @brief Battery Charge Level
*
* Enumeration for the level of charge in the battery.
*/
enum bt_bas_bls_battery_charge_level {
/** Battery charge level is unknown. */
BT_BAS_BLS_CHARGE_LEVEL_UNKNOWN = 0,
/** Battery charge level is good. */
BT_BAS_BLS_CHARGE_LEVEL_GOOD = 1,
/** Battery charge level is low. */
BT_BAS_BLS_CHARGE_LEVEL_LOW = 2,
/** Battery charge level is critical. */
BT_BAS_BLS_CHARGE_LEVEL_CRITICAL = 3
};
/** @brief Battery Charge Type
*
* Enumeration for the type of charging applied to the battery.
*/
enum bt_bas_bls_battery_charge_type {
/** Battery charge type is unknown or not charging. */
BT_BAS_BLS_CHARGE_TYPE_UNKNOWN = 0,
/** Battery is charged using constant current. */
BT_BAS_BLS_CHARGE_TYPE_CONSTANT_CURRENT = 1,
/** Battery is charged using constant voltage. */
BT_BAS_BLS_CHARGE_TYPE_CONSTANT_VOLTAGE = 2,
/** Battery is charged using trickle charge. */
BT_BAS_BLS_CHARGE_TYPE_TRICKLE = 3,
/** Battery is charged using float charge. */
BT_BAS_BLS_CHARGE_TYPE_FLOAT = 4
};
/** @brief Charging Fault Reason
*
* Enumeration for the reasons of charging faults.
*/
enum bt_bas_bls_charging_fault_reason {
/** No charging fault. */
BT_BAS_BLS_FAULT_REASON_NONE = 0,
/** Charging fault due to battery issue. */
BT_BAS_BLS_FAULT_REASON_BATTERY = BIT(0),
/** Charging fault due to external power source issue. */
BT_BAS_BLS_FAULT_REASON_EXTERNAL_POWER = BIT(1),
/** Charging fault for other reasons. */
BT_BAS_BLS_FAULT_REASON_OTHER = BIT(2)
};
/** @brief Service Required Status
*
* Enumeration for whether the service is required.
*/
enum bt_bas_bls_service_required {
/** Service is not required. */
BT_BAS_BLS_SERVICE_REQUIRED_FALSE = 0,
/** Service is required. */
BT_BAS_BLS_SERVICE_REQUIRED_TRUE = 1,
/** Service requirement is unknown. */
BT_BAS_BLS_SERVICE_REQUIRED_UNKNOWN = 2
};
/** @brief Battery Fault Status
*
* Enumeration for the fault status of the battery.
*/
enum bt_bas_bls_battery_fault {
/** No battery fault. */
BT_BAS_BLS_BATTERY_FAULT_NO = 0,
/** Battery fault present. */
BT_BAS_BLS_BATTERY_FAULT_YES = 1
};
/** @brief Read battery level value.
*
* Read the characteristic value of the battery level
*
* @return The battery level in percent.
*/
uint8_t bt_bas_get_battery_level(void);
/** @brief Update battery level value.
*
* Update the characteristic value of the battery level
* This will send a GATT notification to all current subscribers.
*
* @param level The battery level in percent.
*
* @return Zero in case of success and error code in case of error.
*/
int bt_bas_set_battery_level(uint8_t level);
/**
* @brief Set the battery present status.
*
* @param present The battery present status to set.
*/
void bt_bas_bls_set_battery_present(enum bt_bas_bls_battery_present present);
/**
* @brief Set the wired external power source status.
*
* @param source The wired external power source status to set.
*/
void bt_bas_bls_set_wired_external_power_source(enum bt_bas_bls_wired_power_source source);
/**
* @brief Set the wireless external power source status.
*
* @param source The wireless external power source status to set.
*/
void bt_bas_bls_set_wireless_external_power_source(enum bt_bas_bls_wireless_power_source source);
/**
* @brief Set the battery charge state.
*
* @param state The battery charge state to set.
*/
void bt_bas_bls_set_battery_charge_state(enum bt_bas_bls_battery_charge_state state);
/**
* @brief Set the battery charge level.
*
* @param level The battery charge level to set.
*/
void bt_bas_bls_set_battery_charge_level(enum bt_bas_bls_battery_charge_level level);
/**
* @brief Set the battery charge type.
*
* @param type The battery charge type to set.
*/
void bt_bas_bls_set_battery_charge_type(enum bt_bas_bls_battery_charge_type type);
/**
* @brief Set the charging fault reason.
*
* @param reason The charging fault reason to set.
*/
void bt_bas_bls_set_charging_fault_reason(enum bt_bas_bls_charging_fault_reason reason);
/**
* @brief Set the identifier of the battery.
*
* kconfig_dep{CONFIG_BT_BAS_BLS_IDENTIFIER_PRESENT}
*
* @param identifier Identifier to set.
*/
void bt_bas_bls_set_identifier(uint16_t identifier);
/**
* @brief Set the service required status.
*
* kconfig_dep{CONFIG_BT_BAS_BLS_ADDITIONAL_STATUS_PRESENT}
*
* @param value Service required status to set.
*/
void bt_bas_bls_set_service_required(enum bt_bas_bls_service_required value);
/**
* @brief Set the battery fault status.
*
* kconfig_dep{CONFIG_BT_BAS_BLS_ADDITIONAL_STATUS_PRESENT}
*
* @param value Battery fault status to set.
*/
void bt_bas_bls_set_battery_fault(enum bt_bas_bls_battery_fault value);
#ifdef __cplusplus
}
#endif
/**
* @}
*/
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_BAS_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/services/bas.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 1,870 |
```objective-c
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_HRS_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_HRS_H_
/**
* @brief Heart Rate Service (HRS)
* @defgroup bt_hrs Heart Rate Service (HRS)
* @ingroup bluetooth
* @{
*
* [Experimental] Users should note that the APIs can change
* as a part of ongoing development.
*/
#include <stdint.h>
#include <zephyr/sys/slist.h>
#ifdef __cplusplus
extern "C" {
#endif
/** @brief Heart rate service callback structure */
struct bt_hrs_cb {
/** @brief Heart rate notifications changed
*
* @param enabled Flag that is true if notifications were enabled, false
* if they were disabled.
*/
void (*ntf_changed)(bool enabled);
/** Internal member to form a list of callbacks */
sys_snode_t _node;
};
/** @brief Heart rate service callback register
*
* This function will register callbacks that will be called in
* certain events related to Heart rate service.
*
* @param cb Pointer to callbacks structure. Must point to memory that remains valid
* until unregistered.
*
* @return 0 on success
* @return -EINVAL in case @p cb is NULL
*/
int bt_hrs_cb_register(struct bt_hrs_cb *cb);
/** @brief Heart rate service callback unregister
*
* This function will unregister callback from Heart rate service.
*
* @param cb Pointer to callbacks structure
*
* @return 0 on success
* @return -EINVAL in case @p cb is NULL
* @return -ENOENT in case the @p cb was not found in registered callbacks
*/
int bt_hrs_cb_unregister(struct bt_hrs_cb *cb);
/** @brief Notify heart rate measurement.
*
* This will send a GATT notification to all current subscribers.
*
* @param heartrate The heartrate measurement in beats per minute.
*
* @return Zero in case of success and error code in case of error.
*/
int bt_hrs_notify(uint16_t heartrate);
#ifdef __cplusplus
}
#endif
/**
* @}
*/
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_HRS_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/services/hrs.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 475 |
```objective-c
/** @file
* @brief GATT Device Information Service
*/
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_DIS_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_DIS_H_
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_DIS_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/services/dis.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 84 |
```objective-c
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_IAS_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_IAS_H_
/**
* @brief Immediate Alert Service (IAS)
* @defgroup bt_ias Immediate Alert Service (IAS)
* @ingroup bluetooth
* @{
*
* [Experimental] Users should note that the APIs can change
* as a part of ongoing development.
*/
#include <zephyr/bluetooth/conn.h>
#include <zephyr/sys/iterable_sections.h>
#ifdef __cplusplus
extern "C" {
#endif
enum bt_ias_alert_lvl {
/** No alerting should be done on device */
BT_IAS_ALERT_LVL_NO_ALERT,
/** Device shall alert */
BT_IAS_ALERT_LVL_MILD_ALERT,
/** Device should alert in strongest possible way */
BT_IAS_ALERT_LVL_HIGH_ALERT,
};
/** @brief Immediate Alert Service callback structure. */
struct bt_ias_cb {
/**
* @brief Callback function to stop alert.
*
* This callback is called when peer commands to disable alert.
*/
void (*no_alert)(void);
/**
* @brief Callback function for alert level value.
*
* This callback is called when peer commands to alert.
*/
void (*mild_alert)(void);
/**
* @brief Callback function for alert level value.
*
* This callback is called when peer commands to alert in the strongest possible way.
*/
void (*high_alert)(void);
};
/** @brief Method for stopping alert locally
*
* @return Zero in case of success and error code in case of error.
*/
int bt_ias_local_alert_stop(void);
/**
* @brief Register a callback structure for immediate alert events.
*
* @param _name Name of callback structure.
*/
#define BT_IAS_CB_DEFINE(_name) \
static const STRUCT_SECTION_ITERABLE(bt_ias_cb, _CONCAT(bt_ias_cb_, _name))
struct bt_ias_client_cb {
/** @brief Callback function for bt_ias_discover.
*
* This callback is called when discovery procedure is complete.
*
* @param conn Bluetooth connection object.
* @param err 0 on success, ATT error or negative errno otherwise
*/
void (*discover)(struct bt_conn *conn, int err);
};
/** @brief Set alert level
*
* @param conn Bluetooth connection object
* @param bt_ias_alert_lvl Level of alert to write
*
* @return Zero in case of success and error code in case of error.
*/
int bt_ias_client_alert_write(struct bt_conn *conn, enum bt_ias_alert_lvl);
/** @brief Discover Immediate Alert Service
*
* @param conn Bluetooth connection object
*
* @return Zero in case of success and error code in case of error.
*/
int bt_ias_discover(struct bt_conn *conn);
/** @brief Register Immediate Alert Client callbacks
*
* @param cb The callback structure
*
* @return Zero in case of success and error code in case of error.
*/
int bt_ias_client_cb_register(const struct bt_ias_client_cb *cb);
#ifdef __cplusplus
}
#endif
/**
* @}
*/
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_IAS_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/services/ias.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 699 |
```objective-c
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_NUS_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_NUS_H_
#include <zephyr/bluetooth/uuid.h>
#include <zephyr/bluetooth/services/nus/inst.h>
#include <zephyr/sys/slist.h>
#ifdef __cplusplus
extern "C" {
#endif
/** @brief UUIDs of Nordic UART GATT Service.
* Service: 6e400001-b5a3-f393-e0a9-e50e24dcca9e
* RX Char: 6e400002-b5a3-f393-e0a9-e50e24dcca9e
* TX Char: 6e400003-b5a3-f393-e0a9-e50e24dcca9e
*/
#define BT_UUID_NUS_SRV_VAL \
BT_UUID_128_ENCODE(0x6e400001, 0xb5a3, 0xf393, 0xe0a9, 0xe50e24dcca9e)
#define BT_UUID_NUS_RX_CHAR_VAL \
BT_UUID_128_ENCODE(0x6e400002, 0xb5a3, 0xf393, 0xe0a9, 0xe50e24dcca9e)
#define BT_UUID_NUS_TX_CHAR_VAL \
BT_UUID_128_ENCODE(0x6e400003, 0xb5a3, 0xf393, 0xe0a9, 0xe50e24dcca9e)
/** @brief Macro to define instance of NUS Service. It allows users to
* define multiple NUS instances, analogous to Serial endpoints, and use each
* one for different purposes. A default NUS instance may be defined through
* Kconfig.
*/
#define BT_NUS_INST_DEFINE(_name) \
Z_INTERNAL_BT_NUS_INST_DEFINE(_name)
/** @brief Callbacks for getting notified on NUS Service occurrences */
struct bt_nus_cb {
/** @brief Notifications subscription changed
*
* @param enabled Flag that is true if notifications were enabled, false
* if they were disabled.
* @param ctx User context provided in the callback structure.
*/
void (*notif_enabled)(bool enabled, void *ctx);
/** @brief Received Data
*
* @param conn Peer Connection object.
* @param data Pointer to buffer with data received.
* @param len Size in bytes of data received.
* @param ctx User context provided in the callback structure.
*/
void (*received)(struct bt_conn *conn, const void *data, uint16_t len, void *ctx);
/** Internal member. Provided as a callback argument for user context */
void *ctx;
/** Internal member to form a list of callbacks */
sys_snode_t _node;
};
/** @brief NUS server Instance callback register
*
* This function registers callbacks that will be called in
* certain events related to NUS.
*
* @param inst Pointer to instance of NUS service. NULL if using default instance.
* @param cb Pointer to callbacks structure. Must be valid throughout the
* lifetime of the application.
* @param ctx User context to be provided through the callback.
*
* @return 0 on success
* @return -EINVAL in case @p cb is NULL
*/
int bt_nus_inst_cb_register(struct bt_nus_inst *inst, struct bt_nus_cb *cb, void *ctx);
/** @brief Send Data to NUS Instance
*
* @note This API sends the data to the specified peer.
*
* @param conn Connection object to send data to. NULL if notifying all peers.
* @param inst Pointer to instance of NUS service. NULL if using default instance.
* @param data Pointer to buffer with bytes to send.
* @param len Length in bytes of data to send.
*
* @return 0 on success, negative error code if failed.
* @return -EAGAIN when Bluetooth stack has not been enabled.
* @return -ENOTCONN when either no connection has been established or no peers
* have subscribed.
*/
int bt_nus_inst_send(struct bt_conn *conn,
struct bt_nus_inst *inst,
const void *data,
uint16_t len);
/** @brief NUS server callback register
*
* @param cb Pointer to callbacks structure. Must be valid throughout the
* lifetime of the application.
* @param ctx User context to be provided through the callback.
*
* @return 0 on success, negative error code if failed.
* @return -EINVAL in case @p cb is NULL
*/
static inline int bt_nus_cb_register(struct bt_nus_cb *cb, void *ctx)
{
return bt_nus_inst_cb_register(NULL, cb, ctx);
}
/** @brief Send Data over NUS
*
* @note This API sends the data to the specified peer.
*
* @param conn Connection object to send data to. NULL if notifying all peers.
* @param data Pointer to buffer with bytes to send.
* @param len Length in bytes of data to send.
*
* @return 0 on success, negative error code if failed.
* @return -EAGAIN when Bluetooth stack has not been enabled.
* @return -ENOTCONN when either no connection has been established or no peers
* have subscribed.
*/
static inline int bt_nus_send(struct bt_conn *conn, const void *data, uint16_t len)
{
return bt_nus_inst_send(conn, NULL, data, len);
}
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_NUS_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/services/nus.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 1,204 |
```objective-c
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_NUS_INST_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_NUS_INST_H_
#include <zephyr/bluetooth/gatt.h>
#include <zephyr/sys/iterable_sections.h>
#include <zephyr/sys/slist.h>
#ifdef __cplusplus
extern "C" {
#endif
struct bt_nus_inst {
/** Pointer to the NUS Service Instance */
const struct bt_gatt_service_static *svc;
/** List of subscribers to invoke callbacks on asynchronous events */
sys_slist_t *cbs;
};
#define BT_UUID_NUS_SERVICE BT_UUID_DECLARE_128(BT_UUID_NUS_SRV_VAL)
#define BT_UUID_NUS_TX_CHAR BT_UUID_DECLARE_128(BT_UUID_NUS_TX_CHAR_VAL)
#define BT_UUID_NUS_RX_CHAR BT_UUID_DECLARE_128(BT_UUID_NUS_RX_CHAR_VAL)
/** Required as the service may be instantiated outside of the module */
ssize_t nus_bt_chr_write(struct bt_conn *conn, const struct bt_gatt_attr *attr,
const void *buf, uint16_t len, uint16_t offset, uint8_t flags);
void nus_ccc_cfg_changed(const struct bt_gatt_attr *attr, uint16_t value);
#define Z_INTERNAL_BT_NUS_INST_DEFINE(_name) \
\
BT_GATT_SERVICE_DEFINE(_name##_svc, \
BT_GATT_PRIMARY_SERVICE(BT_UUID_NUS_SERVICE), \
BT_GATT_CHARACTERISTIC(BT_UUID_NUS_TX_CHAR, \
BT_GATT_CHRC_NOTIFY, \
BT_GATT_PERM_NONE, \
NULL, NULL, NULL), \
BT_GATT_CCC(nus_ccc_cfg_changed, \
BT_GATT_PERM_READ | BT_GATT_PERM_WRITE), \
BT_GATT_CHARACTERISTIC(BT_UUID_NUS_RX_CHAR, \
BT_GATT_CHRC_WRITE | \
BT_GATT_CHRC_WRITE_WITHOUT_RESP, \
BT_GATT_PERM_WRITE, \
NULL, nus_bt_chr_write, NULL), \
); \
\
sys_slist_t _name##_cbs = SYS_SLIST_STATIC_INIT(&_name##_cbs); \
\
STRUCT_SECTION_ITERABLE(bt_nus_inst, _name) = { \
.svc = &_name##_svc, \
.cbs = &_name##_cbs, \
}
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_NUS_INST_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/services/nus/inst.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 554 |
```objective-c
/* hci.h - Bluetooth Host Control Interface types */
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_HCI_TYPES_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_HCI_TYPES_H_
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include <zephyr/toolchain.h>
#include <zephyr/types.h>
#include <zephyr/sys/util.h>
#include <zephyr/bluetooth/addr.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Bluetooth spec v5.4 Vol 4, Part A Table 2.1: HCI packet indicators
* The following definitions are intended for use with the UART Transport Layer and
* may be reused with other transport layers if desired.
*/
#define BT_HCI_H4_NONE 0x00 /* None of the known packet types */
#define BT_HCI_H4_CMD 0x01 /* HCI Command packet */
#define BT_HCI_H4_ACL 0x02 /* HCI ACL Data packet */
#define BT_HCI_H4_SCO 0x03 /* HCI Synchronous Data packet */
#define BT_HCI_H4_EVT 0x04 /* HCI Event packet */
#define BT_HCI_H4_ISO 0x05 /* HCI ISO Data packet */
/* Special own address types for LL privacy (used in adv & scan parameters) */
#define BT_HCI_OWN_ADDR_RPA_OR_PUBLIC 0x02
#define BT_HCI_OWN_ADDR_RPA_OR_RANDOM 0x03
#define BT_HCI_OWN_ADDR_RPA_MASK 0x02
#define BT_HCI_PEER_ADDR_RPA_UNRESOLVED 0xfe
#define BT_HCI_PEER_ADDR_ANONYMOUS 0xff
#define BT_ENC_KEY_SIZE_MIN 0x07
#define BT_ENC_KEY_SIZE_MAX 0x10
#define BT_HCI_ADV_HANDLE_INVALID 0xff
#define BT_HCI_SYNC_HANDLE_INVALID 0xffff
#define BT_HCI_PAWR_SUBEVENT_MAX 128
/* Bluetooth spec v5.4 Vol 4, Part E - 5.4.3 HCI Synchronous Data Packets */
struct bt_hci_sco_hdr {
uint16_t handle; /* 12 bit handle, 2 bit Packet Status Flag, 1 bit RFU */
uint8_t len;
} __packed;
#define BT_HCI_SCO_HDR_SIZE 3
/* Bluetooth spec v5.4 Vol 4, Part E - 5.4.4 HCI Event Packet */
struct bt_hci_evt_hdr {
uint8_t evt;
uint8_t len;
} __packed;
#define BT_HCI_EVT_HDR_SIZE 2
#define BT_ACL_START_NO_FLUSH 0x00
#define BT_ACL_CONT 0x01
#define BT_ACL_START 0x02
#define BT_ACL_COMPLETE 0x03
#define BT_ACL_POINT_TO_POINT 0x00
#define BT_ACL_BROADCAST 0x01
#define BT_ACL_HANDLE_MASK BIT_MASK(12)
#define bt_acl_handle(h) ((h) & BT_ACL_HANDLE_MASK)
#define bt_acl_flags(h) ((h) >> 12)
#define bt_acl_flags_pb(f) ((f) & BIT_MASK(2))
#define bt_acl_flags_bc(f) ((f) >> 2)
#define bt_acl_handle_pack(h, f) ((h) | ((f) << 12))
/* Bluetooth spec v5.4 Vol 4, Part E - 5.4.2 ACL Data Packets */
struct bt_hci_acl_hdr {
uint16_t handle;
uint16_t len;
} __packed;
#define BT_HCI_ACL_HDR_SIZE 4
#define BT_ISO_START 0x00
#define BT_ISO_CONT 0x01
#define BT_ISO_SINGLE 0x02
#define BT_ISO_END 0x03
#define bt_iso_handle(h) ((h) & 0x0fff)
#define bt_iso_flags(h) ((h) >> 12)
#define bt_iso_flags_pb(f) ((f) & 0x0003)
#define bt_iso_flags_ts(f) (((f) >> 2) & 0x0001)
#define bt_iso_pack_flags(pb, ts) \
(((pb) & 0x0003) | (((ts) & 0x0001) << 2))
#define bt_iso_handle_pack(h, pb, ts) \
((h) | (bt_iso_pack_flags(pb, ts) << 12))
#define bt_iso_hdr_len(h) ((h) & BIT_MASK(14))
#define BT_ISO_DATA_VALID 0x00
#define BT_ISO_DATA_INVALID 0x01
#define BT_ISO_DATA_NOP 0x02
#define bt_iso_pkt_len(h) ((h) & BIT_MASK(12))
#define bt_iso_pkt_flags(h) ((h) >> 14)
#define bt_iso_pkt_len_pack(h, f) (((h) & BIT_MASK(12)) | ((f) << 14))
struct bt_hci_iso_sdu_hdr {
uint16_t sn;
uint16_t slen; /* 12 bit len, 2 bit RFU, 2 bit packet status */
} __packed;
#define BT_HCI_ISO_SDU_HDR_SIZE 4
struct bt_hci_iso_sdu_ts_hdr {
uint32_t ts;
struct bt_hci_iso_sdu_hdr sdu;
} __packed;
#define BT_HCI_ISO_SDU_TS_HDR_SIZE 8
/* Bluetooth spec v5.4 Vol 4, Part E - 5.4.5 HCI ISO Data Packets */
struct bt_hci_iso_hdr {
uint16_t handle; /* 12 bit handle, 2 bit PB flags, 1 bit TS_Flag, 1 bit RFU */
uint16_t len; /* 14 bits, 2 bits RFU */
} __packed;
#define BT_HCI_ISO_HDR_SIZE 4
/* Bluetooth spec v5.4 Vol 4, Part E - 5.4.1 HCI Command Packet */
struct bt_hci_cmd_hdr {
uint16_t opcode;
uint8_t param_len;
} __packed;
#define BT_HCI_CMD_HDR_SIZE 3
/* Supported Commands */
#define BT_CMD_TEST(cmd, octet, bit) (cmd[octet] & BIT(bit))
#define BT_CMD_LE_STATES(cmd) BT_CMD_TEST(cmd, 28, 3)
#define BT_FEAT_TEST(feat, page, octet, bit) (feat[page][octet] & BIT(bit))
#define BT_FEAT_BREDR(feat) !BT_FEAT_TEST(feat, 0, 4, 5)
#define BT_FEAT_LE(feat) BT_FEAT_TEST(feat, 0, 4, 6)
#define BT_FEAT_EXT_FEATURES(feat) BT_FEAT_TEST(feat, 0, 7, 7)
#define BT_FEAT_HOST_SSP(feat) BT_FEAT_TEST(feat, 1, 0, 0)
#define BT_FEAT_SC(feat) BT_FEAT_TEST(feat, 2, 1, 0)
#define BT_FEAT_LMP_SCO_CAPABLE(feat) BT_FEAT_TEST(feat, 0, 1, 3)
#define BT_FEAT_LMP_ESCO_CAPABLE(feat) BT_FEAT_TEST(feat, 0, 3, 7)
#define BT_FEAT_HV2_PKT(feat) BT_FEAT_TEST(feat, 0, 1, 4)
#define BT_FEAT_HV3_PKT(feat) BT_FEAT_TEST(feat, 0, 1, 5)
#define BT_FEAT_EV4_PKT(feat) BT_FEAT_TEST(feat, 0, 4, 0)
#define BT_FEAT_EV5_PKT(feat) BT_FEAT_TEST(feat, 0, 4, 1)
#define BT_FEAT_2EV3_PKT(feat) BT_FEAT_TEST(feat, 0, 5, 5)
#define BT_FEAT_3EV3_PKT(feat) BT_FEAT_TEST(feat, 0, 5, 6)
#define BT_FEAT_3SLOT_PKT(feat) BT_FEAT_TEST(feat, 0, 5, 7)
/* LE features */
#define BT_LE_FEAT_BIT_ENC 0
#define BT_LE_FEAT_BIT_CONN_PARAM_REQ 1
#define BT_LE_FEAT_BIT_EXT_REJ_IND 2
#define BT_LE_FEAT_BIT_PER_INIT_FEAT_XCHG 3
#define BT_LE_FEAT_BIT_PING 4
#define BT_LE_FEAT_BIT_DLE 5
#define BT_LE_FEAT_BIT_PRIVACY 6
#define BT_LE_FEAT_BIT_EXT_SCAN 7
#define BT_LE_FEAT_BIT_PHY_2M 8
#define BT_LE_FEAT_BIT_SMI_TX 9
#define BT_LE_FEAT_BIT_SMI_RX 10
#define BT_LE_FEAT_BIT_PHY_CODED 11
#define BT_LE_FEAT_BIT_EXT_ADV 12
#define BT_LE_FEAT_BIT_PER_ADV 13
#define BT_LE_FEAT_BIT_CHAN_SEL_ALGO_2 14
#define BT_LE_FEAT_BIT_PWR_CLASS_1 15
#define BT_LE_FEAT_BIT_MIN_USED_CHAN_PROC 16
#define BT_LE_FEAT_BIT_CONN_CTE_REQ 17
#define BT_LE_FEAT_BIT_CONN_CTE_RESP 18
#define BT_LE_FEAT_BIT_CONNECTIONLESS_CTE_TX 19
#define BT_LE_FEAT_BIT_CONNECTIONLESS_CTE_RX 20
#define BT_LE_FEAT_BIT_ANT_SWITCH_TX_AOD 21
#define BT_LE_FEAT_BIT_ANT_SWITCH_RX_AOA 22
#define BT_LE_FEAT_BIT_RX_CTE 23
#define BT_LE_FEAT_BIT_PAST_SEND 24
#define BT_LE_FEAT_BIT_PAST_RECV 25
#define BT_LE_FEAT_BIT_SCA_UPDATE 26
#define BT_LE_FEAT_BIT_REMOTE_PUB_KEY_VALIDATE 27
#define BT_LE_FEAT_BIT_CIS_CENTRAL 28
#define BT_LE_FEAT_BIT_CIS_PERIPHERAL 29
#define BT_LE_FEAT_BIT_ISO_BROADCASTER 30
#define BT_LE_FEAT_BIT_SYNC_RECEIVER 31
#define BT_LE_FEAT_BIT_ISO_CHANNELS 32
#define BT_LE_FEAT_BIT_PWR_CTRL_REQ 33
#define BT_LE_FEAT_BIT_PWR_CHG_IND 34
#define BT_LE_FEAT_BIT_PATH_LOSS_MONITOR 35
#define BT_LE_FEAT_BIT_PER_ADV_ADI_SUPP 36
#define BT_LE_FEAT_BIT_CONN_SUBRATING 37
#define BT_LE_FEAT_BIT_CONN_SUBRATING_HOST_SUPP 38
#define BT_LE_FEAT_BIT_CHANNEL_CLASSIFICATION 39
#define BT_LE_FEAT_BIT_PAWR_ADVERTISER 43
#define BT_LE_FEAT_BIT_PAWR_SCANNER 44
#define BT_LE_FEAT_TEST(feat, n) (feat[(n) >> 3] & \
BIT((n) & 7))
#define BT_FEAT_LE_ENCR(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_ENC)
#define BT_FEAT_LE_CONN_PARAM_REQ_PROC(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_CONN_PARAM_REQ)
#define BT_FEAT_LE_PER_INIT_FEAT_XCHG(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_PER_INIT_FEAT_XCHG)
#define BT_FEAT_LE_DLE(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_DLE)
#define BT_FEAT_LE_PHY_2M(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_PHY_2M)
#define BT_FEAT_LE_PHY_CODED(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_PHY_CODED)
#define BT_FEAT_LE_PRIVACY(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_PRIVACY)
#define BT_FEAT_LE_EXT_ADV(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_EXT_ADV)
#define BT_FEAT_LE_EXT_PER_ADV(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_PER_ADV)
#define BT_FEAT_LE_CONNECTION_CTE_REQ(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_CONN_CTE_REQ)
#define BT_FEAT_LE_CONNECTION_CTE_RESP(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_CONN_CTE_RESP)
#define BT_FEAT_LE_CONNECTIONLESS_CTE_TX(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_CONNECTIONLESS_CTE_TX)
#define BT_FEAT_LE_CONNECTIONLESS_CTE_RX(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_CONNECTIONLESS_CTE_RX)
#define BT_FEAT_LE_ANT_SWITCH_TX_AOD(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_ANT_SWITCH_TX_AOD)
#define BT_FEAT_LE_ANT_SWITCH_RX_AOA(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_ANT_SWITCH_RX_AOA)
#define BT_FEAT_LE_RX_CTE(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_RX_CTE)
#define BT_FEAT_LE_PAST_SEND(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_PAST_SEND)
#define BT_FEAT_LE_PAST_RECV(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_PAST_RECV)
#define BT_FEAT_LE_CIS_CENTRAL(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_CIS_CENTRAL)
#define BT_FEAT_LE_CIS_PERIPHERAL(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_CIS_PERIPHERAL)
#define BT_FEAT_LE_ISO_BROADCASTER(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_ISO_BROADCASTER)
#define BT_FEAT_LE_SYNC_RECEIVER(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_SYNC_RECEIVER)
#define BT_FEAT_LE_ISO_CHANNELS(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_ISO_CHANNELS)
#define BT_FEAT_LE_PWR_CTRL_REQ(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_PWR_CTRL_REQ)
#define BT_FEAT_LE_PWR_CHG_IND(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_PWR_CHG_IND)
#define BT_FEAT_LE_PATH_LOSS_MONITOR(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_PATH_LOSS_MONITOR)
#define BT_FEAT_LE_PER_ADV_ADI_SUPP(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_PER_ADV_ADI_SUPP)
#define BT_FEAT_LE_CONN_SUBRATING(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_CONN_SUBRATING)
#define BT_FEAT_LE_CONN_SUBRATING_HOST_SUPP(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_CONN_SUBRATING_HOST_SUPP)
#define BT_FEAT_LE_CHANNEL_CLASSIFICATION(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_CHANNEL_CLASSIFICATION)
#define BT_FEAT_LE_PAWR_ADVERTISER(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_PAWR_ADVERTISER)
#define BT_FEAT_LE_PAWR_SCANNER(feat) BT_LE_FEAT_TEST(feat, \
BT_LE_FEAT_BIT_PAWR_SCANNER)
#define BT_FEAT_LE_CIS(feat) (BT_FEAT_LE_CIS_CENTRAL(feat) | \
BT_FEAT_LE_CIS_PERIPHERAL(feat))
#define BT_FEAT_LE_BIS(feat) (BT_FEAT_LE_ISO_BROADCASTER(feat) | \
BT_FEAT_LE_SYNC_RECEIVER(feat))
#define BT_FEAT_LE_ISO(feat) (BT_FEAT_LE_CIS(feat) | \
BT_FEAT_LE_BIS(feat))
/* LE States. See Core_v5.4, Vol 4, Part E, Section 7.8.27 */
#define BT_LE_STATES_PER_CONN_ADV(states) (states & BIT64_MASK(38))
#if defined(CONFIG_BT_SCAN_AND_INITIATE_IN_PARALLEL)
/* Both passive and active scanner can be run in parallel with initiator. */
#define BT_LE_STATES_SCAN_INIT(states) ((states) & BIT64_MASK(22) && \
(states) & BIT64_MASK(23))
#else
#define BT_LE_STATES_SCAN_INIT(states) 0
#endif
/* Bonding/authentication types */
#define BT_HCI_NO_BONDING 0x00
#define BT_HCI_NO_BONDING_MITM 0x01
#define BT_HCI_DEDICATED_BONDING 0x02
#define BT_HCI_DEDICATED_BONDING_MITM 0x03
#define BT_HCI_GENERAL_BONDING 0x04
#define BT_HCI_GENERAL_BONDING_MITM 0x05
/*
* MITM protection is enabled in SSP authentication requirements octet when
* LSB bit is set.
*/
#define BT_MITM 0x01
/* I/O capabilities */
#define BT_IO_DISPLAY_ONLY 0x00
#define BT_IO_DISPLAY_YESNO 0x01
#define BT_IO_KEYBOARD_ONLY 0x02
#define BT_IO_NO_INPUT_OUTPUT 0x03
/* SCO packet types */
#define HCI_PKT_TYPE_HV1 0x0020
#define HCI_PKT_TYPE_HV2 0x0040
#define HCI_PKT_TYPE_HV3 0x0080
/* eSCO packet types */
#define HCI_PKT_TYPE_SCO_HV1 0x0001
#define HCI_PKT_TYPE_SCO_HV2 0x0002
#define HCI_PKT_TYPE_SCO_HV3 0x0004
#define HCI_PKT_TYPE_ESCO_EV3 0x0008
#define HCI_PKT_TYPE_ESCO_EV4 0x0010
#define HCI_PKT_TYPE_ESCO_EV5 0x0020
#define HCI_PKT_TYPE_ESCO_2EV3 0x0040
#define HCI_PKT_TYPE_ESCO_3EV3 0x0080
#define HCI_PKT_TYPE_ESCO_2EV5 0x0100
#define HCI_PKT_TYPE_ESCO_3EV5 0x0200
#define ESCO_PKT_MASK (HCI_PKT_TYPE_SCO_HV1 | \
HCI_PKT_TYPE_SCO_HV2 | \
HCI_PKT_TYPE_SCO_HV3 | \
HCI_PKT_TYPE_ESCO_EV3 | \
HCI_PKT_TYPE_ESCO_EV4 | \
HCI_PKT_TYPE_ESCO_EV5)
#define SCO_PKT_MASK (HCI_PKT_TYPE_SCO_HV1 | \
HCI_PKT_TYPE_SCO_HV2 | \
HCI_PKT_TYPE_SCO_HV3)
#define EDR_ESCO_PKT_MASK (HCI_PKT_TYPE_ESCO_2EV3 | \
HCI_PKT_TYPE_ESCO_3EV3 | \
HCI_PKT_TYPE_ESCO_2EV5 | \
HCI_PKT_TYPE_ESCO_3EV5)
/* HCI BR/EDR link types */
#define BT_HCI_SCO 0x00
#define BT_HCI_ACL 0x01
#define BT_HCI_ESCO 0x02
/* OpCode Group Fields */
#define BT_OGF_LINK_CTRL 0x01
#define BT_OGF_BASEBAND 0x03
#define BT_OGF_INFO 0x04
#define BT_OGF_STATUS 0x05
#define BT_OGF_LE 0x08
#define BT_OGF_VS 0x3f
/* Construct OpCode from OGF and OCF */
#define BT_OP(ogf, ocf) ((ocf) | ((ogf) << 10))
/* Invalid opcode */
#define BT_OP_NOP 0x0000
/* Obtain OGF from OpCode */
#define BT_OGF(opcode) (((opcode) >> 10) & BIT_MASK(6))
/* Obtain OCF from OpCode */
#define BT_OCF(opcode) ((opcode) & BIT_MASK(10))
#define BT_HCI_OP_INQUIRY BT_OP(BT_OGF_LINK_CTRL, 0x0001) /* 0x0401 */
struct bt_hci_op_inquiry {
uint8_t lap[3];
uint8_t length;
uint8_t num_rsp;
} __packed;
#define BT_HCI_OP_INQUIRY_CANCEL BT_OP(BT_OGF_LINK_CTRL, 0x0002) /* 0x0402 */
#define BT_HCI_OP_CONNECT BT_OP(BT_OGF_LINK_CTRL, 0x0005) /* 0x0405 */
struct bt_hci_cp_connect {
bt_addr_t bdaddr;
uint16_t packet_type;
uint8_t pscan_rep_mode;
uint8_t reserved;
uint16_t clock_offset;
uint8_t allow_role_switch;
} __packed;
#define BT_HCI_OP_DISCONNECT BT_OP(BT_OGF_LINK_CTRL, 0x0006) /* 0x0406 */
struct bt_hci_cp_disconnect {
uint16_t handle;
uint8_t reason;
} __packed;
#define BT_HCI_OP_CONNECT_CANCEL BT_OP(BT_OGF_LINK_CTRL, 0x0008) /* 0x0408 */
struct bt_hci_cp_connect_cancel {
bt_addr_t bdaddr;
} __packed;
struct bt_hci_rp_connect_cancel {
uint8_t status;
bt_addr_t bdaddr;
} __packed;
#define BT_HCI_OP_ACCEPT_CONN_REQ BT_OP(BT_OGF_LINK_CTRL, 0x0009) /* 0x0409 */
struct bt_hci_cp_accept_conn_req {
bt_addr_t bdaddr;
uint8_t role;
} __packed;
#define BT_HCI_OP_SETUP_SYNC_CONN BT_OP(BT_OGF_LINK_CTRL, 0x0028) /* 0x0428 */
struct bt_hci_cp_setup_sync_conn {
uint16_t handle;
uint32_t tx_bandwidth;
uint32_t rx_bandwidth;
uint16_t max_latency;
uint16_t content_format;
uint8_t retrans_effort;
uint16_t pkt_type;
} __packed;
#define BT_HCI_OP_ACCEPT_SYNC_CONN_REQ BT_OP(BT_OGF_LINK_CTRL, 0x0029) /* 0x0429 */
struct bt_hci_cp_accept_sync_conn_req {
bt_addr_t bdaddr;
uint32_t tx_bandwidth;
uint32_t rx_bandwidth;
uint16_t max_latency;
uint16_t content_format;
uint8_t retrans_effort;
uint16_t pkt_type;
} __packed;
#define BT_HCI_OP_REJECT_CONN_REQ BT_OP(BT_OGF_LINK_CTRL, 0x000a) /* 0x040a */
struct bt_hci_cp_reject_conn_req {
bt_addr_t bdaddr;
uint8_t reason;
} __packed;
#define BT_HCI_OP_LINK_KEY_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x000b) /* 0x040b */
struct bt_hci_cp_link_key_reply {
bt_addr_t bdaddr;
uint8_t link_key[16];
} __packed;
#define BT_HCI_OP_LINK_KEY_NEG_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x000c) /* 0x040c */
struct bt_hci_cp_link_key_neg_reply {
bt_addr_t bdaddr;
} __packed;
#define BT_HCI_OP_PIN_CODE_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x000d) /* 0x040d */
struct bt_hci_cp_pin_code_reply {
bt_addr_t bdaddr;
uint8_t pin_len;
uint8_t pin_code[16];
} __packed;
struct bt_hci_rp_pin_code_reply {
uint8_t status;
bt_addr_t bdaddr;
} __packed;
#define BT_HCI_OP_PIN_CODE_NEG_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x000e) /* 0x040e */
struct bt_hci_cp_pin_code_neg_reply {
bt_addr_t bdaddr;
} __packed;
struct bt_hci_rp_pin_code_neg_reply {
uint8_t status;
bt_addr_t bdaddr;
} __packed;
#define BT_HCI_OP_AUTH_REQUESTED BT_OP(BT_OGF_LINK_CTRL, 0x0011) /* 0x0411 */
struct bt_hci_cp_auth_requested {
uint16_t handle;
} __packed;
#define BT_HCI_OP_SET_CONN_ENCRYPT BT_OP(BT_OGF_LINK_CTRL, 0x0013) /* 0x0413 */
struct bt_hci_cp_set_conn_encrypt {
uint16_t handle;
uint8_t encrypt;
} __packed;
#define BT_HCI_OP_REMOTE_NAME_REQUEST BT_OP(BT_OGF_LINK_CTRL, 0x0019) /* 0x0419 */
struct bt_hci_cp_remote_name_request {
bt_addr_t bdaddr;
uint8_t pscan_rep_mode;
uint8_t reserved;
uint16_t clock_offset;
} __packed;
#define BT_HCI_OP_REMOTE_NAME_CANCEL BT_OP(BT_OGF_LINK_CTRL, 0x001a) /* 0x041a */
struct bt_hci_cp_remote_name_cancel {
bt_addr_t bdaddr;
} __packed;
struct bt_hci_rp_remote_name_cancel {
uint8_t status;
bt_addr_t bdaddr;
} __packed;
#define BT_HCI_OP_READ_REMOTE_FEATURES BT_OP(BT_OGF_LINK_CTRL, 0x001b) /* 0x041b */
struct bt_hci_cp_read_remote_features {
uint16_t handle;
} __packed;
#define BT_HCI_OP_READ_REMOTE_EXT_FEATURES BT_OP(BT_OGF_LINK_CTRL, 0x001c) /* 0x041c */
struct bt_hci_cp_read_remote_ext_features {
uint16_t handle;
uint8_t page;
} __packed;
#define BT_HCI_OP_READ_REMOTE_VERSION_INFO BT_OP(BT_OGF_LINK_CTRL, 0x001d) /* 0x041d */
struct bt_hci_cp_read_remote_version_info {
uint16_t handle;
} __packed;
#define BT_HCI_OP_IO_CAPABILITY_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x002b) /* 0x042b */
struct bt_hci_cp_io_capability_reply {
bt_addr_t bdaddr;
uint8_t capability;
uint8_t oob_data;
uint8_t authentication;
} __packed;
#define BT_HCI_OP_USER_CONFIRM_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x002c) /* 0x042c */
#define BT_HCI_OP_USER_CONFIRM_NEG_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x002d) /* 0x042d */
struct bt_hci_cp_user_confirm_reply {
bt_addr_t bdaddr;
} __packed;
struct bt_hci_rp_user_confirm_reply {
uint8_t status;
bt_addr_t bdaddr;
} __packed;
#define BT_HCI_OP_USER_PASSKEY_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x002e) /* 0x042e */
struct bt_hci_cp_user_passkey_reply {
bt_addr_t bdaddr;
uint32_t passkey;
} __packed;
#define BT_HCI_OP_USER_PASSKEY_NEG_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x002f) /* 0x042f */
struct bt_hci_cp_user_passkey_neg_reply {
bt_addr_t bdaddr;
} __packed;
#define BT_HCI_OP_IO_CAPABILITY_NEG_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x0034) /* 0x0434 */
struct bt_hci_cp_io_capability_neg_reply {
bt_addr_t bdaddr;
uint8_t reason;
} __packed;
#define BT_HCI_OP_SET_EVENT_MASK BT_OP(BT_OGF_BASEBAND, 0x0001) /* 0x0c01 */
struct bt_hci_cp_set_event_mask {
uint8_t events[8];
} __packed;
#define BT_HCI_OP_RESET BT_OP(BT_OGF_BASEBAND, 0x0003) /* 0x0c03 */
#define BT_HCI_OP_WRITE_LOCAL_NAME BT_OP(BT_OGF_BASEBAND, 0x0013) /* 0x0c13 */
struct bt_hci_write_local_name {
uint8_t local_name[248];
} __packed;
#define BT_HCI_OP_READ_CONN_ACCEPT_TIMEOUT BT_OP(BT_OGF_BASEBAND, 0x0015) /* 0x0c15 */
struct bt_hci_rp_read_conn_accept_timeout {
uint8_t status;
uint16_t conn_accept_timeout;
} __packed;
#define BT_HCI_OP_WRITE_CONN_ACCEPT_TIMEOUT BT_OP(BT_OGF_BASEBAND, 0x0016) /* 0x0c16 */
struct bt_hci_cp_write_conn_accept_timeout {
uint16_t conn_accept_timeout;
} __packed;
struct bt_hci_rp_write_conn_accept_timeout {
uint8_t status;
} __packed;
#define BT_HCI_OP_WRITE_PAGE_TIMEOUT BT_OP(BT_OGF_BASEBAND, 0x0018) /* 0x0c18 */
#define BT_HCI_OP_WRITE_SCAN_ENABLE BT_OP(BT_OGF_BASEBAND, 0x001a) /* 0x0c1a */
#define BT_BREDR_SCAN_DISABLED 0x00
#define BT_BREDR_SCAN_INQUIRY 0x01
#define BT_BREDR_SCAN_PAGE 0x02
#define BT_COD(major_service, major_device, minor_device) \
(((uint32_t)major_service << 13) | ((uint32_t)major_device << 8) | \
((uint32_t)minor_device << 2))
#define BT_COD_VALID(cod) ((0 == (cod[0] & (BIT(0) | BIT(1)))) ? true : false)
#define BT_COD_MAJOR_SERVICE_CLASSES(cod) \
((((uint32_t)cod[2] & 0xFF) >> 5) | (((uint32_t)cod[1] & 0xD0) >> 5))
#define BT_COD_MAJOR_DEVICE_CLASS(cod) ((((uint32_t)cod[1]) & 0x1FUL))
#define BT_COD_MINOR_DEVICE_CLASS(cod) (((((uint32_t)cod[0]) & 0xFF) >> 2))
#define BT_COD_MAJOR_MISC 0x00
#define BT_COD_MAJOR_COMPUTER 0x01
#define BT_COD_MAJOR_PHONE 0x02
#define BT_COD_MAJOR_LAN_NETWORK_AP 0x03
#define BT_COD_MAJOR_AUDIO_VIDEO 0x04
#define BT_COD_MAJOR_PERIPHERAL 0x05
#define BT_COD_MAJOR_IMAGING 0x06
#define BT_COD_MAJOR_WEARABLE 0x07
#define BT_COD_MAJOR_TOY 0x08
#define BT_COD_MAJOR_HEALTH 0x09
#define BT_COD_MAJOR_UNCATEGORIZED 0x1F
/* Minor Device Class field - Computer Major Class */
#define BT_COD_MAJOR_COMPUTER_MINOR_UNCATEGORIZED 0x00
#define BT_COD_MAJOR_COMPUTER_MINOR_DESKTOP 0x01
#define BT_COD_MAJOR_COMPUTER_MINOR_SERVER_CLASS_COMPUTER 0x02
#define BT_COD_MAJOR_COMPUTER_MINOR_LAPTOP 0x03
#define BT_COD_MAJOR_COMPUTER_MINOR_HANDHELD_PC_PDA 0x04
#define BT_COD_MAJOR_COMPUTER_MINOR_PALM_SIZE_PC_PDA 0x05
#define BT_COD_MAJOR_COMPUTER_MINOR_WEARABLE_COMPUTER 0x06
#define BT_COD_MAJOR_COMPUTER_MINOR_TABLET 0x07
/* Minor Device Class field - Phone Major Class */
#define BT_COD_MAJOR_PHONE_MINOR_UNCATEGORIZED 0x00
#define BT_COD_MAJOR_PHONE_MINOR_CELLULAR 0x01
#define BT_COD_MAJOR_PHONE_MINOR_CORDLESS 0x02
#define BT_COD_MAJOR_PHONE_MINOR_SMARTPHONE 0x03
#define BT_COD_MAJOR_PHONE_MINOR_WIRED_MODEM_VOICE_GATEWAY 0x04
#define BT_COD_MAJOR_PHONE_MINOR_ISDN 0x05
/* Minor Device Class field - Audio/Video Major Class */
#define BT_COD_MAJOR_AUDIO_VIDEO_MINOR_UNCATEGORIZED 0x00
#define BT_COD_MAJOR_AUDIO_VIDEO_MINOR_WEARABLE_HEADSET 0x01
#define BT_COD_MAJOR_AUDIO_VIDEO_MINOR_HANDS_FREE 0x02
#define BT_COD_MAJOR_AUDIO_VIDEO_MINOR_RFU 0x03
#define BT_COD_MAJOR_AUDIO_VIDEO_MINOR_MICROPHONE 0x04
#define BT_COD_MAJOR_AUDIO_VIDEO_MINOR_LOUDSPEAKER 0x05
#define BT_COD_MAJOR_AUDIO_VIDEO_MINOR_HEADPHONES 0x06
#define BT_COD_MAJOR_AUDIO_VIDEO_MINOR_PORTABLE_AUDIO 0x07
#define BT_COD_MAJOR_AUDIO_VIDEO_MINOR_CAR_AUDIO 0x08
#define BT_COD_MAJOR_AUDIO_VIDEO_MINOR_SET_TOP_BOX 0x09
#define BT_COD_MAJOR_AUDIO_VIDEO_MINOR_HIFI_AUDIO 0x0A
#define BT_COD_MAJOR_AUDIO_VIDEO_MINOR_VCR 0x0B
#define BT_COD_MAJOR_AUDIO_VIDEO_MINOR_VIDEO_CAMERA 0x0C
#define BT_COD_MAJOR_AUDIO_VIDEO_MINOR_CAMCORDER 0x0D
#define BT_COD_MAJOR_AUDIO_VIDEO_MINOR_VIDEO_MONITOR 0x0E
#define BT_COD_MAJOR_AUDIO_VIDEO_MINOR_VIDEO_DISPLAY_LOUDSPEAKER 0x0F
#define BT_COD_MAJOR_AUDIO_VIDEO_MINOR_VIDEO_CONFERENCING 0x10
#define BT_COD_MAJOR_AUDIO_VIDEO_MINOR_RFU2 0x11
#define BT_COD_MAJOR_AUDIO_VIDEO_MINOR_GAME_TOY 0x12
#define BT_HCI_OP_WRITE_CLASS_OF_DEVICE BT_OP(BT_OGF_BASEBAND, 0x0024) /* 0x0c24 */
struct bt_hci_cp_write_class_of_device {
uint8_t class_of_device[3];
} __packed;
#define BT_TX_POWER_LEVEL_CURRENT 0x00
#define BT_TX_POWER_LEVEL_MAX 0x01
#define BT_HCI_OP_READ_TX_POWER_LEVEL BT_OP(BT_OGF_BASEBAND, 0x002d) /* 0x0c2d */
struct bt_hci_cp_read_tx_power_level {
uint16_t handle;
uint8_t type;
} __packed;
struct bt_hci_rp_read_tx_power_level {
uint8_t status;
uint16_t handle;
int8_t tx_power_level;
} __packed;
#define BT_HCI_LE_TX_POWER_PHY_1M 0x01
#define BT_HCI_LE_TX_POWER_PHY_2M 0x02
#define BT_HCI_LE_TX_POWER_PHY_CODED_S8 0x03
#define BT_HCI_LE_TX_POWER_PHY_CODED_S2 0x04
#define BT_HCI_OP_LE_ENH_READ_TX_POWER_LEVEL BT_OP(BT_OGF_LE, 0x0076) /* 0x2076 */
struct bt_hci_cp_le_read_tx_power_level {
uint16_t handle;
uint8_t phy;
} __packed;
struct bt_hci_rp_le_read_tx_power_level {
uint8_t status;
uint16_t handle;
uint8_t phy;
int8_t current_tx_power_level;
int8_t max_tx_power_level;
} __packed;
#define BT_HCI_OP_LE_READ_REMOTE_TX_POWER_LEVEL BT_OP(BT_OGF_LE, 0x0077) /* 0x2077 */
#define BT_HCI_LE_TX_POWER_REPORT_DISABLE 0x00
#define BT_HCI_LE_TX_POWER_REPORT_ENABLE 0x01
#define BT_HCI_OP_LE_SET_TX_POWER_REPORT_ENABLE BT_OP(BT_OGF_LE, 0x007A) /* 0x207A */
struct bt_hci_cp_le_set_tx_power_report_enable {
uint16_t handle;
uint8_t local_enable;
uint8_t remote_enable;
} __packed;
struct bt_hci_cp_le_set_path_loss_reporting_parameters {
uint16_t handle;
uint8_t high_threshold;
uint8_t high_hysteresis;
uint8_t low_threshold;
uint8_t low_hysteresis;
uint16_t min_time_spent;
} __packed;
struct bt_hci_cp_le_set_path_loss_reporting_enable {
uint16_t handle;
uint8_t enable;
} __packed;
#define BT_HCI_OP_LE_SET_PATH_LOSS_REPORTING_PARAMETERS BT_OP(BT_OGF_LE, 0x0078) /* 0x2078 */
#define BT_HCI_LE_PATH_LOSS_REPORTING_DISABLE 0x00
#define BT_HCI_LE_PATH_LOSS_REPORTING_ENABLE 0x01
#define BT_HCI_OP_LE_SET_PATH_LOSS_REPORTING_ENABLE BT_OP(BT_OGF_LE, 0x0079) /* 0x2079 */
struct bt_hci_cp_le_set_default_subrate {
uint16_t subrate_min;
uint16_t subrate_max;
uint16_t max_latency;
uint16_t continuation_number;
uint16_t supervision_timeout;
} __packed;
struct bt_hci_cp_le_subrate_request {
uint16_t handle;
uint16_t subrate_min;
uint16_t subrate_max;
uint16_t max_latency;
uint16_t continuation_number;
uint16_t supervision_timeout;
} __packed;
#define BT_HCI_OP_LE_SET_DEFAULT_SUBRATE BT_OP(BT_OGF_LE, 0x007D) /* 0x207D */
#define BT_HCI_OP_LE_SUBRATE_REQUEST BT_OP(BT_OGF_LE, 0x007E) /* 0x207E */
#define BT_HCI_CTL_TO_HOST_FLOW_DISABLE 0x00
#define BT_HCI_CTL_TO_HOST_FLOW_ENABLE 0x01
#define BT_HCI_OP_SET_CTL_TO_HOST_FLOW BT_OP(BT_OGF_BASEBAND, 0x0031) /* 0x0c31 */
struct bt_hci_cp_set_ctl_to_host_flow {
uint8_t flow_enable;
} __packed;
#define BT_HCI_OP_HOST_BUFFER_SIZE BT_OP(BT_OGF_BASEBAND, 0x0033) /* 0x0c33 */
struct bt_hci_cp_host_buffer_size {
uint16_t acl_mtu;
uint8_t sco_mtu;
uint16_t acl_pkts;
uint16_t sco_pkts;
} __packed;
struct bt_hci_handle_count {
uint16_t handle;
uint16_t count;
} __packed;
#define BT_HCI_OP_HOST_NUM_COMPLETED_PACKETS BT_OP(BT_OGF_BASEBAND, 0x0035) /* 0x0c35 */
struct bt_hci_cp_host_num_completed_packets {
uint8_t num_handles;
struct bt_hci_handle_count h[0];
} __packed;
#define BT_HCI_OP_WRITE_INQUIRY_MODE BT_OP(BT_OGF_BASEBAND, 0x0045) /* 0x0c45 */
struct bt_hci_cp_write_inquiry_mode {
uint8_t mode;
} __packed;
#define BT_HCI_OP_WRITE_SSP_MODE BT_OP(BT_OGF_BASEBAND, 0x0056) /* 0x0c56 */
struct bt_hci_cp_write_ssp_mode {
uint8_t mode;
} __packed;
#define BT_HCI_OP_SET_EVENT_MASK_PAGE_2 BT_OP(BT_OGF_BASEBAND, 0x0063) /* 0x0c63 */
struct bt_hci_cp_set_event_mask_page_2 {
uint8_t events_page_2[8];
} __packed;
#define BT_HCI_OP_LE_WRITE_LE_HOST_SUPP BT_OP(BT_OGF_BASEBAND, 0x006d) /* 0x0c6d */
struct bt_hci_cp_write_le_host_supp {
uint8_t le;
uint8_t simul;
} __packed;
#define BT_HCI_OP_WRITE_SC_HOST_SUPP BT_OP(BT_OGF_BASEBAND, 0x007a) /* 0x0c7a */
struct bt_hci_cp_write_sc_host_supp {
uint8_t sc_support;
} __packed;
#define BT_HCI_OP_READ_AUTH_PAYLOAD_TIMEOUT BT_OP(BT_OGF_BASEBAND, 0x007b) /* 0x0c7b */
struct bt_hci_cp_read_auth_payload_timeout {
uint16_t handle;
} __packed;
struct bt_hci_rp_read_auth_payload_timeout {
uint8_t status;
uint16_t handle;
uint16_t auth_payload_timeout;
} __packed;
#define BT_HCI_OP_WRITE_AUTH_PAYLOAD_TIMEOUT BT_OP(BT_OGF_BASEBAND, 0x007c) /* 0x0c7c */
struct bt_hci_cp_write_auth_payload_timeout {
uint16_t handle;
uint16_t auth_payload_timeout;
} __packed;
struct bt_hci_rp_write_auth_payload_timeout {
uint8_t status;
uint16_t handle;
} __packed;
#define BT_HCI_OP_CONFIGURE_DATA_PATH BT_OP(BT_OGF_BASEBAND, 0x0083) /* 0x0c83 */
struct bt_hci_cp_configure_data_path {
uint8_t data_path_dir;
uint8_t data_path_id;
uint8_t vs_config_len;
uint8_t vs_config[0];
} __packed;
struct bt_hci_rp_configure_data_path {
uint8_t status;
} __packed;
/* HCI version from Assigned Numbers */
#define BT_HCI_VERSION_1_0B 0
#define BT_HCI_VERSION_1_1 1
#define BT_HCI_VERSION_1_2 2
#define BT_HCI_VERSION_2_0 3
#define BT_HCI_VERSION_2_1 4
#define BT_HCI_VERSION_3_0 5
#define BT_HCI_VERSION_4_0 6
#define BT_HCI_VERSION_4_1 7
#define BT_HCI_VERSION_4_2 8
#define BT_HCI_VERSION_5_0 9
#define BT_HCI_VERSION_5_1 10
#define BT_HCI_VERSION_5_2 11
#define BT_HCI_VERSION_5_3 12
#define BT_HCI_VERSION_5_4 13
#define BT_HCI_OP_READ_LOCAL_VERSION_INFO BT_OP(BT_OGF_INFO, 0x0001) /* 0x1001 */
struct bt_hci_rp_read_local_version_info {
uint8_t status;
uint8_t hci_version;
uint16_t hci_revision;
uint8_t lmp_version;
uint16_t manufacturer;
uint16_t lmp_subversion;
} __packed;
#define BT_HCI_OP_READ_SUPPORTED_COMMANDS BT_OP(BT_OGF_INFO, 0x0002) /* 0x1002 */
struct bt_hci_rp_read_supported_commands {
uint8_t status;
uint8_t commands[64];
} __packed;
#define BT_HCI_OP_READ_LOCAL_EXT_FEATURES BT_OP(BT_OGF_INFO, 0x0004) /* 0x1004 */
struct bt_hci_cp_read_local_ext_features {
uint8_t page;
};
struct bt_hci_rp_read_local_ext_features {
uint8_t status;
uint8_t page;
uint8_t max_page;
uint8_t ext_features[8];
} __packed;
#define BT_HCI_OP_READ_LOCAL_FEATURES BT_OP(BT_OGF_INFO, 0x0003) /* 0x1003 */
struct bt_hci_rp_read_local_features {
uint8_t status;
uint8_t features[8];
} __packed;
#define BT_HCI_OP_READ_BUFFER_SIZE BT_OP(BT_OGF_INFO, 0x0005) /* 0x1005 */
struct bt_hci_rp_read_buffer_size {
uint8_t status;
uint16_t acl_max_len;
uint8_t sco_max_len;
uint16_t acl_max_num;
uint16_t sco_max_num;
} __packed;
#define BT_HCI_OP_READ_BD_ADDR BT_OP(BT_OGF_INFO, 0x0009) /* 0x1009 */
struct bt_hci_rp_read_bd_addr {
uint8_t status;
bt_addr_t bdaddr;
} __packed;
/* logic transport type bits as returned when reading supported codecs */
#define BT_HCI_CODEC_TRANSPORT_MASK_BREDR_ACL BIT(0)
#define BT_HCI_CODEC_TRANSPORT_MASK_BREDR_SCO BIT(1)
#define BT_HCI_CODEC_TRANSPORT_MASK_LE_CIS BIT(2)
#define BT_HCI_CODEC_TRANSPORT_MASK_LE_BIS BIT(3)
/* logic transport types for reading codec capabilities and controller delays */
#define BT_HCI_LOGICAL_TRANSPORT_TYPE_BREDR_ACL 0x00
#define BT_HCI_LOGICAL_TRANSPORT_TYPE_BREDR_SCO 0x01
#define BT_HCI_LOGICAL_TRANSPORT_TYPE_LE_CIS 0x02
#define BT_HCI_LOGICAL_TRANSPORT_TYPE_LE_BIS 0x03
/* audio datapath directions */
#define BT_HCI_DATAPATH_DIR_HOST_TO_CTLR 0x00
#define BT_HCI_DATAPATH_DIR_CTLR_TO_HOST 0x01
/* audio datapath IDs */
#define BT_HCI_DATAPATH_ID_HCI 0x00
#define BT_HCI_DATAPATH_ID_VS 0x01
#define BT_HCI_DATAPATH_ID_VS_END 0xfe
/* coding format assigned numbers, used for codec IDs */
#define BT_HCI_CODING_FORMAT_ULAW_LOG 0x00
#define BT_HCI_CODING_FORMAT_ALAW_LOG 0x01
#define BT_HCI_CODING_FORMAT_CVSD 0x02
#define BT_HCI_CODING_FORMAT_TRANSPARENT 0x03
#define BT_HCI_CODING_FORMAT_LINEAR_PCM 0x04
#define BT_HCI_CODING_FORMAT_MSBC 0x05
#define BT_HCI_CODING_FORMAT_LC3 0x06
#define BT_HCI_CODING_FORMAT_G729A 0x07
#define BT_HCI_CODING_FORMAT_VS 0xFF
#define BT_HCI_OP_READ_CODECS BT_OP(BT_OGF_INFO, 0x000b) /* 0x100b */
struct bt_hci_std_codec_info {
uint8_t codec_id;
} __packed;
struct bt_hci_std_codecs {
uint8_t num_codecs;
struct bt_hci_std_codec_info codec_info[0];
} __packed;
struct bt_hci_vs_codec_info {
uint16_t company_id;
uint16_t codec_id;
} __packed;
struct bt_hci_vs_codecs {
uint8_t num_codecs;
struct bt_hci_vs_codec_info codec_info[0];
} __packed;
struct bt_hci_rp_read_codecs {
uint8_t status;
/* other fields filled in dynamically */
uint8_t codecs[0];
} __packed;
#define BT_HCI_OP_READ_CODECS_V2 BT_OP(BT_OGF_INFO, 0x000d) /* 0x100d */
struct bt_hci_std_codec_info_v2 {
uint8_t codec_id;
uint8_t transports; /* bitmap */
} __packed;
struct bt_hci_std_codecs_v2 {
uint8_t num_codecs;
struct bt_hci_std_codec_info_v2 codec_info[0];
} __packed;
struct bt_hci_vs_codec_info_v2 {
uint16_t company_id;
uint16_t codec_id;
uint8_t transports; /* bitmap */
} __packed;
struct bt_hci_vs_codecs_v2 {
uint8_t num_codecs;
struct bt_hci_vs_codec_info_v2 codec_info[0];
} __packed;
struct bt_hci_rp_read_codecs_v2 {
uint8_t status;
/* other fields filled in dynamically */
uint8_t codecs[0];
} __packed;
struct bt_hci_cp_codec_id {
uint8_t coding_format;
uint16_t company_id;
uint16_t vs_codec_id;
} __packed;
#define BT_HCI_OP_READ_CODEC_CAPABILITIES BT_OP(BT_OGF_INFO, 0x000e) /* 0x100e */
struct bt_hci_cp_read_codec_capabilities {
struct bt_hci_cp_codec_id codec_id;
uint8_t transport;
uint8_t direction;
} __packed;
struct bt_hci_codec_capability_info {
uint8_t length;
uint8_t data[0];
} __packed;
struct bt_hci_rp_read_codec_capabilities {
uint8_t status;
uint8_t num_capabilities;
/* other fields filled in dynamically */
uint8_t capabilities[0];
} __packed;
#define BT_HCI_OP_READ_CTLR_DELAY BT_OP(BT_OGF_INFO, 0x000f) /* 0x100f */
struct bt_hci_cp_read_ctlr_delay {
struct bt_hci_cp_codec_id codec_id;
uint8_t transport;
uint8_t direction;
uint8_t codec_config_len;
uint8_t codec_config[0];
} __packed;
struct bt_hci_rp_read_ctlr_delay {
uint8_t status;
uint8_t min_ctlr_delay[3];
uint8_t max_ctlr_delay[3];
} __packed;
#define BT_HCI_OP_READ_RSSI BT_OP(BT_OGF_STATUS, 0x0005) /* 0x1405 */
struct bt_hci_cp_read_rssi {
uint16_t handle;
} __packed;
struct bt_hci_rp_read_rssi {
uint8_t status;
uint16_t handle;
int8_t rssi;
} __packed;
#define BT_HCI_ENCRYPTION_KEY_SIZE_MIN 7
#define BT_HCI_ENCRYPTION_KEY_SIZE_MAX 16
#define BT_HCI_OP_READ_ENCRYPTION_KEY_SIZE BT_OP(BT_OGF_STATUS, 0x0008) /* 0x1408 */
struct bt_hci_cp_read_encryption_key_size {
uint16_t handle;
} __packed;
struct bt_hci_rp_read_encryption_key_size {
uint8_t status;
uint16_t handle;
uint8_t key_size;
} __packed;
/* BLE */
#define BT_HCI_OP_LE_SET_EVENT_MASK BT_OP(BT_OGF_LE, 0x0001) /* 0x2001 */
struct bt_hci_cp_le_set_event_mask {
uint8_t events[8];
} __packed;
#define BT_HCI_OP_LE_READ_BUFFER_SIZE BT_OP(BT_OGF_LE, 0x0002) /* 0x2002 */
struct bt_hci_rp_le_read_buffer_size {
uint8_t status;
uint16_t le_max_len;
uint8_t le_max_num;
} __packed;
#define BT_HCI_OP_LE_READ_LOCAL_FEATURES BT_OP(BT_OGF_LE, 0x0003) /* 0x2003 */
struct bt_hci_rp_le_read_local_features {
uint8_t status;
uint8_t features[8];
} __packed;
#define BT_HCI_OP_LE_SET_RANDOM_ADDRESS BT_OP(BT_OGF_LE, 0x0005) /* 0x2005 */
struct bt_hci_cp_le_set_random_address {
bt_addr_t bdaddr;
} __packed;
#define BT_HCI_ADV_IND 0x00
#define BT_HCI_ADV_DIRECT_IND 0x01
#define BT_HCI_ADV_SCAN_IND 0x02
#define BT_HCI_ADV_NONCONN_IND 0x03
#define BT_HCI_ADV_DIRECT_IND_LOW_DUTY 0x04
#define BT_HCI_ADV_SCAN_RSP 0x04
#define BT_LE_ADV_INTERVAL_MIN 0x0020
#define BT_LE_ADV_INTERVAL_MAX 0x4000
#define BT_LE_ADV_INTERVAL_DEFAULT 0x0800
#define BT_LE_ADV_CHAN_MAP_CHAN_37 0x01
#define BT_LE_ADV_CHAN_MAP_CHAN_38 0x02
#define BT_LE_ADV_CHAN_MAP_CHAN_39 0x04
#define BT_LE_ADV_CHAN_MAP_ALL 0x07
#define BT_LE_ADV_FP_NO_FILTER 0x00
#define BT_LE_ADV_FP_FILTER_SCAN_REQ 0x01
#define BT_LE_ADV_FP_FILTER_CONN_IND 0x02
#define BT_LE_ADV_FP_FILTER_BOTH 0x03
#define BT_HCI_OP_LE_SET_ADV_PARAM BT_OP(BT_OGF_LE, 0x0006) /* 0x2006 */
struct bt_hci_cp_le_set_adv_param {
uint16_t min_interval;
uint16_t max_interval;
uint8_t type;
uint8_t own_addr_type;
bt_addr_le_t direct_addr;
uint8_t channel_map;
uint8_t filter_policy;
} __packed;
#define BT_HCI_OP_LE_READ_ADV_CHAN_TX_POWER BT_OP(BT_OGF_LE, 0x0007) /* 0x2007 */
struct bt_hci_rp_le_read_chan_tx_power {
uint8_t status;
int8_t tx_power_level;
} __packed;
#define BT_HCI_OP_LE_SET_ADV_DATA BT_OP(BT_OGF_LE, 0x0008) /* 0x2008 */
struct bt_hci_cp_le_set_adv_data {
uint8_t len;
uint8_t data[31];
} __packed;
#define BT_HCI_OP_LE_SET_SCAN_RSP_DATA BT_OP(BT_OGF_LE, 0x0009) /* 0x2009 */
struct bt_hci_cp_le_set_scan_rsp_data {
uint8_t len;
uint8_t data[31];
} __packed;
#define BT_HCI_LE_ADV_DISABLE 0x00
#define BT_HCI_LE_ADV_ENABLE 0x01
#define BT_HCI_OP_LE_SET_ADV_ENABLE BT_OP(BT_OGF_LE, 0x000a) /* 0x200a */
struct bt_hci_cp_le_set_adv_enable {
uint8_t enable;
} __packed;
/* Scan types */
#define BT_HCI_OP_LE_SET_SCAN_PARAM BT_OP(BT_OGF_LE, 0x000b) /* 0x200b */
#define BT_HCI_LE_SCAN_PASSIVE 0x00
#define BT_HCI_LE_SCAN_ACTIVE 0x01
#define BT_HCI_LE_SCAN_FP_BASIC_NO_FILTER 0x00
#define BT_HCI_LE_SCAN_FP_BASIC_FILTER 0x01
#define BT_HCI_LE_SCAN_FP_EXT_NO_FILTER 0x02
#define BT_HCI_LE_SCAN_FP_EXT_FILTER 0x03
struct bt_hci_cp_le_set_scan_param {
uint8_t scan_type;
uint16_t interval;
uint16_t window;
uint8_t addr_type;
uint8_t filter_policy;
} __packed;
#define BT_HCI_OP_LE_SET_SCAN_ENABLE BT_OP(BT_OGF_LE, 0x000c) /* 0x200c */
#define BT_HCI_LE_SCAN_DISABLE 0x00
#define BT_HCI_LE_SCAN_ENABLE 0x01
#define BT_HCI_LE_SCAN_FILTER_DUP_DISABLE 0x00
#define BT_HCI_LE_SCAN_FILTER_DUP_ENABLE 0x01
struct bt_hci_cp_le_set_scan_enable {
uint8_t enable;
uint8_t filter_dup;
} __packed;
#define BT_HCI_OP_LE_CREATE_CONN BT_OP(BT_OGF_LE, 0x000d) /* 0x200d */
#define BT_HCI_LE_CREATE_CONN_FP_NO_FILTER 0x00
#define BT_HCI_LE_CREATE_CONN_FP_FILTER 0x01
struct bt_hci_cp_le_create_conn {
uint16_t scan_interval;
uint16_t scan_window;
uint8_t filter_policy;
bt_addr_le_t peer_addr;
uint8_t own_addr_type;
uint16_t conn_interval_min;
uint16_t conn_interval_max;
uint16_t conn_latency;
uint16_t supervision_timeout;
uint16_t min_ce_len;
uint16_t max_ce_len;
} __packed;
#define BT_HCI_OP_LE_CREATE_CONN_CANCEL BT_OP(BT_OGF_LE, 0x000e) /* 0x200e */
#define BT_HCI_OP_LE_READ_FAL_SIZE BT_OP(BT_OGF_LE, 0x000f) /* 0x200f */
struct bt_hci_rp_le_read_fal_size {
uint8_t status;
uint8_t fal_size;
} __packed;
#define BT_HCI_OP_LE_CLEAR_FAL BT_OP(BT_OGF_LE, 0x0010) /* 0x2010 */
#define BT_HCI_OP_LE_ADD_DEV_TO_FAL BT_OP(BT_OGF_LE, 0x0011) /* 0x2011 */
struct bt_hci_cp_le_add_dev_to_fal {
bt_addr_le_t addr;
} __packed;
#define BT_HCI_OP_LE_REM_DEV_FROM_FAL BT_OP(BT_OGF_LE, 0x0012) /* 0x2012 */
struct bt_hci_cp_le_rem_dev_from_fal {
bt_addr_le_t addr;
} __packed;
#define BT_HCI_OP_LE_CONN_UPDATE BT_OP(BT_OGF_LE, 0x0013) /* 0x2013 */
struct hci_cp_le_conn_update {
uint16_t handle;
uint16_t conn_interval_min;
uint16_t conn_interval_max;
uint16_t conn_latency;
uint16_t supervision_timeout;
uint16_t min_ce_len;
uint16_t max_ce_len;
} __packed;
#define BT_HCI_OP_LE_SET_HOST_CHAN_CLASSIF BT_OP(BT_OGF_LE, 0x0014) /* 0x2014 */
struct bt_hci_cp_le_set_host_chan_classif {
uint8_t ch_map[5];
} __packed;
#define BT_HCI_OP_LE_READ_CHAN_MAP BT_OP(BT_OGF_LE, 0x0015) /* 0x2015 */
struct bt_hci_cp_le_read_chan_map {
uint16_t handle;
} __packed;
struct bt_hci_rp_le_read_chan_map {
uint8_t status;
uint16_t handle;
uint8_t ch_map[5];
} __packed;
#define BT_HCI_OP_LE_READ_REMOTE_FEATURES BT_OP(BT_OGF_LE, 0x0016) /* 0x2016 */
struct bt_hci_cp_le_read_remote_features {
uint16_t handle;
} __packed;
#define BT_HCI_OP_LE_ENCRYPT BT_OP(BT_OGF_LE, 0x0017) /* 0x2017 */
struct bt_hci_cp_le_encrypt {
uint8_t key[16];
uint8_t plaintext[16];
} __packed;
struct bt_hci_rp_le_encrypt {
uint8_t status;
uint8_t enc_data[16];
} __packed;
#define BT_HCI_OP_LE_RAND BT_OP(BT_OGF_LE, 0x0018) /* 0x2018 */
struct bt_hci_rp_le_rand {
uint8_t status;
uint8_t rand[8];
} __packed;
#define BT_HCI_OP_LE_START_ENCRYPTION BT_OP(BT_OGF_LE, 0x0019) /* 0x2019 */
struct bt_hci_cp_le_start_encryption {
uint16_t handle;
uint64_t rand;
uint16_t ediv;
uint8_t ltk[16];
} __packed;
#define BT_HCI_OP_LE_LTK_REQ_REPLY BT_OP(BT_OGF_LE, 0x001a) /* 0x201a */
struct bt_hci_cp_le_ltk_req_reply {
uint16_t handle;
uint8_t ltk[16];
} __packed;
struct bt_hci_rp_le_ltk_req_reply {
uint8_t status;
uint16_t handle;
} __packed;
#define BT_HCI_OP_LE_LTK_REQ_NEG_REPLY BT_OP(BT_OGF_LE, 0x001b) /* 0x201b */
struct bt_hci_cp_le_ltk_req_neg_reply {
uint16_t handle;
} __packed;
struct bt_hci_rp_le_ltk_req_neg_reply {
uint8_t status;
uint16_t handle;
} __packed;
#define BT_HCI_OP_LE_READ_SUPP_STATES BT_OP(BT_OGF_LE, 0x001c) /* 0x201c */
struct bt_hci_rp_le_read_supp_states {
uint8_t status;
uint8_t le_states[8];
} __packed;
#define BT_HCI_OP_LE_RX_TEST BT_OP(BT_OGF_LE, 0x001d) /* 0x201d */
struct bt_hci_cp_le_rx_test {
uint8_t rx_ch;
} __packed;
#define BT_HCI_TEST_PKT_PAYLOAD_PRBS9 0x00
#define BT_HCI_TEST_PKT_PAYLOAD_11110000 0x01
#define BT_HCI_TEST_PKT_PAYLOAD_10101010 0x02
#define BT_HCI_TEST_PKT_PAYLOAD_PRBS15 0x03
#define BT_HCI_TEST_PKT_PAYLOAD_11111111 0x04
#define BT_HCI_TEST_PKT_PAYLOAD_00000000 0x05
#define BT_HCI_TEST_PKT_PAYLOAD_00001111 0x06
#define BT_HCI_TEST_PKT_PAYLOAD_01010101 0x07
#define BT_HCI_OP_LE_TX_TEST BT_OP(BT_OGF_LE, 0x001e) /* 0x201e */
struct bt_hci_cp_le_tx_test {
uint8_t tx_ch;
uint8_t test_data_len;
uint8_t pkt_payload;
} __packed;
#define BT_HCI_OP_LE_TEST_END BT_OP(BT_OGF_LE, 0x001f) /* 0x201f */
struct bt_hci_rp_le_test_end {
uint8_t status;
uint16_t rx_pkt_count;
} __packed;
#define BT_HCI_OP_LE_CONN_PARAM_REQ_REPLY BT_OP(BT_OGF_LE, 0x0020) /* 0x2020 */
struct bt_hci_cp_le_conn_param_req_reply {
uint16_t handle;
uint16_t interval_min;
uint16_t interval_max;
uint16_t latency;
uint16_t timeout;
uint16_t min_ce_len;
uint16_t max_ce_len;
} __packed;
struct bt_hci_rp_le_conn_param_req_reply {
uint8_t status;
uint16_t handle;
} __packed;
#define BT_HCI_OP_LE_CONN_PARAM_REQ_NEG_REPLY BT_OP(BT_OGF_LE, 0x0021) /* 0x2021 */
struct bt_hci_cp_le_conn_param_req_neg_reply {
uint16_t handle;
uint8_t reason;
} __packed;
struct bt_hci_rp_le_conn_param_req_neg_reply {
uint8_t status;
uint16_t handle;
} __packed;
#define BT_HCI_OP_LE_SET_DATA_LEN BT_OP(BT_OGF_LE, 0x0022) /* 0x2022 */
struct bt_hci_cp_le_set_data_len {
uint16_t handle;
uint16_t tx_octets;
uint16_t tx_time;
} __packed;
struct bt_hci_rp_le_set_data_len {
uint8_t status;
uint16_t handle;
} __packed;
#define BT_HCI_OP_LE_READ_DEFAULT_DATA_LEN BT_OP(BT_OGF_LE, 0x0023) /* 0x2023 */
struct bt_hci_rp_le_read_default_data_len {
uint8_t status;
uint16_t max_tx_octets;
uint16_t max_tx_time;
} __packed;
#define BT_HCI_OP_LE_WRITE_DEFAULT_DATA_LEN BT_OP(BT_OGF_LE, 0x0024) /* 0x2024 */
struct bt_hci_cp_le_write_default_data_len {
uint16_t max_tx_octets;
uint16_t max_tx_time;
} __packed;
#define BT_HCI_OP_LE_P256_PUBLIC_KEY BT_OP(BT_OGF_LE, 0x0025) /* 0x2025 */
#define BT_HCI_OP_LE_GENERATE_DHKEY BT_OP(BT_OGF_LE, 0x0026) /* 0x2026 */
struct bt_hci_cp_le_generate_dhkey {
uint8_t key[64];
} __packed;
#define BT_HCI_OP_LE_GENERATE_DHKEY_V2 BT_OP(BT_OGF_LE, 0x005e) /* 0x205e */
#define BT_HCI_LE_KEY_TYPE_GENERATED 0x00
#define BT_HCI_LE_KEY_TYPE_DEBUG 0x01
struct bt_hci_cp_le_generate_dhkey_v2 {
uint8_t key[64];
uint8_t key_type;
} __packed;
#define BT_HCI_OP_LE_ADD_DEV_TO_RL BT_OP(BT_OGF_LE, 0x0027) /* 0x2027 */
struct bt_hci_cp_le_add_dev_to_rl {
bt_addr_le_t peer_id_addr;
uint8_t peer_irk[16];
uint8_t local_irk[16];
} __packed;
#define BT_HCI_OP_LE_REM_DEV_FROM_RL BT_OP(BT_OGF_LE, 0x0028) /* 0x2028 */
struct bt_hci_cp_le_rem_dev_from_rl {
bt_addr_le_t peer_id_addr;
} __packed;
#define BT_HCI_OP_LE_CLEAR_RL BT_OP(BT_OGF_LE, 0x0029) /* 0x2029 */
#define BT_HCI_OP_LE_READ_RL_SIZE BT_OP(BT_OGF_LE, 0x002a) /* 0x202a */
struct bt_hci_rp_le_read_rl_size {
uint8_t status;
uint8_t rl_size;
} __packed;
#define BT_HCI_OP_LE_READ_PEER_RPA BT_OP(BT_OGF_LE, 0x002b) /* 0x202b */
struct bt_hci_cp_le_read_peer_rpa {
bt_addr_le_t peer_id_addr;
} __packed;
struct bt_hci_rp_le_read_peer_rpa {
uint8_t status;
bt_addr_t peer_rpa;
} __packed;
#define BT_HCI_OP_LE_READ_LOCAL_RPA BT_OP(BT_OGF_LE, 0x002c) /* 0x202c */
struct bt_hci_cp_le_read_local_rpa {
bt_addr_le_t peer_id_addr;
} __packed;
struct bt_hci_rp_le_read_local_rpa {
uint8_t status;
bt_addr_t local_rpa;
} __packed;
#define BT_HCI_ADDR_RES_DISABLE 0x00
#define BT_HCI_ADDR_RES_ENABLE 0x01
#define BT_HCI_OP_LE_SET_ADDR_RES_ENABLE BT_OP(BT_OGF_LE, 0x002d) /* 0x202d */
struct bt_hci_cp_le_set_addr_res_enable {
uint8_t enable;
} __packed;
#define BT_HCI_OP_LE_SET_RPA_TIMEOUT BT_OP(BT_OGF_LE, 0x002e) /* 0x202e */
struct bt_hci_cp_le_set_rpa_timeout {
uint16_t rpa_timeout;
} __packed;
/* All limits according to BT Core spec 5.4 [Vol 4, Part E, 7.8.46] */
#define BT_HCI_LE_MAX_TX_OCTETS_MIN 0x001B
#define BT_HCI_LE_MAX_TX_OCTETS_MAX 0x00FB
#define BT_HCI_LE_MAX_RX_OCTETS_MIN 0x001B
#define BT_HCI_LE_MAX_RX_OCTETS_MAX 0x00FB
#define BT_HCI_LE_MAX_TX_TIME_MIN 0x0148
#define BT_HCI_LE_MAX_TX_TIME_MAX 0x4290
#define BT_HCI_LE_MAX_RX_TIME_MIN 0x0148
#define BT_HCI_LE_MAX_RX_TIME_MAX 0x4290
#define BT_HCI_OP_LE_READ_MAX_DATA_LEN BT_OP(BT_OGF_LE, 0x002f) /* 0x202f */
struct bt_hci_rp_le_read_max_data_len {
uint8_t status;
uint16_t max_tx_octets;
uint16_t max_tx_time;
uint16_t max_rx_octets;
uint16_t max_rx_time;
} __packed;
#define BT_HCI_LE_PHY_1M 0x01
#define BT_HCI_LE_PHY_2M 0x02
#define BT_HCI_LE_PHY_CODED 0x03
#define BT_HCI_OP_LE_READ_PHY BT_OP(BT_OGF_LE, 0x0030) /* 0x2030 */
struct bt_hci_cp_le_read_phy {
uint16_t handle;
} __packed;
struct bt_hci_rp_le_read_phy {
uint8_t status;
uint16_t handle;
uint8_t tx_phy;
uint8_t rx_phy;
} __packed;
#define BT_HCI_LE_PHY_TX_ANY BIT(0)
#define BT_HCI_LE_PHY_RX_ANY BIT(1)
#define BT_HCI_LE_PHY_PREFER_1M BIT(0)
#define BT_HCI_LE_PHY_PREFER_2M BIT(1)
#define BT_HCI_LE_PHY_PREFER_CODED BIT(2)
#define BT_HCI_OP_LE_SET_DEFAULT_PHY BT_OP(BT_OGF_LE, 0x0031) /* 0x2031 */
struct bt_hci_cp_le_set_default_phy {
uint8_t all_phys;
uint8_t tx_phys;
uint8_t rx_phys;
} __packed;
#define BT_HCI_LE_PHY_CODED_ANY 0x00
#define BT_HCI_LE_PHY_CODED_S2 0x01
#define BT_HCI_LE_PHY_CODED_S8 0x02
#define BT_HCI_OP_LE_SET_PHY BT_OP(BT_OGF_LE, 0x0032) /* 0x2032 */
struct bt_hci_cp_le_set_phy {
uint16_t handle;
uint8_t all_phys;
uint8_t tx_phys;
uint8_t rx_phys;
uint16_t phy_opts;
} __packed;
#define BT_HCI_LE_MOD_INDEX_STANDARD 0x00
#define BT_HCI_LE_MOD_INDEX_STABLE 0x01
#define BT_HCI_LE_RX_PHY_1M 0x01
#define BT_HCI_LE_RX_PHY_2M 0x02
#define BT_HCI_LE_RX_PHY_CODED 0x03
#define BT_HCI_OP_LE_ENH_RX_TEST BT_OP(BT_OGF_LE, 0x0033) /* 0x2033 */
struct bt_hci_cp_le_enh_rx_test {
uint8_t rx_ch;
uint8_t phy;
uint8_t mod_index;
} __packed;
#define BT_HCI_LE_TX_PHY_1M 0x01
#define BT_HCI_LE_TX_PHY_2M 0x02
#define BT_HCI_LE_TX_PHY_CODED_S8 0x03
#define BT_HCI_LE_TX_PHY_CODED_S2 0x04
#define BT_HCI_OP_LE_ENH_TX_TEST BT_OP(BT_OGF_LE, 0x0034) /* 0x2034 */
struct bt_hci_cp_le_enh_tx_test {
uint8_t tx_ch;
uint8_t test_data_len;
uint8_t pkt_payload;
uint8_t phy;
} __packed;
#define BT_HCI_OP_LE_SET_ADV_SET_RANDOM_ADDR BT_OP(BT_OGF_LE, 0x0035) /* 0x2035 */
struct bt_hci_cp_le_set_adv_set_random_addr {
uint8_t handle;
bt_addr_t bdaddr;
} __packed;
#define BT_HCI_LE_ADV_PROP_CONN BIT(0)
#define BT_HCI_LE_ADV_PROP_SCAN BIT(1)
#define BT_HCI_LE_ADV_PROP_DIRECT BIT(2)
#define BT_HCI_LE_ADV_PROP_HI_DC_CONN BIT(3)
#define BT_HCI_LE_ADV_PROP_LEGACY BIT(4)
#define BT_HCI_LE_ADV_PROP_ANON BIT(5)
#define BT_HCI_LE_ADV_PROP_TX_POWER BIT(6)
#define BT_HCI_LE_PRIM_ADV_INTERVAL_MIN 0x000020
#define BT_HCI_LE_PRIM_ADV_INTERVAL_MAX 0xFFFFFF
#define BT_HCI_LE_ADV_SCAN_REQ_ENABLE 1
#define BT_HCI_LE_ADV_SCAN_REQ_DISABLE 0
#define BT_HCI_LE_ADV_TX_POWER_NO_PREF 0x7F
#define BT_HCI_LE_ADV_HANDLE_MAX 0xEF
#define BT_HCI_LE_EXT_ADV_SID_INVALID 0xFF
#define BT_HCI_OP_LE_SET_EXT_ADV_PARAM BT_OP(BT_OGF_LE, 0x0036) /* 0x2036 */
struct bt_hci_cp_le_set_ext_adv_param {
uint8_t handle;
uint16_t props;
uint8_t prim_min_interval[3];
uint8_t prim_max_interval[3];
uint8_t prim_channel_map;
uint8_t own_addr_type;
bt_addr_le_t peer_addr;
uint8_t filter_policy;
int8_t tx_power;
uint8_t prim_adv_phy;
uint8_t sec_adv_max_skip;
uint8_t sec_adv_phy;
uint8_t sid;
uint8_t scan_req_notify_enable;
} __packed;
struct bt_hci_rp_le_set_ext_adv_param {
uint8_t status;
int8_t tx_power;
} __packed;
#define BT_HCI_LE_EXT_ADV_OP_INTERM_FRAG 0x00
#define BT_HCI_LE_EXT_ADV_OP_FIRST_FRAG 0x01
#define BT_HCI_LE_EXT_ADV_OP_LAST_FRAG 0x02
#define BT_HCI_LE_EXT_ADV_OP_COMPLETE_DATA 0x03
#define BT_HCI_LE_EXT_ADV_OP_UNCHANGED_DATA 0x04
#define BT_HCI_LE_EXT_ADV_FRAG_ENABLED 0x00
#define BT_HCI_LE_EXT_ADV_FRAG_DISABLED 0x01
#define BT_HCI_LE_EXT_ADV_FRAG_MAX_LEN 251
#define BT_HCI_OP_LE_SET_EXT_ADV_DATA BT_OP(BT_OGF_LE, 0x0037) /* 0x2037 */
struct bt_hci_cp_le_set_ext_adv_data {
uint8_t handle;
uint8_t op;
uint8_t frag_pref;
uint8_t len;
uint8_t data[0];
} __packed;
#define BT_HCI_OP_LE_SET_EXT_SCAN_RSP_DATA BT_OP(BT_OGF_LE, 0x0038) /* 0x2038 */
struct bt_hci_cp_le_set_ext_scan_rsp_data {
uint8_t handle;
uint8_t op;
uint8_t frag_pref;
uint8_t len;
uint8_t data[0];
} __packed;
#define BT_HCI_OP_LE_SET_EXT_ADV_ENABLE BT_OP(BT_OGF_LE, 0x0039) /* 0x2039 */
struct bt_hci_ext_adv_set {
uint8_t handle;
uint16_t duration;
uint8_t max_ext_adv_evts;
} __packed;
struct bt_hci_cp_le_set_ext_adv_enable {
uint8_t enable;
uint8_t set_num;
struct bt_hci_ext_adv_set s[0];
} __packed;
#define BT_HCI_OP_LE_READ_MAX_ADV_DATA_LEN BT_OP(BT_OGF_LE, 0x003a) /* 0x203a */
struct bt_hci_rp_le_read_max_adv_data_len {
uint8_t status;
uint16_t max_adv_data_len;
} __packed;
#define BT_HCI_OP_LE_READ_NUM_ADV_SETS BT_OP(BT_OGF_LE, 0x003b) /* 0x203b */
struct bt_hci_rp_le_read_num_adv_sets {
uint8_t status;
uint8_t num_sets;
} __packed;
#define BT_HCI_OP_LE_REMOVE_ADV_SET BT_OP(BT_OGF_LE, 0x003c) /* 0x203c */
struct bt_hci_cp_le_remove_adv_set {
uint8_t handle;
} __packed;
#define BT_HCI_OP_CLEAR_ADV_SETS BT_OP(BT_OGF_LE, 0x003d) /* 0x203d */
#define BT_HCI_LE_PER_ADV_INTERVAL_MIN 0x0006
#define BT_HCI_LE_PER_ADV_INTERVAL_MAX 0xFFFF
#define BT_HCI_OP_LE_SET_PER_ADV_PARAM BT_OP(BT_OGF_LE, 0x003e) /* 0x203e */
struct bt_hci_cp_le_set_per_adv_param {
uint8_t handle;
uint16_t min_interval;
uint16_t max_interval;
uint16_t props;
} __packed;
#define BT_HCI_LE_PER_ADV_OP_INTERM_FRAG 0x00
#define BT_HCI_LE_PER_ADV_OP_FIRST_FRAG 0x01
#define BT_HCI_LE_PER_ADV_OP_LAST_FRAG 0x02
#define BT_HCI_LE_PER_ADV_OP_COMPLETE_DATA 0x03
#define BT_HCI_LE_PER_ADV_FRAG_MAX_LEN 252
#define BT_HCI_OP_LE_SET_PER_ADV_DATA BT_OP(BT_OGF_LE, 0x003f) /* 0x203f */
struct bt_hci_cp_le_set_per_adv_data {
uint8_t handle;
uint8_t op;
uint8_t len;
uint8_t data[0];
} __packed;
#define BT_HCI_LE_SET_PER_ADV_ENABLE_ENABLE BIT(0)
#define BT_HCI_LE_SET_PER_ADV_ENABLE_ADI BIT(1)
#define BT_HCI_OP_LE_SET_PER_ADV_ENABLE BT_OP(BT_OGF_LE, 0x0040) /* 0x2040 */
struct bt_hci_cp_le_set_per_adv_enable {
uint8_t enable;
uint8_t handle;
} __packed;
#define BT_HCI_OP_LE_SET_EXT_SCAN_PARAM BT_OP(BT_OGF_LE, 0x0041) /* 0x2041 */
struct bt_hci_ext_scan_phy {
uint8_t type;
uint16_t interval;
uint16_t window;
} __packed;
#define BT_HCI_LE_EXT_SCAN_PHY_1M BIT(0)
#define BT_HCI_LE_EXT_SCAN_PHY_2M BIT(1)
#define BT_HCI_LE_EXT_SCAN_PHY_CODED BIT(2)
struct bt_hci_cp_le_set_ext_scan_param {
uint8_t own_addr_type;
uint8_t filter_policy;
uint8_t phys;
struct bt_hci_ext_scan_phy p[0];
} __packed;
/* Extends BT_HCI_LE_SCAN_FILTER_DUP */
#define BT_HCI_LE_EXT_SCAN_FILTER_DUP_ENABLE_RESET 0x02
#define BT_HCI_OP_LE_SET_EXT_SCAN_ENABLE BT_OP(BT_OGF_LE, 0x0042) /* 0x2042 */
struct bt_hci_cp_le_set_ext_scan_enable {
uint8_t enable;
uint8_t filter_dup;
uint16_t duration;
uint16_t period;
} __packed;
#define BT_HCI_OP_LE_EXT_CREATE_CONN BT_OP(BT_OGF_LE, 0x0043) /* 0x2043 */
#define BT_HCI_OP_LE_EXT_CREATE_CONN_V2 BT_OP(BT_OGF_LE, 0x0085) /* 0x2085 */
struct bt_hci_ext_conn_phy {
uint16_t scan_interval;
uint16_t scan_window;
uint16_t conn_interval_min;
uint16_t conn_interval_max;
uint16_t conn_latency;
uint16_t supervision_timeout;
uint16_t min_ce_len;
uint16_t max_ce_len;
} __packed;
struct bt_hci_cp_le_ext_create_conn {
uint8_t filter_policy;
uint8_t own_addr_type;
bt_addr_le_t peer_addr;
uint8_t phys;
struct bt_hci_ext_conn_phy p[0];
} __packed;
struct bt_hci_cp_le_ext_create_conn_v2 {
uint8_t adv_handle;
uint8_t subevent;
uint8_t filter_policy;
uint8_t own_addr_type;
bt_addr_le_t peer_addr;
uint8_t phys;
struct bt_hci_ext_conn_phy p[0];
} __packed;
#define BT_HCI_OP_LE_SET_PER_ADV_SUBEVENT_DATA BT_OP(BT_OGF_LE, 0x0082) /* 0x2082 */
struct bt_hci_cp_le_set_pawr_subevent_data_element {
uint8_t subevent;
uint8_t response_slot_start;
uint8_t response_slot_count;
uint8_t subevent_data_length;
uint8_t subevent_data[0];
} __packed;
struct bt_hci_cp_le_set_pawr_subevent_data {
uint8_t adv_handle;
uint8_t num_subevents;
struct bt_hci_cp_le_set_pawr_subevent_data_element subevents[0];
} __packed;
#define BT_HCI_OP_LE_SET_PER_ADV_RESPONSE_DATA BT_OP(BT_OGF_LE, 0x0083) /* 0x2083 */
struct bt_hci_cp_le_set_pawr_response_data {
uint16_t sync_handle;
uint16_t request_event;
uint8_t request_subevent;
uint8_t response_subevent;
uint8_t response_slot;
uint8_t response_data_length;
uint8_t response_data[0];
} __packed;
#define BT_HCI_OP_LE_SET_PER_ADV_SYNC_SUBEVENT BT_OP(BT_OGF_LE, 0x0084) /* 0x2084 */
struct bt_hci_cp_le_set_pawr_sync_subevent {
uint16_t sync_handle;
uint16_t periodic_adv_properties;
uint8_t num_subevents;
uint8_t subevents[0];
} __packed;
#define BT_HCI_OP_LE_SET_PER_ADV_PARAM_V2 BT_OP(BT_OGF_LE, 0x0086) /* 0x2086 */
struct bt_hci_cp_le_set_per_adv_param_v2 {
uint8_t handle;
uint16_t min_interval;
uint16_t max_interval;
uint16_t props;
uint8_t num_subevents;
uint8_t subevent_interval;
uint8_t response_slot_delay;
uint8_t response_slot_spacing;
uint8_t num_response_slots;
} __packed;
#define BT_HCI_LE_PER_ADV_CREATE_SYNC_FP_USE_LIST BIT(0)
#define BT_HCI_LE_PER_ADV_CREATE_SYNC_FP_REPORTS_DISABLED BIT(1)
#define BT_HCI_LE_PER_ADV_CREATE_SYNC_FP_FILTER_DUPLICATE BIT(2)
#define BT_HCI_LE_PER_ADV_CREATE_SYNC_CTE_TYPE_NO_FILTERING 0
#define BT_HCI_LE_PER_ADV_CREATE_SYNC_CTE_TYPE_NO_AOA BIT(0)
#define BT_HCI_LE_PER_ADV_CREATE_SYNC_CTE_TYPE_NO_AOD_1US BIT(1)
#define BT_HCI_LE_PER_ADV_CREATE_SYNC_CTE_TYPE_NO_AOD_2US BIT(2)
#define BT_HCI_LE_PER_ADV_CREATE_SYNC_CTE_TYPE_NO_CTE BIT(3)
#define BT_HCI_LE_PER_ADV_CREATE_SYNC_CTE_TYPE_ONLY_CTE BIT(4)
/* Constants to check correctness of CTE type */
#define BT_HCI_LE_PER_ADV_CREATE_SYNC_CTE_TYPE_ALLOWED_BITS 5
#define BT_HCI_LE_PER_ADV_CREATE_SYNC_CTE_TYPE_INVALID_VALUE \
(~BIT_MASK(BT_HCI_LE_PER_ADV_CREATE_SYNC_CTE_TYPE_ALLOWED_BITS))
#define BT_HCI_OP_LE_PER_ADV_CREATE_SYNC BT_OP(BT_OGF_LE, 0x0044) /* 0x2044 */
struct bt_hci_cp_le_per_adv_create_sync {
uint8_t options;
uint8_t sid;
bt_addr_le_t addr;
uint16_t skip;
uint16_t sync_timeout;
uint8_t cte_type;
} __packed;
#define BT_HCI_OP_LE_PER_ADV_CREATE_SYNC_CANCEL BT_OP(BT_OGF_LE, 0x0045) /* 0x2045 */
#define BT_HCI_OP_LE_PER_ADV_TERMINATE_SYNC BT_OP(BT_OGF_LE, 0x0046) /* 0x2046 */
struct bt_hci_cp_le_per_adv_terminate_sync {
uint16_t handle;
} __packed;
#define BT_HCI_OP_LE_ADD_DEV_TO_PER_ADV_LIST BT_OP(BT_OGF_LE, 0x0047) /* 0x2047 */
struct bt_hci_cp_le_add_dev_to_per_adv_list {
bt_addr_le_t addr;
uint8_t sid;
} __packed;
#define BT_HCI_OP_LE_REM_DEV_FROM_PER_ADV_LIST BT_OP(BT_OGF_LE, 0x0048) /* 0x2048 */
struct bt_hci_cp_le_rem_dev_from_per_adv_list {
bt_addr_le_t addr;
uint8_t sid;
} __packed;
#define BT_HCI_OP_LE_CLEAR_PER_ADV_LIST BT_OP(BT_OGF_LE, 0x0049) /* 0x2049 */
#define BT_HCI_OP_LE_READ_PER_ADV_LIST_SIZE BT_OP(BT_OGF_LE, 0x004a) /* 0x204a */
struct bt_hci_rp_le_read_per_adv_list_size {
uint8_t status;
uint8_t list_size;
} __packed;
#define BT_HCI_OP_LE_READ_TX_POWER BT_OP(BT_OGF_LE, 0x004b) /* 0x204b */
struct bt_hci_rp_le_read_tx_power {
uint8_t status;
int8_t min_tx_power;
int8_t max_tx_power;
} __packed;
#define BT_HCI_OP_LE_READ_RF_PATH_COMP BT_OP(BT_OGF_LE, 0x004c) /* 0x204c */
struct bt_hci_rp_le_read_rf_path_comp {
uint8_t status;
int16_t tx_path_comp;
int16_t rx_path_comp;
} __packed;
#define BT_HCI_OP_LE_WRITE_RF_PATH_COMP BT_OP(BT_OGF_LE, 0x004d) /* 0x204d */
struct bt_hci_cp_le_write_rf_path_comp {
int16_t tx_path_comp;
int16_t rx_path_comp;
} __packed;
#define BT_HCI_LE_PRIVACY_MODE_NETWORK 0x00
#define BT_HCI_LE_PRIVACY_MODE_DEVICE 0x01
#define BT_HCI_OP_LE_SET_PRIVACY_MODE BT_OP(BT_OGF_LE, 0x004e) /* 0x204e */
struct bt_hci_cp_le_set_privacy_mode {
bt_addr_le_t id_addr;
uint8_t mode;
} __packed;
#define BT_HCI_LE_TEST_CTE_DISABLED 0x00
#define BT_HCI_LE_TEST_CTE_TYPE_ANY 0x00
#define BT_HCI_LE_TEST_SLOT_DURATION_ANY 0x00
#define BT_HCI_LE_TEST_SWITCH_PATTERN_LEN_ANY 0x00
#define BT_HCI_OP_LE_RX_TEST_V3 BT_OP(BT_OGF_LE, 0x004f) /* 0x204f */
struct bt_hci_cp_le_rx_test_v3 {
uint8_t rx_ch;
uint8_t phy;
uint8_t mod_index;
uint8_t expected_cte_len;
uint8_t expected_cte_type;
uint8_t slot_durations;
uint8_t switch_pattern_len;
uint8_t ant_ids[0];
} __packed;
#define BT_HCI_OP_LE_TX_TEST_V3 BT_OP(BT_OGF_LE, 0x0050) /* 0x2050 */
struct bt_hci_cp_le_tx_test_v3 {
uint8_t tx_ch;
uint8_t test_data_len;
uint8_t pkt_payload;
uint8_t phy;
uint8_t cte_len;
uint8_t cte_type;
uint8_t switch_pattern_len;
uint8_t ant_ids[0];
} __packed;
/* Min and max Constant Tone Extension length in 8us units */
#define BT_HCI_LE_CTE_LEN_MIN 0x2
#define BT_HCI_LE_CTE_LEN_MAX 0x14
#define BT_HCI_LE_AOA_CTE 0x0
#define BT_HCI_LE_AOD_CTE_1US 0x1
#define BT_HCI_LE_AOD_CTE_2US 0x2
#define BT_HCI_LE_NO_CTE 0xFF
#define BT_HCI_LE_CTE_COUNT_MIN 0x1
#define BT_HCI_LE_CTE_COUNT_MAX 0x10
#define BT_HCI_OP_LE_SET_CL_CTE_TX_PARAMS BT_OP(BT_OGF_LE, 0x0051) /* 0x2051 */
struct bt_hci_cp_le_set_cl_cte_tx_params {
uint8_t handle;
uint8_t cte_len;
uint8_t cte_type;
uint8_t cte_count;
uint8_t switch_pattern_len;
uint8_t ant_ids[0];
} __packed;
#define BT_HCI_OP_LE_SET_CL_CTE_TX_ENABLE BT_OP(BT_OGF_LE, 0x0052) /* 0x2052 */
struct bt_hci_cp_le_set_cl_cte_tx_enable {
uint8_t handle;
uint8_t cte_enable;
} __packed;
#define BT_HCI_LE_ANTENNA_SWITCHING_SLOT_1US 0x1
#define BT_HCI_LE_ANTENNA_SWITCHING_SLOT_2US 0x2
#define BT_HCI_LE_SAMPLE_CTE_ALL 0x0
#define BT_HCI_LE_SAMPLE_CTE_COUNT_MIN 0x1
#define BT_HCI_LE_SAMPLE_CTE_COUNT_MAX 0x10
#define BT_HCI_OP_LE_SET_CL_CTE_SAMPLING_ENABLE BT_OP(BT_OGF_LE, 0x0053) /* 0x2053 */
struct bt_hci_cp_le_set_cl_cte_sampling_enable {
uint16_t sync_handle;
uint8_t sampling_enable;
uint8_t slot_durations;
uint8_t max_sampled_cte;
uint8_t switch_pattern_len;
uint8_t ant_ids[0];
} __packed;
struct bt_hci_rp_le_set_cl_cte_sampling_enable {
uint8_t status;
uint16_t sync_handle;
} __packed;
#define BT_HCI_OP_LE_SET_CONN_CTE_RX_PARAMS BT_OP(BT_OGF_LE, 0x0054) /* 0x2054 */
struct bt_hci_cp_le_set_conn_cte_rx_params {
uint16_t handle;
uint8_t sampling_enable;
uint8_t slot_durations;
uint8_t switch_pattern_len;
uint8_t ant_ids[0];
} __packed;
struct bt_hci_rp_le_set_conn_cte_rx_params {
uint8_t status;
uint16_t handle;
} __packed;
#define BT_HCI_LE_AOA_CTE_RSP BIT(0)
#define BT_HCI_LE_AOD_CTE_RSP_1US BIT(1)
#define BT_HCI_LE_AOD_CTE_RSP_2US BIT(2)
#define BT_HCI_LE_SWITCH_PATTERN_LEN_MIN 0x2
#define BT_HCI_LE_SWITCH_PATTERN_LEN_MAX 0x4B
#define BT_HCI_OP_LE_SET_CONN_CTE_TX_PARAMS BT_OP(BT_OGF_LE, 0x0055) /* 0x2055 */
struct bt_hci_cp_le_set_conn_cte_tx_params {
uint16_t handle;
uint8_t cte_types;
uint8_t switch_pattern_len;
uint8_t ant_ids[0];
} __packed;
struct bt_hci_rp_le_set_conn_cte_tx_params {
uint8_t status;
uint16_t handle;
} __packed;
/* Interval between consecutive CTE request procedure starts in number of connection events. */
#define BT_HCI_REQUEST_CTE_ONCE 0x0
#define BT_HCI_REQUEST_CTE_INTERVAL_MIN 0x1
#define BT_HCI_REQUEST_CTE_INTERVAL_MAX 0xFFFF
#define BT_HCI_OP_LE_CONN_CTE_REQ_ENABLE BT_OP(BT_OGF_LE, 0x0056) /* 0x2056 */
struct bt_hci_cp_le_conn_cte_req_enable {
uint16_t handle;
uint8_t enable;
uint16_t cte_request_interval;
uint8_t requested_cte_length;
uint8_t requested_cte_type;
} __packed;
struct bt_hci_rp_le_conn_cte_req_enable {
uint8_t status;
uint16_t handle;
} __packed;
#define BT_HCI_OP_LE_CONN_CTE_RSP_ENABLE BT_OP(BT_OGF_LE, 0x0057) /* 0x2057 */
struct bt_hci_cp_le_conn_cte_rsp_enable {
uint16_t handle;
uint8_t enable;
} __packed;
struct bt_hci_rp_le_conn_cte_rsp_enable {
uint8_t status;
uint16_t handle;
} __packed;
#define BT_HCI_LE_1US_AOD_TX BIT(0)
#define BT_HCI_LE_1US_AOD_RX BIT(1)
#define BT_HCI_LE_1US_AOA_RX BIT(2)
#define BT_HCI_LE_NUM_ANT_MIN 0x1
#define BT_HCI_LE_NUM_ANT_MAX 0x4B
#define BT_HCI_LE_MAX_SWITCH_PATTERN_LEN_MIN 0x2
#define BT_HCI_LE_MAX_SWITCH_PATTERN_LEN_MAX 0x4B
#define BT_HCI_LE_MAX_CTE_LEN_MIN 0x2
#define BT_HCI_LE_MAX_CTE_LEN_MAX 0x14
#define BT_HCI_OP_LE_READ_ANT_INFO BT_OP(BT_OGF_LE, 0x0058) /* 0x2058 */
struct bt_hci_rp_le_read_ant_info {
uint8_t status;
uint8_t switch_sample_rates;
uint8_t num_ant;
uint8_t max_switch_pattern_len;
uint8_t max_cte_len;
};
#define BT_HCI_LE_SET_PER_ADV_RECV_ENABLE_ENABLE BIT(0)
#define BT_HCI_LE_SET_PER_ADV_RECV_ENABLE_FILTER_DUPLICATE BIT(1)
#define BT_HCI_OP_LE_SET_PER_ADV_RECV_ENABLE BT_OP(BT_OGF_LE, 0x0059) /* 0x2059 */
struct bt_hci_cp_le_set_per_adv_recv_enable {
uint16_t handle;
uint8_t enable;
} __packed;
#define BT_HCI_OP_LE_PER_ADV_SYNC_TRANSFER BT_OP(BT_OGF_LE, 0x005a) /* 0x205a */
struct bt_hci_cp_le_per_adv_sync_transfer {
uint16_t conn_handle;
uint16_t service_data;
uint16_t sync_handle;
} __packed;
struct bt_hci_rp_le_per_adv_sync_transfer {
uint8_t status;
uint16_t conn_handle;
} __packed;
#define BT_HCI_OP_LE_PER_ADV_SET_INFO_TRANSFER BT_OP(BT_OGF_LE, 0x005b) /* 0x205b */
struct bt_hci_cp_le_per_adv_set_info_transfer {
uint16_t conn_handle;
uint16_t service_data;
uint8_t adv_handle;
} __packed;
struct bt_hci_rp_le_per_adv_set_info_transfer {
uint8_t status;
uint16_t conn_handle;
} __packed;
#define BT_HCI_LE_PAST_MODE_NO_SYNC 0x00
#define BT_HCI_LE_PAST_MODE_NO_REPORTS 0x01
#define BT_HCI_LE_PAST_MODE_SYNC 0x02
#define BT_HCI_LE_PAST_MODE_SYNC_FILTER_DUPLICATES 0x03
#define BT_HCI_LE_PAST_CTE_TYPE_NO_AOA BIT(0)
#define BT_HCI_LE_PAST_CTE_TYPE_NO_AOD_1US BIT(1)
#define BT_HCI_LE_PAST_CTE_TYPE_NO_AOD_2US BIT(2)
#define BT_HCI_LE_PAST_CTE_TYPE_NO_CTE BIT(3)
#define BT_HCI_LE_PAST_CTE_TYPE_ONLY_CTE BIT(4)
#define BT_HCI_OP_LE_PAST_PARAM BT_OP(BT_OGF_LE, 0x005c) /* 0x205c */
struct bt_hci_cp_le_past_param {
uint16_t conn_handle;
uint8_t mode;
uint16_t skip;
uint16_t timeout;
uint8_t cte_type;
} __packed;
struct bt_hci_rp_le_past_param {
uint8_t status;
uint16_t conn_handle;
} __packed;
#define BT_HCI_OP_LE_DEFAULT_PAST_PARAM BT_OP(BT_OGF_LE, 0x005d) /* 0x205d */
struct bt_hci_cp_le_default_past_param {
uint8_t mode;
uint16_t skip;
uint16_t timeout;
uint8_t cte_type;
} __packed;
struct bt_hci_rp_le_default_past_param {
uint8_t status;
} __packed;
#define BT_HCI_OP_LE_READ_BUFFER_SIZE_V2 BT_OP(BT_OGF_LE, 0x0060) /* 0x2060 */
struct bt_hci_rp_le_read_buffer_size_v2 {
uint8_t status;
uint16_t acl_max_len;
uint8_t acl_max_num;
uint16_t iso_max_len;
uint8_t iso_max_num;
} __packed;
#define BT_HCI_OP_LE_READ_ISO_TX_SYNC BT_OP(BT_OGF_LE, 0x0061) /* 0x2061 */
struct bt_hci_cp_le_read_iso_tx_sync {
uint16_t handle;
} __packed;
struct bt_hci_rp_le_read_iso_tx_sync {
uint8_t status;
uint16_t handle;
uint16_t seq;
uint32_t timestamp;
uint8_t offset[3];
} __packed;
#define BT_HCI_ISO_CIG_ID_MAX 0xFE
#define BT_HCI_ISO_CIS_COUNT_MAX 0x1F
#define BT_HCI_ISO_SDU_INTERVAL_MIN 0x0000FF
#define BT_HCI_ISO_SDU_INTERVAL_MAX 0x0FFFFF
#define BT_HCI_ISO_WORST_CASE_SCA_VALID_MASK 0x07
#define BT_HCI_ISO_PACKING_VALID_MASK 0x01
#define BT_HCI_ISO_FRAMING_VALID_MASK 0x01
#define BT_HCI_ISO_MAX_TRANSPORT_LATENCY_MIN 0x0005
#define BT_HCI_ISO_MAX_TRANSPORT_LATENCY_MAX 0x0FA0
#define BT_HCI_ISO_CIS_ID_VALID_MAX 0xEF
#define BT_HCI_ISO_MAX_SDU_VALID_MASK 0x0FFF
#define BT_HCI_ISO_PHY_VALID_MASK 0x07
#define BT_HCI_ISO_INTERVAL_MIN 0x0004
#define BT_HCI_ISO_INTERVAL_MAX 0x0C80
#define BT_HCI_OP_LE_SET_CIG_PARAMS BT_OP(BT_OGF_LE, 0x0062) /* 0x2062 */
struct bt_hci_cis_params {
uint8_t cis_id;
uint16_t c_sdu;
uint16_t p_sdu;
uint8_t c_phy;
uint8_t p_phy;
uint8_t c_rtn;
uint8_t p_rtn;
} __packed;
struct bt_hci_cp_le_set_cig_params {
uint8_t cig_id;
uint8_t c_interval[3];
uint8_t p_interval[3];
uint8_t sca;
uint8_t packing;
uint8_t framing;
uint16_t c_latency;
uint16_t p_latency;
uint8_t num_cis;
struct bt_hci_cis_params cis[0];
} __packed;
struct bt_hci_rp_le_set_cig_params {
uint8_t status;
uint8_t cig_id;
uint8_t num_handles;
uint16_t handle[0];
} __packed;
#define BT_HCI_OP_LE_SET_CIG_PARAMS_TEST BT_OP(BT_OGF_LE, 0x0063) /* 0x2063 */
struct bt_hci_cis_params_test {
uint8_t cis_id;
uint8_t nse;
uint16_t c_sdu;
uint16_t p_sdu;
uint16_t c_pdu;
uint16_t p_pdu;
uint8_t c_phy;
uint8_t p_phy;
uint8_t c_bn;
uint8_t p_bn;
} __packed;
struct bt_hci_cp_le_set_cig_params_test {
uint8_t cig_id;
uint8_t c_interval[3];
uint8_t p_interval[3];
uint8_t c_ft;
uint8_t p_ft;
uint16_t iso_interval;
uint8_t sca;
uint8_t packing;
uint8_t framing;
uint8_t num_cis;
struct bt_hci_cis_params_test cis[0];
} __packed;
struct bt_hci_rp_le_set_cig_params_test {
uint8_t status;
uint8_t cig_id;
uint8_t num_handles;
uint16_t handle[0];
} __packed;
#define BT_HCI_OP_LE_CREATE_CIS BT_OP(BT_OGF_LE, 0x0064) /* 0x2064 */
struct bt_hci_cis {
uint16_t cis_handle;
uint16_t acl_handle;
} __packed;
struct bt_hci_cp_le_create_cis {
uint8_t num_cis;
struct bt_hci_cis cis[0];
} __packed;
#define BT_HCI_OP_LE_REMOVE_CIG BT_OP(BT_OGF_LE, 0x0065) /* 0x2065 */
struct bt_hci_cp_le_remove_cig {
uint8_t cig_id;
} __packed;
struct bt_hci_rp_le_remove_cig {
uint8_t status;
uint8_t cig_id;
} __packed;
#define BT_HCI_OP_LE_ACCEPT_CIS BT_OP(BT_OGF_LE, 0x0066) /* 0x2066 */
struct bt_hci_cp_le_accept_cis {
uint16_t handle;
} __packed;
#define BT_HCI_OP_LE_REJECT_CIS BT_OP(BT_OGF_LE, 0x0067) /* 0x2067 */
struct bt_hci_cp_le_reject_cis {
uint16_t handle;
uint8_t reason;
} __packed;
struct bt_hci_rp_le_reject_cis {
uint8_t status;
uint16_t handle;
} __packed;
#define BT_HCI_OP_LE_CREATE_BIG BT_OP(BT_OGF_LE, 0x0068) /* 0x2068 */
struct bt_hci_cp_le_create_big {
uint8_t big_handle;
uint8_t adv_handle;
uint8_t num_bis;
uint8_t sdu_interval[3];
uint16_t max_sdu;
uint16_t max_latency;
uint8_t rtn;
uint8_t phy;
uint8_t packing;
uint8_t framing;
uint8_t encryption;
uint8_t bcode[16];
} __packed;
#define BT_HCI_OP_LE_CREATE_BIG_TEST BT_OP(BT_OGF_LE, 0x0069) /* 0x2069 */
struct bt_hci_cp_le_create_big_test {
uint8_t big_handle;
uint8_t adv_handle;
uint8_t num_bis;
uint8_t sdu_interval[3];
uint16_t iso_interval;
uint8_t nse;
uint16_t max_sdu;
uint16_t max_pdu;
uint8_t phy;
uint8_t packing;
uint8_t framing;
uint8_t bn;
uint8_t irc;
uint8_t pto;
uint8_t encryption;
uint8_t bcode[16];
} __packed;
#define BT_HCI_OP_LE_TERMINATE_BIG BT_OP(BT_OGF_LE, 0x006a) /* 0x206a */
struct bt_hci_cp_le_terminate_big {
uint8_t big_handle;
uint8_t reason;
} __packed;
#define BT_HCI_OP_LE_BIG_CREATE_SYNC BT_OP(BT_OGF_LE, 0x006b) /* 0x206b */
struct bt_hci_cp_le_big_create_sync {
uint8_t big_handle;
uint16_t sync_handle;
uint8_t encryption;
uint8_t bcode[16];
uint8_t mse;
uint16_t sync_timeout;
uint8_t num_bis;
uint8_t bis[0];
} __packed;
#define BT_HCI_OP_LE_BIG_TERMINATE_SYNC BT_OP(BT_OGF_LE, 0x006c) /* 0x206c */
struct bt_hci_cp_le_big_terminate_sync {
uint8_t big_handle;
} __packed;
struct bt_hci_rp_le_big_terminate_sync {
uint8_t status;
uint8_t big_handle;
} __packed;
#define BT_HCI_OP_LE_REQ_PEER_SC BT_OP(BT_OGF_LE, 0x006d) /* 0x206d */
struct bt_hci_cp_le_req_peer_sca {
uint16_t handle;
} __packed;
#define BT_HCI_OP_LE_SETUP_ISO_PATH BT_OP(BT_OGF_LE, 0x006e) /* 0x206e */
struct bt_hci_cp_le_setup_iso_path {
uint16_t handle;
uint8_t path_dir;
uint8_t path_id;
struct bt_hci_cp_codec_id codec_id;
uint8_t controller_delay[3];
uint8_t codec_config_len;
uint8_t codec_config[0];
} __packed;
struct bt_hci_rp_le_setup_iso_path {
uint8_t status;
uint16_t handle;
} __packed;
#define BT_HCI_OP_LE_REMOVE_ISO_PATH BT_OP(BT_OGF_LE, 0x006f) /* 0x206f */
struct bt_hci_cp_le_remove_iso_path {
uint16_t handle;
uint8_t path_dir;
} __packed;
struct bt_hci_rp_le_remove_iso_path {
uint8_t status;
uint16_t handle;
} __packed;
#define BT_HCI_ISO_TEST_ZERO_SIZE_SDU 0
#define BT_HCI_ISO_TEST_VARIABLE_SIZE_SDU 1
#define BT_HCI_ISO_TEST_MAX_SIZE_SDU 2
#define BT_HCI_OP_LE_ISO_TRANSMIT_TEST BT_OP(BT_OGF_LE, 0x0070) /* 0x2070 */
struct bt_hci_cp_le_iso_transmit_test {
uint16_t handle;
uint8_t payload_type;
} __packed;
struct bt_hci_rp_le_iso_transmit_test {
uint8_t status;
uint16_t handle;
} __packed;
#define BT_HCI_OP_LE_ISO_RECEIVE_TEST BT_OP(BT_OGF_LE, 0x0071) /* 0x2071 */
struct bt_hci_cp_le_iso_receive_test {
uint16_t handle;
uint8_t payload_type;
} __packed;
struct bt_hci_rp_le_iso_receive_test {
uint8_t status;
uint16_t handle;
} __packed;
#define BT_HCI_OP_LE_ISO_READ_TEST_COUNTERS BT_OP(BT_OGF_LE, 0x0072) /* 0x2072 */
struct bt_hci_cp_le_read_test_counters {
uint16_t handle;
} __packed;
struct bt_hci_rp_le_read_test_counters {
uint8_t status;
uint16_t handle;
uint32_t received_cnt;
uint32_t missed_cnt;
uint32_t failed_cnt;
} __packed;
#define BT_HCI_OP_LE_ISO_TEST_END BT_OP(BT_OGF_LE, 0x0073) /* 0x2073 */
struct bt_hci_cp_le_iso_test_end {
uint16_t handle;
} __packed;
struct bt_hci_rp_le_iso_test_end {
uint8_t status;
uint16_t handle;
uint32_t received_cnt;
uint32_t missed_cnt;
uint32_t failed_cnt;
} __packed;
#define BT_HCI_OP_LE_SET_HOST_FEATURE BT_OP(BT_OGF_LE, 0x0074) /* 0x2074 */
struct bt_hci_cp_le_set_host_feature {
uint8_t bit_number;
uint8_t bit_value;
} __packed;
struct bt_hci_rp_le_set_host_feature {
uint8_t status;
} __packed;
#define BT_HCI_OP_LE_READ_ISO_LINK_QUALITY BT_OP(BT_OGF_LE, 0x0075) /* 0x2075 */
struct bt_hci_cp_le_read_iso_link_quality {
uint16_t handle;
} __packed;
struct bt_hci_rp_le_read_iso_link_quality {
uint8_t status;
uint16_t handle;
uint32_t tx_unacked_packets;
uint32_t tx_flushed_packets;
uint32_t tx_last_subevent_packets;
uint32_t retransmitted_packets;
uint32_t crc_error_packets;
uint32_t rx_unreceived_packets;
uint32_t duplicate_packets;
} __packed;
#define BT_HCI_OP_LE_TX_TEST_V4 BT_OP(BT_OGF_LE, 0x007B) /* 0x207B */
struct bt_hci_cp_le_tx_test_v4 {
uint8_t tx_ch;
uint8_t test_data_len;
uint8_t pkt_payload;
uint8_t phy;
uint8_t cte_len;
uint8_t cte_type;
uint8_t switch_pattern_len;
uint8_t ant_ids[0];
} __packed;
#define BT_HCI_TX_TEST_POWER_MIN -0x7F
#define BT_HCI_TX_TEST_POWER_MAX 0x14
#define BT_HCI_TX_TEST_POWER_MIN_SET 0x7E
#define BT_HCI_TX_TEST_POWER_MAX_SET 0x7F
/* Helper structure for Tx power parameter in the HCI Tx Test v4 command.
* Previous parameter of this command is variable size so having separated structure
* for this parameter helps in command parameters unpacking.
*/
struct bt_hci_cp_le_tx_test_v4_tx_power {
int8_t tx_power;
} __packed;
/* Event definitions */
#define BT_HCI_EVT_UNKNOWN 0x00
#define BT_HCI_EVT_VENDOR 0xff
#define BT_HCI_EVT_INQUIRY_COMPLETE 0x01
struct bt_hci_evt_inquiry_complete {
uint8_t status;
} __packed;
#define BT_HCI_EVT_CONN_COMPLETE 0x03
struct bt_hci_evt_conn_complete {
uint8_t status;
uint16_t handle;
bt_addr_t bdaddr;
uint8_t link_type;
uint8_t encr_enabled;
} __packed;
#define BT_HCI_EVT_CONN_REQUEST 0x04
struct bt_hci_evt_conn_request {
bt_addr_t bdaddr;
uint8_t dev_class[3];
uint8_t link_type;
} __packed;
#define BT_HCI_EVT_DISCONN_COMPLETE 0x05
struct bt_hci_evt_disconn_complete {
uint8_t status;
uint16_t handle;
uint8_t reason;
} __packed;
#define BT_HCI_EVT_AUTH_COMPLETE 0x06
struct bt_hci_evt_auth_complete {
uint8_t status;
uint16_t handle;
} __packed;
#define BT_HCI_EVT_REMOTE_NAME_REQ_COMPLETE 0x07
struct bt_hci_evt_remote_name_req_complete {
uint8_t status;
bt_addr_t bdaddr;
uint8_t name[248];
} __packed;
#define BT_HCI_EVT_ENCRYPT_CHANGE 0x08
struct bt_hci_evt_encrypt_change {
uint8_t status;
uint16_t handle;
uint8_t encrypt;
} __packed;
#define BT_HCI_EVT_REMOTE_FEATURES 0x0b
struct bt_hci_evt_remote_features {
uint8_t status;
uint16_t handle;
uint8_t features[8];
} __packed;
#define BT_HCI_EVT_REMOTE_VERSION_INFO 0x0c
struct bt_hci_evt_remote_version_info {
uint8_t status;
uint16_t handle;
uint8_t version;
uint16_t manufacturer;
uint16_t subversion;
} __packed;
#define BT_HCI_EVT_CMD_COMPLETE 0x0e
struct bt_hci_evt_cmd_complete {
uint8_t ncmd;
uint16_t opcode;
} __packed;
struct bt_hci_evt_cc_status {
uint8_t status;
} __packed;
#define BT_HCI_EVT_CMD_STATUS 0x0f
struct bt_hci_evt_cmd_status {
uint8_t status;
uint8_t ncmd;
uint16_t opcode;
} __packed;
#define BT_HCI_EVT_HARDWARE_ERROR 0x10
struct bt_hci_evt_hardware_error {
uint8_t hardware_code;
} __packed;
#define BT_HCI_EVT_ROLE_CHANGE 0x12
struct bt_hci_evt_role_change {
uint8_t status;
bt_addr_t bdaddr;
uint8_t role;
} __packed;
#define BT_HCI_EVT_NUM_COMPLETED_PACKETS 0x13
struct bt_hci_evt_num_completed_packets {
uint8_t num_handles;
struct bt_hci_handle_count h[0];
} __packed;
#define BT_HCI_EVT_PIN_CODE_REQ 0x16
struct bt_hci_evt_pin_code_req {
bt_addr_t bdaddr;
} __packed;
#define BT_HCI_EVT_LINK_KEY_REQ 0x17
struct bt_hci_evt_link_key_req {
bt_addr_t bdaddr;
} __packed;
/* Link Key types */
#define BT_LK_COMBINATION 0x00
#define BT_LK_LOCAL_UNIT 0x01
#define BT_LK_REMOTE_UNIT 0x02
#define BT_LK_DEBUG_COMBINATION 0x03
#define BT_LK_UNAUTH_COMBINATION_P192 0x04
#define BT_LK_AUTH_COMBINATION_P192 0x05
#define BT_LK_CHANGED_COMBINATION 0x06
#define BT_LK_UNAUTH_COMBINATION_P256 0x07
#define BT_LK_AUTH_COMBINATION_P256 0x08
#define BT_HCI_EVT_LINK_KEY_NOTIFY 0x18
struct bt_hci_evt_link_key_notify {
bt_addr_t bdaddr;
uint8_t link_key[16];
uint8_t key_type;
} __packed;
/* Overflow link types */
#define BT_OVERFLOW_LINK_SYNCH 0x00
#define BT_OVERFLOW_LINK_ACL 0x01
#define BT_OVERFLOW_LINK_ISO 0x02
#define BT_HCI_EVT_DATA_BUF_OVERFLOW 0x1a
struct bt_hci_evt_data_buf_overflow {
uint8_t link_type;
} __packed;
#define BT_HCI_EVT_INQUIRY_RESULT_WITH_RSSI 0x22
struct bt_hci_evt_inquiry_result_with_rssi {
bt_addr_t addr;
uint8_t pscan_rep_mode;
uint8_t reserved;
uint8_t cod[3];
uint16_t clock_offset;
int8_t rssi;
} __packed;
#define BT_HCI_EVT_REMOTE_EXT_FEATURES 0x23
struct bt_hci_evt_remote_ext_features {
uint8_t status;
uint16_t handle;
uint8_t page;
uint8_t max_page;
uint8_t features[8];
} __packed;
#define BT_HCI_EVT_LE_PER_ADV_SYNC_ESTABLISHED_V2 0x24
struct bt_hci_evt_le_per_adv_sync_established_v2 {
uint8_t status;
uint16_t handle;
uint8_t sid;
bt_addr_le_t adv_addr;
uint8_t phy;
uint16_t interval;
uint8_t clock_accuracy;
uint8_t num_subevents;
uint8_t subevent_interval;
uint8_t response_slot_delay;
uint8_t response_slot_spacing;
} __packed;
#define BT_HCI_EVT_LE_PER_ADVERTISING_REPORT_V2 0x25
struct bt_hci_evt_le_per_advertising_report_v2 {
uint16_t handle;
int8_t tx_power;
int8_t rssi;
uint8_t cte_type;
uint16_t periodic_event_counter;
uint8_t subevent;
uint8_t data_status;
uint8_t length;
uint8_t data[0];
} __packed;
#define BT_HCI_EVT_LE_PAST_RECEIVED_V2 0x26
struct bt_hci_evt_le_past_received_v2 {
uint8_t status;
uint16_t conn_handle;
uint16_t service_data;
uint16_t sync_handle;
uint8_t adv_sid;
bt_addr_le_t addr;
uint8_t phy;
uint16_t interval;
uint8_t clock_accuracy;
uint8_t num_subevents;
uint8_t subevent_interval;
uint8_t response_slot_delay;
uint8_t response_slot_spacing;
} __packed;
#define BT_HCI_EVT_LE_PER_ADV_SUBEVENT_DATA_REQUEST 0x27
struct bt_hci_evt_le_per_adv_subevent_data_request {
uint8_t adv_handle;
uint8_t subevent_start;
uint8_t subevent_data_count;
} __packed;
#define BT_HCI_EVT_LE_PER_ADV_RESPONSE_REPORT 0x28
struct bt_hci_evt_le_per_adv_response {
int8_t tx_power;
int8_t rssi;
uint8_t cte_type;
uint8_t response_slot;
uint8_t data_status;
uint8_t data_length;
uint8_t data[0];
} __packed;
struct bt_hci_evt_le_per_adv_response_report {
uint8_t adv_handle;
uint8_t subevent;
uint8_t tx_status;
uint8_t num_responses;
struct bt_hci_evt_le_per_adv_response responses[0];
} __packed;
#define BT_HCI_EVT_LE_ENH_CONN_COMPLETE_V2 0x29
struct bt_hci_evt_le_enh_conn_complete_v2 {
uint8_t status;
uint16_t handle;
uint8_t role;
bt_addr_le_t peer_addr;
bt_addr_t local_rpa;
bt_addr_t peer_rpa;
uint16_t interval;
uint16_t latency;
uint16_t supv_timeout;
uint8_t clock_accuracy;
uint8_t adv_handle;
uint16_t sync_handle;
} __packed;
#define BT_HCI_EVT_SYNC_CONN_COMPLETE 0x2c
struct bt_hci_evt_sync_conn_complete {
uint8_t status;
uint16_t handle;
bt_addr_t bdaddr;
uint8_t link_type;
uint8_t tx_interval;
uint8_t retansmission_window;
uint16_t rx_pkt_length;
uint16_t tx_pkt_length;
uint8_t air_mode;
} __packed;
#define BT_HCI_EVT_EXTENDED_INQUIRY_RESULT 0x2f
struct bt_hci_evt_extended_inquiry_result {
uint8_t num_reports;
bt_addr_t addr;
uint8_t pscan_rep_mode;
uint8_t reserved;
uint8_t cod[3];
uint16_t clock_offset;
int8_t rssi;
uint8_t eir[240];
} __packed;
#define BT_HCI_EVT_ENCRYPT_KEY_REFRESH_COMPLETE 0x30
struct bt_hci_evt_encrypt_key_refresh_complete {
uint8_t status;
uint16_t handle;
} __packed;
#define BT_HCI_EVT_IO_CAPA_REQ 0x31
struct bt_hci_evt_io_capa_req {
bt_addr_t bdaddr;
} __packed;
#define BT_HCI_EVT_IO_CAPA_RESP 0x32
struct bt_hci_evt_io_capa_resp {
bt_addr_t bdaddr;
uint8_t capability;
uint8_t oob_data;
uint8_t authentication;
} __packed;
#define BT_HCI_EVT_USER_CONFIRM_REQ 0x33
struct bt_hci_evt_user_confirm_req {
bt_addr_t bdaddr;
uint32_t passkey;
} __packed;
#define BT_HCI_EVT_USER_PASSKEY_REQ 0x34
struct bt_hci_evt_user_passkey_req {
bt_addr_t bdaddr;
} __packed;
#define BT_HCI_EVT_SSP_COMPLETE 0x36
struct bt_hci_evt_ssp_complete {
uint8_t status;
bt_addr_t bdaddr;
} __packed;
#define BT_HCI_EVT_USER_PASSKEY_NOTIFY 0x3b
struct bt_hci_evt_user_passkey_notify {
bt_addr_t bdaddr;
uint32_t passkey;
} __packed;
#define BT_HCI_EVT_LE_META_EVENT 0x3e
struct bt_hci_evt_le_meta_event {
uint8_t subevent;
} __packed;
#define BT_HCI_EVT_AUTH_PAYLOAD_TIMEOUT_EXP 0x57
struct bt_hci_evt_auth_payload_timeout_exp {
uint16_t handle;
} __packed;
#define BT_HCI_ROLE_CENTRAL 0x00
#define BT_HCI_ROLE_PERIPHERAL 0x01
#define BT_HCI_EVT_LE_CONN_COMPLETE 0x01
struct bt_hci_evt_le_conn_complete {
uint8_t status;
uint16_t handle;
uint8_t role;
bt_addr_le_t peer_addr;
uint16_t interval;
uint16_t latency;
uint16_t supv_timeout;
uint8_t clock_accuracy;
} __packed;
#define BT_HCI_LE_RSSI_NOT_AVAILABLE 0x7F
#define BT_HCI_EVT_LE_ADVERTISING_REPORT 0x02
struct bt_hci_evt_le_advertising_info {
uint8_t evt_type;
bt_addr_le_t addr;
uint8_t length;
uint8_t data[0];
} __packed;
struct bt_hci_evt_le_advertising_report {
uint8_t num_reports;
struct bt_hci_evt_le_advertising_info adv_info[0];
} __packed;
#define BT_HCI_EVT_LE_CONN_UPDATE_COMPLETE 0x03
struct bt_hci_evt_le_conn_update_complete {
uint8_t status;
uint16_t handle;
uint16_t interval;
uint16_t latency;
uint16_t supv_timeout;
} __packed;
#define BT_HCI_EVT_LE_REMOTE_FEAT_COMPLETE 0x04
struct bt_hci_evt_le_remote_feat_complete {
uint8_t status;
uint16_t handle;
uint8_t features[8];
} __packed;
#define BT_HCI_EVT_LE_LTK_REQUEST 0x05
struct bt_hci_evt_le_ltk_request {
uint16_t handle;
uint64_t rand;
uint16_t ediv;
} __packed;
#define BT_HCI_EVT_LE_CONN_PARAM_REQ 0x06
struct bt_hci_evt_le_conn_param_req {
uint16_t handle;
uint16_t interval_min;
uint16_t interval_max;
uint16_t latency;
uint16_t timeout;
} __packed;
#define BT_HCI_EVT_LE_DATA_LEN_CHANGE 0x07
struct bt_hci_evt_le_data_len_change {
uint16_t handle;
uint16_t max_tx_octets;
uint16_t max_tx_time;
uint16_t max_rx_octets;
uint16_t max_rx_time;
} __packed;
#define BT_HCI_EVT_LE_P256_PUBLIC_KEY_COMPLETE 0x08
struct bt_hci_evt_le_p256_public_key_complete {
uint8_t status;
uint8_t key[64];
} __packed;
#define BT_HCI_EVT_LE_GENERATE_DHKEY_COMPLETE 0x09
struct bt_hci_evt_le_generate_dhkey_complete {
uint8_t status;
uint8_t dhkey[32];
} __packed;
#define BT_HCI_EVT_LE_ENH_CONN_COMPLETE 0x0a
struct bt_hci_evt_le_enh_conn_complete {
uint8_t status;
uint16_t handle;
uint8_t role;
bt_addr_le_t peer_addr;
bt_addr_t local_rpa;
bt_addr_t peer_rpa;
uint16_t interval;
uint16_t latency;
uint16_t supv_timeout;
uint8_t clock_accuracy;
} __packed;
#define BT_HCI_EVT_LE_DIRECT_ADV_REPORT 0x0b
struct bt_hci_evt_le_direct_adv_info {
uint8_t evt_type;
bt_addr_le_t addr;
bt_addr_le_t dir_addr;
int8_t rssi;
} __packed;
struct bt_hci_evt_le_direct_adv_report {
uint8_t num_reports;
struct bt_hci_evt_le_direct_adv_info direct_adv_info[0];
} __packed;
#define BT_HCI_EVT_LE_PHY_UPDATE_COMPLETE 0x0c
struct bt_hci_evt_le_phy_update_complete {
uint8_t status;
uint16_t handle;
uint8_t tx_phy;
uint8_t rx_phy;
} __packed;
#define BT_HCI_EVT_LE_EXT_ADVERTISING_REPORT 0x0d
#define BT_HCI_LE_ADV_EVT_TYPE_CONN BIT(0)
#define BT_HCI_LE_ADV_EVT_TYPE_SCAN BIT(1)
#define BT_HCI_LE_ADV_EVT_TYPE_DIRECT BIT(2)
#define BT_HCI_LE_ADV_EVT_TYPE_SCAN_RSP BIT(3)
#define BT_HCI_LE_ADV_EVT_TYPE_LEGACY BIT(4)
#define BT_HCI_LE_ADV_EVT_TYPE_DATA_STATUS(ev_type) (((ev_type) >> 5) & 0x03)
#define BT_HCI_LE_ADV_EVT_TYPE_DATA_STATUS_COMPLETE 0
#define BT_HCI_LE_ADV_EVT_TYPE_DATA_STATUS_PARTIAL 1
#define BT_HCI_LE_ADV_EVT_TYPE_DATA_STATUS_INCOMPLETE 2
#define BT_HCI_LE_ADV_EVT_TYPE_DATA_STATUS_RX_FAILED 0xFF
struct bt_hci_evt_le_ext_advertising_info {
uint16_t evt_type;
bt_addr_le_t addr;
uint8_t prim_phy;
uint8_t sec_phy;
uint8_t sid;
int8_t tx_power;
int8_t rssi;
uint16_t interval;
bt_addr_le_t direct_addr;
uint8_t length;
uint8_t data[0];
} __packed;
struct bt_hci_evt_le_ext_advertising_report {
uint8_t num_reports;
struct bt_hci_evt_le_ext_advertising_info adv_info[0];
} __packed;
#define BT_HCI_EVT_LE_PER_ADV_SYNC_ESTABLISHED 0x0e
struct bt_hci_evt_le_per_adv_sync_established {
uint8_t status;
uint16_t handle;
uint8_t sid;
bt_addr_le_t adv_addr;
uint8_t phy;
uint16_t interval;
uint8_t clock_accuracy;
} __packed;
#define BT_HCI_EVT_LE_PER_ADVERTISING_REPORT 0x0f
struct bt_hci_evt_le_per_advertising_report {
uint16_t handle;
int8_t tx_power;
int8_t rssi;
uint8_t cte_type;
uint8_t data_status;
uint8_t length;
uint8_t data[0];
} __packed;
#define BT_HCI_EVT_LE_PER_ADV_SYNC_LOST 0x10
struct bt_hci_evt_le_per_adv_sync_lost {
uint16_t handle;
} __packed;
#define BT_HCI_EVT_LE_SCAN_TIMEOUT 0x11
#define BT_HCI_EVT_LE_ADV_SET_TERMINATED 0x12
struct bt_hci_evt_le_adv_set_terminated {
uint8_t status;
uint8_t adv_handle;
uint16_t conn_handle;
uint8_t num_completed_ext_adv_evts;
} __packed;
#define BT_HCI_EVT_LE_SCAN_REQ_RECEIVED 0x13
struct bt_hci_evt_le_scan_req_received {
uint8_t handle;
bt_addr_le_t addr;
} __packed;
#define BT_HCI_LE_CHAN_SEL_ALGO_1 0x00
#define BT_HCI_LE_CHAN_SEL_ALGO_2 0x01
#define BT_HCI_EVT_LE_CHAN_SEL_ALGO 0x14
struct bt_hci_evt_le_chan_sel_algo {
uint16_t handle;
uint8_t chan_sel_algo;
} __packed;
#define BT_HCI_LE_CTE_CRC_OK 0x0
#define BT_HCI_LE_CTE_CRC_ERR_CTE_BASED_TIME 0x1
#define BT_HCI_LE_CTE_CRC_ERR_CTE_BASED_OTHER 0x2
#define BT_HCI_LE_CTE_INSUFFICIENT_RESOURCES 0xFF
#define B_HCI_LE_CTE_REPORT_SAMPLE_COUNT_MIN 0x9
#define B_HCI_LE_CTE_REPORT_SAMPLE_COUNT_MAX 0x52
#define BT_HCI_LE_CTE_REPORT_NO_VALID_SAMPLE 0x80
#define BT_HCI_EVT_LE_CONNECTIONLESS_IQ_REPORT 0x15
struct bt_hci_le_iq_sample {
int8_t i;
int8_t q;
};
struct bt_hci_evt_le_connectionless_iq_report {
uint16_t sync_handle;
uint8_t chan_idx;
int16_t rssi;
uint8_t rssi_ant_id;
uint8_t cte_type;
uint8_t slot_durations;
uint8_t packet_status;
uint16_t per_evt_counter;
uint8_t sample_count;
struct bt_hci_le_iq_sample sample[0];
} __packed;
#define BT_HCI_EVT_LE_CONNECTION_IQ_REPORT 0x16
struct bt_hci_evt_le_connection_iq_report {
uint16_t conn_handle;
uint8_t rx_phy;
uint8_t data_chan_idx;
int16_t rssi;
uint8_t rssi_ant_id;
uint8_t cte_type;
uint8_t slot_durations;
uint8_t packet_status;
uint16_t conn_evt_counter;
uint8_t sample_count;
struct bt_hci_le_iq_sample sample[0];
} __packed;
#define BT_HCI_CTE_REQ_STATUS_RSP_WITHOUT_CTE 0x0
#define BT_HCI_EVT_LE_CTE_REQUEST_FAILED 0x17
struct bt_hci_evt_le_cte_req_failed {
/* According to BT 5.3 Core Spec the status field may have following
* values:
* - BT_HCI_CTE_REQ_STATUS_RSP_WITHOUT_CTE when received LL_CTE_RSP_PDU without CTE.
* - Other Controller error code for peer rejected request.
*/
uint8_t status;
uint16_t conn_handle;
} __packed;
#define BT_HCI_EVT_LE_PAST_RECEIVED 0x18
struct bt_hci_evt_le_past_received {
uint8_t status;
uint16_t conn_handle;
uint16_t service_data;
uint16_t sync_handle;
uint8_t adv_sid;
bt_addr_le_t addr;
uint8_t phy;
uint16_t interval;
uint8_t clock_accuracy;
} __packed;
#define BT_HCI_EVT_LE_CIS_ESTABLISHED 0x19
struct bt_hci_evt_le_cis_established {
uint8_t status;
uint16_t conn_handle;
uint8_t cig_sync_delay[3];
uint8_t cis_sync_delay[3];
uint8_t c_latency[3];
uint8_t p_latency[3];
uint8_t c_phy;
uint8_t p_phy;
uint8_t nse;
uint8_t c_bn;
uint8_t p_bn;
uint8_t c_ft;
uint8_t p_ft;
uint16_t c_max_pdu;
uint16_t p_max_pdu;
uint16_t interval;
} __packed;
#define BT_HCI_EVT_LE_CIS_REQ 0x1a
struct bt_hci_evt_le_cis_req {
uint16_t acl_handle;
uint16_t cis_handle;
uint8_t cig_id;
uint8_t cis_id;
} __packed;
#define BT_HCI_EVT_LE_BIG_COMPLETE 0x1b
struct bt_hci_evt_le_big_complete {
uint8_t status;
uint8_t big_handle;
uint8_t sync_delay[3];
uint8_t latency[3];
uint8_t phy;
uint8_t nse;
uint8_t bn;
uint8_t pto;
uint8_t irc;
uint16_t max_pdu;
uint16_t iso_interval;
uint8_t num_bis;
uint16_t handle[0];
} __packed;
#define BT_HCI_EVT_LE_BIG_TERMINATE 0x1c
struct bt_hci_evt_le_big_terminate {
uint8_t big_handle;
uint8_t reason;
} __packed;
#define BT_HCI_EVT_LE_BIG_SYNC_ESTABLISHED 0x1d
struct bt_hci_evt_le_big_sync_established {
uint8_t status;
uint8_t big_handle;
uint8_t latency[3];
uint8_t nse;
uint8_t bn;
uint8_t pto;
uint8_t irc;
uint16_t max_pdu;
uint16_t iso_interval;
uint8_t num_bis;
uint16_t handle[0];
} __packed;
#define BT_HCI_EVT_LE_BIG_SYNC_LOST 0x1e
struct bt_hci_evt_le_big_sync_lost {
uint8_t big_handle;
uint8_t reason;
} __packed;
#define BT_HCI_EVT_LE_REQ_PEER_SCA_COMPLETE 0x1f
struct bt_hci_evt_le_req_peer_sca_complete {
uint8_t status;
uint16_t handle;
uint8_t sca;
} __packed;
#define BT_HCI_LE_ZONE_ENTERED_LOW 0x0
#define BT_HCI_LE_ZONE_ENTERED_MIDDLE 0x1
#define BT_HCI_LE_ZONE_ENTERED_HIGH 0x2
#define BT_HCI_LE_PATH_LOSS_UNAVAILABLE 0xFF
#define BT_HCI_EVT_LE_PATH_LOSS_THRESHOLD 0x20
struct bt_hci_evt_le_path_loss_threshold {
uint16_t handle;
uint8_t current_path_loss;
uint8_t zone_entered;
} __packed;
/** Reason for Transmit power reporting.
*/
/* Local Transmit power changed. */
#define BT_HCI_LE_TX_POWER_REPORT_REASON_LOCAL_CHANGED 0x00
/* Remote Transmit power changed. */
#define BT_HCI_LE_TX_POWER_REPORT_REASON_REMOTE_CHANGED 0x01
/* HCI_LE_Read_Remote_Transmit_Power_Level command completed. */
#define BT_HCI_LE_TX_POWER_REPORT_REASON_READ_REMOTE_COMPLETED 0x02
#define BT_HCI_EVT_LE_TRANSMIT_POWER_REPORT 0x21
struct bt_hci_evt_le_transmit_power_report {
uint8_t status;
uint16_t handle;
uint8_t reason;
uint8_t phy;
int8_t tx_power_level;
uint8_t tx_power_level_flag;
int8_t delta;
} __packed;
#define BT_HCI_EVT_LE_BIGINFO_ADV_REPORT 0x22
struct bt_hci_evt_le_biginfo_adv_report {
uint16_t sync_handle;
uint8_t num_bis;
uint8_t nse;
uint16_t iso_interval;
uint8_t bn;
uint8_t pto;
uint8_t irc;
uint16_t max_pdu;
uint8_t sdu_interval[3];
uint16_t max_sdu;
uint8_t phy;
uint8_t framing;
uint8_t encryption;
} __packed;
#define BT_HCI_EVT_LE_SUBRATE_CHANGE 0x23
struct bt_hci_evt_le_subrate_change {
uint8_t status;
uint16_t handle;
uint16_t subrate_factor;
uint16_t peripheral_latency;
uint16_t continuation_number;
uint16_t supervision_timeout;
} __packed;
/* Event mask bits */
#define BT_EVT_BIT(n) (1ULL << (n))
#define BT_EVT_MASK_INQUIRY_COMPLETE BT_EVT_BIT(0)
#define BT_EVT_MASK_CONN_COMPLETE BT_EVT_BIT(2)
#define BT_EVT_MASK_CONN_REQUEST BT_EVT_BIT(3)
#define BT_EVT_MASK_DISCONN_COMPLETE BT_EVT_BIT(4)
#define BT_EVT_MASK_AUTH_COMPLETE BT_EVT_BIT(5)
#define BT_EVT_MASK_REMOTE_NAME_REQ_COMPLETE BT_EVT_BIT(6)
#define BT_EVT_MASK_ENCRYPT_CHANGE BT_EVT_BIT(7)
#define BT_EVT_MASK_REMOTE_FEATURES BT_EVT_BIT(10)
#define BT_EVT_MASK_REMOTE_VERSION_INFO BT_EVT_BIT(11)
#define BT_EVT_MASK_HARDWARE_ERROR BT_EVT_BIT(15)
#define BT_EVT_MASK_ROLE_CHANGE BT_EVT_BIT(17)
#define BT_EVT_MASK_PIN_CODE_REQ BT_EVT_BIT(21)
#define BT_EVT_MASK_LINK_KEY_REQ BT_EVT_BIT(22)
#define BT_EVT_MASK_LINK_KEY_NOTIFY BT_EVT_BIT(23)
#define BT_EVT_MASK_DATA_BUFFER_OVERFLOW BT_EVT_BIT(25)
#define BT_EVT_MASK_INQUIRY_RESULT_WITH_RSSI BT_EVT_BIT(33)
#define BT_EVT_MASK_REMOTE_EXT_FEATURES BT_EVT_BIT(34)
#define BT_EVT_MASK_SYNC_CONN_COMPLETE BT_EVT_BIT(43)
#define BT_EVT_MASK_EXTENDED_INQUIRY_RESULT BT_EVT_BIT(46)
#define BT_EVT_MASK_ENCRYPT_KEY_REFRESH_COMPLETE BT_EVT_BIT(47)
#define BT_EVT_MASK_IO_CAPA_REQ BT_EVT_BIT(48)
#define BT_EVT_MASK_IO_CAPA_RESP BT_EVT_BIT(49)
#define BT_EVT_MASK_USER_CONFIRM_REQ BT_EVT_BIT(50)
#define BT_EVT_MASK_USER_PASSKEY_REQ BT_EVT_BIT(51)
#define BT_EVT_MASK_SSP_COMPLETE BT_EVT_BIT(53)
#define BT_EVT_MASK_USER_PASSKEY_NOTIFY BT_EVT_BIT(58)
#define BT_EVT_MASK_LE_META_EVENT BT_EVT_BIT(61)
/* Page 2 */
#define BT_EVT_MASK_NUM_COMPLETE_DATA_BLOCKS BT_EVT_BIT(8)
#define BT_EVT_MASK_TRIGG_CLOCK_CAPTURE BT_EVT_BIT(14)
#define BT_EVT_MASK_SYNCH_TRAIN_COMPLETE BT_EVT_BIT(15)
#define BT_EVT_MASK_SYNCH_TRAIN_RX BT_EVT_BIT(16)
#define BT_EVT_MASK_CL_PER_BC_RX BT_EVT_BIT(17)
#define BT_EVT_MASK_CL_PER_BC_TIMEOUT BT_EVT_BIT(18)
#define BT_EVT_MASK_TRUNC_PAGE_COMPLETE BT_EVT_BIT(19)
#define BT_EVT_MASK_PER_PAGE_RSP_TIMEOUT BT_EVT_BIT(20)
#define BT_EVT_MASK_CL_PER_BC_CH_MAP_CHANGE BT_EVT_BIT(21)
#define BT_EVT_MASK_INQUIRY_RSP_NOT BT_EVT_BIT(22)
#define BT_EVT_MASK_AUTH_PAYLOAD_TIMEOUT_EXP BT_EVT_BIT(23)
#define BT_EVT_MASK_SAM_STATUS_CHANGE BT_EVT_BIT(24)
#define BT_EVT_MASK_LE_CONN_COMPLETE BT_EVT_BIT(0)
#define BT_EVT_MASK_LE_ADVERTISING_REPORT BT_EVT_BIT(1)
#define BT_EVT_MASK_LE_CONN_UPDATE_COMPLETE BT_EVT_BIT(2)
#define BT_EVT_MASK_LE_REMOTE_FEAT_COMPLETE BT_EVT_BIT(3)
#define BT_EVT_MASK_LE_LTK_REQUEST BT_EVT_BIT(4)
#define BT_EVT_MASK_LE_CONN_PARAM_REQ BT_EVT_BIT(5)
#define BT_EVT_MASK_LE_DATA_LEN_CHANGE BT_EVT_BIT(6)
#define BT_EVT_MASK_LE_P256_PUBLIC_KEY_COMPLETE BT_EVT_BIT(7)
#define BT_EVT_MASK_LE_GENERATE_DHKEY_COMPLETE BT_EVT_BIT(8)
#define BT_EVT_MASK_LE_ENH_CONN_COMPLETE BT_EVT_BIT(9)
#define BT_EVT_MASK_LE_DIRECT_ADV_REPORT BT_EVT_BIT(10)
#define BT_EVT_MASK_LE_PHY_UPDATE_COMPLETE BT_EVT_BIT(11)
#define BT_EVT_MASK_LE_EXT_ADVERTISING_REPORT BT_EVT_BIT(12)
#define BT_EVT_MASK_LE_PER_ADV_SYNC_ESTABLISHED BT_EVT_BIT(13)
#define BT_EVT_MASK_LE_PER_ADVERTISING_REPORT BT_EVT_BIT(14)
#define BT_EVT_MASK_LE_PER_ADV_SYNC_LOST BT_EVT_BIT(15)
#define BT_EVT_MASK_LE_SCAN_TIMEOUT BT_EVT_BIT(16)
#define BT_EVT_MASK_LE_ADV_SET_TERMINATED BT_EVT_BIT(17)
#define BT_EVT_MASK_LE_SCAN_REQ_RECEIVED BT_EVT_BIT(18)
#define BT_EVT_MASK_LE_CHAN_SEL_ALGO BT_EVT_BIT(19)
#define BT_EVT_MASK_LE_CONNECTIONLESS_IQ_REPORT BT_EVT_BIT(20)
#define BT_EVT_MASK_LE_CONNECTION_IQ_REPORT BT_EVT_BIT(21)
#define BT_EVT_MASK_LE_CTE_REQUEST_FAILED BT_EVT_BIT(22)
#define BT_EVT_MASK_LE_PAST_RECEIVED BT_EVT_BIT(23)
#define BT_EVT_MASK_LE_CIS_ESTABLISHED BT_EVT_BIT(24)
#define BT_EVT_MASK_LE_CIS_REQ BT_EVT_BIT(25)
#define BT_EVT_MASK_LE_BIG_COMPLETE BT_EVT_BIT(26)
#define BT_EVT_MASK_LE_BIG_TERMINATED BT_EVT_BIT(27)
#define BT_EVT_MASK_LE_BIG_SYNC_ESTABLISHED BT_EVT_BIT(28)
#define BT_EVT_MASK_LE_BIG_SYNC_LOST BT_EVT_BIT(29)
#define BT_EVT_MASK_LE_REQ_PEER_SCA_COMPLETE BT_EVT_BIT(30)
#define BT_EVT_MASK_LE_PATH_LOSS_THRESHOLD BT_EVT_BIT(31)
#define BT_EVT_MASK_LE_TRANSMIT_POWER_REPORTING BT_EVT_BIT(32)
#define BT_EVT_MASK_LE_BIGINFO_ADV_REPORT BT_EVT_BIT(33)
#define BT_EVT_MASK_LE_SUBRATE_CHANGE BT_EVT_BIT(34)
#define BT_EVT_MASK_LE_PER_ADV_SYNC_ESTABLISHED_V2 BT_EVT_BIT(35)
#define BT_EVT_MASK_LE_PER_ADVERTISING_REPORT_V2 BT_EVT_BIT(36)
#define BT_EVT_MASK_LE_PAST_RECEIVED_V2 BT_EVT_BIT(37)
#define BT_EVT_MASK_LE_PER_ADV_SUBEVENT_DATA_REQ BT_EVT_BIT(38)
#define BT_EVT_MASK_LE_PER_ADV_RESPONSE_REPORT BT_EVT_BIT(39)
#define BT_EVT_MASK_LE_ENH_CONN_COMPLETE_V2 BT_EVT_BIT(40)
/** HCI Error Codes, BT Core Spec v5.4 [Vol 1, Part F]. */
#define BT_HCI_ERR_SUCCESS 0x00
#define BT_HCI_ERR_UNKNOWN_CMD 0x01
#define BT_HCI_ERR_UNKNOWN_CONN_ID 0x02
#define BT_HCI_ERR_HW_FAILURE 0x03
#define BT_HCI_ERR_PAGE_TIMEOUT 0x04
#define BT_HCI_ERR_AUTH_FAIL 0x05
#define BT_HCI_ERR_PIN_OR_KEY_MISSING 0x06
#define BT_HCI_ERR_MEM_CAPACITY_EXCEEDED 0x07
#define BT_HCI_ERR_CONN_TIMEOUT 0x08
#define BT_HCI_ERR_CONN_LIMIT_EXCEEDED 0x09
#define BT_HCI_ERR_SYNC_CONN_LIMIT_EXCEEDED 0x0a
#define BT_HCI_ERR_CONN_ALREADY_EXISTS 0x0b
#define BT_HCI_ERR_CMD_DISALLOWED 0x0c
#define BT_HCI_ERR_INSUFFICIENT_RESOURCES 0x0d
#define BT_HCI_ERR_INSUFFICIENT_SECURITY 0x0e
#define BT_HCI_ERR_BD_ADDR_UNACCEPTABLE 0x0f
#define BT_HCI_ERR_CONN_ACCEPT_TIMEOUT 0x10
#define BT_HCI_ERR_UNSUPP_FEATURE_PARAM_VAL 0x11
#define BT_HCI_ERR_INVALID_PARAM 0x12
#define BT_HCI_ERR_REMOTE_USER_TERM_CONN 0x13
#define BT_HCI_ERR_REMOTE_LOW_RESOURCES 0x14
#define BT_HCI_ERR_REMOTE_POWER_OFF 0x15
#define BT_HCI_ERR_LOCALHOST_TERM_CONN 0x16
#define BT_HCI_ERR_REPEATED_ATTEMPTS 0x17
#define BT_HCI_ERR_PAIRING_NOT_ALLOWED 0x18
#define BT_HCI_ERR_UNKNOWN_LMP_PDU 0x19
#define BT_HCI_ERR_UNSUPP_REMOTE_FEATURE 0x1a
#define BT_HCI_ERR_SCO_OFFSET_REJECTED 0x1b
#define BT_HCI_ERR_SCO_INTERVAL_REJECTED 0x1c
#define BT_HCI_ERR_SCO_AIR_MODE_REJECTED 0x1d
#define BT_HCI_ERR_INVALID_LL_PARAM 0x1e
#define BT_HCI_ERR_UNSPECIFIED 0x1f
#define BT_HCI_ERR_UNSUPP_LL_PARAM_VAL 0x20
#define BT_HCI_ERR_ROLE_CHANGE_NOT_ALLOWED 0x21
#define BT_HCI_ERR_LL_RESP_TIMEOUT 0x22
#define BT_HCI_ERR_LL_PROC_COLLISION 0x23
#define BT_HCI_ERR_LMP_PDU_NOT_ALLOWED 0x24
#define BT_HCI_ERR_ENC_MODE_NOT_ACCEPTABLE 0x25
#define BT_HCI_ERR_LINK_KEY_CANNOT_BE_CHANGED 0x26
#define BT_HCI_ERR_REQUESTED_QOS_NOT_SUPPORTED 0x27
#define BT_HCI_ERR_INSTANT_PASSED 0x28
#define BT_HCI_ERR_PAIRING_NOT_SUPPORTED 0x29
#define BT_HCI_ERR_DIFF_TRANS_COLLISION 0x2a
#define BT_HCI_ERR_QOS_UNACCEPTABLE_PARAM 0x2c
#define BT_HCI_ERR_QOS_REJECTED 0x2d
#define BT_HCI_ERR_CHAN_ASSESS_NOT_SUPPORTED 0x2e
#define BT_HCI_ERR_INSUFF_SECURITY 0x2f
#define BT_HCI_ERR_PARAM_OUT_OF_MANDATORY_RANGE 0x30
#define BT_HCI_ERR_ROLE_SWITCH_PENDING 0x32
#define BT_HCI_ERR_RESERVED_SLOT_VIOLATION 0x34
#define BT_HCI_ERR_ROLE_SWITCH_FAILED 0x35
#define BT_HCI_ERR_EXT_INQ_RESP_TOO_LARGE 0x36
#define BT_HCI_ERR_SIMPLE_PAIR_NOT_SUPP_BY_HOST 0x37
#define BT_HCI_ERR_HOST_BUSY_PAIRING 0x38
#define BT_HCI_ERR_CONN_REJECTED_DUE_TO_NO_CHAN 0x39
#define BT_HCI_ERR_CONTROLLER_BUSY 0x3a
#define BT_HCI_ERR_UNACCEPT_CONN_PARAM 0x3b
#define BT_HCI_ERR_ADV_TIMEOUT 0x3c
#define BT_HCI_ERR_TERM_DUE_TO_MIC_FAIL 0x3d
#define BT_HCI_ERR_CONN_FAIL_TO_ESTAB 0x3e
#define BT_HCI_ERR_MAC_CONN_FAILED 0x3f
#define BT_HCI_ERR_CLOCK_ADJUST_REJECTED 0x40
#define BT_HCI_ERR_SUBMAP_NOT_DEFINED 0x41
#define BT_HCI_ERR_UNKNOWN_ADV_IDENTIFIER 0x42
#define BT_HCI_ERR_LIMIT_REACHED 0x43
#define BT_HCI_ERR_OP_CANCELLED_BY_HOST 0x44
#define BT_HCI_ERR_PACKET_TOO_LONG 0x45
#define BT_HCI_ERR_TOO_LATE 0x46
#define BT_HCI_ERR_TOO_EARLY 0x47
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_HCI_TYPES_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/hci_types.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 31,493 |
```objective-c
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_MESH_PRIV_BEACON_SRV_H__
#define ZEPHYR_INCLUDE_BLUETOOTH_MESH_PRIV_BEACON_SRV_H__
#include <zephyr/bluetooth/mesh.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup bt_mesh_priv_beacon_srv Bluetooth Mesh Private Beacon Server
* @ingroup bt_mesh
* @{
*/
/**
*
* @brief Private Beacon Server model composition data entry.
*/
#define BT_MESH_MODEL_PRIV_BEACON_SRV \
BT_MESH_MODEL_CB(BT_MESH_MODEL_ID_PRIV_BEACON_SRV, \
bt_mesh_priv_beacon_srv_op, NULL, NULL, \
&bt_mesh_priv_beacon_srv_cb)
/** @cond INTERNAL_HIDDEN */
extern const struct bt_mesh_model_op bt_mesh_priv_beacon_srv_op[];
extern const struct bt_mesh_model_cb bt_mesh_priv_beacon_srv_cb;
/** @endcond */
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_MESH_PRIV_BEACON_SRV_H__ */
``` | /content/code_sandbox/include/zephyr/bluetooth/mesh/priv_beacon_srv.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 232 |
```objective-c
/** @file
* @brief Configuration Server Model APIs.
*/
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_MESH_CFG_SRV_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_MESH_CFG_SRV_H_
/**
* @brief Configuration Server Model
* @defgroup bt_mesh_cfg_srv Configuration Server Model
* @ingroup bt_mesh
* @{
*/
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Generic Configuration Server model composition data entry.
*/
#define BT_MESH_MODEL_CFG_SRV \
BT_MESH_MODEL_CNT_CB(BT_MESH_MODEL_ID_CFG_SRV, \
bt_mesh_cfg_srv_op, NULL, \
NULL, 1, 0, &bt_mesh_cfg_srv_cb)
/** @cond INTERNAL_HIDDEN */
extern const struct bt_mesh_model_op bt_mesh_cfg_srv_op[];
extern const struct bt_mesh_model_cb bt_mesh_cfg_srv_cb;
/** @endcond */
#ifdef __cplusplus
}
#endif
/**
* @}
*/
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_MESH_CFG_SRV_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/mesh/cfg_srv.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 218 |
```objective-c
/*
*
*/
/**
* @file
* @defgroup bt_mesh_dfd_srv Firmware Distribution Server model
* @ingroup bt_mesh_dfd
* @{
* @brief API for the Firmware Distribution Server model
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_MESH_DFD_SRV_H__
#define ZEPHYR_INCLUDE_BLUETOOTH_MESH_DFD_SRV_H__
#include <zephyr/bluetooth/mesh/access.h>
#include <zephyr/bluetooth/mesh/dfd.h>
#include <zephyr/bluetooth/mesh/blob_srv.h>
#include <zephyr/bluetooth/mesh/blob_cli.h>
#include <zephyr/bluetooth/mesh/dfu_cli.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef CONFIG_BT_MESH_DFD_SRV_TARGETS_MAX
#define CONFIG_BT_MESH_DFD_SRV_TARGETS_MAX 0
#endif
#ifndef CONFIG_BT_MESH_DFD_SRV_SLOT_MAX_SIZE
#define CONFIG_BT_MESH_DFD_SRV_SLOT_MAX_SIZE 0
#endif
#ifndef CONFIG_BT_MESH_DFD_SRV_SLOT_SPACE
#define CONFIG_BT_MESH_DFD_SRV_SLOT_SPACE 0
#endif
struct bt_mesh_dfd_srv;
#ifdef CONFIG_BT_MESH_DFD_SRV_OOB_UPLOAD
/**
*
* @brief Initialization parameters for the @ref bt_mesh_dfd_srv with OOB
* upload support.
*
* @param[in] _cb Pointer to a @ref bt_mesh_dfd_srv_cb instance.
* @param[in] _oob_schemes Array of OOB schemes supported by the server,
* each scheme being a code point from the
* Bluetooth SIG Assigned Numbers document.
* @param[in] _oob_schemes_count Number of schemes in @c _oob_schemes.
*/
#define BT_MESH_DFD_SRV_OOB_INIT(_cb, _oob_schemes, _oob_schemes_count) \
{ \
.cb = _cb, \
.dfu = BT_MESH_DFU_CLI_INIT(&_bt_mesh_dfd_srv_dfu_cb), \
.upload = { \
.blob = { .cb = &_bt_mesh_dfd_srv_blob_cb }, \
}, \
.oob_schemes = { \
.schemes = _oob_schemes, \
.count = _oob_schemes_count, \
}, \
}
#endif /* CONFIG_BT_MESH_DFD_SRV_OOB_UPLOAD */
/**
*
* @brief Initialization parameters for the @ref bt_mesh_dfd_srv.
*
* @param[in] _cb Pointer to a @ref bt_mesh_dfd_srv_cb instance.
*/
#define BT_MESH_DFD_SRV_INIT(_cb) \
{ \
.cb = _cb, \
.dfu = BT_MESH_DFU_CLI_INIT(&_bt_mesh_dfd_srv_dfu_cb), \
.upload = { \
.blob = { .cb = &_bt_mesh_dfd_srv_blob_cb }, \
}, \
}
/**
*
* @brief Firmware Distribution Server model Composition Data entry.
*
* @param _srv Pointer to a @ref bt_mesh_dfd_srv instance.
*/
#define BT_MESH_MODEL_DFD_SRV(_srv) \
BT_MESH_MODEL_DFU_CLI(&(_srv)->dfu), \
BT_MESH_MODEL_BLOB_SRV(&(_srv)->upload.blob), \
BT_MESH_MODEL_CB(BT_MESH_MODEL_ID_DFD_SRV, _bt_mesh_dfd_srv_op, NULL, \
_srv, &_bt_mesh_dfd_srv_cb)
/** Firmware Distribution Server callbacks: */
struct bt_mesh_dfd_srv_cb {
/** @brief Slot receive callback.
*
* Called at the start of an upload procedure. The callback must fill
* @c io with a pointer to a writable BLOB stream for the Firmware Distribution
* Server to write the firmware image to.
*
* @param srv Firmware Distribution Server model instance.
* @param slot DFU image slot being received.
* @param io BLOB stream response pointer.
*
* @return 0 on success, or (negative) error code otherwise.
*/
int (*recv)(struct bt_mesh_dfd_srv *srv,
const struct bt_mesh_dfu_slot *slot,
const struct bt_mesh_blob_io **io);
#ifdef CONFIG_BT_MESH_DFD_SRV_OOB_UPLOAD
/** @brief Firmware upload OOB start callback.
*
* Called at the start of an OOB firmware upload. The application must
* start a firmware check using an OOB mechanism, and then call
* @ref bt_mesh_dfd_srv_oob_check_complete. Depending on the return
* value of this function, the application must then start storing the
* firmware image using an OOB mechanism, and call
* @ref bt_mesh_dfd_srv_oob_store_complete. This callback is mandatory
* to support OOB uploads.
*
* @param srv Firmware Distribution Server model instance.
* @param slot Slot to be used for the upload.
* @param uri Pointer to buffer containing the URI used to
* check for new firmware.
* @param uri_len Length of the URI buffer.
* @param fwid Pointer to buffer containing the current
* firmware ID to be used when checking for
* availability of new firmware.
* @param fwid_len Length of the current firmware ID. Must be set
* to the length of the new firmware ID if it is
* available, or to 0 if new firmware is not
* available.
*
* @return BT_MESH_DFD_SUCCESS on success, or error code otherwise.
*/
int (*start_oob_upload)(struct bt_mesh_dfd_srv *srv,
const struct bt_mesh_dfu_slot *slot,
const char *uri, uint8_t uri_len,
const uint8_t *fwid, uint16_t fwid_len);
/** @brief Cancel store OOB callback
*
* Called when an OOB store is cancelled. The application must stop
* any ongoing OOB image transfer. This callback is mandatory to
* support OOB uploads.
*
* @param srv Firmware Distribution Server model instance.
* @param slot DFU image slot to cancel
*/
void (*cancel_oob_upload)(struct bt_mesh_dfd_srv *srv,
const struct bt_mesh_dfu_slot *slot);
/** @brief Get the progress of an ongoing OOB store
*
* Called by the Firmware Distribution Server model when it needs to
* get the current progress of an ongoing OOB store from the
* application. This callback is mandatory to support OOB uploads.
*
* @param srv Firmware Distribution Server model instance.
* @param slot DFU image slot to get progress for.
*
* @return The current progress of the ongoing OOB store, in percent.
*/
uint8_t (*oob_progress_get)(struct bt_mesh_dfd_srv *srv,
const struct bt_mesh_dfu_slot *slot);
#endif /* CONFIG_BT_MESH_DFD_SRV_OOB_UPLOAD */
/** @brief Slot delete callback.
*
* Called when the Firmware Distribution Server is about to delete a DFU image slot.
* All allocated data associated with the firmware slot should be
* deleted.
*
* @param srv Firmware Update Server instance.
* @param slot DFU image slot being deleted.
*/
void (*del)(struct bt_mesh_dfd_srv *srv,
const struct bt_mesh_dfu_slot *slot);
/** @brief Slot send callback.
*
* Called at the start of a distribution procedure. The callback must
* fill @c io with a pointer to a readable BLOB stream for the Firmware
* Distribution Server to read the firmware image from.
*
* @param srv Firmware Distribution Server model instance.
* @param slot DFU image slot being sent.
* @param io BLOB stream response pointer.
*
* @return 0 on success, or (negative) error code otherwise.
*/
int (*send)(struct bt_mesh_dfd_srv *srv,
const struct bt_mesh_dfu_slot *slot,
const struct bt_mesh_blob_io **io);
/** @brief Phase change callback (Optional).
*
* Called whenever the phase of the Firmware Distribution Server changes.
*
* @param srv Firmware Distribution Server model instance.
* @param phase New Firmware Distribution phase.
*/
void (*phase)(struct bt_mesh_dfd_srv *srv, enum bt_mesh_dfd_phase phase);
};
/** Firmware Distribution Server instance. */
struct bt_mesh_dfd_srv {
const struct bt_mesh_dfd_srv_cb *cb;
const struct bt_mesh_model *mod;
struct bt_mesh_dfu_cli dfu;
struct bt_mesh_dfu_target targets[CONFIG_BT_MESH_DFD_SRV_TARGETS_MAX];
struct bt_mesh_blob_target_pull pull_ctxs[CONFIG_BT_MESH_DFD_SRV_TARGETS_MAX];
const struct bt_mesh_blob_io *io;
uint16_t target_cnt;
uint16_t slot_idx;
bool apply;
enum bt_mesh_dfd_phase phase;
struct bt_mesh_blob_cli_inputs inputs;
struct {
enum bt_mesh_dfd_upload_phase phase;
struct bt_mesh_dfu_slot *slot;
const struct flash_area *area;
struct bt_mesh_blob_srv blob;
#ifdef CONFIG_BT_MESH_DFD_SRV_OOB_UPLOAD
bool is_oob;
bool is_pending_oob_check;
struct {
uint8_t uri_len;
uint8_t uri[CONFIG_BT_MESH_DFU_URI_MAXLEN];
uint16_t current_fwid_len;
uint8_t current_fwid[CONFIG_BT_MESH_DFU_FWID_MAXLEN];
struct bt_mesh_msg_ctx ctx;
} oob;
#endif /* CONFIG_BT_MESH_DFD_SRV_OOB_UPLOAD */
} upload;
#ifdef CONFIG_BT_MESH_DFD_SRV_OOB_UPLOAD
struct {
const uint8_t *schemes;
const uint8_t count;
} oob_schemes;
#endif /* CONFIG_BT_MESH_DFD_SRV_OOB_UPLOAD */
};
#ifdef CONFIG_BT_MESH_DFD_SRV_OOB_UPLOAD
/** @brief Call when an OOB check has completed or failed
*
* This should be called by the application after an OOB check started by the @c start_oob_upload
* callback has completed or failed. The @p status param should be set to one of the following
* values:
*
* * @c BT_MESH_DFD_SUCCESS if the check was successful and a new firmware ID was found.
* * @c BT_MESH_DFD_ERR_URI_MALFORMED if the URI is not formatted correctly.
* * @c BT_MESH_DFD_ERR_URI_NOT_SUPPORTED if the URI scheme is not supported by the node.
* * @c BT_MESH_DFD_ERR_URI_UNREACHABLE if the URI can't be reached.
* * @c BT_MESH_DFD_ERR_NEW_FW_NOT_AVAILABLE if the check completes successfully but no new
* firmware is available.
*
* If this function returns 0, the application should then download the firmware to the
* slot. If an error code is returned, the application should abort the OOB upload.
*
* @param srv Firmware Distribution Server model instance.
* @param slot The slot used in the OOB upload.
* @param status The result of the firmware check.
* @param fwid If the check was successful and new firmware found, this should point to a
* buffer containing the new firmware ID to store.
* @param fwid_len The length of the firmware ID pointed to by @p fwid.
*
* @return 0 on success, (negative) error code otherwise.
*/
int bt_mesh_dfd_srv_oob_check_complete(struct bt_mesh_dfd_srv *srv,
const struct bt_mesh_dfu_slot *slot, int status,
uint8_t *fwid, size_t fwid_len);
/** @brief Call when an OOB store has completed or failed
*
* This should be called by the application after an OOB store started after a successful call to
* @c bt_mesh_dfd_srv_oob_check_complete has completed successfully or failed.
*
* @param srv Firmware Distribution Server model instance.
* @param slot The slot used when storing the firmware image.
* @param success @c true if the OOB store completed successfully, @c false otherwise.
* @param size The size of the stored firmware image, in bytes.
* @param metadata Pointer to the metadata received OOB, or @c NULL if no metadata was
* received.
* @param metadata_len Size of the metadata pointed to by @p metadata.
*
* @return 0 on success, (negative) error code otherwise.
*/
int bt_mesh_dfd_srv_oob_store_complete(struct bt_mesh_dfd_srv *srv,
const struct bt_mesh_dfu_slot *slot, bool success,
size_t size, const uint8_t *metadata, size_t metadata_len);
#endif /* CONFIG_BT_MESH_DFD_SRV_OOB_UPLOAD */
/** @cond INTERNAL_HIDDEN */
extern const struct bt_mesh_model_op _bt_mesh_dfd_srv_op[];
extern const struct bt_mesh_model_cb _bt_mesh_dfd_srv_cb;
extern const struct bt_mesh_dfu_cli_cb _bt_mesh_dfd_srv_dfu_cb;
extern const struct bt_mesh_blob_srv_cb _bt_mesh_dfd_srv_blob_cb;
/** @endcond */
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_MESH_DFD_SRV_H__ */
/** @} */
``` | /content/code_sandbox/include/zephyr/bluetooth/mesh/dfd_srv.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 2,955 |
```objective-c
/** @file
* @brief Keys APIs.
*/
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_MESH_KEYS_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_MESH_KEYS_H_
#include <stdint.h>
#if defined CONFIG_BT_MESH_USES_MBEDTLS_PSA || defined CONFIG_BT_MESH_USES_TFM_PSA
#include <psa/crypto.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
#if defined CONFIG_BT_MESH_USES_MBEDTLS_PSA || defined CONFIG_BT_MESH_USES_TFM_PSA
/** The structure that keeps representation of key. */
struct bt_mesh_key {
/** PSA key representation is the PSA key identifier. */
psa_key_id_t key;
};
#elif defined CONFIG_BT_MESH_USES_TINYCRYPT
/** The structure that keeps representation of key. */
struct bt_mesh_key {
/** tinycrypt key representation is the pure key value. */
uint8_t key[16];
};
#else
#error "Crypto library has not been chosen"
#endif
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_MESH_KEYS_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/mesh/keys.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 236 |
```objective-c
/** @file
* @brief Access layer APIs.
*/
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_MESH_ACCESS_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_MESH_ACCESS_H_
#include <zephyr/sys/util.h>
#include <zephyr/settings/settings.h>
#include <zephyr/bluetooth/mesh/msg.h>
/* Internal macros used to initialize array members */
#define BT_MESH_KEY_UNUSED_ELT_(IDX, _) BT_MESH_KEY_UNUSED
#define BT_MESH_ADDR_UNASSIGNED_ELT_(IDX, _) BT_MESH_ADDR_UNASSIGNED
#define BT_MESH_UUID_UNASSIGNED_ELT_(IDX, _) NULL
#define BT_MESH_MODEL_KEYS_UNUSED(_keys) \
{ LISTIFY(_keys, BT_MESH_KEY_UNUSED_ELT_, (,)) }
#define BT_MESH_MODEL_GROUPS_UNASSIGNED(_grps) \
{ LISTIFY(_grps, BT_MESH_ADDR_UNASSIGNED_ELT_, (,)) }
#if CONFIG_BT_MESH_LABEL_COUNT > 0
#define BT_MESH_MODEL_UUIDS_UNASSIGNED() \
.uuids = (const uint8_t *[]){ LISTIFY(CONFIG_BT_MESH_LABEL_COUNT, \
BT_MESH_UUID_UNASSIGNED_ELT_, (,)) },
#else
#define BT_MESH_MODEL_UUIDS_UNASSIGNED()
#endif
#define BT_MESH_MODEL_RUNTIME_INIT(_user_data) \
.rt = &(struct bt_mesh_model_rt_ctx){ .user_data = (_user_data) },
/**
* @brief Access layer
* @defgroup bt_mesh_access Access layer
* @ingroup bt_mesh
* @{
*/
#ifdef __cplusplus
extern "C" {
#endif
/**
* @name Group addresses
* @{
*/
#define BT_MESH_ADDR_UNASSIGNED 0x0000 /**< unassigned */
#define BT_MESH_ADDR_ALL_NODES 0xffff /**< all-nodes */
#define BT_MESH_ADDR_RELAYS 0xfffe /**< all-relays */
#define BT_MESH_ADDR_FRIENDS 0xfffd /**< all-friends */
#define BT_MESH_ADDR_PROXIES 0xfffc /**< all-proxies */
#define BT_MESH_ADDR_DFW_NODES 0xfffb /**< all-directed-forwarding-nodes */
#define BT_MESH_ADDR_IP_NODES 0xfffa /**< all-ipt-nodes */
#define BT_MESH_ADDR_IP_BR_ROUTERS 0xfff9 /**< all-ipt-border-routers */
/**
* @}
*/
/**
* @name Predefined key indexes
* @{
*/
#define BT_MESH_KEY_UNUSED 0xffff /**< Key unused */
#define BT_MESH_KEY_ANY 0xffff /**< Any key index */
#define BT_MESH_KEY_DEV 0xfffe /**< Device key */
#define BT_MESH_KEY_DEV_LOCAL BT_MESH_KEY_DEV /**< Local device key */
#define BT_MESH_KEY_DEV_REMOTE 0xfffd /**< Remote device key */
#define BT_MESH_KEY_DEV_ANY 0xfffc /**< Any device key */
/**
* @}
*/
/**
* Check if a Bluetooth Mesh address is a unicast address.
*/
#define BT_MESH_ADDR_IS_UNICAST(addr) ((addr) && (addr) < 0x8000)
/**
* Check if a Bluetooth Mesh address is a group address.
*/
#define BT_MESH_ADDR_IS_GROUP(addr) ((addr) >= 0xc000 && (addr) < 0xff00)
/**
* Check if a Bluetooth Mesh address is a fixed group address.
*/
#define BT_MESH_ADDR_IS_FIXED_GROUP(addr) ((addr) >= 0xff00 && (addr) < 0xffff)
/**
* Check if a Bluetooth Mesh address is a virtual address.
*/
#define BT_MESH_ADDR_IS_VIRTUAL(addr) ((addr) >= 0x8000 && (addr) < 0xc000)
/**
* Check if a Bluetooth Mesh address is an RFU address.
*/
#define BT_MESH_ADDR_IS_RFU(addr) ((addr) >= 0xff00 && (addr) <= 0xfff8)
/**
* Check if a Bluetooth Mesh key is a device key.
*/
#define BT_MESH_IS_DEV_KEY(key) (key == BT_MESH_KEY_DEV_LOCAL || \
key == BT_MESH_KEY_DEV_REMOTE)
/** Maximum size of an access message segment (in octets). */
#define BT_MESH_APP_SEG_SDU_MAX 12
/** Maximum payload size of an unsegmented access message (in octets). */
#define BT_MESH_APP_UNSEG_SDU_MAX 15
/** Maximum number of segments supported for incoming messages. */
#if defined(CONFIG_BT_MESH_RX_SEG_MAX)
#define BT_MESH_RX_SEG_MAX CONFIG_BT_MESH_RX_SEG_MAX
#else
#define BT_MESH_RX_SEG_MAX 0
#endif
/** Maximum number of segments supported for outgoing messages. */
#if defined(CONFIG_BT_MESH_TX_SEG_MAX)
#define BT_MESH_TX_SEG_MAX CONFIG_BT_MESH_TX_SEG_MAX
#else
#define BT_MESH_TX_SEG_MAX 0
#endif
/** Maximum possible payload size of an outgoing access message (in octets). */
#define BT_MESH_TX_SDU_MAX MAX((BT_MESH_TX_SEG_MAX * \
BT_MESH_APP_SEG_SDU_MAX), \
BT_MESH_APP_UNSEG_SDU_MAX)
/** Maximum possible payload size of an incoming access message (in octets). */
#define BT_MESH_RX_SDU_MAX MAX((BT_MESH_RX_SEG_MAX * \
BT_MESH_APP_SEG_SDU_MAX), \
BT_MESH_APP_UNSEG_SDU_MAX)
/** Helper to define a mesh element within an array.
*
* In case the element has no SIG or Vendor models the helper
* macro BT_MESH_MODEL_NONE can be given instead.
*
* @param _loc Location Descriptor.
* @param _mods Array of models.
* @param _vnd_mods Array of vendor models.
*/
#define BT_MESH_ELEM(_loc, _mods, _vnd_mods) \
{ \
.rt = &(struct bt_mesh_elem_rt_ctx) { 0 }, \
.loc = (_loc), \
.model_count = ARRAY_SIZE(_mods), \
.vnd_model_count = ARRAY_SIZE(_vnd_mods), \
.models = (_mods), \
.vnd_models = (_vnd_mods), \
}
/** Abstraction that describes a Mesh Element */
struct bt_mesh_elem {
/** Mesh Element runtime information */
struct bt_mesh_elem_rt_ctx {
/** Unicast Address. Set at runtime during provisioning. */
uint16_t addr;
} * const rt;
/** Location Descriptor (GATT Bluetooth Namespace Descriptors) */
const uint16_t loc;
/** The number of SIG models in this element */
const uint8_t model_count;
/** The number of vendor models in this element */
const uint8_t vnd_model_count;
/** The list of SIG models in this element */
const struct bt_mesh_model * const models;
/** The list of vendor models in this element */
const struct bt_mesh_model * const vnd_models;
};
/**
* @name Foundation Models
* @{
*/
/** Configuration Server */
#define BT_MESH_MODEL_ID_CFG_SRV 0x0000
/** Configuration Client */
#define BT_MESH_MODEL_ID_CFG_CLI 0x0001
/** Health Server */
#define BT_MESH_MODEL_ID_HEALTH_SRV 0x0002
/** Health Client */
#define BT_MESH_MODEL_ID_HEALTH_CLI 0x0003
/** Remote Provisioning Server */
#define BT_MESH_MODEL_ID_REMOTE_PROV_SRV 0x0004
/** Remote Provisioning Client */
#define BT_MESH_MODEL_ID_REMOTE_PROV_CLI 0x0005
/** Private Beacon Server */
#define BT_MESH_MODEL_ID_PRIV_BEACON_SRV 0x000a
/** Private Beacon Client */
#define BT_MESH_MODEL_ID_PRIV_BEACON_CLI 0x000b
/** SAR Configuration Server */
#define BT_MESH_MODEL_ID_SAR_CFG_SRV 0x000e
/** SAR Configuration Client */
#define BT_MESH_MODEL_ID_SAR_CFG_CLI 0x000f
/** Opcodes Aggregator Server */
#define BT_MESH_MODEL_ID_OP_AGG_SRV 0x0010
/** Opcodes Aggregator Client */
#define BT_MESH_MODEL_ID_OP_AGG_CLI 0x0011
/** Large Composition Data Server */
#define BT_MESH_MODEL_ID_LARGE_COMP_DATA_SRV 0x0012
/** Large Composition Data Client */
#define BT_MESH_MODEL_ID_LARGE_COMP_DATA_CLI 0x0013
/** Solicitation PDU RPL Configuration Client */
#define BT_MESH_MODEL_ID_SOL_PDU_RPL_SRV 0x0014
/** Solicitation PDU RPL Configuration Server */
#define BT_MESH_MODEL_ID_SOL_PDU_RPL_CLI 0x0015
/** Private Proxy Server */
#define BT_MESH_MODEL_ID_ON_DEMAND_PROXY_SRV 0x000c
/** Private Proxy Client */
#define BT_MESH_MODEL_ID_ON_DEMAND_PROXY_CLI 0x000d
/**
* @}
*/
/**
* @name Models from the Mesh Model Specification
* @{
*/
/** Generic OnOff Server */
#define BT_MESH_MODEL_ID_GEN_ONOFF_SRV 0x1000
/** Generic OnOff Client */
#define BT_MESH_MODEL_ID_GEN_ONOFF_CLI 0x1001
/** Generic Level Server */
#define BT_MESH_MODEL_ID_GEN_LEVEL_SRV 0x1002
/** Generic Level Client */
#define BT_MESH_MODEL_ID_GEN_LEVEL_CLI 0x1003
/** Generic Default Transition Time Server */
#define BT_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_SRV 0x1004
/** Generic Default Transition Time Client */
#define BT_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_CLI 0x1005
/** Generic Power OnOff Server */
#define BT_MESH_MODEL_ID_GEN_POWER_ONOFF_SRV 0x1006
/** Generic Power OnOff Setup Server */
#define BT_MESH_MODEL_ID_GEN_POWER_ONOFF_SETUP_SRV 0x1007
/** Generic Power OnOff Client */
#define BT_MESH_MODEL_ID_GEN_POWER_ONOFF_CLI 0x1008
/** Generic Power Level Server */
#define BT_MESH_MODEL_ID_GEN_POWER_LEVEL_SRV 0x1009
/** Generic Power Level Setup Server */
#define BT_MESH_MODEL_ID_GEN_POWER_LEVEL_SETUP_SRV 0x100a
/** Generic Power Level Client */
#define BT_MESH_MODEL_ID_GEN_POWER_LEVEL_CLI 0x100b
/** Generic Battery Server */
#define BT_MESH_MODEL_ID_GEN_BATTERY_SRV 0x100c
/** Generic Battery Client */
#define BT_MESH_MODEL_ID_GEN_BATTERY_CLI 0x100d
/** Generic Location Server */
#define BT_MESH_MODEL_ID_GEN_LOCATION_SRV 0x100e
/** Generic Location Setup Server */
#define BT_MESH_MODEL_ID_GEN_LOCATION_SETUPSRV 0x100f
/** Generic Location Client */
#define BT_MESH_MODEL_ID_GEN_LOCATION_CLI 0x1010
/** Generic Admin Property Server */
#define BT_MESH_MODEL_ID_GEN_ADMIN_PROP_SRV 0x1011
/** Generic Manufacturer Property Server */
#define BT_MESH_MODEL_ID_GEN_MANUFACTURER_PROP_SRV 0x1012
/** Generic User Property Server */
#define BT_MESH_MODEL_ID_GEN_USER_PROP_SRV 0x1013
/** Generic Client Property Server */
#define BT_MESH_MODEL_ID_GEN_CLIENT_PROP_SRV 0x1014
/** Generic Property Client */
#define BT_MESH_MODEL_ID_GEN_PROP_CLI 0x1015
/** Sensor Server */
#define BT_MESH_MODEL_ID_SENSOR_SRV 0x1100
/** Sensor Setup Server */
#define BT_MESH_MODEL_ID_SENSOR_SETUP_SRV 0x1101
/** Sensor Client */
#define BT_MESH_MODEL_ID_SENSOR_CLI 0x1102
/** Time Server */
#define BT_MESH_MODEL_ID_TIME_SRV 0x1200
/** Time Setup Server */
#define BT_MESH_MODEL_ID_TIME_SETUP_SRV 0x1201
/** Time Client */
#define BT_MESH_MODEL_ID_TIME_CLI 0x1202
/** Scene Server */
#define BT_MESH_MODEL_ID_SCENE_SRV 0x1203
/** Scene Setup Server */
#define BT_MESH_MODEL_ID_SCENE_SETUP_SRV 0x1204
/** Scene Client */
#define BT_MESH_MODEL_ID_SCENE_CLI 0x1205
/** Scheduler Server */
#define BT_MESH_MODEL_ID_SCHEDULER_SRV 0x1206
/** Scheduler Setup Server */
#define BT_MESH_MODEL_ID_SCHEDULER_SETUP_SRV 0x1207
/** Scheduler Client */
#define BT_MESH_MODEL_ID_SCHEDULER_CLI 0x1208
/** Light Lightness Server */
#define BT_MESH_MODEL_ID_LIGHT_LIGHTNESS_SRV 0x1300
/** Light Lightness Setup Server */
#define BT_MESH_MODEL_ID_LIGHT_LIGHTNESS_SETUP_SRV 0x1301
/** Light Lightness Client */
#define BT_MESH_MODEL_ID_LIGHT_LIGHTNESS_CLI 0x1302
/** Light CTL Server */
#define BT_MESH_MODEL_ID_LIGHT_CTL_SRV 0x1303
/** Light CTL Setup Server */
#define BT_MESH_MODEL_ID_LIGHT_CTL_SETUP_SRV 0x1304
/** Light CTL Client */
#define BT_MESH_MODEL_ID_LIGHT_CTL_CLI 0x1305
/** Light CTL Temperature Server */
#define BT_MESH_MODEL_ID_LIGHT_CTL_TEMP_SRV 0x1306
/** Light HSL Server */
#define BT_MESH_MODEL_ID_LIGHT_HSL_SRV 0x1307
/** Light HSL Setup Server */
#define BT_MESH_MODEL_ID_LIGHT_HSL_SETUP_SRV 0x1308
/** Light HSL Client */
#define BT_MESH_MODEL_ID_LIGHT_HSL_CLI 0x1309
/** Light HSL Hue Server */
#define BT_MESH_MODEL_ID_LIGHT_HSL_HUE_SRV 0x130a
/** Light HSL Saturation Server */
#define BT_MESH_MODEL_ID_LIGHT_HSL_SAT_SRV 0x130b
/** Light xyL Server */
#define BT_MESH_MODEL_ID_LIGHT_XYL_SRV 0x130c
/** Light xyL Setup Server */
#define BT_MESH_MODEL_ID_LIGHT_XYL_SETUP_SRV 0x130d
/** Light xyL Client */
#define BT_MESH_MODEL_ID_LIGHT_XYL_CLI 0x130e
/** Light LC Server */
#define BT_MESH_MODEL_ID_LIGHT_LC_SRV 0x130f
/** Light LC Setup Server */
#define BT_MESH_MODEL_ID_LIGHT_LC_SETUPSRV 0x1310
/** Light LC Client */
#define BT_MESH_MODEL_ID_LIGHT_LC_CLI 0x1311
/**
* @}
*/
/**
* @name Models from the Mesh Binary Large Object Transfer Model Specification
* @{
*/
/** BLOB Transfer Server */
#define BT_MESH_MODEL_ID_BLOB_SRV 0x1400
/** BLOB Transfer Client */
#define BT_MESH_MODEL_ID_BLOB_CLI 0x1401
/**
* @}
*/
/**
* @name Models from the Mesh Device Firmware Update Model Specification
* @{
*/
/** Firmware Update Server */
#define BT_MESH_MODEL_ID_DFU_SRV 0x1402
/** Firmware Update Client */
#define BT_MESH_MODEL_ID_DFU_CLI 0x1403
/** Firmware Distribution Server */
#define BT_MESH_MODEL_ID_DFD_SRV 0x1404
/** Firmware Distribution Client */
#define BT_MESH_MODEL_ID_DFD_CLI 0x1405
/**
* @}
*/
/** Model opcode handler. */
struct bt_mesh_model_op {
/** OpCode encoded using the BT_MESH_MODEL_OP_* macros */
const uint32_t opcode;
/** Message length. If the message has variable length then this value
* indicates minimum message length and should be positive. Handler
* function should verify precise length based on the contents of the
* message. If the message has fixed length then this value should
* be negative. Use BT_MESH_LEN_* macros when defining this value.
*/
const ssize_t len;
/** @brief Handler function for this opcode.
*
* @param model Model instance receiving the message.
* @param ctx Message context for the message.
* @param buf Message buffer containing the message payload, not
* including the opcode.
*
* @return Zero on success or (negative) error code otherwise.
*/
int (*const func)(const struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *buf);
};
#define BT_MESH_MODEL_OP_1(b0) (b0)
#define BT_MESH_MODEL_OP_2(b0, b1) (((b0) << 8) | (b1))
#define BT_MESH_MODEL_OP_3(b0, cid) ((((b0) << 16) | 0xc00000) | (cid))
/** Macro for encoding exact message length for fixed-length messages. */
#define BT_MESH_LEN_EXACT(len) (-len)
/** Macro for encoding minimum message length for variable-length messages. */
#define BT_MESH_LEN_MIN(len) (len)
/** End of the opcode list. Must always be present. */
#define BT_MESH_MODEL_OP_END { 0, 0, NULL }
#if !defined(__cplusplus) || defined(__DOXYGEN__)
/**
* @brief Helper to define an empty opcode list.
*
* This macro uses compound literal feature of C99 standard and thus is available only from C,
* not C++.
*/
#define BT_MESH_MODEL_NO_OPS ((struct bt_mesh_model_op []) \
{ BT_MESH_MODEL_OP_END })
/**
* @brief Helper to define an empty model array
*
* This macro uses compound literal feature of C99 standard and thus is available only from C,
* not C++.
*/
#define BT_MESH_MODEL_NONE ((const struct bt_mesh_model []){})
/**
* @brief Composition data SIG model entry with callback functions
* with specific number of keys & groups.
*
* This macro uses compound literal feature of C99 standard and thus is available only from C,
* not C++.
*
* @param _id Model ID.
* @param _op Array of model opcode handlers.
* @param _pub Model publish parameters.
* @param _user_data User data for the model.
* @param _keys Number of keys that can be bound to the model.
* Shall not exceed @kconfig{CONFIG_BT_MESH_MODEL_KEY_COUNT}.
* @param _grps Number of addresses that the model can be subscribed to.
* Shall not exceed @kconfig{CONFIG_BT_MESH_MODEL_GROUP_COUNT}.
* @param _cb Callback structure, or NULL to keep no callbacks.
*/
#define BT_MESH_MODEL_CNT_CB(_id, _op, _pub, _user_data, _keys, _grps, _cb) \
{ \
.id = (_id), \
BT_MESH_MODEL_RUNTIME_INIT(_user_data) \
.pub = _pub, \
.keys = (uint16_t []) BT_MESH_MODEL_KEYS_UNUSED(_keys), \
.keys_cnt = _keys, \
.groups = (uint16_t []) BT_MESH_MODEL_GROUPS_UNASSIGNED(_grps), \
.groups_cnt = _grps, \
BT_MESH_MODEL_UUIDS_UNASSIGNED() \
.op = _op, \
.cb = _cb, \
}
/**
* @brief Composition data vendor model entry with callback functions
* with specific number of keys & groups.
*
* This macro uses compound literal feature of C99 standard and thus is available only from C,
* not C++.
*
* @param _company Company ID.
* @param _id Model ID.
* @param _op Array of model opcode handlers.
* @param _pub Model publish parameters.
* @param _user_data User data for the model.
* @param _keys Number of keys that can be bound to the model.
* Shall not exceed @kconfig{CONFIG_BT_MESH_MODEL_KEY_COUNT}.
* @param _grps Number of addresses that the model can be subscribed to.
* Shall not exceed @kconfig{CONFIG_BT_MESH_MODEL_GROUP_COUNT}.
* @param _cb Callback structure, or NULL to keep no callbacks.
*/
#define BT_MESH_MODEL_CNT_VND_CB(_company, _id, _op, _pub, _user_data, _keys, _grps, _cb) \
{ \
.vnd.company = (_company), \
.vnd.id = (_id), \
BT_MESH_MODEL_RUNTIME_INIT(_user_data) \
.op = _op, \
.pub = _pub, \
.keys = (uint16_t []) BT_MESH_MODEL_KEYS_UNUSED(_keys), \
.keys_cnt = _keys, \
.groups = (uint16_t []) BT_MESH_MODEL_GROUPS_UNASSIGNED(_grps), \
.groups_cnt = _grps, \
BT_MESH_MODEL_UUIDS_UNASSIGNED() \
.cb = _cb, \
}
/**
* @brief Composition data SIG model entry with callback functions.
*
* This macro uses compound literal feature of C99 standard and thus is available only from C,
* not C++.
*
* @param _id Model ID.
* @param _op Array of model opcode handlers.
* @param _pub Model publish parameters.
* @param _user_data User data for the model.
* @param _cb Callback structure, or NULL to keep no callbacks.
*/
#define BT_MESH_MODEL_CB(_id, _op, _pub, _user_data, _cb) \
BT_MESH_MODEL_CNT_CB(_id, _op, _pub, _user_data, \
CONFIG_BT_MESH_MODEL_KEY_COUNT, \
CONFIG_BT_MESH_MODEL_GROUP_COUNT, _cb)
/**
*
* @brief Composition data SIG model entry with callback functions and metadata.
*
* This macro uses compound literal feature of C99 standard and thus is available only from C,
* not C++.
*
* @param _id Model ID.
* @param _op Array of model opcode handlers.
* @param _pub Model publish parameters.
* @param _user_data User data for the model.
* @param _cb Callback structure, or NULL to keep no callbacks.
* @param _metadata Metadata structure. Used if @kconfig{CONFIG_BT_MESH_LARGE_COMP_DATA_SRV}
* is enabled.
*/
#if defined(CONFIG_BT_MESH_LARGE_COMP_DATA_SRV)
#define BT_MESH_MODEL_METADATA_CB(_id, _op, _pub, _user_data, _cb, _metadata) \
{ \
.id = (_id), \
BT_MESH_MODEL_RUNTIME_INIT(_user_data) \
.pub = _pub, \
.keys = (uint16_t []) BT_MESH_MODEL_KEYS_UNUSED(CONFIG_BT_MESH_MODEL_KEY_COUNT), \
.keys_cnt = CONFIG_BT_MESH_MODEL_KEY_COUNT, \
.groups = (uint16_t []) BT_MESH_MODEL_GROUPS_UNASSIGNED(CONFIG_BT_MESH_MODEL_GROUP_COUNT), \
.groups_cnt = CONFIG_BT_MESH_MODEL_GROUP_COUNT, \
BT_MESH_MODEL_UUIDS_UNASSIGNED() \
.op = _op, \
.cb = _cb, \
.metadata = _metadata, \
}
#else
#define BT_MESH_MODEL_METADATA_CB(_id, _op, _pub, _user_data, _cb, _metadata) \
BT_MESH_MODEL_CB(_id, _op, _pub, _user_data, _cb)
#endif
/**
*
* @brief Composition data vendor model entry with callback functions.
*
* This macro uses compound literal feature of C99 standard and thus is available only from C,
* not C++.
*
* @param _company Company ID.
* @param _id Model ID.
* @param _op Array of model opcode handlers.
* @param _pub Model publish parameters.
* @param _user_data User data for the model.
* @param _cb Callback structure, or NULL to keep no callbacks.
*/
#define BT_MESH_MODEL_VND_CB(_company, _id, _op, _pub, _user_data, _cb) \
BT_MESH_MODEL_CNT_VND_CB(_company, _id, _op, _pub, _user_data, \
CONFIG_BT_MESH_MODEL_KEY_COUNT, \
CONFIG_BT_MESH_MODEL_GROUP_COUNT, _cb)
/**
*
* @brief Composition data vendor model entry with callback functions and metadata.
*
* This macro uses compound literal feature of C99 standard and thus is available only from C,
* not C++.
*
* @param _company Company ID.
* @param _id Model ID.
* @param _op Array of model opcode handlers.
* @param _pub Model publish parameters.
* @param _user_data User data for the model.
* @param _cb Callback structure, or NULL to keep no callbacks.
* @param _metadata Metadata structure. Used if @kconfig{CONFIG_BT_MESH_LARGE_COMP_DATA_SRV}
* is enabled.
*/
#if defined(CONFIG_BT_MESH_LARGE_COMP_DATA_SRV)
#define BT_MESH_MODEL_VND_METADATA_CB(_company, _id, _op, _pub, _user_data, _cb, _metadata) \
{ \
.vnd.company = (_company), \
.vnd.id = (_id), \
BT_MESH_MODEL_RUNTIME_INIT(_user_data) \
.op = _op, \
.pub = _pub, \
.keys = (uint16_t []) BT_MESH_MODEL_KEYS_UNUSED(CONFIG_BT_MESH_MODEL_KEY_COUNT), \
.keys_cnt = CONFIG_BT_MESH_MODEL_KEY_COUNT, \
.groups = (uint16_t []) BT_MESH_MODEL_GROUPS_UNASSIGNED(CONFIG_BT_MESH_MODEL_GROUP_COUNT), \
.groups_cnt = CONFIG_BT_MESH_MODEL_GROUP_COUNT, \
BT_MESH_MODEL_UUIDS_UNASSIGNED() \
.cb = _cb, \
.metadata = _metadata, \
}
#else
#define BT_MESH_MODEL_VND_METADATA_CB(_company, _id, _op, _pub, _user_data, _cb, _metadata) \
BT_MESH_MODEL_VND_CB(_company, _id, _op, _pub, _user_data, _cb)
#endif
/**
* @brief Composition data SIG model entry.
*
* This macro uses compound literal feature of C99 standard and thus is available only from C,
* not C++.
*
* @param _id Model ID.
* @param _op Array of model opcode handlers.
* @param _pub Model publish parameters.
* @param _user_data User data for the model.
*/
#define BT_MESH_MODEL(_id, _op, _pub, _user_data) \
BT_MESH_MODEL_CB(_id, _op, _pub, _user_data, NULL)
/**
* @brief Composition data vendor model entry.
*
* This macro uses compound literal feature of C99 standard and thus is available only from C,
* not C++.
*
* @param _company Company ID.
* @param _id Model ID.
* @param _op Array of model opcode handlers.
* @param _pub Model publish parameters.
* @param _user_data User data for the model.
*/
#define BT_MESH_MODEL_VND(_company, _id, _op, _pub, _user_data) \
BT_MESH_MODEL_VND_CB(_company, _id, _op, _pub, _user_data, NULL)
#endif /* !defined(__cplusplus) || defined(__DOXYGEN__) */
/**
* @brief Encode transmission count & interval steps.
*
* @param count Number of retransmissions (first transmission is excluded).
* @param int_ms Interval steps in milliseconds. Must be greater than 0,
* less than or equal to 320, and a multiple of 10.
*
* @return Mesh transmit value that can be used e.g. for the default
* values of the configuration model data.
*/
#define BT_MESH_TRANSMIT(count, int_ms) ((count) | (((int_ms / 10) - 1) << 3))
/**
* @brief Decode transmit count from a transmit value.
*
* @param transmit Encoded transmit count & interval value.
*
* @return Transmission count (actual transmissions is N + 1).
*/
#define BT_MESH_TRANSMIT_COUNT(transmit) (((transmit) & (uint8_t)BIT_MASK(3)))
/**
* @brief Decode transmit interval from a transmit value.
*
* @param transmit Encoded transmit count & interval value.
*
* @return Transmission interval in milliseconds.
*/
#define BT_MESH_TRANSMIT_INT(transmit) ((((transmit) >> 3) + 1) * 10)
/**
* @brief Encode Publish Retransmit count & interval steps.
*
* @param count Number of retransmissions (first transmission is excluded).
* @param int_ms Interval steps in milliseconds. Must be greater than 0 and a
* multiple of 50.
*
* @return Mesh transmit value that can be used e.g. for the default
* values of the configuration model data.
*/
#define BT_MESH_PUB_TRANSMIT(count, int_ms) BT_MESH_TRANSMIT(count, \
(int_ms) / 5)
/**
* @brief Decode Publish Retransmit count from a given value.
*
* @param transmit Encoded Publish Retransmit count & interval value.
*
* @return Retransmission count (actual transmissions is N + 1).
*/
#define BT_MESH_PUB_TRANSMIT_COUNT(transmit) BT_MESH_TRANSMIT_COUNT(transmit)
/**
* @brief Decode Publish Retransmit interval from a given value.
*
* @param transmit Encoded Publish Retransmit count & interval value.
*
* @return Transmission interval in milliseconds.
*/
#define BT_MESH_PUB_TRANSMIT_INT(transmit) ((((transmit) >> 3) + 1) * 50)
/**
* @brief Get total number of messages within one publication interval including initial
* publication.
*
* @param pub Model publication context.
*
* @return total number of messages.
*/
#define BT_MESH_PUB_MSG_TOTAL(pub) (BT_MESH_PUB_TRANSMIT_COUNT((pub)->retransmit) + 1)
/**
* @brief Get message number within one publication interval.
*
* Meant to be used inside @ref bt_mesh_model_pub.update.
*
* @param pub Model publication context.
*
* @return message number starting from 1.
*/
#define BT_MESH_PUB_MSG_NUM(pub) (BT_MESH_PUB_TRANSMIT_COUNT((pub)->retransmit) + 1 - (pub)->count)
/** Model publication context.
*
* The context should primarily be created using the
* BT_MESH_MODEL_PUB_DEFINE macro.
*/
struct bt_mesh_model_pub {
/** The model the context belongs to. Initialized by the stack. */
const struct bt_mesh_model *mod;
uint16_t addr; /**< Publish Address. */
const uint8_t *uuid; /**< Label UUID if Publish Address is Virtual Address. */
uint16_t key:12, /**< Publish AppKey Index. */
cred:1, /**< Friendship Credentials Flag. */
send_rel:1, /**< Force reliable sending (segment acks) */
fast_period:1, /**< Use FastPeriodDivisor */
retr_update:1; /**< Call update callback on every retransmission. */
uint8_t ttl; /**< Publish Time to Live. */
uint8_t retransmit; /**< Retransmit Count & Interval Steps. */
uint8_t period; /**< Publish Period. */
uint8_t period_div:4, /**< Divisor for the Period. */
count:4; /**< Transmissions left. */
uint8_t delayable:1; /**< Use random delay for publishing. */
uint32_t period_start; /**< Start of the current period. */
/** @brief Publication buffer, containing the publication message.
*
* This will get correctly created when the publication context
* has been defined using the BT_MESH_MODEL_PUB_DEFINE macro.
*
* BT_MESH_MODEL_PUB_DEFINE(name, update, size);
*/
struct net_buf_simple *msg;
/** @brief Callback for updating the publication buffer.
*
* When set to NULL, the model is assumed not to support
* periodic publishing. When set to non-NULL the callback
* will be called periodically and is expected to update
* @ref bt_mesh_model_pub.msg with a valid publication
* message.
*
* If the callback returns non-zero, the publication is skipped
* and will resume on the next periodic publishing interval.
*
* When @ref bt_mesh_model_pub.retr_update is set to 1,
* the callback will be called on every retransmission.
*
* @param mod The Model the Publication Context belongs to.
*
* @return Zero on success or (negative) error code otherwise.
*/
int (*update)(const struct bt_mesh_model *mod);
/** Publish Period Timer. Only for stack-internal use. */
struct k_work_delayable timer;
};
/**
* Define a model publication context.
*
* @param _name Variable name given to the context.
* @param _update Optional message update callback (may be NULL).
* @param _msg_len Length of the publication message.
*/
#define BT_MESH_MODEL_PUB_DEFINE(_name, _update, _msg_len) \
NET_BUF_SIMPLE_DEFINE_STATIC(bt_mesh_pub_msg_##_name, _msg_len); \
static struct bt_mesh_model_pub _name = { \
.msg = &bt_mesh_pub_msg_##_name, \
.update = _update, \
}
/** Models Metadata Entry struct
*
* The struct should primarily be created using the
* BT_MESH_MODELS_METADATA_ENTRY macro.
*/
struct bt_mesh_models_metadata_entry {
/* Length of the metadata */
const uint16_t len;
/* ID of the metadata */
const uint16_t id;
/* Pointer to raw data */
const void * const data;
};
/**
*
* Initialize a Models Metadata entry structure in a list.
*
* @param _len Length of the metadata entry.
* @param _id ID of the Models Metadata entry.
* @param _data Pointer to a contiguous memory that contains the metadata.
*/
#define BT_MESH_MODELS_METADATA_ENTRY(_len, _id, _data) \
{ \
.len = (_len), .id = _id, .data = _data, \
}
/** Helper to define an empty Models metadata array */
#define BT_MESH_MODELS_METADATA_NONE NULL
/** End of the Models Metadata list. Must always be present. */
#define BT_MESH_MODELS_METADATA_END { 0, 0, NULL }
/** Model callback functions. */
struct bt_mesh_model_cb {
/** @brief Set value handler of user data tied to the model.
*
* @sa settings_handler::h_set
*
* @param model Model to set the persistent data of.
* @param name Name/key of the settings item.
* @param len_rd The size of the data found in the backend.
* @param read_cb Function provided to read the data from the backend.
* @param cb_arg Arguments for the read function provided by the
* backend.
*
* @return 0 on success, error otherwise.
*/
int (*const settings_set)(const struct bt_mesh_model *model,
const char *name, size_t len_rd,
settings_read_cb read_cb, void *cb_arg);
/** @brief Callback called when the mesh is started.
*
* This handler gets called after the node has been provisioned, or
* after all mesh data has been loaded from persistent storage.
*
* When this callback fires, the mesh model may start its behavior,
* and all Access APIs are ready for use.
*
* @param model Model this callback belongs to.
*
* @return 0 on success, error otherwise.
*/
int (*const start)(const struct bt_mesh_model *model);
/** @brief Model init callback.
*
* Called on every model instance during mesh initialization.
*
* If any of the model init callbacks return an error, the Mesh
* subsystem initialization will be aborted, and the error will be
* returned to the caller of @ref bt_mesh_init.
*
* @param model Model to be initialized.
*
* @return 0 on success, error otherwise.
*/
int (*const init)(const struct bt_mesh_model *model);
/** @brief Model reset callback.
*
* Called when the mesh node is reset. All model data is deleted on
* reset, and the model should clear its state.
*
* @note If the model stores any persistent data, this needs to be
* erased manually.
*
* @param model Model this callback belongs to.
*/
void (*const reset)(const struct bt_mesh_model *model);
/** @brief Callback used to store pending model's user data.
*
* Triggered by @ref bt_mesh_model_data_store_schedule.
*
* To store the user data, call @ref bt_mesh_model_data_store.
*
* @param model Model this callback belongs to.
*/
void (*const pending_store)(const struct bt_mesh_model *model);
};
/** Vendor model ID */
struct bt_mesh_mod_id_vnd {
/** Vendor's company ID */
uint16_t company;
/** Model ID */
uint16_t id;
};
/** Abstraction that describes a Mesh Model instance */
struct bt_mesh_model {
union {
/** SIG model ID */
const uint16_t id;
/** Vendor model ID */
const struct bt_mesh_mod_id_vnd vnd;
};
/* Model runtime information */
struct bt_mesh_model_rt_ctx {
uint8_t elem_idx; /* Belongs to Nth element */
uint8_t mod_idx; /* Is the Nth model in the element */
uint16_t flags; /* Model flags for internal bookkeeping */
#ifdef CONFIG_BT_MESH_MODEL_EXTENSIONS
/* Pointer to the next model in a model extension list. */
const struct bt_mesh_model *next;
#endif
/** Model-specific user data */
void *user_data;
} * const rt;
/** Model Publication */
struct bt_mesh_model_pub * const pub;
/** AppKey List */
uint16_t * const keys;
const uint16_t keys_cnt;
/** Subscription List (group or virtual addresses) */
uint16_t * const groups;
const uint16_t groups_cnt;
#if (CONFIG_BT_MESH_LABEL_COUNT > 0) || defined(__DOXYGEN__)
/** List of Label UUIDs the model is subscribed to. */
const uint8_t ** const uuids;
#endif
/** Opcode handler list */
const struct bt_mesh_model_op * const op;
/** Model callback structure. */
const struct bt_mesh_model_cb * const cb;
#if defined(CONFIG_BT_MESH_LARGE_COMP_DATA_SRV) || defined(__DOXYGEN__)
/* Pointer to the array of model metadata entries. */
const struct bt_mesh_models_metadata_entry * const metadata;
#endif
};
/** Callback structure for monitoring model message sending */
struct bt_mesh_send_cb {
/** @brief Handler called at the start of the transmission.
*
* @param duration The duration of the full transmission.
* @param err Error occurring during sending.
* @param cb_data Callback data, as passed to the send API.
*/
void (*start)(uint16_t duration, int err, void *cb_data);
/** @brief Handler called at the end of the transmission.
*
* @param err Error occurring during sending.
* @param cb_data Callback data, as passed to the send API.
*/
void (*end)(int err, void *cb_data);
};
/** Special TTL value to request using configured default TTL */
#define BT_MESH_TTL_DEFAULT 0xff
/** Maximum allowed TTL value */
#define BT_MESH_TTL_MAX 0x7f
/** @brief Send an Access Layer message.
*
* @param model Mesh (client) Model that the message belongs to.
* @param ctx Message context, includes keys, TTL, etc.
* @param msg Access Layer payload (the actual message to be sent).
* @param cb Optional "message sent" callback.
* @param cb_data User data to be passed to the callback.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_model_send(const struct bt_mesh_model *model,
struct bt_mesh_msg_ctx *ctx,
struct net_buf_simple *msg,
const struct bt_mesh_send_cb *cb,
void *cb_data);
/** @brief Send a model publication message.
*
* Before calling this function, the user needs to ensure that the model
* publication message (@ref bt_mesh_model_pub.msg) contains a valid
* message to be sent. Note that this API is only to be used for
* non-period publishing. For periodic publishing the app only needs
* to make sure that @ref bt_mesh_model_pub.msg contains a valid message
* whenever the @ref bt_mesh_model_pub.update callback is called.
*
* @param model Mesh (client) Model that's publishing the message.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_model_publish(const struct bt_mesh_model *model);
/** @brief Check if a message is being retransmitted.
*
* Meant to be used inside the @ref bt_mesh_model_pub.update callback.
*
* @param model Mesh Model that supports publication.
*
* @return true if this is a retransmission, false if this is a first publication.
*/
static inline bool bt_mesh_model_pub_is_retransmission(const struct bt_mesh_model *model)
{
return model->pub->count != BT_MESH_PUB_TRANSMIT_COUNT(model->pub->retransmit);
}
/** @brief Get the element that a model belongs to.
*
* @param mod Mesh model.
*
* @return Pointer to the element that the given model belongs to.
*/
const struct bt_mesh_elem *bt_mesh_model_elem(const struct bt_mesh_model *mod);
/** @brief Find a SIG model.
*
* @param elem Element to search for the model in.
* @param id Model ID of the model.
*
* @return A pointer to the Mesh model matching the given parameters, or NULL
* if no SIG model with the given ID exists in the given element.
*/
const struct bt_mesh_model *bt_mesh_model_find(const struct bt_mesh_elem *elem,
uint16_t id);
/** @brief Find a vendor model.
*
* @param elem Element to search for the model in.
* @param company Company ID of the model.
* @param id Model ID of the model.
*
* @return A pointer to the Mesh model matching the given parameters, or NULL
* if no vendor model with the given ID exists in the given element.
*/
const struct bt_mesh_model *bt_mesh_model_find_vnd(const struct bt_mesh_elem *elem,
uint16_t company, uint16_t id);
/** @brief Get whether the model is in the primary element of the device.
*
* @param mod Mesh model.
*
* @return true if the model is on the primary element, false otherwise.
*/
static inline bool bt_mesh_model_in_primary(const struct bt_mesh_model *mod)
{
return (mod->rt->elem_idx == 0);
}
/** @brief Immediately store the model's user data in persistent storage.
*
* @param mod Mesh model.
* @param vnd This is a vendor model.
* @param name Name/key of the settings item. Only
* @ref SETTINGS_MAX_DIR_DEPTH bytes will be used at most.
* @param data Model data to store, or NULL to delete any model data.
* @param data_len Length of the model data.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_model_data_store(const struct bt_mesh_model *mod, bool vnd,
const char *name, const void *data,
size_t data_len);
/** @brief Schedule the model's user data store in persistent storage.
*
* This function triggers the @ref bt_mesh_model_cb.pending_store callback
* for the corresponding model after delay defined by
* @kconfig{CONFIG_BT_MESH_STORE_TIMEOUT}.
*
* The delay is global for all models. Once scheduled, the callback can
* not be re-scheduled until previous schedule completes.
*
* @param mod Mesh model.
*/
void bt_mesh_model_data_store_schedule(const struct bt_mesh_model *mod);
/** @brief Let a model extend another.
*
* Mesh models may be extended to reuse their functionality, forming a more
* complex model. A Mesh model may extend any number of models, in any element.
* The extensions may also be nested, ie a model that extends another may
* itself be extended.
*
* A set of models that extend each other form a model extension list.
*
* All models in an extension list share one subscription list per element. The
* access layer will utilize the combined subscription list of all models in an
* extension list and element, giving the models extended subscription list
* capacity.
*
* If @kconfig{CONFIG_BT_MESH_COMP_PAGE_1} is enabled, it is not allowed to call
* this function before the @ref bt_mesh_model_cb.init callback is called
* for both models, except if it is called as part of the final callback.
*
* @param extending_mod Mesh model that is extending the base model.
* @param base_mod The model being extended.
*
* @retval 0 Successfully extended the base_mod model.
*/
int bt_mesh_model_extend(const struct bt_mesh_model *extending_mod,
const struct bt_mesh_model *base_mod);
/** @brief Let a model correspond to another.
*
* Mesh models may correspond to each other, which means that if one is present,
* other must be present too. A Mesh model may correspond to any number of models,
* in any element. All models connected together via correspondence form single
* Correspondence Group, which has it's unique Correspondence ID. Information about
* Correspondence is used to construct Composition Data Page 1.
*
* This function must be called on already initialized base_mod. Because this function
* is designed to be called in corresponding_mod initializer, this means that base_mod
* shall be initialized before corresponding_mod is.
*
* @param corresponding_mod Mesh model that is corresponding to the base model.
* @param base_mod The model being corresponded to.
*
* @retval 0 Successfully saved correspondence to the base_mod model.
* @retval -ENOMEM There is no more space to save this relation.
* @retval -ENOTSUP Composition Data Page 1 is not supported.
*/
int bt_mesh_model_correspond(const struct bt_mesh_model *corresponding_mod,
const struct bt_mesh_model *base_mod);
/** @brief Check if model is extended by another model.
*
* @param model The model to check.
*
* @retval true If model is extended by another model, otherwise false
*/
bool bt_mesh_model_is_extended(const struct bt_mesh_model *model);
/** @brief Indicate that the composition data will change on next bootup.
*
* Tell the config server that the composition data is expected to change on
* the next bootup, and the current composition data should be backed up.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_mesh_comp_change_prepare(void);
/** @brief Indicate that the metadata will change on next bootup.
*
* Tell the config server that the models metadata is expected to change on
* the next bootup, and the current models metadata should be backed up.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_mesh_models_metadata_change_prepare(void);
/** Node Composition */
struct bt_mesh_comp {
uint16_t cid; /**< Company ID */
uint16_t pid; /**< Product ID */
uint16_t vid; /**< Version ID */
size_t elem_count; /**< The number of elements in this device. */
const struct bt_mesh_elem *elem; /**< List of elements. */
};
/** Composition data page 2 record. */
struct bt_mesh_comp2_record {
/** Mesh profile ID. */
uint16_t id;
/** Mesh Profile Version. */
struct {
/** Major version. */
uint8_t x;
/** Minor version. */
uint8_t y;
/** Z version. */
uint8_t z;
} version;
/** Element offset count. */
uint8_t elem_offset_cnt;
/** Element offset list. */
const uint8_t *elem_offset;
/** Length of additional data. */
uint16_t data_len;
/** Additional data. */
const void *data;
};
/** Node Composition data page 2 */
struct bt_mesh_comp2 {
/** The number of Mesh Profile records on a device. */
size_t record_cnt;
/** List of records. */
const struct bt_mesh_comp2_record *record;
};
/** @brief Register composition data page 2 of the device.
*
* Register Mesh Profiles information (Ref section 3.12 in
* Bluetooth SIG Assigned Numbers) for composition data
* page 2 of the device.
*
* @note There must be at least one record present in @c comp2
*
* @param comp2 Pointer to composition data page 2.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_mesh_comp2_register(const struct bt_mesh_comp2 *comp2);
#ifdef __cplusplus
}
#endif
/**
* @}
*/
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_MESH_ACCESS_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/mesh/access.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 10,669 |
```objective-c
/** @file
* @brief BLE mesh statistic APIs.
*/
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_MESH_STATISTIC_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_MESH_STATISTIC_H_
#include <stdint.h>
/**
* @brief Statistic
* @defgroup bt_mesh_stat Statistic
* @ingroup bt_mesh
* @{
*/
#ifdef __cplusplus
extern "C" {
#endif
/** The structure that keeps statistics of mesh frames handling. */
struct bt_mesh_statistic {
/** All received frames passed basic validation and decryption. */
/** Received frames over advertiser. */
uint32_t rx_adv;
/** Received frames over loopback. */
uint32_t rx_loopback;
/** Received frames over proxy. */
uint32_t rx_proxy;
/** Received over unknown interface. */
uint32_t rx_uknown;
/** Counter of frames that were initiated to relay over advertiser bearer. */
uint32_t tx_adv_relay_planned;
/** Counter of frames that succeeded relaying over advertiser bearer. */
uint32_t tx_adv_relay_succeeded;
/** Counter of frames that were initiated to send over advertiser bearer locally. */
uint32_t tx_local_planned;
/** Counter of frames that succeeded to send over advertiser bearer locally. */
uint32_t tx_local_succeeded;
/** Counter of frames that were initiated to send over friend bearer. */
uint32_t tx_friend_planned;
/** Counter of frames that succeeded to send over friend bearer. */
uint32_t tx_friend_succeeded;
};
/** @brief Get mesh frame handling statistic.
*
* @param st BLE mesh statistic.
*/
void bt_mesh_stat_get(struct bt_mesh_statistic *st);
/** @brief Reset mesh frame handling statistic.
*/
void bt_mesh_stat_reset(void);
#ifdef __cplusplus
}
#endif
/**
* @}
*/
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_MESH_STATISTIC_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/mesh/statistic.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 401 |
```objective-c
/*
*
*/
#ifndef BT_MESH_SAR_CFG_H__
#define BT_MESH_SAR_CFG_H__
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup bt_mesh_sar_cfg SAR Configuration common header
* @ingroup bt_mesh
* @{
*/
/** SAR Transmitter Configuration state structure */
struct bt_mesh_sar_tx {
/** SAR Segment Interval Step state */
uint8_t seg_int_step;
/** SAR Unicast Retransmissions Count state */
uint8_t unicast_retrans_count;
/** SAR Unicast Retransmissions Without Progress Count state */
uint8_t unicast_retrans_without_prog_count;
/* SAR Unicast Retransmissions Interval Step state */
uint8_t unicast_retrans_int_step;
/** SAR Unicast Retransmissions Interval Increment state */
uint8_t unicast_retrans_int_inc;
/** SAR Multicast Retransmissions Count state */
uint8_t multicast_retrans_count;
/** SAR Multicast Retransmissions Interval state */
uint8_t multicast_retrans_int;
};
/** SAR Receiver Configuration state structure */
struct bt_mesh_sar_rx {
/** SAR Segments Threshold state */
uint8_t seg_thresh;
/** SAR Acknowledgment Delay Increment state */
uint8_t ack_delay_inc;
/** SAR Discard Timeout state */
uint8_t discard_timeout;
/** SAR Receiver Segment Interval Step state */
uint8_t rx_seg_int_step;
/** SAR Acknowledgment Retransmissions Count state */
uint8_t ack_retrans_count;
};
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* BT_MESH_SAR_CFG_H__ */
``` | /content/code_sandbox/include/zephyr/bluetooth/mesh/sar_cfg.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 333 |
```objective-c
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BT_MESH_RPR_SRV_H__
#define ZEPHYR_INCLUDE_BT_MESH_RPR_SRV_H__
#include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/mesh/access.h>
#include <zephyr/bluetooth/mesh/rpr.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup bt_mesh_rpr_srv Remote provisioning server
* @ingroup bt_mesh
* @{
*/
/**
*
* @brief Remote Provisioning Server model composition data entry.
*/
#define BT_MESH_MODEL_RPR_SRV \
BT_MESH_MODEL_CB(BT_MESH_MODEL_ID_REMOTE_PROV_SRV, \
_bt_mesh_rpr_srv_op, NULL, NULL, \
&_bt_mesh_rpr_srv_cb)
/** @cond INTERNAL_HIDDEN */
extern const struct bt_mesh_model_op _bt_mesh_rpr_srv_op[];
extern const struct bt_mesh_model_cb _bt_mesh_rpr_srv_cb;
/** @endcond */
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_INCLUDE_BT_MESH_RPR_SRV_H__ */
``` | /content/code_sandbox/include/zephyr/bluetooth/mesh/rpr_srv.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 230 |
```objective-c
/*
*
*/
/** @file
* @brief Bluetooth Mesh SAR Configuration Server Model APIs.
*/
#ifndef BT_MESH_SAR_CFG_SRV_H__
#define BT_MESH_SAR_CFG_SRV_H__
#include <zephyr/bluetooth/mesh.h>
#include <zephyr/bluetooth/mesh/sar_cfg.h>
/**
* @brief Bluetooth Mesh
* @defgroup bt_mesh_sar_cfg_srv Bluetooth Mesh SAR Configuration Server Model
* @ingroup bt_mesh
* @{
*/
#ifdef __cplusplus
extern "C" {
#endif
/**
*
* @brief Transport SAR Configuration Server model composition data entry.
*/
#define BT_MESH_MODEL_SAR_CFG_SRV \
BT_MESH_MODEL_CB(BT_MESH_MODEL_ID_SAR_CFG_SRV, bt_mesh_sar_cfg_srv_op, \
NULL, NULL, &bt_mesh_sar_cfg_srv_cb)
/** @cond INTERNAL_HIDDEN */
extern const struct bt_mesh_model_op bt_mesh_sar_cfg_srv_op[];
extern const struct bt_mesh_model_cb bt_mesh_sar_cfg_srv_cb;
/** @endcond */
#ifdef __cplusplus
}
#endif
#endif /* BT_MESH_SAR_CFG_SRV_H__ */
/**
* @}
*/
``` | /content/code_sandbox/include/zephyr/bluetooth/mesh/sar_cfg_srv.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 235 |
```objective-c
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BT_MESH_RPR_CLI_H__
#define ZEPHYR_INCLUDE_BT_MESH_RPR_CLI_H__
#include <zephyr/kernel.h>
#include <zephyr/bluetooth/mesh/access.h>
#include <zephyr/bluetooth/mesh/rpr.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup bt_mesh_rpr_cli Remote Provisioning Client model
* @ingroup bt_mesh
* @{
*/
/** Special value for the @c max_devs parameter of @ref bt_mesh_rpr_scan_start.
*
* Tells the Remote Provisioning Server not to put restrictions on the max
* number of devices reported to the Client.
*/
#define BT_MESH_RPR_SCAN_MAX_DEVS_ANY 0
struct bt_mesh_rpr_cli;
/**
*
* @brief Remote Provisioning Client model composition data entry.
*
* @param _cli Pointer to a @ref bt_mesh_rpr_cli instance.
*/
#define BT_MESH_MODEL_RPR_CLI(_cli) \
BT_MESH_MODEL_CB(BT_MESH_MODEL_ID_REMOTE_PROV_CLI, \
_bt_mesh_rpr_cli_op, NULL, _cli, &_bt_mesh_rpr_cli_cb)
/** Scan status response */
struct bt_mesh_rpr_scan_status {
/** Current scan status */
enum bt_mesh_rpr_status status;
/** Current scan state */
enum bt_mesh_rpr_scan scan;
/** Max number of devices to report in current scan. */
uint8_t max_devs;
/** Seconds remaining of the scan. */
uint8_t timeout;
};
/** Remote Provisioning Server scanning capabilities */
struct bt_mesh_rpr_caps {
/** Max number of scannable devices */
uint8_t max_devs;
/** Supports active scan */
bool active_scan;
};
/** Remote Provisioning Client model instance. */
struct bt_mesh_rpr_cli {
/** @brief Scan report callback.
*
* @param cli Remote Provisioning Client.
* @param srv Remote Provisioning Server.
* @param unprov Unprovisioned device.
* @param adv_data Advertisement data for the unprovisioned device, or
* NULL if extended scanning hasn't been enabled. An
* empty buffer indicates that the extended scanning
* finished without collecting additional information.
*/
void (*scan_report)(struct bt_mesh_rpr_cli *cli,
const struct bt_mesh_rpr_node *srv,
struct bt_mesh_rpr_unprov *unprov,
struct net_buf_simple *adv_data);
/* Internal parameters */
struct bt_mesh_msg_ack_ctx scan_ack_ctx;
struct bt_mesh_msg_ack_ctx prov_ack_ctx;
struct {
struct k_work_delayable timeout;
struct bt_mesh_rpr_node srv;
uint8_t time;
uint8_t tx_pdu;
uint8_t rx_pdu;
enum bt_mesh_rpr_link_state state;
} link;
const struct bt_mesh_model *mod;
};
/** @brief Get scanning capabilities of Remote Provisioning Server.
*
* @param cli Remote Provisioning Client.
* @param srv Remote Provisioning Server.
* @param caps Capabilities response buffer.
*
* @return 0 on success, or (negative) error code otherwise.
*/
int bt_mesh_rpr_scan_caps_get(struct bt_mesh_rpr_cli *cli,
const struct bt_mesh_rpr_node *srv,
struct bt_mesh_rpr_caps *caps);
/** @brief Get current scanning state of Remote Provisioning Server.
*
* @param cli Remote Provisioning Client.
* @param srv Remote Provisioning Server.
* @param status Scan status response buffer.
*
* @return 0 on success, or (negative) error code otherwise.
*/
int bt_mesh_rpr_scan_get(struct bt_mesh_rpr_cli *cli,
const struct bt_mesh_rpr_node *srv,
struct bt_mesh_rpr_scan_status *status);
/** @brief Start scanning for unprovisioned devices.
*
* Tells the Remote Provisioning Server to start scanning for unprovisioned
* devices. The Server will report back the results through the @ref
* bt_mesh_rpr_cli::scan_report callback.
*
* Use the @c uuid parameter to scan for a specific device, or leave it as NULL
* to report all unprovisioned devices.
*
* The Server will ignore duplicates, and report up to @c max_devs number of
* devices. Requesting a @c max_devs number that's higher than the Server's
* capability will result in an error.
*
* @param cli Remote Provisioning Client.
* @param srv Remote Provisioning Server.
* @param uuid Device UUID to scan for, or NULL to report all devices.
* @param timeout Scan timeout in seconds. Must be at least 1 second.
* @param max_devs Max number of devices to report, or 0 to report as many as
* possible.
* @param status Scan status response buffer.
*
* @return 0 on success, or (negative) error code otherwise.
*/
int bt_mesh_rpr_scan_start(struct bt_mesh_rpr_cli *cli,
const struct bt_mesh_rpr_node *srv,
const uint8_t uuid[16], uint8_t timeout,
uint8_t max_devs,
struct bt_mesh_rpr_scan_status *status);
/** @brief Start extended scanning for unprovisioned devices.
*
* Extended scanning supplements regular unprovisioned scanning, by allowing
* the Server to report additional data for a specific device. The Remote
* Provisioning Server will use active scanning to request a scan
* response from the unprovisioned device, if supported. If no UUID is
* provided, the Server will report a scan on its own OOB information and
* advertising data.
*
* Use the ad_types array to specify which AD types to include in the scan
* report. Some AD types invoke special behavior:
* - @ref BT_DATA_NAME_COMPLETE Will report both the complete and the
* shortened name.
* - @ref BT_DATA_URI If the unprovisioned beacon contains a URI hash, the
* Server will extend the scanning to include packets other than
* the scan response, to look for URIs matching the URI hash. Only matching
* URIs will be reported.
*
* The following AD types should not be used:
* - @ref BT_DATA_NAME_SHORTENED
* - @ref BT_DATA_UUID16_SOME
* - @ref BT_DATA_UUID32_SOME
* - @ref BT_DATA_UUID128_SOME
*
* Additionally, each AD type should only occur once.
*
* @param cli Remote Provisioning Client.
* @param srv Remote Provisioning Server.
* @param uuid Device UUID to start extended scanning for, or NULL to scan
* the remote server.
* @param timeout Scan timeout in seconds. Valid values from @ref BT_MESH_RPR_EXT_SCAN_TIME_MIN
* to @ref BT_MESH_RPR_EXT_SCAN_TIME_MAX. Ignored if UUID is NULL.
* @param ad_types List of AD types to include in the scan report. Must contain 1 to
* CONFIG_BT_MESH_RPR_AD_TYPES_MAX entries.
* @param ad_count Number of AD types in @c ad_types.
*
* @return 0 on success, or (negative) error code otherwise.
*/
int bt_mesh_rpr_scan_start_ext(struct bt_mesh_rpr_cli *cli,
const struct bt_mesh_rpr_node *srv,
const uint8_t uuid[16], uint8_t timeout,
const uint8_t *ad_types, size_t ad_count);
/** @brief Stop any ongoing scanning on the Remote Provisioning Server.
*
* @param cli Remote Provisioning Client.
* @param srv Remote Provisioning Server.
* @param status Scan status response buffer.
*
* @return 0 on success, or (negative) error code otherwise.
*/
int bt_mesh_rpr_scan_stop(struct bt_mesh_rpr_cli *cli,
const struct bt_mesh_rpr_node *srv,
struct bt_mesh_rpr_scan_status *status);
/** @brief Get the current link status of the Remote Provisioning Server.
*
* @param cli Remote Provisioning Client.
* @param srv Remote Provisioning Server.
* @param rsp Link status response buffer.
*
* @return 0 on success, or (negative) error code otherwise.
*/
int bt_mesh_rpr_link_get(struct bt_mesh_rpr_cli *cli,
const struct bt_mesh_rpr_node *srv,
struct bt_mesh_rpr_link *rsp);
/** @brief Close any open link on the Remote Provisioning Server.
*
* @param cli Remote Provisioning Client.
* @param srv Remote Provisioning Server.
* @param rsp Link status response buffer.
*
* @return 0 on success, or (negative) error code otherwise.
*/
int bt_mesh_rpr_link_close(struct bt_mesh_rpr_cli *cli,
const struct bt_mesh_rpr_node *srv,
struct bt_mesh_rpr_link *rsp);
/** @brief Get the current transmission timeout value.
*
* @return The configured transmission timeout in milliseconds.
*/
int32_t bt_mesh_rpr_cli_timeout_get(void);
/** @brief Set the transmission timeout value.
*
* The transmission timeout controls the amount of time the Remote Provisioning
* Client models will wait for a response from the Server.
*
* @param timeout The new transmission timeout.
*/
void bt_mesh_rpr_cli_timeout_set(int32_t timeout);
/** @cond INTERNAL_HIDDEN */
extern const struct bt_mesh_model_op _bt_mesh_rpr_cli_op[];
extern const struct bt_mesh_model_cb _bt_mesh_rpr_cli_cb;
/** @endcond */
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_INCLUDE_BT_MESH_RPR_CLI_H__ */
``` | /content/code_sandbox/include/zephyr/bluetooth/mesh/rpr_cli.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 2,126 |
```objective-c
/** @file
* @brief Health faults
*/
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_MESH_HEALTH_FAULTS_H__
#define ZEPHYR_INCLUDE_BLUETOOTH_MESH_HEALTH_FAULTS_H__
/**
* @brief List of specification defined Health fault values.
* @defgroup bt_mesh_health_faults Health faults
* @ingroup bt_mesh
* @{
*/
/** No fault has occurred. */
#define BT_MESH_HEALTH_FAULT_NO_FAULT 0x00
#define BT_MESH_HEALTH_FAULT_BATTERY_LOW_WARNING 0x01
#define BT_MESH_HEALTH_FAULT_BATTERY_LOW_ERROR 0x02
#define BT_MESH_HEALTH_FAULT_SUPPLY_VOLTAGE_TOO_LOW_WARNING 0x03
#define BT_MESH_HEALTH_FAULT_SUPPLY_VOLTAGE_TOO_LOW_ERROR 0x04
#define BT_MESH_HEALTH_FAULT_SUPPLY_VOLTAGE_TOO_HIGH_WARNING 0x05
#define BT_MESH_HEALTH_FAULT_SUPPLY_VOLTAGE_TOO_HIGH_ERROR 0x06
#define BT_MESH_HEALTH_FAULT_POWER_SUPPLY_INTERRUPTED_WARNING 0x07
#define BT_MESH_HEALTH_FAULT_POWER_SUPPLY_INTERRUPTED_ERROR 0x08
#define BT_MESH_HEALTH_FAULT_NO_LOAD_WARNING 0x09
#define BT_MESH_HEALTH_FAULT_NO_LOAD_ERROR 0x0A
#define BT_MESH_HEALTH_FAULT_OVERLOAD_WARNING 0x0B
#define BT_MESH_HEALTH_FAULT_OVERLOAD_ERROR 0x0C
#define BT_MESH_HEALTH_FAULT_OVERHEAT_WARNING 0x0D
#define BT_MESH_HEALTH_FAULT_OVERHEAT_ERROR 0x0E
#define BT_MESH_HEALTH_FAULT_CONDENSATION_WARNING 0x0F
#define BT_MESH_HEALTH_FAULT_CONDENSATION_ERROR 0x10
#define BT_MESH_HEALTH_FAULT_VIBRATION_WARNING 0x11
#define BT_MESH_HEALTH_FAULT_VIBRATION_ERROR 0x12
#define BT_MESH_HEALTH_FAULT_CONFIGURATION_WARNING 0x13
#define BT_MESH_HEALTH_FAULT_CONFIGURATION_ERROR 0x14
#define BT_MESH_HEALTH_FAULT_ELEMENT_NOT_CALIBRATED_WARNING 0x15
#define BT_MESH_HEALTH_FAULT_ELEMENT_NOT_CALIBRATED_ERROR 0x16
#define BT_MESH_HEALTH_FAULT_MEMORY_WARNING 0x17
#define BT_MESH_HEALTH_FAULT_MEMORY_ERROR 0x18
#define BT_MESH_HEALTH_FAULT_SELF_TEST_WARNING 0x19
#define BT_MESH_HEALTH_FAULT_SELF_TEST_ERROR 0x1A
#define BT_MESH_HEALTH_FAULT_INPUT_TOO_LOW_WARNING 0x1B
#define BT_MESH_HEALTH_FAULT_INPUT_TOO_LOW_ERROR 0x1C
#define BT_MESH_HEALTH_FAULT_INPUT_TOO_HIGH_WARNING 0x1D
#define BT_MESH_HEALTH_FAULT_INPUT_TOO_HIGH_ERROR 0x1E
#define BT_MESH_HEALTH_FAULT_INPUT_NO_CHANGE_WARNING 0x1F
#define BT_MESH_HEALTH_FAULT_INPUT_NO_CHANGE_ERROR 0x20
#define BT_MESH_HEALTH_FAULT_ACTUATOR_BLOCKED_WARNING 0x21
#define BT_MESH_HEALTH_FAULT_ACTUATOR_BLOCKED_ERROR 0x22
#define BT_MESH_HEALTH_FAULT_HOUSING_OPENED_WARNING 0x23
#define BT_MESH_HEALTH_FAULT_HOUSING_OPENED_ERROR 0x24
#define BT_MESH_HEALTH_FAULT_TAMPER_WARNING 0x25
#define BT_MESH_HEALTH_FAULT_TAMPER_ERROR 0x26
#define BT_MESH_HEALTH_FAULT_DEVICE_MOVED_WARNING 0x27
#define BT_MESH_HEALTH_FAULT_DEVICE_MOVED_ERROR 0x28
#define BT_MESH_HEALTH_FAULT_DEVICE_DROPPED_WARNING 0x29
#define BT_MESH_HEALTH_FAULT_DEVICE_DROPPED_ERROR 0x2A
#define BT_MESH_HEALTH_FAULT_OVERFLOW_WARNING 0x2B
#define BT_MESH_HEALTH_FAULT_OVERFLOW_ERROR 0x2C
#define BT_MESH_HEALTH_FAULT_EMPTY_WARNING 0x2D
#define BT_MESH_HEALTH_FAULT_EMPTY_ERROR 0x2E
#define BT_MESH_HEALTH_FAULT_INTERNAL_BUS_WARNING 0x2F
#define BT_MESH_HEALTH_FAULT_INTERNAL_BUS_ERROR 0x30
#define BT_MESH_HEALTH_FAULT_MECHANISM_JAMMED_WARNING 0x31
#define BT_MESH_HEALTH_FAULT_MECHANISM_JAMMED_ERROR 0x32
/**
* Start of the vendor specific fault values.
*
* All values below this are reserved for the Bluetooth Specification.
*/
#define BT_MESH_HEALTH_FAULT_VENDOR_SPECIFIC_START 0x80
/**
* @}
*/
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_MESH_HEALTH_FAULTS_H__ */
``` | /content/code_sandbox/include/zephyr/bluetooth/mesh/health_faults.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 939 |
```objective-c
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_MESH_BLOB_H__
#define ZEPHYR_INCLUDE_BLUETOOTH_MESH_BLOB_H__
#include <sys/types.h>
#include <zephyr/kernel.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup bt_mesh_blob Bluetooth Mesh BLOB model API
* @ingroup bt_mesh
* @{
*/
#ifndef CONFIG_BT_MESH_BLOB_CHUNK_COUNT_MAX
#define CONFIG_BT_MESH_BLOB_CHUNK_COUNT_MAX 0
#endif
/** BLOB transfer mode. */
enum bt_mesh_blob_xfer_mode {
/** No valid transfer mode. */
BT_MESH_BLOB_XFER_MODE_NONE,
/** Push mode (Push BLOB Transfer Mode). */
BT_MESH_BLOB_XFER_MODE_PUSH,
/** Pull mode (Pull BLOB Transfer Mode). */
BT_MESH_BLOB_XFER_MODE_PULL,
/** Both modes are valid. */
BT_MESH_BLOB_XFER_MODE_ALL,
};
/** Transfer phase. */
enum bt_mesh_blob_xfer_phase {
/** The BLOB Transfer Server is awaiting configuration. */
BT_MESH_BLOB_XFER_PHASE_INACTIVE,
/** The BLOB Transfer Server is ready to receive a BLOB transfer. */
BT_MESH_BLOB_XFER_PHASE_WAITING_FOR_START,
/** The BLOB Transfer Server is waiting for the next block of data. */
BT_MESH_BLOB_XFER_PHASE_WAITING_FOR_BLOCK,
/** The BLOB Transfer Server is waiting for the next chunk of data. */
BT_MESH_BLOB_XFER_PHASE_WAITING_FOR_CHUNK,
/** The BLOB was transferred successfully. */
BT_MESH_BLOB_XFER_PHASE_COMPLETE,
/** The BLOB transfer is paused. */
BT_MESH_BLOB_XFER_PHASE_SUSPENDED,
};
/** BLOB model status codes. */
enum bt_mesh_blob_status {
/** The message was processed successfully. */
BT_MESH_BLOB_SUCCESS,
/** The Block Number field value is not within the range of blocks being
* transferred.
*/
BT_MESH_BLOB_ERR_INVALID_BLOCK_NUM,
/** The block size is smaller than the size indicated by the Min Block
* Size Log state or is larger than the size indicated by the Max Block
* Size Log state.
*/
BT_MESH_BLOB_ERR_INVALID_BLOCK_SIZE,
/** The chunk size exceeds the size indicated by the Max Chunk Size
* state, or the number of chunks exceeds the number specified by the
* Max Total Chunks state.
*/
BT_MESH_BLOB_ERR_INVALID_CHUNK_SIZE,
/** The operation cannot be performed while the server is in the current
* phase.
*/
BT_MESH_BLOB_ERR_WRONG_PHASE,
/** A parameter value in the message cannot be accepted. */
BT_MESH_BLOB_ERR_INVALID_PARAM,
/** The message contains a BLOB ID value that is not expected. */
BT_MESH_BLOB_ERR_WRONG_BLOB_ID,
/** There is not enough space available in memory to receive the BLOB.
*/
BT_MESH_BLOB_ERR_BLOB_TOO_LARGE,
/** The transfer mode is not supported by the BLOB Transfer Server
* model.
*/
BT_MESH_BLOB_ERR_UNSUPPORTED_MODE,
/** An internal error occurred on the node. */
BT_MESH_BLOB_ERR_INTERNAL,
/** The requested information cannot be provided while the server is in
* the current phase.
*/
BT_MESH_BLOB_ERR_INFO_UNAVAILABLE,
};
/** BLOB transfer data block. */
struct bt_mesh_blob_block {
/** Block size in bytes */
size_t size;
/** Offset in bytes from the start of the BLOB. */
off_t offset;
/** Block number */
uint16_t number;
/** Number of chunks in block. */
uint16_t chunk_count;
/** Bitmap of missing chunks. */
uint8_t missing[DIV_ROUND_UP(CONFIG_BT_MESH_BLOB_CHUNK_COUNT_MAX,
8)];
};
/** BLOB data chunk. */
struct bt_mesh_blob_chunk {
/** Offset of the chunk data from the start of the block. */
off_t offset;
/** Chunk data size. */
size_t size;
/** Chunk data. */
uint8_t *data;
};
/** BLOB transfer. */
struct bt_mesh_blob_xfer {
/** BLOB ID. */
uint64_t id;
/** Total BLOB size in bytes. */
size_t size;
/** BLOB transfer mode. */
enum bt_mesh_blob_xfer_mode mode;
/* Logarithmic representation of the block size. */
uint8_t block_size_log;
/** Base chunk size. May be smaller for the last chunk. */
uint16_t chunk_size;
};
/** BLOB stream interaction mode. */
enum bt_mesh_blob_io_mode {
/** Read data from the stream. */
BT_MESH_BLOB_READ,
/** Write data to the stream. */
BT_MESH_BLOB_WRITE,
};
/** BLOB stream. */
struct bt_mesh_blob_io {
/** @brief Open callback.
*
* Called when the reader is opened for reading.
*
* @param io BLOB stream.
* @param xfer BLOB transfer.
* @param mode Direction of the stream (read/write).
*
* @return 0 on success, or (negative) error code otherwise.
*/
int (*open)(const struct bt_mesh_blob_io *io,
const struct bt_mesh_blob_xfer *xfer,
enum bt_mesh_blob_io_mode mode);
/** @brief Close callback.
*
* Called when the reader is closed.
*
* @param io BLOB stream.
* @param xfer BLOB transfer.
*/
void (*close)(const struct bt_mesh_blob_io *io,
const struct bt_mesh_blob_xfer *xfer);
/** @brief Block start callback.
*
* Called when a new block is opened for sending. Each block is only
* sent once, and are always sent in increasing order. The data chunks
* inside a single block may be requested out of order and multiple
* times.
*
* @param io BLOB stream.
* @param xfer BLOB transfer.
* @param block Block that was started.
*/
int (*block_start)(const struct bt_mesh_blob_io *io,
const struct bt_mesh_blob_xfer *xfer,
const struct bt_mesh_blob_block *block);
/** @brief Block end callback.
*
* Called when the current block has been transmitted in full.
* No data from this block will be requested again, and the application
* data associated with this block may be discarded.
*
* @param io BLOB stream.
* @param xfer BLOB transfer.
* @param block Block that finished sending.
*/
void (*block_end)(const struct bt_mesh_blob_io *io,
const struct bt_mesh_blob_xfer *xfer,
const struct bt_mesh_blob_block *block);
/** @brief Chunk data write callback.
*
* Used by the BLOB Transfer Server on incoming data.
*
* Each block is divided into chunks of data. This callback is called
* when a new chunk of data is received. Chunks may be received in
* any order within their block.
*
* If the callback returns successfully, this chunk will be marked as
* received, and will not be received again unless the block is
* restarted due to a transfer suspension. If the callback returns a
* non-zero value, the chunk remains unreceived, and the BLOB Transfer
* Client will attempt to resend it later.
*
* Note that the Client will only perform a limited number of attempts
* at delivering a chunk before dropping a Target node from the transfer.
* The number of retries performed by the Client is implementation
* specific.
*
* @param io BLOB stream.
* @param xfer BLOB transfer.
* @param block Block the chunk is part of.
* @param chunk Received chunk.
*
* @return 0 on success, or (negative) error code otherwise.
*/
int (*wr)(const struct bt_mesh_blob_io *io,
const struct bt_mesh_blob_xfer *xfer,
const struct bt_mesh_blob_block *block,
const struct bt_mesh_blob_chunk *chunk);
/** @brief Chunk data read callback.
*
* Used by the BLOB Transfer Client to fetch outgoing data.
*
* The Client calls the chunk data request callback to populate a chunk
* message going out to the Target nodes. The data request callback
* may be called out of order and multiple times for each offset, and
* cannot be used as an indication of progress.
*
* Returning a non-zero status code on the chunk data request callback
* results in termination of the transfer.
*
* @param io BLOB stream.
* @param xfer BLOB transfer.
* @param block Block the chunk is part of.
* @param chunk Chunk to get the data of. The buffer pointer to by the
* @c data member should be filled by the callback.
*
* @return 0 on success, or (negative) error code otherwise.
*/
int (*rd)(const struct bt_mesh_blob_io *io,
const struct bt_mesh_blob_xfer *xfer,
const struct bt_mesh_blob_block *block,
const struct bt_mesh_blob_chunk *chunk);
};
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_MESH_BLOB_H__ */
``` | /content/code_sandbox/include/zephyr/bluetooth/mesh/blob.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 2,103 |
```objective-c
/*
*
*/
/** @file
* @brief Bluetooth Mesh SAR Configuration Client Model APIs.
*/
#ifndef BT_MESH_SAR_CFG_CLI_H__
#define BT_MESH_SAR_CFG_CLI_H__
#include <zephyr/bluetooth/mesh.h>
#include <zephyr/bluetooth/mesh/sar_cfg.h>
/**
* @brief Bluetooth Mesh
* @defgroup bt_mesh_sar_cfg_cli Bluetooth Mesh SAR Configuration Client Model
* @ingroup bt_mesh
* @{
*/
#ifdef __cplusplus
extern "C" {
#endif
/** Mesh SAR Configuration Client Model Context */
struct bt_mesh_sar_cfg_cli {
/** Access model pointer. */
const struct bt_mesh_model *model;
/* Publication structure instance */
struct bt_mesh_model_pub pub;
/* Synchronous message timeout in milliseconds. */
int32_t timeout;
/* Internal parameters for tracking message responses. */
struct bt_mesh_msg_ack_ctx ack_ctx;
};
/**
*
* @brief SAR Configuration Client model composition data entry.
*
* @param[in] _cli Pointer to a @ref bt_mesh_sar_cfg_cli instance.
*/
#define BT_MESH_MODEL_SAR_CFG_CLI(_cli) \
BT_MESH_MODEL_CB(BT_MESH_MODEL_ID_SAR_CFG_CLI, \
_bt_mesh_sar_cfg_cli_op, _cli.pub, _cli, \
&_bt_mesh_sar_cfg_cli_cb)
/** @brief Get the SAR Transmitter state of the target node.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param rsp Status response parameter.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_sar_cfg_cli_transmitter_get(uint16_t net_idx, uint16_t addr,
struct bt_mesh_sar_tx *rsp);
/** @brief Set the SAR Transmitter state of the target node.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param set New SAR Transmitter state to set on the target node.
* @param rsp Status response parameter.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_sar_cfg_cli_transmitter_set(uint16_t net_idx, uint16_t addr,
const struct bt_mesh_sar_tx *set,
struct bt_mesh_sar_tx *rsp);
/** @brief Get the SAR Receiver state of the target node.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param rsp Status response parameter.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_sar_cfg_cli_receiver_get(uint16_t net_idx, uint16_t addr,
struct bt_mesh_sar_rx *rsp);
/** @brief Set the SAR Receiver state of the target node.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param set New SAR Receiver state to set on the target node.
* @param rsp Status response parameter.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_sar_cfg_cli_receiver_set(uint16_t net_idx, uint16_t addr,
const struct bt_mesh_sar_rx *set,
struct bt_mesh_sar_rx *rsp);
/** @brief Get the current transmission timeout value.
*
* @return The configured transmission timeout in milliseconds.
*/
int32_t bt_mesh_sar_cfg_cli_timeout_get(void);
/** @brief Set the transmission timeout value.
*
* @param timeout The new transmission timeout.
*/
void bt_mesh_sar_cfg_cli_timeout_set(int32_t timeout);
/** @cond INTERNAL_HIDDEN */
extern const struct bt_mesh_model_op _bt_mesh_sar_cfg_cli_op[];
extern const struct bt_mesh_model_cb _bt_mesh_sar_cfg_cli_cb;
/** @endcond */
#ifdef __cplusplus
}
#endif
#endif /* BT_MESH_SAR_CFG_CLI_H__ */
/** @} */
``` | /content/code_sandbox/include/zephyr/bluetooth/mesh/sar_cfg_cli.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 860 |
```objective-c
/*
*
*/
#ifndef BT_MESH_SOL_PDU_RPL_CLI_H__
#define BT_MESH_SOL_PDU_RPL_CLI_H__
#include <zephyr/bluetooth/mesh.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup bt_mesh_sol_pdu_rpl_cli Bluetooth Mesh Solicitation PDU RPL Client
* @ingroup bt_mesh
* @{
*/
/** Solicitation PDU RPL Client Model Context */
struct bt_mesh_sol_pdu_rpl_cli {
/** Solicitation PDU RPL model entry pointer. */
const struct bt_mesh_model *model;
/* Internal parameters for tracking message responses. */
struct bt_mesh_msg_ack_ctx ack_ctx;
/** @brief Optional callback for Solicitation PDU RPL Status messages.
*
* Handles received Solicitation PDU RPL Status messages from a Solicitation
* PDU RPL server.The @c start param represents the start of range that server
* has cleared. The @c length param represents length of range cleared by server.
*
* @param cli Solicitation PDU RPL client that received the status message.
* @param addr Address of the sender.
* @param range_start Range start value.
* @param range_length Range length value.
*/
void (*srpl_status)(struct bt_mesh_sol_pdu_rpl_cli *cli, uint16_t addr,
uint16_t range_start, uint8_t range_length);
};
/**
* @brief Solicitation PDU RPL Client model composition data entry.
*/
#define BT_MESH_MODEL_SOL_PDU_RPL_CLI(cli_data) \
BT_MESH_MODEL_CB(BT_MESH_MODEL_ID_SOL_PDU_RPL_CLI, \
_bt_mesh_sol_pdu_rpl_cli_op, NULL, cli_data, \
&_bt_mesh_sol_pdu_rpl_cli_cb)
/** @brief Remove entries from Solicitation PDU RPL of addresses in given range.
*
* This method can be used asynchronously by setting @p start_rsp or
* @p len_rsp as NULL. This way the method will not wait for response and will
* return immediately after sending the command.
*
* To process the response arguments of an async method, register
* the @c srpl_status callback in @c bt_mesh_sol_pdu_rpl_cli struct.
*
* @param ctx Message context for the message.
* @param range_start Start of Unicast address range.
* @param range_len Length of Unicast address range. Valid values are 0x00 and 0x02
* to 0xff.
* @param start_rsp Range start response buffer.
* @param len_rsp Range length response buffer.
*
* @return 0 on success, or (negative) error code otherwise.
*/
int bt_mesh_sol_pdu_rpl_clear(struct bt_mesh_msg_ctx *ctx, uint16_t range_start,
uint8_t range_len, uint16_t *start_rsp, uint8_t *len_rsp);
/** @brief Remove entries from Solicitation PDU RPL of addresses in given range (unacked).
*
* @param ctx Message context for the message.
* @param range_start Start of Unicast address range.
* @param range_len Length of Unicast address range. Valid values are 0x00 and 0x02
* to 0xff.
*
* @return 0 on success, or (negative) error code otherwise.
*/
int bt_mesh_sol_pdu_rpl_clear_unack(struct bt_mesh_msg_ctx *ctx, uint16_t range_start,
uint8_t range_len);
/** @brief Set the transmission timeout value.
*
* @param timeout The new transmission timeout in milliseconds.
*/
void bt_mesh_sol_pdu_rpl_cli_timeout_set(int32_t timeout);
/** @cond INTERNAL_HIDDEN */
extern const struct bt_mesh_model_op _bt_mesh_sol_pdu_rpl_cli_op[];
extern const struct bt_mesh_model_cb _bt_mesh_sol_pdu_rpl_cli_cb;
/** @endcond */
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* BT_MESH_SOL_PDU_RPL_CLI_H__ */
``` | /content/code_sandbox/include/zephyr/bluetooth/mesh/sol_pdu_rpl_cli.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 877 |
```objective-c
/*
*
*/
#ifndef BT_MESH_OD_PRIV_PROXY_SRV_H__
#define BT_MESH_OD_PRIV_PROXY_SRV_H__
#include <zephyr/bluetooth/mesh.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup bt_mesh_od_priv_proxy_srv Bluetooth Mesh On-Demand Private GATT Proxy Server
* @ingroup bt_mesh
* @{
*/
/**
* @brief On-Demand Private Proxy Server model composition data entry.
*/
#define BT_MESH_MODEL_OD_PRIV_PROXY_SRV \
BT_MESH_MODEL_SOL_PDU_RPL_SRV, \
BT_MESH_MODEL_CB(BT_MESH_MODEL_ID_ON_DEMAND_PROXY_SRV, \
_bt_mesh_od_priv_proxy_srv_op, NULL, NULL, \
&_bt_mesh_od_priv_proxy_srv_cb)
/** @cond INTERNAL_HIDDEN */
extern const struct bt_mesh_model_op _bt_mesh_od_priv_proxy_srv_op[];
extern const struct bt_mesh_model_cb _bt_mesh_od_priv_proxy_srv_cb;
/** @endcond */
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* BT_MESH_OD_PRIV_PROXY_SRV_H__ */
``` | /content/code_sandbox/include/zephyr/bluetooth/mesh/od_priv_proxy_srv.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 222 |
```objective-c
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_MESH_DFD_H__
#define ZEPHYR_INCLUDE_BLUETOOTH_MESH_DFD_H__
#include <zephyr/bluetooth/mesh.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup bt_mesh_dfd Firmware Distribution models
* @ingroup bt_mesh
* @{
*/
/** Firmware distribution status. */
enum bt_mesh_dfd_status {
/** The message was processed successfully. */
BT_MESH_DFD_SUCCESS,
/** Insufficient resources on the node. */
BT_MESH_DFD_ERR_INSUFFICIENT_RESOURCES,
/** The operation cannot be performed while the Server is in the current
* phase.
*/
BT_MESH_DFD_ERR_WRONG_PHASE,
/** An internal error occurred on the node. */
BT_MESH_DFD_ERR_INTERNAL,
/** The requested firmware image is not stored on the Distributor. */
BT_MESH_DFD_ERR_FW_NOT_FOUND,
/** The AppKey identified by the AppKey Index is not known to the node.
*/
BT_MESH_DFD_ERR_INVALID_APPKEY_INDEX,
/** There are no Target nodes in the Distribution Receivers List
* state.
*/
BT_MESH_DFD_ERR_RECEIVERS_LIST_EMPTY,
/** Another firmware image distribution is in progress. */
BT_MESH_DFD_ERR_BUSY_WITH_DISTRIBUTION,
/** Another upload is in progress. */
BT_MESH_DFD_ERR_BUSY_WITH_UPLOAD,
/** The URI scheme name indicated by the Update URI is not supported. */
BT_MESH_DFD_ERR_URI_NOT_SUPPORTED,
/** The format of the Update URI is invalid. */
BT_MESH_DFD_ERR_URI_MALFORMED,
/** The URI is currently unreachable. */
BT_MESH_DFD_ERR_URI_UNREACHABLE,
/** The Check Firmware OOB procedure did not find any new firmware. */
BT_MESH_DFD_ERR_NEW_FW_NOT_AVAILABLE,
/** The suspension of the Distribute Firmware procedure failed. */
BT_MESH_DFD_ERR_SUSPEND_FAILED,
};
/** Firmware distribution phases. */
enum bt_mesh_dfd_phase {
/** No firmware distribution is in progress. */
BT_MESH_DFD_PHASE_IDLE,
/** Firmware distribution is in progress. */
BT_MESH_DFD_PHASE_TRANSFER_ACTIVE,
/** The Transfer BLOB procedure has completed successfully. */
BT_MESH_DFD_PHASE_TRANSFER_SUCCESS,
/** The Apply Firmware on Target Nodes procedure is being executed. */
BT_MESH_DFD_PHASE_APPLYING_UPDATE,
/** The Distribute Firmware procedure has completed successfully. */
BT_MESH_DFD_PHASE_COMPLETED,
/** The Distribute Firmware procedure has failed. */
BT_MESH_DFD_PHASE_FAILED,
/** The Cancel Firmware Update procedure is being executed. */
BT_MESH_DFD_PHASE_CANCELING_UPDATE,
/** The Transfer BLOB procedure is suspended. */
BT_MESH_DFD_PHASE_TRANSFER_SUSPENDED,
};
/** Firmware upload phases. */
enum bt_mesh_dfd_upload_phase {
/** No firmware upload is in progress. */
BT_MESH_DFD_UPLOAD_PHASE_IDLE,
/** The Store Firmware procedure is being executed. */
BT_MESH_DFD_UPLOAD_PHASE_TRANSFER_ACTIVE,
/** The Store Firmware procedure or Store Firmware OOB procedure failed.
*/
BT_MESH_DFD_UPLOAD_PHASE_TRANSFER_ERROR,
/** The Store Firmware procedure or the Store Firmware OOB procedure
* completed successfully.
*/
BT_MESH_DFD_UPLOAD_PHASE_TRANSFER_SUCCESS,
};
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_MESH_DFD_H__ */
``` | /content/code_sandbox/include/zephyr/bluetooth/mesh/dfd.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 748 |
```objective-c
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_MESH_DFU_H__
#define ZEPHYR_INCLUDE_BLUETOOTH_MESH_DFU_H__
#include <sys/types.h>
#include <zephyr/kernel.h>
#include <zephyr/bluetooth/mesh/blob.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup bt_mesh_dfu Bluetooth Mesh Device Firmware Update
* @ingroup bt_mesh
* @{
*/
#ifndef CONFIG_BT_MESH_DFU_FWID_MAXLEN
#define CONFIG_BT_MESH_DFU_FWID_MAXLEN 0
#endif
#ifndef CONFIG_BT_MESH_DFU_METADATA_MAXLEN
#define CONFIG_BT_MESH_DFU_METADATA_MAXLEN 0
#endif
#ifndef CONFIG_BT_MESH_DFU_URI_MAXLEN
#define CONFIG_BT_MESH_DFU_URI_MAXLEN 0
#endif
#ifndef CONFIG_BT_MESH_DFU_SLOT_CNT
#define CONFIG_BT_MESH_DFU_SLOT_CNT 0
#endif
/** DFU transfer phase. */
enum bt_mesh_dfu_phase {
/** Ready to start a Receive Firmware procedure. */
BT_MESH_DFU_PHASE_IDLE,
/** The Transfer BLOB procedure failed. */
BT_MESH_DFU_PHASE_TRANSFER_ERR,
/** The Receive Firmware procedure is being executed. */
BT_MESH_DFU_PHASE_TRANSFER_ACTIVE,
/** The Verify Firmware procedure is being executed. */
BT_MESH_DFU_PHASE_VERIFY,
/** The Verify Firmware procedure completed successfully. */
BT_MESH_DFU_PHASE_VERIFY_OK,
/** The Verify Firmware procedure failed. */
BT_MESH_DFU_PHASE_VERIFY_FAIL,
/** The Apply New Firmware procedure is being executed. */
BT_MESH_DFU_PHASE_APPLYING,
/** Firmware transfer has been canceled. */
BT_MESH_DFU_PHASE_TRANSFER_CANCELED,
/** Firmware applying succeeded. */
BT_MESH_DFU_PHASE_APPLY_SUCCESS,
/** Firmware applying failed. */
BT_MESH_DFU_PHASE_APPLY_FAIL,
/** Phase of a node was not yet retrieved. */
BT_MESH_DFU_PHASE_UNKNOWN,
};
/** DFU status. */
enum bt_mesh_dfu_status {
/** The message was processed successfully. */
BT_MESH_DFU_SUCCESS,
/** Insufficient resources on the node */
BT_MESH_DFU_ERR_RESOURCES,
/** The operation cannot be performed while the Server is in the current
* phase.
*/
BT_MESH_DFU_ERR_WRONG_PHASE,
/** An internal error occurred on the node. */
BT_MESH_DFU_ERR_INTERNAL,
/** The message contains a firmware index value that is not expected. */
BT_MESH_DFU_ERR_FW_IDX,
/** The metadata check failed. */
BT_MESH_DFU_ERR_METADATA,
/** The Server cannot start a firmware update. */
BT_MESH_DFU_ERR_TEMPORARILY_UNAVAILABLE,
/** Another BLOB transfer is in progress. */
BT_MESH_DFU_ERR_BLOB_XFER_BUSY,
};
/** Expected effect of a DFU transfer. */
enum bt_mesh_dfu_effect {
/** No changes to node Composition Data. */
BT_MESH_DFU_EFFECT_NONE,
/** Node Composition Data changed and the node does not support remote
* provisioning.
*/
BT_MESH_DFU_EFFECT_COMP_CHANGE_NO_RPR,
/** Node Composition Data changed, and remote provisioning is supported.
* The node supports remote provisioning and Composition Data Page
* 0x80. Page 0x80 contains different Composition Data than Page 0x0.
*/
BT_MESH_DFU_EFFECT_COMP_CHANGE,
/** Node will be unprovisioned after the update. */
BT_MESH_DFU_EFFECT_UNPROV,
};
/** Action for DFU iteration callbacks. */
enum bt_mesh_dfu_iter {
/** Stop iterating. */
BT_MESH_DFU_ITER_STOP,
/** Continue iterating. */
BT_MESH_DFU_ITER_CONTINUE,
};
/** DFU image instance.
*
* Each DFU image represents a single updatable firmware image.
*/
struct bt_mesh_dfu_img {
/** Firmware ID. */
const void *fwid;
/** Length of the firmware ID. */
size_t fwid_len;
/** Update URI, or NULL. */
const char *uri;
};
/** DFU image slot for DFU distribution. */
struct bt_mesh_dfu_slot {
/** Size of the firmware in bytes. */
size_t size;
/** Length of the firmware ID. */
size_t fwid_len;
/** Length of the metadata. */
size_t metadata_len;
/** Firmware ID. */
uint8_t fwid[CONFIG_BT_MESH_DFU_FWID_MAXLEN];
/** Metadata. */
uint8_t metadata[CONFIG_BT_MESH_DFU_METADATA_MAXLEN];
};
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_MESH_DFU_H__ */
``` | /content/code_sandbox/include/zephyr/bluetooth/mesh/dfu.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 999 |
```objective-c
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_MESH_PRIV_BEACON_CLI_H__
#define ZEPHYR_INCLUDE_BLUETOOTH_MESH_PRIV_BEACON_CLI_H__
#include <zephyr/bluetooth/mesh.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup bt_mesh_priv_beacon_cli Bluetooth Mesh Private Beacon Client
* @ingroup bt_mesh
* @{
*/
/**
*
* @brief Private Beacon Client model composition data entry.
*
* @param cli_data Pointer to a @ref bt_mesh_priv_beacon_cli instance.
*/
#define BT_MESH_MODEL_PRIV_BEACON_CLI(cli_data) \
BT_MESH_MODEL_CB(BT_MESH_MODEL_ID_PRIV_BEACON_CLI, \
bt_mesh_priv_beacon_cli_op, NULL, cli_data, \
&bt_mesh_priv_beacon_cli_cb)
struct bt_mesh_priv_beacon_cli;
/** Private Beacon */
struct bt_mesh_priv_beacon {
/** Private beacon is enabled */
uint8_t enabled;
/** Random refresh interval (in 10 second steps), or 0 to keep current
* value.
*/
uint8_t rand_interval;
};
/** Private Node Identity */
struct bt_mesh_priv_node_id {
/** Index of the NetKey. */
uint16_t net_idx;
/** Private Node Identity state */
uint8_t state;
/** Response status code. */
uint8_t status;
};
/** Private Beacon Client Status messages callbacks */
struct bt_mesh_priv_beacon_cli_cb {
/** @brief Optional callback for Private Beacon Status message.
*
* Handles received Private Beacon Status messages from a Private Beacon server.
*
* @param cli Private Beacon client context.
* @param addr Address of the sender.
* @param priv_beacon Mesh Private Beacon state received from the server.
*/
void (*priv_beacon_status)(struct bt_mesh_priv_beacon_cli *cli, uint16_t addr,
struct bt_mesh_priv_beacon *priv_beacon);
/** @brief Optional callback for Private GATT Proxy Status message.
*
* Handles received Private GATT Proxy Status messages from a Private Beacon server.
*
* @param cli Private Beacon client context.
* @param addr Address of the sender.
* @param gatt_proxy Private GATT Proxy state received from the server.
*/
void (*priv_gatt_proxy_status)(struct bt_mesh_priv_beacon_cli *cli, uint16_t addr,
uint8_t gatt_proxy);
/** @brief Optional callback for Private Node Identity Status message.
*
* Handles received Private Node Identity Status messages from a Private Beacon server.
*
* @param cli Private Beacon client context.
* @param addr Address of the sender.
* @param priv_node_id Private Node Identity state received from the server.
*/
void (*priv_node_id_status)(struct bt_mesh_priv_beacon_cli *cli, uint16_t addr,
struct bt_mesh_priv_node_id *priv_node_id);
};
/** Mesh Private Beacon Client model */
struct bt_mesh_priv_beacon_cli {
const struct bt_mesh_model *model;
/* Internal parameters for tracking message responses. */
struct bt_mesh_msg_ack_ctx ack_ctx;
/** Optional callback for Private Beacon Client Status messages. */
const struct bt_mesh_priv_beacon_cli_cb *cb;
};
/** @brief Set the target's Private Beacon state.
*
* This method can be used asynchronously by setting @p rsp as NULL.
* This way the method will not wait for response and will return
* immediately after sending the command.
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param val New Private Beacon value.
* @param rsp If set, returns response status on success.
*
* @return 0 on success, or (negative) error code otherwise.
*/
int bt_mesh_priv_beacon_cli_set(uint16_t net_idx, uint16_t addr,
struct bt_mesh_priv_beacon *val,
struct bt_mesh_priv_beacon *rsp);
/** @brief Get the target's Private Beacon state.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param val Response buffer for Private Beacon value.
*
* @return 0 on success, or (negative) error code otherwise.
*/
int bt_mesh_priv_beacon_cli_get(uint16_t net_idx, uint16_t addr,
struct bt_mesh_priv_beacon *val);
/** @brief Set the target's Private GATT Proxy state.
*
* This method can be used asynchronously by setting @p rsp as NULL.
* This way the method will not wait for response and will return
* immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param val New Private GATT Proxy value.
* @param rsp If set, returns response status on success.
*
* @return 0 on success, or (negative) error code otherwise.
*/
int bt_mesh_priv_beacon_cli_gatt_proxy_set(uint16_t net_idx, uint16_t addr,
uint8_t val, uint8_t *rsp);
/** @brief Get the target's Private GATT Proxy state.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param val Response buffer for Private GATT Proxy value.
*
* @return 0 on success, or (negative) error code otherwise.
*/
int bt_mesh_priv_beacon_cli_gatt_proxy_get(uint16_t net_idx, uint16_t addr,
uint8_t *val);
/** @brief Set the target's Private Node Identity state.
*
* This method can be used asynchronously by setting @p rsp as NULL.
* This way the method will not wait for response and will return
* immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param val New Private Node Identity value.
* @param rsp If set, returns response status on success.
*
* @return 0 on success, or (negative) error code otherwise.
*/
int bt_mesh_priv_beacon_cli_node_id_set(uint16_t net_idx, uint16_t addr,
struct bt_mesh_priv_node_id *val,
struct bt_mesh_priv_node_id *rsp);
/** @brief Get the target's Private Node Identity state.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param key_net_idx Network index to get the Private Node Identity state of.
* @param val Response buffer for Private Node Identity value.
*
* @return 0 on success, or (negative) error code otherwise.
*/
int bt_mesh_priv_beacon_cli_node_id_get(uint16_t net_idx, uint16_t addr,
uint16_t key_net_idx,
struct bt_mesh_priv_node_id *val);
/** @cond INTERNAL_HIDDEN */
extern const struct bt_mesh_model_op bt_mesh_priv_beacon_cli_op[];
extern const struct bt_mesh_model_cb bt_mesh_priv_beacon_cli_cb;
/** @endcond */
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_MESH_PRIV_BEACON_CLI_H__ */
``` | /content/code_sandbox/include/zephyr/bluetooth/mesh/priv_beacon_cli.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 1,605 |
```objective-c
/** @file
* @brief Health Server Model APIs.
*/
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_MESH_HEALTH_SRV_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_MESH_HEALTH_SRV_H_
/**
* @brief Health Server Model
* @defgroup bt_mesh_health_srv Health Server Model
* @ingroup bt_mesh
* @{
*/
#include <zephyr/bluetooth/mesh.h>
#include <zephyr/bluetooth/byteorder.h>
#ifdef __cplusplus
extern "C" {
#endif
/** Callback function for the Health Server model */
struct bt_mesh_health_srv_cb {
/** @brief Callback for fetching current faults.
*
* Fault values may either be defined by the specification, or by a
* vendor. Vendor specific faults should be interpreted in the context
* of the accompanying Company ID. Specification defined faults may be
* reported for any Company ID, and the same fault may be presented
* for multiple Company IDs.
*
* All faults shall be associated with at least one Company ID,
* representing the device vendor or some other vendor whose vendor
* specific fault values are used.
*
* If there are multiple Company IDs that have active faults,
* return only the faults associated with one of them at the time.
* To report faults for multiple Company IDs, interleave which Company
* ID is reported for each call.
*
* @param model Health Server model instance to get faults of.
* @param test_id Test ID response buffer.
* @param company_id Company ID response buffer.
* @param faults Array to fill with current faults.
* @param fault_count The number of faults the fault array can fit.
* Should be updated to reflect the number of faults
* copied into the array.
*
* @return 0 on success, or (negative) error code otherwise.
*/
int (*fault_get_cur)(const struct bt_mesh_model *model, uint8_t *test_id,
uint16_t *company_id, uint8_t *faults,
uint8_t *fault_count);
/** @brief Callback for fetching all registered faults.
*
* Registered faults are all past and current faults since the last
* call to @c fault_clear. Only faults associated with the given
* Company ID should be reported.
*
* Fault values may either be defined by the specification, or by a
* vendor. Vendor specific faults should be interpreted in the context
* of the accompanying Company ID. Specification defined faults may be
* reported for any Company ID, and the same fault may be presented
* for multiple Company IDs.
*
* @param model Health Server model instance to get faults of.
* @param company_id Company ID to get faults for.
* @param test_id Test ID response buffer.
* @param faults Array to fill with registered faults.
* @param fault_count The number of faults the fault array can fit.
* Should be updated to reflect the number of faults
* copied into the array.
*
* @return 0 on success, or (negative) error code otherwise.
*/
int (*fault_get_reg)(const struct bt_mesh_model *model, uint16_t company_id,
uint8_t *test_id, uint8_t *faults,
uint8_t *fault_count);
/** @brief Clear all registered faults associated with the given Company
* ID.
*
* @param model Health Server model instance to clear faults of.
* @param company_id Company ID to clear faults for.
*
* @return 0 on success, or (negative) error code otherwise.
*/
int (*fault_clear)(const struct bt_mesh_model *model, uint16_t company_id);
/** @brief Run a self-test.
*
* The Health server may support up to 256 self-tests for each Company
* ID. The behavior for all test IDs are vendor specific, and should be
* interpreted based on the accompanying Company ID. Test failures
* should result in changes to the fault array.
*
* @param model Health Server model instance to run test for.
* @param test_id Test ID to run.
* @param company_id Company ID to run test for.
*
* @return 0 if the test execution was started successfully, or
* (negative) error code otherwise. Note that the fault array will not
* be reported back to the client if the test execution didn't start.
*/
int (*fault_test)(const struct bt_mesh_model *model, uint8_t test_id,
uint16_t company_id);
/** @brief Start calling attention to the device.
*
* The attention state is used to map an element address to a
* physical device. When this callback is called, the device should
* start some physical procedure meant to call attention to itself,
* like blinking, buzzing, vibrating or moving. If there are multiple
* Health server instances on the device, the attention state should
* also help identify the specific element the server is in.
*
* The attention calling behavior should continue until the @c attn_off
* callback is called.
*
* @param model Health Server model to start the attention state of.
*/
void (*attn_on)(const struct bt_mesh_model *model);
/** @brief Stop the attention state.
*
* Any physical activity started to call attention to the device should
* be stopped.
*
* @param model
*/
void (*attn_off)(const struct bt_mesh_model *model);
};
/**
* A helper to define a health publication context
*
* @param _name Name given to the publication context variable.
* @param _max_faults Maximum number of faults the element can have.
*/
#define BT_MESH_HEALTH_PUB_DEFINE(_name, _max_faults) \
BT_MESH_MODEL_PUB_DEFINE(_name, NULL, (1 + 3 + (_max_faults)))
/** Mesh Health Server Model Context */
struct bt_mesh_health_srv {
/** Composition data model entry pointer. */
const struct bt_mesh_model *model;
/** Optional callback struct */
const struct bt_mesh_health_srv_cb *cb;
/** Attention Timer state */
struct k_work_delayable attn_timer;
};
/**
* Define a new health server model. Note that this API needs to be
* repeated for each element that the application wants to have a
* health server model on. Each instance also needs a unique
* bt_mesh_health_srv and bt_mesh_model_pub context.
*
* @param srv Pointer to a unique struct bt_mesh_health_srv.
* @param pub Pointer to a unique struct bt_mesh_model_pub.
* @param ... Optional Health Server metadata if application is compiled with
* Large Composition Data Server support, otherwise this parameter
* is ignored.
*
* @return New mesh model instance.
*/
#define BT_MESH_MODEL_HEALTH_SRV(srv, pub, ...) \
BT_MESH_MODEL_METADATA_CB(BT_MESH_MODEL_ID_HEALTH_SRV, \
bt_mesh_health_srv_op, \
pub, \
srv, \
&bt_mesh_health_srv_cb, __VA_ARGS__)
/**
*
* Health Test Information Metadata ID.
*/
#define BT_MESH_HEALTH_TEST_INFO_METADATA_ID 0x0000
#define BT_MESH_HEALTH_TEST_INFO_METADATA(tests) \
{ \
.len = ARRAY_SIZE(tests), \
.id = BT_MESH_HEALTH_TEST_INFO_METADATA_ID, \
.data = tests, \
}
/**
*
* Define a Health Test Info Metadata array.
*
* @param cid Company ID of the Health Test suite.
* @param tests A comma separated list of tests.
*
* @return A comma separated list of values that make Health Test Info Metadata
*/
#define BT_MESH_HEALTH_TEST_INFO(cid, tests...) \
BT_BYTES_LIST_LE16(cid), sizeof((uint8_t[]){ tests }), tests
/** @brief Notify the stack that the fault array state of the given element has
* changed.
*
* This prompts the Health server on this element to publish the current fault
* array if periodic publishing is disabled.
*
* @param elem Element to update the fault state of.
*
* @return 0 on success, or (negative) error code otherwise.
*/
int bt_mesh_health_srv_fault_update(const struct bt_mesh_elem *elem);
/** @cond INTERNAL_HIDDEN */
extern const struct bt_mesh_model_op bt_mesh_health_srv_op[];
extern const struct bt_mesh_model_cb bt_mesh_health_srv_cb;
/** @endcond */
#ifdef __cplusplus
}
#endif
/**
* @}
*/
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_MESH_HEALTH_SRV_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/mesh/health_srv.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 1,938 |
```objective-c
/*
*
*/
#ifndef BT_MESH_OD_PRIV_PROXY_CLI_H__
#define BT_MESH_OD_PRIV_PROXY_CLI_H__
#include <zephyr/bluetooth/mesh.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup bt_mesh_od_priv_proxy_cli Bluetooth Mesh On-Demand Private GATT Proxy Client
* @ingroup bt_mesh
* @{
*/
/** On-Demand Private Proxy Client Model Context */
struct bt_mesh_od_priv_proxy_cli {
/** Solicitation PDU RPL model entry pointer. */
const struct bt_mesh_model *model;
/* Internal parameters for tracking message responses. */
struct bt_mesh_msg_ack_ctx ack_ctx;
/** @brief Optional callback for On-Demand Private Proxy Status messages.
*
* Handles received On-Demand Private Proxy Status messages from a On-Demand Private Proxy
* server.The @c state param represents state of On-Demand Private Proxy server.
*
* @param cli On-Demand Private Proxy client that received the status message.
* @param addr Address of the sender.
* @param state State value.
*/
void (*od_status)(struct bt_mesh_od_priv_proxy_cli *cli, uint16_t addr, uint8_t state);
};
/**
* @brief On-Demand Private Proxy Client model composition data entry.
*/
#define BT_MESH_MODEL_OD_PRIV_PROXY_CLI(cli_data) \
BT_MESH_MODEL_CB(BT_MESH_MODEL_ID_ON_DEMAND_PROXY_CLI, \
_bt_mesh_od_priv_proxy_cli_op, NULL, cli_data, \
&_bt_mesh_od_priv_proxy_cli_cb)
/** @brief Get the target's On-Demand Private GATT Proxy state.
*
* This method can be used asynchronously by setting @p val_rsp as NULL.
* This way the method will not wait for response and will
* return immediately after sending the command.
*
* To process the response arguments of an async method, register
* the @c od_status callback in @c bt_mesh_od_priv_proxy_cli struct.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param val_rsp Response buffer for On-Demand Private GATT Proxy value.
*
* @return 0 on success, or (negative) error code otherwise.
*/
int bt_mesh_od_priv_proxy_cli_get(uint16_t net_idx, uint16_t addr, uint8_t *val_rsp);
/** @brief Set the target's On-Demand Private GATT Proxy state.
*
* This method can be used asynchronously by setting @p val_rsp as NULL.
* This way the method will not wait for response and will
* return immediately after sending the command.
*
* To process the response arguments of an async method, register
* the @c od_status callback in @c bt_mesh_od_priv_proxy_cli struct.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param val On-Demand Private GATT Proxy state to be set
* @param val_rsp Response buffer for On-Demand Private GATT Proxy value.
*
* @return 0 on success, or (negative) error code otherwise.
*/
int bt_mesh_od_priv_proxy_cli_set(uint16_t net_idx, uint16_t addr, uint8_t val, uint8_t *val_rsp);
/** @brief Set the transmission timeout value.
*
* @param timeout The new transmission timeout in milliseconds.
*/
void bt_mesh_od_priv_proxy_cli_timeout_set(int32_t timeout);
/** @cond INTERNAL_HIDDEN */
extern const struct bt_mesh_model_op _bt_mesh_od_priv_proxy_cli_op[];
extern const struct bt_mesh_model_cb _bt_mesh_od_priv_proxy_cli_cb;
/** @endcond */
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* BT_MESH_OD_PRIV_PROXY_CLI_H__ */
``` | /content/code_sandbox/include/zephyr/bluetooth/mesh/od_priv_proxy_cli.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 816 |
```objective-c
/** @file
* @brief Proxy APIs.
*/
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_MESH_PROXY_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_MESH_PROXY_H_
#include <stdint.h>
#include <zephyr/kernel.h>
#include <zephyr/sys/iterable_sections.h>
/**
* @brief Proxy
* @defgroup bt_mesh_proxy Proxy
* @ingroup bt_mesh
* @{
*/
#ifdef __cplusplus
extern "C" {
#endif
/** Callbacks for the Proxy feature.
*
* Should be instantiated with @ref BT_MESH_PROXY_CB_DEFINE.
*/
struct bt_mesh_proxy_cb {
/** @brief Started sending Node Identity beacons on the given subnet.
*
* @param net_idx Network index the Node Identity beacons are running
* on.
*/
void (*identity_enabled)(uint16_t net_idx);
/** @brief Stopped sending Node Identity beacons on the given subnet.
*
* @param net_idx Network index the Node Identity beacons were running
* on.
*/
void (*identity_disabled)(uint16_t net_idx);
};
/**
* @brief Register a callback structure for Proxy events.
*
* Registers a structure with callback functions that gets called on various
* Proxy events.
*
* @param _name Name of callback structure.
*/
#define BT_MESH_PROXY_CB_DEFINE(_name) \
static const STRUCT_SECTION_ITERABLE( \
bt_mesh_proxy_cb, _CONCAT(bt_mesh_proxy_cb_, _name))
/** @brief Enable advertising with Node Identity.
*
* This API requires that GATT Proxy support has been enabled. Once called
* each subnet will start advertising using Node Identity for the next
* 60 seconds.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_proxy_identity_enable(void);
/** @brief Enable advertising with Private Node Identity.
*
* This API requires that GATT Proxy support has been enabled. Once called
* each subnet will start advertising using Private Node Identity for the next
* 60 seconds.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_proxy_private_identity_enable(void);
/** @brief Allow Proxy Client to auto connect to a network.
*
* This API allows a proxy client to auto-connect a given network.
*
* @param net_idx Network Key Index
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_proxy_connect(uint16_t net_idx);
/** @brief Disallow Proxy Client to auto connect to a network.
*
* This API disallows a proxy client to connect a given network.
*
* @param net_idx Network Key Index
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_proxy_disconnect(uint16_t net_idx);
/** @brief Schedule advertising of Solicitation PDUs.
*
* Once called, the device will schedule advertising Solicitation PDUs for the amount of time
* defined by @c adv_int * (@c CONFIG_BT_MESH_SOL_ADV_XMIT + 1), where @c adv_int is 20ms
* for Bluetooth v5.0 or higher, or 100ms otherwise.
*
* If the number of advertised Solicitation PDUs reached 0xFFFFFF, the advertisements will
* no longer be started until the node is reprovisioned.
*
* @param net_idx Network Key Index
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_proxy_solicit(uint16_t net_idx);
#ifdef __cplusplus
}
#endif
/**
* @}
*/
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_MESH_PROXY_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/mesh/proxy.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 806 |
```objective-c
/** @file
* @brief Health Client Model APIs.
*/
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_MESH_HEALTH_CLI_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_MESH_HEALTH_CLI_H_
#include <zephyr/bluetooth/mesh.h>
/**
* @brief Health Client Model
* @defgroup bt_mesh_health_cli Health Client Model
* @ingroup bt_mesh
* @{
*/
#ifdef __cplusplus
extern "C" {
#endif
/** Health Client Model Context */
struct bt_mesh_health_cli {
/** Composition data model entry pointer. */
const struct bt_mesh_model *model;
/** Publication structure instance */
struct bt_mesh_model_pub pub;
/** Publication buffer */
struct net_buf_simple pub_buf;
/** Publication data */
uint8_t pub_data[BT_MESH_MODEL_BUF_LEN(BT_MESH_MODEL_OP_2(0x80, 0x32), 3)];
/** @brief Optional callback for Health Period Status messages.
*
* Handles received Health Period Status messages from a Health
* server. The @c divisor param represents the period divisor value.
*
* @param cli Health client that received the status message.
* @param addr Address of the sender.
* @param divisor Health Period Divisor value.
*/
void (*period_status)(struct bt_mesh_health_cli *cli, uint16_t addr,
uint8_t divisor);
/** @brief Optional callback for Health Attention Status messages.
*
* Handles received Health Attention Status messages from a Health
* server. The @c attention param represents the current attention value.
*
* @param cli Health client that received the status message.
* @param addr Address of the sender.
* @param attention Current attention value.
*/
void (*attention_status)(struct bt_mesh_health_cli *cli, uint16_t addr,
uint8_t attention);
/** @brief Optional callback for Health Fault Status messages.
*
* Handles received Health Fault Status messages from a Health
* server. The @c fault array represents all faults that are
* currently present in the server's element.
*
* @see bt_mesh_health_faults
*
* @param cli Health client that received the status message.
* @param addr Address of the sender.
* @param test_id Identifier of a most recently performed test.
* @param cid Company Identifier of the node.
* @param faults Array of faults.
* @param fault_count Number of faults in the fault array.
*/
void (*fault_status)(struct bt_mesh_health_cli *cli, uint16_t addr,
uint8_t test_id, uint16_t cid, uint8_t *faults,
size_t fault_count);
/** @brief Optional callback for Health Current Status messages.
*
* Handles received Health Current Status messages from a Health
* server. The @c fault array represents all faults that are
* currently present in the server's element.
*
* @see bt_mesh_health_faults
*
* @param cli Health client that received the status message.
* @param addr Address of the sender.
* @param test_id Identifier of a most recently performed test.
* @param cid Company Identifier of the node.
* @param faults Array of faults.
* @param fault_count Number of faults in the fault array.
*/
void (*current_status)(struct bt_mesh_health_cli *cli, uint16_t addr,
uint8_t test_id, uint16_t cid, uint8_t *faults,
size_t fault_count);
/* Internal parameters for tracking message responses. */
struct bt_mesh_msg_ack_ctx ack_ctx;
};
/**
* @brief Generic Health Client model composition data entry.
*
* @param cli_data Pointer to a @ref bt_mesh_health_cli instance.
*/
#define BT_MESH_MODEL_HEALTH_CLI(cli_data) \
BT_MESH_MODEL_CB(BT_MESH_MODEL_ID_HEALTH_CLI, bt_mesh_health_cli_op, \
&(cli_data)->pub, cli_data, &bt_mesh_health_cli_cb)
/** @brief Get the registered fault state for the given Company ID.
*
* This method can be used asynchronously by setting @p test_id
* and ( @p faults or @p fault_count ) as NULL This way the method
* will not wait for response and will return immediately after
* sending the command.
*
* To process the response arguments of an async method, register
* the @c fault_status callback in @c bt_mesh_health_cli struct.
*
* @see bt_mesh_health_faults
*
* @param cli Client model to send on.
* @param ctx Message context, or NULL to use the configured publish
* parameters.
* @param cid Company ID to get the registered faults of.
* @param test_id Test ID response buffer.
* @param faults Fault array response buffer.
* @param fault_count Fault count response buffer.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_health_cli_fault_get(struct bt_mesh_health_cli *cli, struct bt_mesh_msg_ctx *ctx,
uint16_t cid, uint8_t *test_id, uint8_t *faults,
size_t *fault_count);
/** @brief Clear the registered faults for the given Company ID.
*
* This method can be used asynchronously by setting @p test_id
* and ( @p faults or @p fault_count ) as NULL This way the method
* will not wait for response and will return immediately after
* sending the command.
*
* To process the response arguments of an async method, register
* the @c fault_status callback in @c bt_mesh_health_cli struct.
*
* @see bt_mesh_health_faults
*
* @param cli Client model to send on.
* @param ctx Message context, or NULL to use the configured publish
* parameters.
* @param cid Company ID to clear the registered faults for.
* @param test_id Test ID response buffer.
* @param faults Fault array response buffer.
* @param fault_count Fault count response buffer.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_health_cli_fault_clear(struct bt_mesh_health_cli *cli, struct bt_mesh_msg_ctx *ctx,
uint16_t cid, uint8_t *test_id, uint8_t *faults,
size_t *fault_count);
/** @brief Clear the registered faults for the given Company ID (unacked).
*
* @see bt_mesh_health_faults
*
* @param cli Client model to send on.
* @param ctx Message context, or NULL to use the configured publish
* parameters.
* @param cid Company ID to clear the registered faults for.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_health_cli_fault_clear_unack(struct bt_mesh_health_cli *cli,
struct bt_mesh_msg_ctx *ctx, uint16_t cid);
/** @brief Invoke a self-test procedure for the given Company ID.
*
* This method can be used asynchronously by setting @p faults
* or @p fault_count as NULL This way the method will not wait
* for response and will return immediately after sending the command.
*
* To process the response arguments of an async method, register
* the @c fault_status callback in @c bt_mesh_health_cli struct.
*
* @param cli Client model to send on.
* @param ctx Message context, or NULL to use the configured publish
* parameters.
* @param cid Company ID to invoke the test for.
* @param test_id Test ID response buffer.
* @param faults Fault array response buffer.
* @param fault_count Fault count response buffer.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_health_cli_fault_test(struct bt_mesh_health_cli *cli, struct bt_mesh_msg_ctx *ctx,
uint16_t cid, uint8_t test_id, uint8_t *faults,
size_t *fault_count);
/** @brief Invoke a self-test procedure for the given Company ID (unacked).
*
* @param cli Client model to send on.
* @param ctx Message context, or NULL to use the configured publish
* parameters.
* @param cid Company ID to invoke the test for.
* @param test_id Test ID response buffer.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_health_cli_fault_test_unack(struct bt_mesh_health_cli *cli, struct bt_mesh_msg_ctx *ctx,
uint16_t cid, uint8_t test_id);
/** @brief Get the target node's Health fast period divisor.
*
* The health period divisor is used to increase the publish rate when a fault
* is registered. Normally, the Health server will publish with the period in
* the configured publish parameters. When a fault is registered, the publish
* period is divided by (1 << divisor). For example, if the target node's
* Health server is configured to publish with a period of 16 seconds, and the
* Health fast period divisor is 5, the Health server will publish with an
* interval of 500 ms when a fault is registered.
*
* This method can be used asynchronously by setting @p divisor
* as NULL. This way the method will not wait for response and will
* return immediately after sending the command.
*
* To process the response arguments of an async method, register
* the @c period_status callback in @c bt_mesh_health_cli struct.
*
* @param cli Client model to send on.
* @param ctx Message context, or NULL to use the configured publish
* parameters.
* @param divisor Health period divisor response buffer.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_health_cli_period_get(struct bt_mesh_health_cli *cli, struct bt_mesh_msg_ctx *ctx,
uint8_t *divisor);
/** @brief Set the target node's Health fast period divisor.
*
* The health period divisor is used to increase the publish rate when a fault
* is registered. Normally, the Health server will publish with the period in
* the configured publish parameters. When a fault is registered, the publish
* period is divided by (1 << divisor). For example, if the target node's
* Health server is configured to publish with a period of 16 seconds, and the
* Health fast period divisor is 5, the Health server will publish with an
* interval of 500 ms when a fault is registered.
*
* This method can be used asynchronously by setting @p updated_divisor
* as NULL. This way the method will not wait for response and will
* return immediately after sending the command.
*
* To process the response arguments of an async method, register
* the @c period_status callback in @c bt_mesh_health_cli struct.
*
* @param cli Client model to send on.
* @param ctx Message context, or NULL to use the configured publish
* parameters.
* @param divisor New Health period divisor.
* @param updated_divisor Health period divisor response buffer.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_health_cli_period_set(struct bt_mesh_health_cli *cli, struct bt_mesh_msg_ctx *ctx,
uint8_t divisor, uint8_t *updated_divisor);
/** @brief Set the target node's Health fast period divisor (unacknowledged).
*
* This is an unacknowledged version of this API.
*
* @param cli Client model to send on.
* @param ctx Message context, or NULL to use the configured publish
* parameters.
* @param divisor New Health period divisor.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_health_cli_period_set_unack(struct bt_mesh_health_cli *cli, struct bt_mesh_msg_ctx *ctx,
uint8_t divisor);
/** @brief Get the current attention timer value.
*
* This method can be used asynchronously by setting @p attention
* as NULL. This way the method will not wait for response and will
* return immediately after sending the command.
*
* To process the response arguments of an async method, register
* the @c attention_status callback in @c bt_mesh_health_cli struct.
*
* @param cli Client model to send on.
* @param ctx Message context, or NULL to use the configured publish
* parameters.
* @param attention Attention timer response buffer, measured in seconds.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_health_cli_attention_get(struct bt_mesh_health_cli *cli, struct bt_mesh_msg_ctx *ctx,
uint8_t *attention);
/** @brief Set the attention timer.
*
* This method can be used asynchronously by setting @p updated_attention
* as NULL. This way the method will not wait for response and will
* return immediately after sending the command.
*
* To process the response arguments of an async method, register
* the @c attention_status callback in @c bt_mesh_health_cli struct.
*
* @param cli Client model to send on.
* @param ctx Message context, or NULL to use the configured publish
* parameters.
* @param attention New attention timer time, in seconds.
* @param updated_attention Attention timer response buffer, measured in
* seconds.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_health_cli_attention_set(struct bt_mesh_health_cli *cli, struct bt_mesh_msg_ctx *ctx,
uint8_t attention, uint8_t *updated_attention);
/** @brief Set the attention timer (unacknowledged).
*
* @param cli Client model to send on.
* @param ctx Message context, or NULL to use the configured publish
* parameters.
* @param attention New attention timer time, in seconds.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_health_cli_attention_set_unack(struct bt_mesh_health_cli *cli,
struct bt_mesh_msg_ctx *ctx, uint8_t attention);
/** @brief Get the current transmission timeout value.
*
* @return The configured transmission timeout in milliseconds.
*/
int32_t bt_mesh_health_cli_timeout_get(void);
/** @brief Set the transmission timeout value.
*
* @param timeout The new transmission timeout.
*/
void bt_mesh_health_cli_timeout_set(int32_t timeout);
/** @cond INTERNAL_HIDDEN */
extern const struct bt_mesh_model_op bt_mesh_health_cli_op[];
extern const struct bt_mesh_model_cb bt_mesh_health_cli_cb;
/** @endcond */
#ifdef __cplusplus
}
#endif
/**
* @}
*/
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_MESH_HEALTH_CLI_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/mesh/health_cli.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 3,297 |
```objective-c
/*
*
*/
/**
* @file
* @defgroup bt_mesh_dfu_cli Firmware Uppdate Client model
* @ingroup bt_mesh_dfu
* @{
* @brief API for the Bluetooth Mesh Firmware Update Client model
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_MESH_DFU_CLI_H__
#define ZEPHYR_INCLUDE_BLUETOOTH_MESH_DFU_CLI_H__
#include <zephyr/bluetooth/mesh/access.h>
#include <zephyr/bluetooth/mesh/blob_cli.h>
#include <zephyr/bluetooth/mesh/dfu.h>
#ifdef __cplusplus
extern "C" {
#endif
struct bt_mesh_dfu_cli;
/**
*
* @brief Initialization parameters for the @ref bt_mesh_dfu_cli.
*
* @sa bt_mesh_dfu_cli_cb.
*
* @param _handlers Handler callback structure.
*/
#define BT_MESH_DFU_CLI_INIT(_handlers) \
{ \
.cb = _handlers, \
.blob = { .cb = &_bt_mesh_dfu_cli_blob_handlers }, \
}
/**
*
* @brief Firmware Update Client model Composition Data entry.
*
* @param _cli Pointer to a @ref bt_mesh_dfu_cli instance.
*/
#define BT_MESH_MODEL_DFU_CLI(_cli) \
BT_MESH_MODEL_BLOB_CLI(&(_cli)->blob), \
BT_MESH_MODEL_CB(BT_MESH_MODEL_ID_DFU_CLI, _bt_mesh_dfu_cli_op, NULL, \
_cli, &_bt_mesh_dfu_cli_cb)
/** DFU Target node. */
struct bt_mesh_dfu_target {
/** BLOB Target node */
struct bt_mesh_blob_target blob;
/** Image index on the Target node */
uint8_t img_idx;
/** Expected DFU effect, see @ref bt_mesh_dfu_effect. */
uint8_t effect;
/** Current DFU status, see @ref bt_mesh_dfu_status. */
uint8_t status;
/** Current DFU phase, see @ref bt_mesh_dfu_phase. */
uint8_t phase;
};
/** Metadata status response. */
struct bt_mesh_dfu_metadata_status {
/** Image index. */
uint8_t idx;
/** Status code. */
enum bt_mesh_dfu_status status;
/** Effect of transfer. */
enum bt_mesh_dfu_effect effect;
};
/** DFU Target node status parameters. */
struct bt_mesh_dfu_target_status {
/** Status of the previous operation. */
enum bt_mesh_dfu_status status;
/** Phase of the current DFU transfer. */
enum bt_mesh_dfu_phase phase;
/** The effect the update will have on the Target device's state. */
enum bt_mesh_dfu_effect effect;
/** BLOB ID used in the transfer. */
uint64_t blob_id;
/** Image index to transfer. */
uint8_t img_idx;
/** TTL used in the transfer. */
uint8_t ttl;
/** Additional response time for the Target nodes, in 10-second increments.
*
* The extra time can be used to give the Target nodes more time to respond
* to messages from the Client. The actual timeout will be calculated
* according to the following formula:
*
* @verbatim
* timeout = 20 seconds + (10 seconds * timeout_base) + (100 ms * TTL)
* @endverbatim
*
* If a Target node fails to respond to a message from the Client within the
* configured transfer timeout, the Target node is dropped.
*/
uint16_t timeout_base;
};
/** @brief DFU image callback.
*
* The image callback is called for every DFU image on the Target node when
* calling @ref bt_mesh_dfu_cli_imgs_get.
*
* @param cli Firmware Update Client model instance.
* @param ctx Message context of the received message.
* @param idx Image index.
* @param total Total number of images on the Target node.
* @param img Image information for the given image index.
* @param cb_data Callback data.
*
* @retval BT_MESH_DFU_ITER_STOP Stop iterating through the image list and
* return from @ref bt_mesh_dfu_cli_imgs_get.
* @retval BT_MESH_DFU_ITER_CONTINUE Continue iterating through the image list
* if any images remain.
*/
typedef enum bt_mesh_dfu_iter (*bt_mesh_dfu_img_cb_t)(
struct bt_mesh_dfu_cli *cli, struct bt_mesh_msg_ctx *ctx, uint8_t idx,
uint8_t total, const struct bt_mesh_dfu_img *img, void *cb_data);
/** Firmware Update Client event callbacks. */
struct bt_mesh_dfu_cli_cb {
/** @brief BLOB transfer is suspended.
*
* Called when the BLOB transfer is suspended due to response timeout from all Target nodes.
*
* @param cli Firmware Update Client model instance.
*/
void (*suspended)(struct bt_mesh_dfu_cli *cli);
/** @brief DFU ended.
*
* Called when the DFU transfer ends, either because all Target nodes were
* lost or because the transfer was completed successfully.
*
* @param cli Firmware Update Client model instance.
* @param reason Reason for ending.
*/
void (*ended)(struct bt_mesh_dfu_cli *cli,
enum bt_mesh_dfu_status reason);
/** @brief DFU transfer applied on all active Target nodes.
*
* Called at the end of the apply procedure started by @ref
* bt_mesh_dfu_cli_apply.
*
* @param cli Firmware Update Client model instance.
*/
void (*applied)(struct bt_mesh_dfu_cli *cli);
/** @brief DFU transfer confirmed on all active Target nodes.
*
* Called at the end of the apply procedure started by @ref
* bt_mesh_dfu_cli_confirm.
*
* @param cli Firmware Update Client model instance.
*/
void (*confirmed)(struct bt_mesh_dfu_cli *cli);
/** @brief DFU Target node was lost.
*
* A DFU Target node was dropped from the receivers list. The Target node's
* @c status is set to reflect the reason for the failure.
*
* @param cli Firmware Update Client model instance.
* @param target DFU Target node that was lost.
*/
void (*lost_target)(struct bt_mesh_dfu_cli *cli,
struct bt_mesh_dfu_target *target);
};
/** Firmware Update Client model instance.
*
* Should be initialized with @ref BT_MESH_DFU_CLI_INIT.
*/
struct bt_mesh_dfu_cli {
/** Callback structure. */
const struct bt_mesh_dfu_cli_cb *cb;
/** Underlying BLOB Transfer Client. */
struct bt_mesh_blob_cli blob;
/* runtime state */
uint32_t op;
const struct bt_mesh_model *mod;
struct {
const struct bt_mesh_dfu_slot *slot;
const struct bt_mesh_blob_io *io;
struct bt_mesh_blob_xfer blob;
uint8_t state;
uint8_t flags;
} xfer;
struct {
uint8_t ttl;
uint8_t type;
uint8_t img_cnt;
uint16_t addr;
struct k_sem sem;
void *params;
bt_mesh_dfu_img_cb_t img_cb;
} req;
};
/** BLOB parameters for Firmware Update Client transfer: */
struct bt_mesh_dfu_cli_xfer_blob_params {
/* Logarithmic representation of the block size. */
uint8_t block_size_log;
/** Base chunk size. May be smaller for the last chunk. */
uint16_t chunk_size;
};
/** Firmware Update Client transfer parameters: */
struct bt_mesh_dfu_cli_xfer {
/** BLOB ID to use for this transfer, or 0 to set it randomly. */
uint64_t blob_id;
/** DFU image slot to transfer. */
const struct bt_mesh_dfu_slot *slot;
/** Transfer mode (Push (Push BLOB Transfer Mode) or Pull (Pull BLOB Transfer Mode)) */
enum bt_mesh_blob_xfer_mode mode;
/** BLOB parameters to be used for the transfer, or NULL to retrieve Target nodes'
* capabilities before sending a firmware.
*/
const struct bt_mesh_dfu_cli_xfer_blob_params *blob_params;
};
/** @brief Start distributing a DFU.
*
* Starts distribution of the firmware in the given slot to the list of DFU
* Target nodes in @c ctx. The transfer runs in the background, and its end is
* signalled through the @ref bt_mesh_dfu_cli_cb::ended callback.
*
* @note The BLOB Transfer Client transfer inputs @c targets list must point to a list of @ref
* bt_mesh_dfu_target nodes.
*
* @param cli Firmware Update Client model instance.
* @param inputs BLOB Transfer Client transfer inputs.
* @param io BLOB stream to read BLOB from.
* @param xfer Firmware Update Client transfer parameters.
*
* @return 0 on success, or (negative) error code otherwise.
*/
int bt_mesh_dfu_cli_send(struct bt_mesh_dfu_cli *cli,
const struct bt_mesh_blob_cli_inputs *inputs,
const struct bt_mesh_blob_io *io,
const struct bt_mesh_dfu_cli_xfer *xfer);
/** @brief Suspend a DFU transfer.
*
* @param cli Firmware Update Client instance.
*
* @return 0 on success, or (negative) error code otherwise.
*/
int bt_mesh_dfu_cli_suspend(struct bt_mesh_dfu_cli *cli);
/** @brief Resume the suspended transfer.
*
* @param cli Firmware Update Client instance.
*
* @return 0 on success, or (negative) error code otherwise.
*/
int bt_mesh_dfu_cli_resume(struct bt_mesh_dfu_cli *cli);
/** @brief Cancel a DFU transfer.
*
* Will cancel the ongoing DFU transfer, or the transfer on a specific Target
* node if @c ctx is valid.
*
* @param cli Firmware Update Client model instance.
* @param ctx Message context, or NULL to cancel the ongoing DFU transfer.
*
* @return 0 on success, or (negative) error code otherwise.
*/
int bt_mesh_dfu_cli_cancel(struct bt_mesh_dfu_cli *cli,
struct bt_mesh_msg_ctx *ctx);
/** @brief Apply the completed DFU transfer.
*
* A transfer can only be applied after it has ended successfully. The Firmware
* Update Client's @c applied callback is called at the end of the apply procedure.
*
* @param cli Firmware Update Client model instance.
*
* @return 0 on success, or (negative) error code otherwise.
*/
int bt_mesh_dfu_cli_apply(struct bt_mesh_dfu_cli *cli);
/** @brief Confirm that the active transfer has been applied on the Target nodes.
*
* A transfer can only be confirmed after it has been applied. The Firmware Update
* Client's @c confirmed callback is called at the end of the confirm
* procedure.
*
* Target nodes that have reported the effect as @ref BT_MESH_DFU_EFFECT_UNPROV
* are expected to not respond to the query, and will fail if they do.
*
* @param cli Firmware Update Client model instance.
*
* @return 0 on success, or (negative) error code otherwise.
*/
int bt_mesh_dfu_cli_confirm(struct bt_mesh_dfu_cli *cli);
/** @brief Get progress as a percentage of completion.
*
* @param cli Firmware Update Client model instance.
*
* @return The progress of the current transfer in percent, or 0 if no
* transfer is active.
*/
uint8_t bt_mesh_dfu_cli_progress(struct bt_mesh_dfu_cli *cli);
/** @brief Check whether a DFU transfer is in progress.
*
* @param cli Firmware Update Client model instance.
*
* @return true if the BLOB Transfer Client is currently participating in a transfer,
* false otherwise.
*/
bool bt_mesh_dfu_cli_is_busy(struct bt_mesh_dfu_cli *cli);
/** @brief Perform a DFU image list request.
*
* Requests the full list of DFU images on a Target node, and iterates through
* them, calling the @c cb for every image.
*
* The DFU image list request can be used to determine which image index the
* Target node holds its different firmwares in.
*
* Waits for a response until the procedure timeout expires.
*
* @param cli Firmware Update Client model instance.
* @param ctx Message context.
* @param cb Callback to call for each image index.
* @param cb_data Callback data to pass to @c cb.
* @param max_count Max number of images to return.
*
* @return 0 on success, or (negative) error code otherwise.
*/
int bt_mesh_dfu_cli_imgs_get(struct bt_mesh_dfu_cli *cli,
struct bt_mesh_msg_ctx *ctx,
bt_mesh_dfu_img_cb_t cb, void *cb_data,
uint8_t max_count);
/** @brief Perform a metadata check for the given DFU image slot.
*
* The metadata check procedure allows the Firmware Update Client to check if a Target
* node will accept a transfer of this DFU image slot, and what the effect would be.
*
* Waits for a response until the procedure timeout expires.
*
* @param cli Firmware Update Client model instance.
* @param ctx Message context.
* @param img_idx Target node's image index to check.
* @param slot DFU image slot to check for.
* @param rsp Metadata status response buffer.
*
* @return 0 on success, or (negative) error code otherwise.
*/
int bt_mesh_dfu_cli_metadata_check(struct bt_mesh_dfu_cli *cli,
struct bt_mesh_msg_ctx *ctx, uint8_t img_idx,
const struct bt_mesh_dfu_slot *slot,
struct bt_mesh_dfu_metadata_status *rsp);
/** @brief Get the status of a Target node.
*
* @param cli Firmware Update Client model instance.
* @param ctx Message context.
* @param rsp Response data buffer.
*
* @return 0 on success, or (negative) error code otherwise.
*/
int bt_mesh_dfu_cli_status_get(struct bt_mesh_dfu_cli *cli,
struct bt_mesh_msg_ctx *ctx,
struct bt_mesh_dfu_target_status *rsp);
/** @brief Get the current procedure timeout value.
*
* @return The configured procedure timeout.
*/
int32_t bt_mesh_dfu_cli_timeout_get(void);
/** @brief Set the procedure timeout value.
*
* @param timeout The new procedure timeout.
*/
void bt_mesh_dfu_cli_timeout_set(int32_t timeout);
/** @cond INTERNAL_HIDDEN */
extern const struct bt_mesh_blob_cli_cb _bt_mesh_dfu_cli_blob_handlers;
extern const struct bt_mesh_model_cb _bt_mesh_dfu_cli_cb;
extern const struct bt_mesh_model_op _bt_mesh_dfu_cli_op[];
/** @endcond */
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_MESH_DFU_CLI_H__ */
/** @} */
``` | /content/code_sandbox/include/zephyr/bluetooth/mesh/dfu_cli.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 3,279 |
```objective-c
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_MESH_CDB_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_MESH_CDB_H_
#include <stdbool.h>
#include <stdint.h>
#include <zephyr/sys/atomic.h>
#include <zephyr/bluetooth/mesh.h>
#ifdef __cplusplus
extern "C" {
#endif
#if defined(CONFIG_BT_MESH_CDB)
#define NODE_COUNT CONFIG_BT_MESH_CDB_NODE_COUNT
#define SUBNET_COUNT CONFIG_BT_MESH_CDB_SUBNET_COUNT
#define APP_KEY_COUNT CONFIG_BT_MESH_CDB_APP_KEY_COUNT
#else
#define NODE_COUNT 0
#define SUBNET_COUNT 0
#define APP_KEY_COUNT 0
#endif
enum {
BT_MESH_CDB_NODE_CONFIGURED,
BT_MESH_CDB_NODE_FLAG_COUNT
};
struct bt_mesh_cdb_node {
uint8_t uuid[16];
uint16_t addr;
uint16_t net_idx;
uint8_t num_elem;
struct bt_mesh_key dev_key;
ATOMIC_DEFINE(flags, BT_MESH_CDB_NODE_FLAG_COUNT);
};
struct bt_mesh_cdb_subnet {
uint16_t net_idx;
uint8_t kr_phase;
struct {
struct bt_mesh_key net_key;
} keys[2];
};
struct bt_mesh_cdb_app_key {
uint16_t net_idx;
uint16_t app_idx;
struct {
struct bt_mesh_key app_key;
} keys[2];
};
enum {
BT_MESH_CDB_VALID,
BT_MESH_CDB_SUBNET_PENDING,
BT_MESH_CDB_KEYS_PENDING,
BT_MESH_CDB_NODES_PENDING,
BT_MESH_CDB_IVU_IN_PROGRESS,
BT_MESH_CDB_FLAG_COUNT,
};
struct bt_mesh_cdb {
uint32_t iv_index;
uint16_t lowest_avail_addr;
ATOMIC_DEFINE(flags, BT_MESH_CDB_FLAG_COUNT);
struct bt_mesh_cdb_node nodes[NODE_COUNT];
struct bt_mesh_cdb_subnet subnets[SUBNET_COUNT];
struct bt_mesh_cdb_app_key app_keys[APP_KEY_COUNT];
};
extern struct bt_mesh_cdb bt_mesh_cdb;
/** @brief Create the Mesh Configuration Database.
*
* Create and initialize the Mesh Configuration Database. A primary subnet,
* ie one with NetIdx 0, will be added and the provided key will be used as
* NetKey for that subnet.
*
* @param key The NetKey to be used for the primary subnet.
*
* @return 0 on success or negative error code on failure.
*/
int bt_mesh_cdb_create(const uint8_t key[16]);
/** @brief Clear the Mesh Configuration Database.
*
* Remove all nodes, subnets and app-keys stored in the database and mark
* the database as invalid. The data will be cleared from persistent storage
* if CONFIG_BT_SETTINGS is enabled.
*/
void bt_mesh_cdb_clear(void);
/** @brief Set and store the IV Index and IV Update flag.
*
* The IV Index stored in the CDB will be the one used during provisioning
* of new nodes. This function is generally only used from inside the stack.
*
* This function will store the data to persistent storage if
* CONFIG_BT_SETTINGS is enabled.
*
* @param iv_index The new IV Index to use.
* @param iv_update True if there is an ongoing IV Update procedure.
*/
void bt_mesh_cdb_iv_update(uint32_t iv_index, bool iv_update);
/** @brief Allocate a node.
*
* Allocate a new node in the CDB.
*
* If @c addr is 0, @ref bt_mesh_cdb_free_addr_get will be used to allocate
* a free address.
*
* @param uuid UUID of the node.
* @param addr Address of the node's primary element. If 0, the lowest
* possible address available will be assigned to the node.
* @param num_elem Number of elements that the node has.
* @param net_idx NetIdx that the node was provisioned to.
*
* @return The new node or NULL if CDB has already allocated
* :kconfig:option:`CONFIG_BT_MESH_CDB_NODE_COUNT` nodes, or reached the
* end of the unicast address range, or if @c addr is non-zero and less
* than the lowest available address or collide with the allocated addresses.
*/
struct bt_mesh_cdb_node *bt_mesh_cdb_node_alloc(const uint8_t uuid[16], uint16_t addr,
uint8_t num_elem, uint16_t net_idx);
/** @brief Get the first available address for the given element count.
*
* @param num_elem Number of elements to accommodate.
*
* @return The first unicast address in an address range that allows a node
* with the given number of elements to fit.
*/
uint16_t bt_mesh_cdb_free_addr_get(uint8_t num_elem);
/** @brief Delete a node.
*
* Delete a node from the CDB. When deleting the node and the address of the
* last element of the deleted node is greater than the lowest available
* address, CDB will update the lowest available address. The lowest
* available address is reset and the deleted addresses can be reused only
* after IV Index update.
*
* @param node The node to be deleted.
* @param store If true, the node will be cleared from persistent storage.
*/
void bt_mesh_cdb_node_del(struct bt_mesh_cdb_node *node, bool store);
/** @brief Update a node.
*
* Assigns the node a new address and clears the previous persistent storage
* entry.
*
* @param node The node to be deleted.
* @param addr New unicast address for the node.
* @param num_elem Updated number of elements in the node.
*/
void bt_mesh_cdb_node_update(struct bt_mesh_cdb_node *node, uint16_t addr,
uint8_t num_elem);
/** @brief Get a node by address.
*
* Try to find the node that has the provided address assigned to one of its
* elements.
*
* @param addr Address of the element to look for.
*
* @return The node that has an element with address addr or NULL if no such
* node exists.
*/
struct bt_mesh_cdb_node *bt_mesh_cdb_node_get(uint16_t addr);
/** @brief Store node to persistent storage.
*
* @param node Node to be stored.
*/
void bt_mesh_cdb_node_store(const struct bt_mesh_cdb_node *node);
/** @brief Import device key for selected node.
*
* Using security library with PSA implementation access to the key by pointer
* will not give a valid value since the key is hidden in the library.
* The application has to import the key.
*
* @param node Selected node.
* @param in key value.
*
* @return 0 on success or negative error code on failure.
*/
int bt_mesh_cdb_node_key_import(struct bt_mesh_cdb_node *node, const uint8_t in[16]);
/** @brief Export device key from selected node.
*
* Using security library with PSA implementation access to the key by pointer
* will not give a valid value since the key is hidden in the library.
* The application has to export the key.
*
* @param node Selected node.
* @param out key value.
*
* @return 0 on success or negative error code on failure.
*/
int bt_mesh_cdb_node_key_export(const struct bt_mesh_cdb_node *node, uint8_t out[16]);
enum {
BT_MESH_CDB_ITER_STOP = 0,
BT_MESH_CDB_ITER_CONTINUE,
};
/** @typedef bt_mesh_cdb_node_func_t
* @brief Node iterator callback.
*
* @param node Node found.
* @param user_data Data given.
*
* @return BT_MESH_CDB_ITER_CONTINUE to continue to iterate through the nodes
* or BT_MESH_CDB_ITER_STOP to stop.
*/
typedef uint8_t (*bt_mesh_cdb_node_func_t)(struct bt_mesh_cdb_node *node,
void *user_data);
/** @brief Node iterator.
*
* Iterate nodes in the Mesh Configuration Database. The callback function
* will only be called for valid, ie allocated, nodes.
*
* @param func Callback function.
* @param user_data Data to pass to the callback.
*/
void bt_mesh_cdb_node_foreach(bt_mesh_cdb_node_func_t func, void *user_data);
/** @brief Allocate a subnet.
*
* Allocate a new subnet in the CDB.
*
* @param net_idx NetIdx of the subnet.
*
* @return The new subnet or NULL if it cannot be allocated due to
* lack of resources or the subnet has been already allocated.
*/
struct bt_mesh_cdb_subnet *bt_mesh_cdb_subnet_alloc(uint16_t net_idx);
/** @brief Delete a subnet.
*
* Delete a subnet from the CDB.
*
* @param sub The subnet to be deleted.
* @param store If true, the subnet will be cleared from persistent storage.
*/
void bt_mesh_cdb_subnet_del(struct bt_mesh_cdb_subnet *sub, bool store);
/** @brief Get a subnet by NetIdx
*
* Try to find the subnet with the specified NetIdx.
*
* @param net_idx NetIdx of the subnet to look for.
*
* @return The subnet with the specified NetIdx or NULL if no such subnet
* exists.
*/
struct bt_mesh_cdb_subnet *bt_mesh_cdb_subnet_get(uint16_t net_idx);
/** @brief Store subnet to persistent storage.
*
* @param sub Subnet to be stored.
*/
void bt_mesh_cdb_subnet_store(const struct bt_mesh_cdb_subnet *sub);
/** @brief Get the flags for a subnet
*
* @param sub The subnet to get flags for.
*
* @return The flags for the subnet.
*/
uint8_t bt_mesh_cdb_subnet_flags(const struct bt_mesh_cdb_subnet *sub);
/** @brief Import network key for selected subnetwork.
*
* Using security library with PSA implementation access to the key by pointer
* will not give a valid value since the key is hidden in the library.
* The application has to import the key.
*
* @param sub Selected subnetwork.
* @param key_idx 0 or 1. If Key Refresh procedure is in progress then two keys are available.
* The old key has an index 0 and the new one has an index 1.
* Otherwise, the only key with index 0 exists.
* @param in key value.
*
* @return 0 on success or negative error code on failure.
*/
int bt_mesh_cdb_subnet_key_import(struct bt_mesh_cdb_subnet *sub, int key_idx,
const uint8_t in[16]);
/** @brief Export network key from selected subnetwork.
*
* Using security library with PSA implementation access to the key by pointer
* will not give a valid value since the key is hidden in the library.
* The application has to export the key.
*
* @param sub Selected subnetwork.
* @param key_idx 0 or 1. If Key Refresh procedure is in progress then two keys are available.
* The old key has an index 0 and the new one has an index 1.
* Otherwise, the only key with index 0 exists.
* @param out key value.
*
* @return 0 on success or negative error code on failure.
*/
int bt_mesh_cdb_subnet_key_export(const struct bt_mesh_cdb_subnet *sub, int key_idx,
uint8_t out[16]);
/** @brief Allocate an application key.
*
* Allocate a new application key in the CDB.
*
* @param net_idx NetIdx of NetKey that the application key is bound to.
* @param app_idx AppIdx of the application key.
*
* @return The new application key or NULL if it cannot be allocated due to
* lack of resources or the key has been already allocated.
*/
struct bt_mesh_cdb_app_key *bt_mesh_cdb_app_key_alloc(uint16_t net_idx,
uint16_t app_idx);
/** @brief Delete an application key.
*
* Delete an application key from the CDB.
*
* @param key The application key to be deleted.
* @param store If true, the key will be cleared from persistent storage.
*/
void bt_mesh_cdb_app_key_del(struct bt_mesh_cdb_app_key *key, bool store);
/** @brief Get an application key by AppIdx
*
* Try to find the application key with the specified AppIdx.
*
* @param app_idx AppIdx of the application key to look for.
*
* @return The application key with the specified AppIdx or NULL if no such key
* exists.
*/
struct bt_mesh_cdb_app_key *bt_mesh_cdb_app_key_get(uint16_t app_idx);
/** @brief Store application key to persistent storage.
*
* @param key Application key to be stored.
*/
void bt_mesh_cdb_app_key_store(const struct bt_mesh_cdb_app_key *key);
/** @brief Import application key.
*
* Using security library with PSA implementation access to the key by pointer
* will not give a valid value since the key is hidden in the library.
* The application has to import the key.
*
* @param key cdb application key structure.
* @param key_idx 0 or 1. If Key Refresh procedure is in progress then two keys are available.
* The old key has an index 0 and the new one has an index 1.
* Otherwise, the only key with index 0 exists.
* @param in key value.
*
* @return 0 on success or negative error code on failure.
*/
int bt_mesh_cdb_app_key_import(struct bt_mesh_cdb_app_key *key, int key_idx, const uint8_t in[16]);
/** @brief Export application key.
*
* Using security library with PSA implementation access to the key by pointer
* will not give a valid value since the key is hidden in the library.
* The application has to export the key.
*
* @param key cdb application key structure.
* @param key_idx 0 or 1. If Key Refresh procedure is in progress then two keys are available.
* The old key has an index 0 and the new one has an index 1.
* Otherwise, the only key with index 0 exists.
* @param out key value.
*
* @return 0 on success or negative error code on failure.
*/
int bt_mesh_cdb_app_key_export(const struct bt_mesh_cdb_app_key *key, int key_idx, uint8_t out[16]);
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_MESH_CDB_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/mesh/cdb.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 3,177 |
```objective-c
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BT_MESH_RPR_H__
#define ZEPHYR_INCLUDE_BT_MESH_RPR_H__
#include <zephyr/kernel.h>
#include <zephyr/bluetooth/mesh/main.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup bt_mesh_rpr Remote Provisioning models
* @ingroup bt_mesh
* @{
*/
/** Unprovisioned device has URI hash value */
#define BT_MESH_RPR_UNPROV_HASH BIT(0)
#define BT_MESH_RPR_UNPROV_ACTIVE BIT(1) /**< Internal */
#define BT_MESH_RPR_UNPROV_FOUND BIT(2) /**< Internal */
#define BT_MESH_RPR_UNPROV_REPORTED BIT(3) /**< Internal */
#define BT_MESH_RPR_UNPROV_EXT BIT(4) /**< Internal */
#define BT_MESH_RPR_UNPROV_HAS_LINK BIT(5) /**< Internal */
#define BT_MESH_RPR_UNPROV_EXT_ADV_RXD BIT(6) /**< Internal */
/** Minimum extended scan duration in seconds */
#define BT_MESH_RPR_EXT_SCAN_TIME_MIN 1
/** Maximum extended scan duration in seconds */
#define BT_MESH_RPR_EXT_SCAN_TIME_MAX 21
enum bt_mesh_rpr_status {
BT_MESH_RPR_SUCCESS,
BT_MESH_RPR_ERR_SCANNING_CANNOT_START,
BT_MESH_RPR_ERR_INVALID_STATE,
BT_MESH_RPR_ERR_LIMITED_RESOURCES,
BT_MESH_RPR_ERR_LINK_CANNOT_OPEN,
BT_MESH_RPR_ERR_LINK_OPEN_FAILED,
BT_MESH_RPR_ERR_LINK_CLOSED_BY_DEVICE,
BT_MESH_RPR_ERR_LINK_CLOSED_BY_SERVER,
BT_MESH_RPR_ERR_LINK_CLOSED_BY_CLIENT,
BT_MESH_RPR_ERR_LINK_CLOSED_AS_CANNOT_RECEIVE_PDU,
BT_MESH_RPR_ERR_LINK_CLOSED_AS_CANNOT_SEND_PDU,
BT_MESH_RPR_ERR_LINK_CLOSED_AS_CANNOT_DELIVER_PDU_REPORT,
};
enum bt_mesh_rpr_scan {
BT_MESH_RPR_SCAN_IDLE,
BT_MESH_RPR_SCAN_MULTI,
BT_MESH_RPR_SCAN_SINGLE,
};
enum bt_mesh_rpr_node_refresh {
/** Change the Device key. */
BT_MESH_RPR_NODE_REFRESH_DEVKEY,
/** Change the Device key and address. Device composition may change. */
BT_MESH_RPR_NODE_REFRESH_ADDR,
/** Change the Device key and composition. */
BT_MESH_RPR_NODE_REFRESH_COMPOSITION,
};
enum bt_mesh_rpr_link_state {
BT_MESH_RPR_LINK_IDLE,
BT_MESH_RPR_LINK_OPENING,
BT_MESH_RPR_LINK_ACTIVE,
BT_MESH_RPR_LINK_SENDING,
BT_MESH_RPR_LINK_CLOSING,
};
/** Remote provisioning actor, as seen across the mesh. */
struct bt_mesh_rpr_node {
/** Unicast address of the node. */
uint16_t addr;
/** Network index used when communicating with the node. */
uint16_t net_idx;
/** Time To Live value used when communicating with the node. */
uint8_t ttl;
};
/** Unprovisioned device. */
struct bt_mesh_rpr_unprov {
/** Unprovisioned device UUID. */
uint8_t uuid[16];
/** Flags, see @p BT_MESH_RPR_UNPROV_* flags. */
uint8_t flags;
/** RSSI of unprovisioned device, as received by server. */
int8_t rssi;
/** Out of band information. */
bt_mesh_prov_oob_info_t oob;
/** URI hash in unprovisioned beacon.
*
* Only valid if @c flags has @ref BT_MESH_RPR_UNPROV_HASH set.
*/
uint32_t hash;
};
/** Remote Provisioning Link status */
struct bt_mesh_rpr_link {
/** Link status */
enum bt_mesh_rpr_status status;
/** Link state */
enum bt_mesh_rpr_link_state state;
};
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_INCLUDE_BT_MESH_RPR_H__ */
``` | /content/code_sandbox/include/zephyr/bluetooth/mesh/rpr.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 831 |
```objective-c
/*
*
*/
#ifndef BT_MESH_SOL_PDU_RPL_SRV_H__
#define BT_MESH_SOL_PDU_RPL_SRV_H__
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup bt_mesh_sol_pdu_rpl_srv Bluetooth Mesh Solicitation PDU RPL Server
* @ingroup bt_mesh
* @{
*/
/**
* @brief Solicitation PDU RPL Server model composition data entry.
*/
#define BT_MESH_MODEL_SOL_PDU_RPL_SRV \
BT_MESH_MODEL_CB(BT_MESH_MODEL_ID_SOL_PDU_RPL_SRV, \
_bt_mesh_sol_pdu_rpl_srv_op, NULL, NULL, \
&_bt_mesh_sol_pdu_rpl_srv_cb)
/** @cond INTERNAL_HIDDEN */
extern const struct bt_mesh_model_op _bt_mesh_sol_pdu_rpl_srv_op[];
extern const struct bt_mesh_model_cb _bt_mesh_sol_pdu_rpl_srv_cb;
/** @endcond */
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* BT_MESH_SOL_PDU_RPL_SRV_H__ */
``` | /content/code_sandbox/include/zephyr/bluetooth/mesh/sol_pdu_rpl_srv.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 212 |
```objective-c
/** @file
* @brief Bluetooth Mesh Protocol APIs.
*/
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_MESH_MAIN_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_MESH_MAIN_H_
#include <stdbool.h>
#include <stdint.h>
#include <zephyr/kernel.h>
#include <zephyr/sys/iterable_sections.h>
/**
* @brief Provisioning
* @defgroup bt_mesh_prov Provisioning
* @ingroup bt_mesh
* @{
*/
#ifdef __cplusplus
extern "C" {
#endif
/** Available authentication algorithms. */
enum {
BT_MESH_PROV_AUTH_CMAC_AES128_AES_CCM,
BT_MESH_PROV_AUTH_HMAC_SHA256_AES_CCM,
};
/** OOB Type field values. */
enum {
BT_MESH_STATIC_OOB_AVAILABLE = BIT(0), /**< Static OOB information available */
BT_MESH_OOB_AUTH_REQUIRED = BIT(1) /**< OOB authentication required */
};
/** Available Provisioning output authentication actions. */
typedef enum {
BT_MESH_NO_OUTPUT = 0,
BT_MESH_BLINK = BIT(0), /**< Blink */
BT_MESH_BEEP = BIT(1), /**< Beep */
BT_MESH_VIBRATE = BIT(2), /**< Vibrate */
BT_MESH_DISPLAY_NUMBER = BIT(3), /**< Output numeric */
BT_MESH_DISPLAY_STRING = BIT(4), /**< Output alphanumeric */
} bt_mesh_output_action_t;
/** Available Provisioning input authentication actions. */
typedef enum {
BT_MESH_NO_INPUT = 0,
BT_MESH_PUSH = BIT(0), /**< Push */
BT_MESH_TWIST = BIT(1), /**< Twist */
BT_MESH_ENTER_NUMBER = BIT(2), /**< Input number */
BT_MESH_ENTER_STRING = BIT(3), /**< Input alphanumeric */
} bt_mesh_input_action_t;
/** Available Provisioning bearers. */
typedef enum {
BT_MESH_PROV_ADV = BIT(0), /**< PB-ADV bearer */
BT_MESH_PROV_GATT = BIT(1), /**< PB-GATT bearer */
BT_MESH_PROV_REMOTE = BIT(2), /**< PB-Remote bearer */
} bt_mesh_prov_bearer_t;
/** Out of Band information location. */
typedef enum {
BT_MESH_PROV_OOB_OTHER = BIT(0), /**< Other */
BT_MESH_PROV_OOB_URI = BIT(1), /**< Electronic / URI */
BT_MESH_PROV_OOB_2D_CODE = BIT(2), /**< 2D machine-readable code */
BT_MESH_PROV_OOB_BAR_CODE = BIT(3), /**< Bar Code */
BT_MESH_PROV_OOB_NFC = BIT(4), /**< Near Field Communication (NFC) */
BT_MESH_PROV_OOB_NUMBER = BIT(5), /**< Number */
BT_MESH_PROV_OOB_STRING = BIT(6), /**< String */
BT_MESH_PROV_OOB_CERTIFICATE = BIT(7), /**< Support for certificate-based provisioning */
BT_MESH_PROV_OOB_RECORDS = BIT(8), /**< Support for provisioning records */
/* 9 - 10 are reserved */
BT_MESH_PROV_OOB_ON_BOX = BIT(11), /**< On box */
BT_MESH_PROV_OOB_IN_BOX = BIT(12), /**< Inside box */
BT_MESH_PROV_OOB_ON_PAPER = BIT(13), /**< On piece of paper */
BT_MESH_PROV_OOB_IN_MANUAL = BIT(14), /**< Inside manual */
BT_MESH_PROV_OOB_ON_DEV = BIT(15), /**< On device */
} bt_mesh_prov_oob_info_t;
/** Device Capabilities. */
struct bt_mesh_dev_capabilities {
/** Number of elements supported by the device */
uint8_t elem_count;
/** Supported algorithms and other capabilities */
uint16_t algorithms;
/** Supported public key types */
uint8_t pub_key_type;
/** Supported OOB Types */
uint8_t oob_type;
/** Supported Output OOB Actions */
bt_mesh_output_action_t output_actions;
/** Supported Input OOB Actions */
bt_mesh_input_action_t input_actions;
/** Maximum size of Output OOB supported */
uint8_t output_size;
/** Maximum size in octets of Input OOB supported */
uint8_t input_size;
};
/** Provisioning properties & capabilities. */
struct bt_mesh_prov {
/** The UUID that's used when advertising as unprovisioned */
const uint8_t *uuid;
/** Optional URI. This will be advertised separately from the
* unprovisioned beacon, however the unprovisioned beacon will
* contain a hash of it so the two can be associated by the
* provisioner.
*/
const char *uri;
/** Out of Band information field. */
bt_mesh_prov_oob_info_t oob_info;
/** Pointer to Public Key in big-endian for OOB public key type support.
*
* Remember to enable @kconfig{CONFIG_BT_MESH_PROV_OOB_PUBLIC_KEY}
* when initializing this parameter.
*
* Must be used together with @ref bt_mesh_prov::private_key_be.
*/
const uint8_t *public_key_be;
/** Pointer to Private Key in big-endian for OOB public key type support.
*
* Remember to enable @kconfig{CONFIG_BT_MESH_PROV_OOB_PUBLIC_KEY}
* when initializing this parameter.
*
* Must be used together with @ref bt_mesh_prov::public_key_be.
*/
const uint8_t *private_key_be;
/** Static OOB value */
const uint8_t *static_val;
/** Static OOB value length */
uint8_t static_val_len;
/** Maximum size of Output OOB supported */
uint8_t output_size;
/** Supported Output OOB Actions */
uint16_t output_actions;
/** Maximum size of Input OOB supported */
uint8_t input_size;
/** Supported Input OOB Actions */
uint16_t input_actions;
/** @brief Provisioning Capabilities.
*
* This callback notifies the application that the provisioning capabilities
* of the unprovisioned device has been received.
*
* The application can consequently call bt_mesh_auth_method_set_<*> to
* select suitable provisioning oob authentication method.
*
* When this callback returns, the provisioner will start authentication with
* the chosen method.
*
* @param cap capabilities supported by device.
*/
void (*capabilities)(const struct bt_mesh_dev_capabilities *cap);
/** @brief Output of a number is requested.
*
* This callback notifies the application that it should
* output the given number using the given action.
*
* @param act Action for outputting the number.
* @param num Number to be outputted.
*
* @return Zero on success or negative error code otherwise
*/
int (*output_number)(bt_mesh_output_action_t act, uint32_t num);
/** @brief Output of a string is requested.
*
* This callback notifies the application that it should
* display the given string to the user.
*
* @param str String to be displayed.
*
* @return Zero on success or negative error code otherwise
*/
int (*output_string)(const char *str);
/** @brief Input is requested.
*
* This callback notifies the application that it should
* request input from the user using the given action. The
* requested input will either be a string or a number, and
* the application needs to consequently call the
* bt_mesh_input_string() or bt_mesh_input_number() functions
* once the data has been acquired from the user.
*
* @param act Action for inputting data.
* @param num Maximum size of the inputted data.
*
* @return Zero on success or negative error code otherwise
*/
int (*input)(bt_mesh_input_action_t act, uint8_t size);
/** @brief The other device finished their OOB input.
*
* This callback notifies the application that it should stop
* displaying its output OOB value, as the other party finished their
* OOB input.
*/
void (*input_complete)(void);
/** @brief Unprovisioned beacon has been received.
*
* This callback notifies the application that an unprovisioned
* beacon has been received.
*
* @param uuid UUID
* @param oob_info OOB Information
* @param uri_hash Pointer to URI Hash value. NULL if no hash was
* present in the beacon.
*/
void (*unprovisioned_beacon)(uint8_t uuid[16],
bt_mesh_prov_oob_info_t oob_info,
uint32_t *uri_hash);
/** @brief PB-GATT Unprovisioned Advertising has been received.
*
* This callback notifies the application that an PB-GATT
* unprovisioned Advertising has been received.
*
* @param uuid UUID
* @param oob_info OOB Information
*/
void (*unprovisioned_beacon_gatt)(uint8_t uuid[16],
bt_mesh_prov_oob_info_t oob_info);
/** @brief Provisioning link has been opened.
*
* This callback notifies the application that a provisioning
* link has been opened on the given provisioning bearer.
*
* @param bearer Provisioning bearer.
*/
void (*link_open)(bt_mesh_prov_bearer_t bearer);
/** @brief Provisioning link has been closed.
*
* This callback notifies the application that a provisioning
* link has been closed on the given provisioning bearer.
*
* @param bearer Provisioning bearer.
*/
void (*link_close)(bt_mesh_prov_bearer_t bearer);
/** @brief Provisioning is complete.
*
* This callback notifies the application that provisioning has
* been successfully completed, and that the local node has been
* assigned the specified NetKeyIndex and primary element address.
*
* @param net_idx NetKeyIndex given during provisioning.
* @param addr Primary element address.
*/
void (*complete)(uint16_t net_idx, uint16_t addr);
/** @brief Local node has been reprovisioned.
*
* This callback notifies the application that reprovisioning has
* been successfully completed.
*
* @param addr New primary element address.
*/
void (*reprovisioned)(uint16_t addr);
/** @brief A new node has been added to the provisioning database.
*
* This callback notifies the application that provisioning has
* been successfully completed, and that a node has been assigned
* the specified NetKeyIndex and primary element address.
*
* @param net_idx NetKeyIndex given during provisioning.
* @param uuid UUID of the added node
* @param addr Primary element address.
* @param num_elem Number of elements that this node has.
*/
void (*node_added)(uint16_t net_idx, uint8_t uuid[16], uint16_t addr,
uint8_t num_elem);
/** @brief Node has been reset.
*
* This callback notifies the application that the local node
* has been reset and needs to be provisioned again. The node will
* not automatically advertise as unprovisioned, rather the
* bt_mesh_prov_enable() API needs to be called to enable
* unprovisioned advertising on one or more provisioning bearers.
*/
void (*reset)(void);
};
struct bt_mesh_rpr_cli;
struct bt_mesh_rpr_node;
/** @brief Provide provisioning input OOB string.
*
* This is intended to be called after the bt_mesh_prov input callback
* has been called with BT_MESH_ENTER_STRING as the action.
*
* @param str String.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_mesh_input_string(const char *str);
/** @brief Provide provisioning input OOB number.
*
* This is intended to be called after the bt_mesh_prov input callback
* has been called with BT_MESH_ENTER_NUMBER as the action.
*
* @param num Number.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_mesh_input_number(uint32_t num);
/** @brief Provide Device public key.
*
* @param public_key Device public key in big-endian.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_mesh_prov_remote_pub_key_set(const uint8_t public_key[64]);
/** @brief Use Input OOB authentication.
*
* Provisioner only.
*
* Instruct the unprovisioned device to use the specified Input OOB
* authentication action. When using @ref BT_MESH_PUSH, @ref BT_MESH_TWIST or
* @ref BT_MESH_ENTER_NUMBER, the @ref bt_mesh_prov::output_number callback is
* called with a random number that has to be entered on the unprovisioned
* device.
*
* When using @ref BT_MESH_ENTER_STRING, the @ref bt_mesh_prov::output_string
* callback is called with a random string that has to be entered on the
* unprovisioned device.
*
* @param action Authentication action used by the unprovisioned device.
* @param size Authentication size.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_mesh_auth_method_set_input(bt_mesh_input_action_t action, uint8_t size);
/** @brief Use Output OOB authentication.
*
* Provisioner only.
*
* Instruct the unprovisioned device to use the specified Output OOB
* authentication action. The @ref bt_mesh_prov::input callback will
* be called.
*
* When using @ref BT_MESH_BLINK, @ref BT_MESH_BEEP, @ref BT_MESH_VIBRATE
* or @ref BT_MESH_DISPLAY_NUMBER, and the application has to call
* @ref bt_mesh_input_number with the random number indicated by
* the unprovisioned device.
*
* When using @ref BT_MESH_DISPLAY_STRING, the application has to call
* @ref bt_mesh_input_string with the random string displayed by the
* unprovisioned device.
*
* @param action Authentication action used by the unprovisioned device.
* @param size Authentication size.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_mesh_auth_method_set_output(bt_mesh_output_action_t action, uint8_t size);
/** @brief Use static OOB authentication.
*
* Provisioner only.
*
* Instruct the unprovisioned device to use static OOB authentication, and use
* the given static authentication value when provisioning.
*
* @param static_val Static OOB value.
* @param size Static OOB value size.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_mesh_auth_method_set_static(const uint8_t *static_val, uint8_t size);
/** @brief Don't use OOB authentication.
*
* Provisioner only.
*
* Don't use any authentication when provisioning new devices. This is the
* default behavior.
*
* @warning Not using any authentication exposes the mesh network to
* impersonation attacks, where attackers can pretend to be the
* unprovisioned device to gain access to the network. Authentication
* is strongly encouraged.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_mesh_auth_method_set_none(void);
/** @brief Enable specific provisioning bearers
*
* Enable one or more provisioning bearers.
*
* @param bearers Bit-wise or of provisioning bearers.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_mesh_prov_enable(bt_mesh_prov_bearer_t bearers);
/** @brief Disable specific provisioning bearers
*
* Disable one or more provisioning bearers.
*
* @param bearers Bit-wise or of provisioning bearers.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_mesh_prov_disable(bt_mesh_prov_bearer_t bearers);
/** @brief Provision the local Mesh Node.
*
* This API should normally not be used directly by the application. The
* only exception is for testing purposes where manual provisioning is
* desired without an actual external provisioner.
*
* @param net_key Network Key
* @param net_idx Network Key Index
* @param flags Provisioning Flags
* @param iv_index IV Index
* @param addr Primary element address
* @param dev_key Device Key
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_mesh_provision(const uint8_t net_key[16], uint16_t net_idx,
uint8_t flags, uint32_t iv_index, uint16_t addr,
const uint8_t dev_key[16]);
/** @brief Provision a Mesh Node using PB-ADV
*
* @param uuid UUID
* @param net_idx Network Key Index
* @param addr Address to assign to remote device. If addr is 0,
* the lowest available address will be chosen.
* @param attention_duration The attention duration to be send to remote device
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_mesh_provision_adv(const uint8_t uuid[16], uint16_t net_idx, uint16_t addr,
uint8_t attention_duration);
/** @brief Provision a Mesh Node using PB-GATT
*
* @param uuid UUID
* @param net_idx Network Key Index
* @param addr Address to assign to remote device. If addr is 0,
* the lowest available address will be chosen.
* @param attention_duration The attention duration to be send to remote device
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_mesh_provision_gatt(const uint8_t uuid[16], uint16_t net_idx, uint16_t addr,
uint8_t attention_duration);
/** @brief Provision a Mesh Node using PB-Remote
*
* @param cli Remote Provisioning Client Model to provision with.
* @param srv Remote Provisioning Server that should be used to tunnel the
* provisioning.
* @param uuid UUID of the unprovisioned node
* @param net_idx Network Key Index to give to the unprovisioned node.
* @param addr Address to assign to remote device. If addr is 0,
* the lowest available address will be chosen.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_mesh_provision_remote(struct bt_mesh_rpr_cli *cli,
const struct bt_mesh_rpr_node *srv,
const uint8_t uuid[16], uint16_t net_idx,
uint16_t addr);
/** @brief Reprovision a Mesh Node using PB-Remote
*
* Reprovisioning can be used to change the device key, unicast address and
* composition data of another device. The reprovisioning procedure uses the
* same protocol as normal provisioning, with the same level of security.
*
* There are three tiers of reprovisioning:
* 1. Refreshing the device key
* 2. Refreshing the device key and node address. Composition data may change,
* including the number of elements.
* 3. Refreshing the device key and composition data, in case the composition
* data of the target node changed due to a firmware update or a similar
* procedure.
*
* The target node indicates that its composition data changed by instantiating
* its composition data page 128. If the number of elements have changed, it
* may be necessary to move the unicast address of the target node as well, to
* avoid overlapping addresses.
*
* @note Changing the unicast addresses of the target node requires changes to
* all nodes that publish directly to any of the target node's models.
*
* @param cli Remote Provisioning Client Model to provision on
* @param srv Remote Provisioning Server to reprovision
* @param addr Address to assign to remote device. If addr is 0, the
* lowest available address will be chosen.
* @param comp_change The target node has indicated that its composition
* data has changed. Note that the target node will reject
* the update if this isn't true.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_mesh_reprovision_remote(struct bt_mesh_rpr_cli *cli,
struct bt_mesh_rpr_node *srv,
uint16_t addr, bool comp_change);
/** @brief Check if the local node has been provisioned.
*
* This API can be used to check if the local node has been provisioned
* or not. It can e.g. be helpful to determine if there was a stored
* network in flash, i.e. if the network was restored after calling
* settings_load().
*
* @return True if the node is provisioned. False otherwise.
*/
bool bt_mesh_is_provisioned(void);
/**
* @}
*/
/**
* @brief Bluetooth Mesh
* @defgroup bt_mesh Bluetooth Mesh
* @ingroup bluetooth
* @{
*/
/** Primary Network Key index */
#define BT_MESH_NET_PRIMARY 0x000
/** Relay feature */
#define BT_MESH_FEAT_RELAY BIT(0)
/** GATT Proxy feature */
#define BT_MESH_FEAT_PROXY BIT(1)
/** Friend feature */
#define BT_MESH_FEAT_FRIEND BIT(2)
/** Low Power Node feature */
#define BT_MESH_FEAT_LOW_POWER BIT(3)
/** Supported heartbeat publication features */
#define BT_MESH_FEAT_SUPPORTED (BT_MESH_FEAT_RELAY | \
BT_MESH_FEAT_PROXY | \
BT_MESH_FEAT_FRIEND | \
BT_MESH_FEAT_LOW_POWER)
/** @brief Initialize Mesh support
*
* After calling this API, the node will not automatically advertise as
* unprovisioned, rather the bt_mesh_prov_enable() API needs to be called
* to enable unprovisioned advertising on one or more provisioning bearers.
*
* @param prov Node provisioning information.
* @param comp Node Composition.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_mesh_init(const struct bt_mesh_prov *prov,
const struct bt_mesh_comp *comp);
/** @brief Reset the state of the local Mesh node.
*
* Resets the state of the node, which means that it needs to be
* reprovisioned to become an active node in a Mesh network again.
*
* After calling this API, the node will not automatically advertise as
* unprovisioned, rather the bt_mesh_prov_enable() API needs to be called
* to enable unprovisioned advertising on one or more provisioning bearers.
*
*/
void bt_mesh_reset(void);
/** @brief Suspend the Mesh network temporarily.
*
* This API can be used for power saving purposes, but the user should be
* aware that leaving the local node suspended for a long period of time
* may cause it to become permanently disconnected from the Mesh network.
* If at all possible, the Friendship feature should be used instead, to
* make the node into a Low Power Node.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_suspend(void);
/** @brief Resume a suspended Mesh network.
*
* This API resumes the local node, after it has been suspended using the
* bt_mesh_suspend() API.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_resume(void);
/** @brief Toggle the IV Update test mode
*
* This API is only available if the IV Update test mode has been enabled
* in Kconfig. It is needed for passing most of the IV Update qualification
* test cases.
*
* @param enable true to enable IV Update test mode, false to disable it.
*/
void bt_mesh_iv_update_test(bool enable);
/** @brief Toggle the IV Update state
*
* This API is only available if the IV Update test mode has been enabled
* in Kconfig. It is needed for passing most of the IV Update qualification
* test cases.
*
* @return true if IV Update In Progress state was entered, false otherwise.
*/
bool bt_mesh_iv_update(void);
/** @brief Toggle the Low Power feature of the local device
*
* Enables or disables the Low Power feature of the local device. This is
* exposed as a run-time feature, since the device might want to change
* this e.g. based on being plugged into a stable power source or running
* from a battery power source.
*
* @param enable true to enable LPN functionality, false to disable it.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_mesh_lpn_set(bool enable);
/** @brief Send out a Friend Poll message.
*
* Send a Friend Poll message to the Friend of this node. If there is no
* established Friendship the function will return an error.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_mesh_lpn_poll(void);
/** Low Power Node callback functions. */
struct bt_mesh_lpn_cb {
/** @brief Friendship established.
*
* This callback notifies the application that friendship has
* been successfully established.
*
* @param net_idx NetKeyIndex used during friendship establishment.
* @param friend_addr Friend address.
* @param queue_size Friend queue size.
* @param recv_window Low Power Node's listens duration for
* Friend response.
*/
void (*established)(uint16_t net_idx, uint16_t friend_addr,
uint8_t queue_size, uint8_t recv_window);
/** @brief Friendship terminated.
*
* This callback notifies the application that friendship has
* been terminated.
*
* @param net_idx NetKeyIndex used during friendship establishment.
* @param friend_addr Friend address.
*/
void (*terminated)(uint16_t net_idx, uint16_t friend_addr);
/** @brief Local Poll Request.
*
* This callback notifies the application that the local node has
* polled the friend node.
*
* This callback will be called before @ref bt_mesh_lpn_cb::established
* when attempting to establish a friendship.
*
* @param net_idx NetKeyIndex used during friendship establishment.
* @param friend_addr Friend address.
* @param retry Retry or first poll request for each transaction.
*/
void (*polled)(uint16_t net_idx, uint16_t friend_addr, bool retry);
};
/**
* @brief Register a callback structure for Friendship events.
*
* @param _name Name of callback structure.
*/
#define BT_MESH_LPN_CB_DEFINE(_name) \
static const STRUCT_SECTION_ITERABLE(bt_mesh_lpn_cb, \
_CONCAT(bt_mesh_lpn_cb_, \
_name))
/** Friend Node callback functions. */
struct bt_mesh_friend_cb {
/** @brief Friendship established.
*
* This callback notifies the application that friendship has
* been successfully established.
*
* @param net_idx NetKeyIndex used during friendship establishment.
* @param lpn_addr Low Power Node address.
* @param recv_delay Receive Delay in units of 1 millisecond.
* @param polltimeout PollTimeout in units of 1 millisecond.
*/
void (*established)(uint16_t net_idx, uint16_t lpn_addr,
uint8_t recv_delay, uint32_t polltimeout);
/** @brief Friendship terminated.
*
* This callback notifies the application that friendship has
* been terminated.
*
* @param net_idx NetKeyIndex used during friendship establishment.
* @param lpn_addr Low Power Node address.
*/
void (*terminated)(uint16_t net_idx, uint16_t lpn_addr);
/** @brief Friend Poll Request.
*
* This callback notifies the application that the low power node has
* polled the friend node.
*
* This callback will be called before @ref bt_mesh_friend_cb::established
* when attempting to establish a friendship.
*
* @param net_idx NetKeyIndex used during friendship establishment.
* @param lpn_addr LPN address.
*/
void (*polled)(uint16_t net_idx, uint16_t lpn_addr);
};
/**
* @brief Register a callback structure for Friendship events.
*
* Registers a callback structure that will be called whenever Friendship
* gets established or terminated.
*
* @param _name Name of callback structure.
*/
#define BT_MESH_FRIEND_CB_DEFINE(_name) \
static const STRUCT_SECTION_ITERABLE(bt_mesh_friend_cb, \
_CONCAT(bt_mesh_friend_cb_, \
_name))
#if defined(CONFIG_BT_TESTING)
struct bt_mesh_snb {
/** Flags */
uint8_t flags;
/** Network ID */
uint64_t net_id;
/** IV Index */
uint32_t iv_idx;
/** Authentication Value */
uint64_t auth_val;
};
struct bt_mesh_prb {
/** Random */
uint8_t random[13];
/** Flags */
uint8_t flags;
/** IV Index */
uint32_t iv_idx;
/** Authentication tag */
uint64_t auth_tag;
};
/** Beacon callback functions. */
struct bt_mesh_beacon_cb {
/** @brief Secure Network Beacon received.
*
* This callback notifies the application that Secure Network Beacon
* was received.
*
* @param snb Structure describing received Secure Network Beacon
*/
void (*snb_received)(const struct bt_mesh_snb *snb);
/** @brief Private Beacon received.
*
* This callback notifies the application that Private Beacon
* was received and successfully decrypted.
*
* @param prb Structure describing received Private Beacon
*/
void (*priv_received)(const struct bt_mesh_prb *prb);
};
/**
* @brief Register a callback structure for beacon events.
*
* Registers a callback structure that will be called whenever beacon advertisement
* is received.
*
* @param _name Name of callback structure.
*/
#define BT_MESH_BEACON_CB_DEFINE(_name) \
static const STRUCT_SECTION_ITERABLE(bt_mesh_beacon_cb, \
_CONCAT(bt_mesh_beacon_cb_, \
_name))
#endif
/** @brief Terminate Friendship.
*
* Terminated Friendship for given LPN.
*
* @param lpn_addr Low Power Node address.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_mesh_friend_terminate(uint16_t lpn_addr);
/** @brief Store pending RPL entry(ies) in the persistent storage.
*
* This API allows the user to store pending RPL entry(ies) in the persistent
* storage without waiting for the timeout.
*
* @note When flash is used as the persistent storage, calling this API too
* frequently may wear it out.
*
* @param addr Address of the node which RPL entry needs to be stored or
* @ref BT_MESH_ADDR_ALL_NODES to store all pending RPL entries.
*/
void bt_mesh_rpl_pending_store(uint16_t addr);
/** @brief Iterate stored Label UUIDs.
*
* When @c addr is @ref BT_MESH_ADDR_UNASSIGNED, this function iterates over all available addresses
* starting with @c uuid. In this case, use @c retaddr to get virtual address representation of
* the returned Label UUID. When @c addr is a virtual address, this function returns next Label
* UUID corresponding to the @c addr. When @c uuid is NULL, this function returns the first
* available UUID. If @c uuid is previously returned uuid, this function returns following uuid.
*
* @param addr Virtual address to search for, or @ref BT_MESH_ADDR_UNASSIGNED.
* @param uuid Pointer to the previously returned Label UUID or NULL.
* @param retaddr Pointer to a memory where virtual address representation of the returning UUID is
* to be stored to.
*
* @return Pointer to Label UUID, or NULL if no more entries found.
*/
const uint8_t *bt_mesh_va_uuid_get(uint16_t addr, const uint8_t *uuid, uint16_t *retaddr);
#ifdef __cplusplus
}
#endif
/**
* @}
*/
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_MESH_MAIN_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/mesh/main.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 7,199 |
```objective-c
/** @file
* @brief Heartbeat APIs.
*/
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_MESH_HEARTBEAT_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_MESH_HEARTBEAT_H_
#include <stdint.h>
#include <zephyr/sys/iterable_sections.h>
#include <zephyr/sys/slist.h>
/**
* @brief Heartbeat
* @defgroup bt_mesh_heartbeat Heartbeat
* @ingroup bt_mesh
* @{
*/
#ifdef __cplusplus
extern "C" {
#endif
/** Heartbeat Publication parameters */
struct bt_mesh_hb_pub {
/** Destination address. */
uint16_t dst;
/** Remaining publish count. */
uint16_t count;
/** Time To Live value. */
uint8_t ttl;
/**
* Bitmap of features that trigger a Heartbeat publication if
* they change. Legal values are @ref BT_MESH_FEAT_RELAY,
* @ref BT_MESH_FEAT_PROXY, @ref BT_MESH_FEAT_FRIEND and
* @ref BT_MESH_FEAT_LOW_POWER.
*/
uint16_t feat;
/** Network index used for publishing. */
uint16_t net_idx;
/** Publication period in seconds. */
uint32_t period;
};
/** Heartbeat Subscription parameters. */
struct bt_mesh_hb_sub {
/** Subscription period in seconds. */
uint32_t period;
/** Remaining subscription time in seconds. */
uint32_t remaining;
/** Source address to receive Heartbeats from. */
uint16_t src;
/** Destination address to received Heartbeats on. */
uint16_t dst;
/** The number of received Heartbeat messages so far. */
uint16_t count;
/**
* Minimum hops in received messages, ie the shortest registered
* path from the publishing node to the subscribing node. A
* Heartbeat received from an immediate neighbor has hop
* count = 1.
*/
uint8_t min_hops;
/**
* Maximum hops in received messages, ie the longest registered
* path from the publishing node to the subscribing node. A
* Heartbeat received from an immediate neighbor has hop
* count = 1.
*/
uint8_t max_hops;
};
/** Heartbeat callback structure */
struct bt_mesh_hb_cb {
/** @brief Receive callback for heartbeats.
*
* Gets called on every received Heartbeat that matches the current
* Heartbeat subscription parameters.
*
* @param sub Current Heartbeat subscription parameters.
* @param hops The number of hops the Heartbeat was received
* with.
* @param feat The feature set of the publishing node. The
* value is a bitmap of @ref BT_MESH_FEAT_RELAY,
* @ref BT_MESH_FEAT_PROXY,
* @ref BT_MESH_FEAT_FRIEND and
* @ref BT_MESH_FEAT_LOW_POWER.
*/
void (*recv)(const struct bt_mesh_hb_sub *sub, uint8_t hops,
uint16_t feat);
/** @brief Subscription end callback for heartbeats.
*
* Gets called when the subscription period ends, providing a summary
* of the received heartbeat messages.
*
* @param sub Current Heartbeat subscription parameters.
*/
void (*sub_end)(const struct bt_mesh_hb_sub *sub);
/** @brief Publication sent callback for heartbeats.
*
* Gets called when the heartbeat is successfully published.
*
* @param pub Current Heartbeat publication parameters.
*/
void (*pub_sent)(const struct bt_mesh_hb_pub *pub);
};
/**
* @brief Register a callback structure for Heartbeat events.
*
* Registers a callback structure that will be called whenever Heartbeat
* events occur
*
* @param _name Name of callback structure.
*/
#define BT_MESH_HB_CB_DEFINE(_name) \
static const STRUCT_SECTION_ITERABLE(bt_mesh_hb_cb, _name)
/** @brief Get the current Heartbeat publication parameters.
*
* @param get Heartbeat publication parameters return buffer.
*/
void bt_mesh_hb_pub_get(struct bt_mesh_hb_pub *get);
/** @brief Get the current Heartbeat subscription parameters.
*
* @param get Heartbeat subscription parameters return buffer.
*/
void bt_mesh_hb_sub_get(struct bt_mesh_hb_sub *get);
#ifdef __cplusplus
}
#endif
/**
* @}
*/
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_MESH_HEARTBEAT_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/mesh/heartbeat.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 964 |
```objective-c
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_MESH_SHELL_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_MESH_SHELL_H_
#include <zephyr/bluetooth/mesh.h>
#ifdef __cplusplus
extern "C" {
#endif
/** Maximum number of faults the health server can have. */
#define BT_MESH_SHELL_CUR_FAULTS_MAX 4
/**
* A helper to define a health publication context for shell with the shell's
* maximum number of faults the element can have.
*
* @param _name Name given to the publication context variable.
*/
#define BT_MESH_SHELL_HEALTH_PUB_DEFINE(_name) \
BT_MESH_HEALTH_PUB_DEFINE(_name, \
BT_MESH_SHELL_CUR_FAULTS_MAX);
/** Target context for the mesh shell */
struct bt_mesh_shell_target {
/* Current destination address */
uint16_t dst;
/* Current net index */
uint16_t net_idx;
/* Current app index */
uint16_t app_idx;
};
/** @brief External reference to health server */
extern struct bt_mesh_health_srv bt_mesh_shell_health_srv;
/** @brief External reference to health server metadata */
extern const struct bt_mesh_models_metadata_entry health_srv_meta[];
/** @brief External reference to health client */
extern struct bt_mesh_health_cli bt_mesh_shell_health_cli;
/** @brief External reference to Firmware Update Server */
extern struct bt_mesh_dfu_srv bt_mesh_shell_dfu_srv;
/** @brief External reference to Firmware Update Client */
extern struct bt_mesh_dfu_cli bt_mesh_shell_dfu_cli;
/** @brief External reference to BLOB Transfer Server */
extern struct bt_mesh_blob_srv bt_mesh_shell_blob_srv;
/** @brief External reference to BLOB Transfer Client */
extern struct bt_mesh_blob_cli bt_mesh_shell_blob_cli;
/** @brief External reference to Remote Provisioning Client */
extern struct bt_mesh_rpr_cli bt_mesh_shell_rpr_cli;
/** @brief External reference to provisioning handler. */
extern struct bt_mesh_prov bt_mesh_shell_prov;
/** @brief External reference to shell target context. */
extern struct bt_mesh_shell_target bt_mesh_shell_target_ctx;
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_MESH_SHELL_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/mesh/shell.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 462 |
```objective-c
/*
*
*/
#ifndef BT_MESH_OP_AGG_CLI_H__
#define BT_MESH_OP_AGG_CLI_H__
#include <zephyr/bluetooth/mesh.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup bt_mesh_op_agg_cli Opcodes Aggregator Client model
* @ingroup bt_mesh
* @{
*/
/**
*
* @brief Opcodes Aggregator Client model composition data entry.
*/
#define BT_MESH_MODEL_OP_AGG_CLI \
BT_MESH_MODEL_CB(BT_MESH_MODEL_ID_OP_AGG_CLI, _bt_mesh_op_agg_cli_op, \
NULL, NULL, &_bt_mesh_op_agg_cli_cb)
/** @brief Configure Opcodes Aggregator context.
*
* @param net_idx NetKey index to encrypt with.
* @param app_idx AppKey index to encrypt with.
* @param dst Target Opcodes Aggregator Server address.
* @param elem_addr Target node element address for the sequence message.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_op_agg_cli_seq_start(uint16_t net_idx, uint16_t app_idx, uint16_t dst,
uint16_t elem_addr);
/** @brief Opcodes Aggregator message send.
*
* Uses previously configured context and sends aggregated message
* to target node.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_op_agg_cli_seq_send(void);
/** @brief Abort Opcodes Aggregator context.
*/
void bt_mesh_op_agg_cli_seq_abort(void);
/** @brief Check if Opcodes Aggregator Sequence context is started.
*
* @return true if it is started, otherwise false.
*/
bool bt_mesh_op_agg_cli_seq_is_started(void);
/** @brief Get Opcodes Aggregator context tailroom.
*
* @return Remaining tailroom of Opcodes Aggregator SDU.
*/
size_t bt_mesh_op_agg_cli_seq_tailroom(void);
/** @brief Get the current transmission timeout value.
*
* @return The configured transmission timeout in milliseconds.
*/
int32_t bt_mesh_op_agg_cli_timeout_get(void);
/** @brief Set the transmission timeout value.
*
* @param timeout The new transmission timeout.
*/
void bt_mesh_op_agg_cli_timeout_set(int32_t timeout);
/** @cond INTERNAL_HIDDEN */
extern const struct bt_mesh_model_op _bt_mesh_op_agg_cli_op[];
extern const struct bt_mesh_model_cb _bt_mesh_op_agg_cli_cb;
/** @endcond */
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* BT_MESH_OP_AGG_CLI_H__ */
``` | /content/code_sandbox/include/zephyr/bluetooth/mesh/op_agg_cli.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 548 |
```objective-c
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_MESH_BLOB_CLI_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_MESH_BLOB_CLI_H_
#include <sys/types.h>
#include <zephyr/bluetooth/mesh/access.h>
#include <zephyr/bluetooth/mesh/blob.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup bt_mesh_blob_cli Bluetooth Mesh BLOB Transfer Client model API
* @ingroup bt_mesh
* @{
*/
struct bt_mesh_blob_cli;
/**
*
* @brief BLOB Transfer Client model Composition Data entry.
*
* @param _cli Pointer to a @ref bt_mesh_blob_cli instance.
*/
#define BT_MESH_MODEL_BLOB_CLI(_cli) \
BT_MESH_MODEL_CB(BT_MESH_MODEL_ID_BLOB_CLI, _bt_mesh_blob_cli_op, \
NULL, _cli, &_bt_mesh_blob_cli_cb)
/** Target node's Pull mode (Pull BLOB Transfer Mode) context used
* while sending chunks to the Target node.
*/
struct bt_mesh_blob_target_pull {
/** Timestamp when the Block Report Timeout Timer expires for this Target node. */
int64_t block_report_timestamp;
/** Missing chunks reported by this Target node. */
uint8_t missing[DIV_ROUND_UP(CONFIG_BT_MESH_BLOB_CHUNK_COUNT_MAX, 8)];
};
/** BLOB Transfer Client Target node. */
struct bt_mesh_blob_target {
/** Linked list node */
sys_snode_t n;
/** Target node address. */
uint16_t addr;
/** Target node's Pull mode context.
* Needs to be initialized when sending a BLOB in Pull mode.
*/
struct bt_mesh_blob_target_pull *pull;
/** BLOB transfer status, see @ref bt_mesh_blob_status. */
uint8_t status;
uint8_t procedure_complete:1, /* Procedure has been completed. */
acked:1, /* Message has been acknowledged. Not used when sending. */
timedout:1, /* Target node didn't respond after specified timeout. */
skip:1; /* Skip Target node from broadcast. */
};
/** BLOB transfer information.
*
* If @c phase is @ref BT_MESH_BLOB_XFER_PHASE_INACTIVE,
* the fields below @c phase are not initialized.
* If @c phase is @ref BT_MESH_BLOB_XFER_PHASE_WAITING_FOR_START,
* the fields below @c id are not initialized.
*/
struct bt_mesh_blob_xfer_info {
/** BLOB transfer status. */
enum bt_mesh_blob_status status;
/** BLOB transfer mode. */
enum bt_mesh_blob_xfer_mode mode;
/** BLOB transfer phase. */
enum bt_mesh_blob_xfer_phase phase;
/** BLOB ID. */
uint64_t id;
/** BLOB size in octets. */
uint32_t size;
/** Logarithmic representation of the block size. */
uint8_t block_size_log;
/** MTU size in octets. */
uint16_t mtu_size;
/** Bit field indicating blocks that were not received. */
const uint8_t *missing_blocks;
};
/** BLOB Transfer Client transfer inputs. */
struct bt_mesh_blob_cli_inputs {
/** Linked list of Target nodes. Each node should point to @ref
* bt_mesh_blob_target::n.
*/
sys_slist_t targets;
/** AppKey index to send with. */
uint16_t app_idx;
/** Group address destination for the BLOB transfer, or @ref
* BT_MESH_ADDR_UNASSIGNED to send every message to each Target
* node individually.
*/
uint16_t group;
/** Time to live value of BLOB transfer messages. */
uint8_t ttl;
/** Additional response time for the Target nodes, in 10-second increments.
*
* The extra time can be used to give the Target nodes more time to respond
* to messages from the Client. The actual timeout will be calculated
* according to the following formula:
*
* @verbatim
* timeout = 20 seconds + (10 seconds * timeout_base) + (100 ms * TTL)
* @endverbatim
*
* If a Target node fails to respond to a message from the Client within the
* configured transfer timeout, the Target node is dropped.
*/
uint16_t timeout_base;
};
/** Transfer capabilities of a Target node. */
struct bt_mesh_blob_cli_caps {
/** Max BLOB size. */
size_t max_size;
/** Logarithmic representation of the minimum block size. */
uint8_t min_block_size_log;
/** Logarithmic representation of the maximum block size. */
uint8_t max_block_size_log;
/** Max number of chunks per block. */
uint16_t max_chunks;
/** Max chunk size. */
uint16_t max_chunk_size;
/** Max MTU size. */
uint16_t mtu_size;
/** Supported transfer modes. */
enum bt_mesh_blob_xfer_mode modes;
};
/** BLOB Transfer Client state. */
enum bt_mesh_blob_cli_state {
/** No transfer is active. */
BT_MESH_BLOB_CLI_STATE_NONE,
/** Retrieving transfer capabilities. */
BT_MESH_BLOB_CLI_STATE_CAPS_GET,
/** Sending transfer start. */
BT_MESH_BLOB_CLI_STATE_START,
/** Sending block start. */
BT_MESH_BLOB_CLI_STATE_BLOCK_START,
/** Sending block chunks. */
BT_MESH_BLOB_CLI_STATE_BLOCK_SEND,
/** Checking block status. */
BT_MESH_BLOB_CLI_STATE_BLOCK_CHECK,
/** Checking transfer status. */
BT_MESH_BLOB_CLI_STATE_XFER_CHECK,
/** Cancelling transfer. */
BT_MESH_BLOB_CLI_STATE_CANCEL,
/** Transfer is suspended. */
BT_MESH_BLOB_CLI_STATE_SUSPENDED,
/** Checking transfer progress. */
BT_MESH_BLOB_CLI_STATE_XFER_PROGRESS_GET,
};
/** Event handler callbacks for the BLOB Transfer Client model.
*
* All handlers are optional.
*/
struct bt_mesh_blob_cli_cb {
/** @brief Capabilities retrieval completion callback.
*
* Called when the capabilities retrieval procedure completes, indicating that
* a common set of acceptable transfer parameters have been established
* for the given list of Target nodes. All compatible Target nodes have
* status code @ref BT_MESH_BLOB_SUCCESS.
*
* @param cli BLOB Transfer Client instance.
* @param caps Safe transfer capabilities if the transfer capabilities
* of at least one Target node has satisfied the Client, or NULL otherwise.
*/
void (*caps)(struct bt_mesh_blob_cli *cli,
const struct bt_mesh_blob_cli_caps *caps);
/** @brief Target node loss callback.
*
* Called whenever a Target node has been lost due to some error in the
* transfer. Losing a Target node is not considered a fatal error for
* the Client until all Target nodes have been lost.
*
* @param cli BLOB Transfer Client instance.
* @param target Target node that was lost.
* @param reason Reason for the Target node loss.
*/
void (*lost_target)(struct bt_mesh_blob_cli *cli,
struct bt_mesh_blob_target *target,
enum bt_mesh_blob_status reason);
/** @brief Transfer is suspended.
*
* Called when the transfer is suspended due to response timeout from all Target nodes.
*
* @param cli BLOB Transfer Client instance.
*/
void (*suspended)(struct bt_mesh_blob_cli *cli);
/** @brief Transfer end callback.
*
* Called when the transfer ends.
*
* @param cli BLOB Transfer Client instance.
* @param xfer Completed transfer.
* @param success Status of the transfer.
* Is @c true if at least one Target
* node received the whole transfer.
*/
void (*end)(struct bt_mesh_blob_cli *cli,
const struct bt_mesh_blob_xfer *xfer, bool success);
/** @brief Transfer progress callback
*
* The content of @c info is invalidated upon exit from the callback.
* Therefore it needs to be copied if it is planned to be used later.
*
* @param cli BLOB Transfer Client instance.
* @param target Target node that responded to the request.
* @param info BLOB transfer information.
*/
void (*xfer_progress)(struct bt_mesh_blob_cli *cli,
struct bt_mesh_blob_target *target,
const struct bt_mesh_blob_xfer_info *info);
/** @brief End of Get Transfer Progress procedure.
*
* Called when all Target nodes have responded or the procedure timed-out.
*
* @param cli BLOB Transfer Client instance.
*/
void (*xfer_progress_complete)(struct bt_mesh_blob_cli *cli);
};
/** @cond INTERNAL_HIDDEN */
struct blob_cli_broadcast_ctx {
/** Called for every Target node in unicast mode, or once in case of multicast mode. */
void (*send)(struct bt_mesh_blob_cli *cli, uint16_t dst);
/** Called after every @ref blob_cli_broadcast_ctx::send callback. */
void (*send_complete)(struct bt_mesh_blob_cli *cli, uint16_t dst);
/** If @ref blob_cli_broadcast_ctx::acked is true, called after all Target nodes
* have confirmed reception by @ref blob_cli_broadcast_rsp. Otherwise, called
* after transmission has been completed.
*/
void (*next)(struct bt_mesh_blob_cli *cli);
/** If true, every transmission needs to be confirmed by @ref blob_cli_broadcast_rsp before
* @ref blob_cli_broadcast_ctx::next is called.
*/
bool acked;
/** If true, the message is always sent in a unicast way. */
bool force_unicast;
/** If true, non-responsive Target nodes won't be dropped after transfer has timed out. */
bool optional;
/** Set to true by the BLOB Transfer Client between blob_cli_broadcast
* and broadcast_complete calls.
*/
bool is_inited;
};
/** INTERNAL_HIDDEN @endcond */
/** BLOB Transfer Client model instance. */
struct bt_mesh_blob_cli {
/** Event handler callbacks */
const struct bt_mesh_blob_cli_cb *cb;
/* Runtime state */
const struct bt_mesh_model *mod;
struct {
struct bt_mesh_blob_target *target;
struct blob_cli_broadcast_ctx ctx;
struct k_work_delayable retry;
/* Represents Client Timeout timer in a timestamp. Used in Pull mode only. */
int64_t cli_timestamp;
struct k_work complete;
uint16_t pending;
uint8_t retries;
uint8_t sending : 1,
cancelled : 1;
} tx;
const struct bt_mesh_blob_io *io;
const struct bt_mesh_blob_cli_inputs *inputs;
const struct bt_mesh_blob_xfer *xfer;
uint16_t block_count;
uint16_t chunk_idx;
uint16_t mtu_size;
enum bt_mesh_blob_cli_state state;
struct bt_mesh_blob_block block;
struct bt_mesh_blob_cli_caps caps;
};
/** @brief Retrieve transfer capabilities for a list of Target nodes.
*
* Queries the availability and capabilities of all Target nodes, producing a
* cumulative set of transfer capabilities for the Target nodes, and returning
* it through the @ref bt_mesh_blob_cli_cb::caps callback.
*
* Retrieving the capabilities may take several seconds, depending on the
* number of Target nodes and mesh network performance. The end of the procedure
* is indicated through the @ref bt_mesh_blob_cli_cb::caps callback.
*
* This procedure is not required, but strongly recommended as a
* preparation for a transfer to maximize performance and the chances of
* success.
*
* @param cli BLOB Transfer Client instance.
* @param inputs Statically allocated BLOB Transfer Client transfer inputs.
*
* @return 0 on success, or (negative) error code otherwise.
*/
int bt_mesh_blob_cli_caps_get(struct bt_mesh_blob_cli *cli,
const struct bt_mesh_blob_cli_inputs *inputs);
/** @brief Perform a BLOB transfer.
*
* Starts sending the transfer to the Target nodes. Only Target nodes with a
* @c status of @ref BT_MESH_BLOB_SUCCESS will be considered.
*
* The transfer will keep going either until all Target nodes have been dropped, or
* the full BLOB has been sent.
*
* The BLOB transfer may take several minutes, depending on the number of
* Target nodes, size of the BLOB and mesh network performance. The end of the
* transfer is indicated through the @ref bt_mesh_blob_cli_cb::end callback.
*
* A Client only supports one transfer at the time.
*
* @param cli BLOB Transfer Client instance.
* @param inputs Statically allocated BLOB Transfer Client transfer inputs.
* @param xfer Statically allocated transfer parameters.
* @param io BLOB stream to read the transfer from.
*
* @return 0 on success, or (negative) error code otherwise.
*/
int bt_mesh_blob_cli_send(struct bt_mesh_blob_cli *cli,
const struct bt_mesh_blob_cli_inputs *inputs,
const struct bt_mesh_blob_xfer *xfer,
const struct bt_mesh_blob_io *io);
/** @brief Suspend the active transfer.
*
* @param cli BLOB Transfer Client instance.
*
* @return 0 on success, or (negative) error code otherwise.
*/
int bt_mesh_blob_cli_suspend(struct bt_mesh_blob_cli *cli);
/** @brief Resume the suspended transfer.
*
* @param cli BLOB Transfer Client instance.
*
* @return 0 on success, or (negative) error code otherwise.
*/
int bt_mesh_blob_cli_resume(struct bt_mesh_blob_cli *cli);
/** @brief Cancel an ongoing transfer.
*
* @param cli BLOB Transfer Client instance.
*/
void bt_mesh_blob_cli_cancel(struct bt_mesh_blob_cli *cli);
/** @brief Get the progress of BLOB transfer.
*
* This function can only be used if the BLOB Transfer Client is currently
* not performing a BLOB transfer.
* To get progress of the active BLOB transfer, use the
* @ref bt_mesh_blob_cli_xfer_progress_active_get function.
*
* @param cli BLOB Transfer Client instance.
* @param inputs Statically allocated BLOB Transfer Client transfer inputs.
*
* @return 0 on success, or (negative) error code otherwise.
*/
int bt_mesh_blob_cli_xfer_progress_get(struct bt_mesh_blob_cli *cli,
const struct bt_mesh_blob_cli_inputs *inputs);
/** @brief Get the current progress of the active transfer in percent.
*
* @param cli BLOB Transfer Client instance.
*
* @return The current transfer progress, or 0 if no transfer is active.
*/
uint8_t bt_mesh_blob_cli_xfer_progress_active_get(struct bt_mesh_blob_cli *cli);
/** @brief Get the current state of the BLOB Transfer Client.
*
* @param cli BLOB Transfer Client instance.
*
* @return true if the BLOB Transfer Client is currently participating in a transfer or
* retrieving the capabilities and false otherwise.
*/
bool bt_mesh_blob_cli_is_busy(struct bt_mesh_blob_cli *cli);
/** @cond INTERNAL_HIDDEN */
extern const struct bt_mesh_model_op _bt_mesh_blob_cli_op[];
extern const struct bt_mesh_model_cb _bt_mesh_blob_cli_cb;
/** @endcond */
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_MESH_BLOB_CLI_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/mesh/blob_cli.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 3,341 |
```objective-c
/** @file
* @brief Message APIs.
*/
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_MESH_MSG_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_MESH_MSG_H_
/**
* @brief Message
* @defgroup bt_mesh_msg Message
* @ingroup bt_mesh
* @{
*/
#include <zephyr/kernel.h>
#include <zephyr/net/buf.h>
#ifdef __cplusplus
extern "C" {
#endif
struct bt_mesh_model;
/** Length of a short Mesh MIC. */
#define BT_MESH_MIC_SHORT 4
/** Length of a long Mesh MIC. */
#define BT_MESH_MIC_LONG 8
/**
* @brief Helper to determine the length of an opcode.
*
* @param _op Opcode.
*/
#define BT_MESH_MODEL_OP_LEN(_op) ((_op) <= 0xff ? 1 : (_op) <= 0xffff ? 2 : 3)
/**
* @brief Helper for model message buffer length.
*
* Returns the length of a Mesh model message buffer, including the opcode
* length and a short MIC.
*
* @param _op Opcode of the message.
* @param _payload_len Length of the model payload.
*/
#define BT_MESH_MODEL_BUF_LEN(_op, _payload_len) \
(BT_MESH_MODEL_OP_LEN(_op) + (_payload_len) + BT_MESH_MIC_SHORT)
/**
* @brief Helper for model message buffer length.
*
* Returns the length of a Mesh model message buffer, including the opcode
* length and a long MIC.
*
* @param _op Opcode of the message.
* @param _payload_len Length of the model payload.
*/
#define BT_MESH_MODEL_BUF_LEN_LONG_MIC(_op, _payload_len) \
(BT_MESH_MODEL_OP_LEN(_op) + (_payload_len) + BT_MESH_MIC_LONG)
/**
* @brief Define a Mesh model message buffer using @ref NET_BUF_SIMPLE_DEFINE.
*
* @param _buf Buffer name.
* @param _op Opcode of the message.
* @param _payload_len Length of the model message payload.
*/
#define BT_MESH_MODEL_BUF_DEFINE(_buf, _op, _payload_len) \
NET_BUF_SIMPLE_DEFINE(_buf, BT_MESH_MODEL_BUF_LEN(_op, (_payload_len)))
/** Message sending context. */
struct bt_mesh_msg_ctx {
/** NetKey Index of the subnet to send the message on. */
uint16_t net_idx;
/** AppKey Index to encrypt the message with. */
uint16_t app_idx;
/** Remote address. */
uint16_t addr;
/** Destination address of a received message. Not used for sending. */
uint16_t recv_dst;
/** Label UUID if Remote address is Virtual address, or NULL otherwise. */
const uint8_t *uuid;
/** RSSI of received packet. Not used for sending. */
int8_t recv_rssi;
/** Received TTL value. Not used for sending. */
uint8_t recv_ttl;
/** Force sending reliably by using segment acknowledgment */
bool send_rel;
/** Send message with a random delay according to the Access layer transmitting rules. */
bool rnd_delay;
/** TTL, or BT_MESH_TTL_DEFAULT for default TTL. */
uint8_t send_ttl;
};
/**
* @brief Helper for bt_mesh_msg_ctx structure initialization.
*
* @note If @c dst is a Virtual Address, Label UUID shall be initialized separately.
*
* @param net_key_idx NetKey Index of the subnet to send the message on. Only used if
* @c app_key_idx points to devkey.
* @param app_key_idx AppKey Index to encrypt the message with.
* @param dst Remote addr.
* @param ttl Time To Live.
*/
#define BT_MESH_MSG_CTX_INIT(net_key_idx, app_key_idx, dst, ttl) \
{ \
.net_idx = (net_key_idx), \
.app_idx = (app_key_idx), \
.addr = (dst), \
.send_ttl = (ttl), \
}
/**
* @brief Helper for bt_mesh_msg_ctx structure initialization secured with Application Key.
*
* @param app_key_idx AppKey Index to encrypt the message with.
* @param dst Remote addr.
*/
#define BT_MESH_MSG_CTX_INIT_APP(app_key_idx, dst) \
BT_MESH_MSG_CTX_INIT(0, app_key_idx, dst, BT_MESH_TTL_DEFAULT)
/**
* @brief Helper for bt_mesh_msg_ctx structure initialization secured with Device Key of a remote
* device.
*
* @param net_key_idx NetKey Index of the subnet to send the message on.
* @param dst Remote addr.
*/
#define BT_MESH_MSG_CTX_INIT_DEV(net_key_idx, dst) \
BT_MESH_MSG_CTX_INIT(net_key_idx, BT_MESH_KEY_DEV_REMOTE, dst, BT_MESH_TTL_DEFAULT)
/**
* @brief Helper for bt_mesh_msg_ctx structure initialization using Model Publication context.
*
* @param pub Pointer to a model publication context.
*/
#define BT_MESH_MSG_CTX_INIT_PUB(pub) \
{ \
.app_idx = (pub)->key, \
.addr = (pub)->addr, \
.send_ttl = (pub)->ttl, \
.uuid = (pub)->uuid, \
}
/** @brief Initialize a model message.
*
* Clears the message buffer contents, and encodes the given opcode.
* The message buffer will be ready for filling in payload data.
*
* @param msg Message buffer.
* @param opcode Opcode to encode.
*/
void bt_mesh_model_msg_init(struct net_buf_simple *msg, uint32_t opcode);
/**
* Acknowledged message context for tracking the status of model messages pending a response.
*/
struct bt_mesh_msg_ack_ctx {
struct k_sem sem; /**< Sync semaphore. */
uint32_t op; /**< Opcode we're waiting for. */
uint16_t dst; /**< Address of the node that should respond. */
void *user_data; /**< User specific parameter. */
};
/** @brief Initialize an acknowledged message context.
*
* Initializes semaphore used for synchronization between @ref bt_mesh_msg_ack_ctx_wait and
* @ref bt_mesh_msg_ack_ctx_rx calls. Call this function before using @ref bt_mesh_msg_ack_ctx.
*
* @param ack Acknowledged message context to initialize.
*/
static inline void bt_mesh_msg_ack_ctx_init(struct bt_mesh_msg_ack_ctx *ack)
{
k_sem_init(&ack->sem, 0, 1);
}
/** @brief Reset the synchronization semaphore in an acknowledged message context.
*
* This function aborts call to @ref bt_mesh_msg_ack_ctx_wait.
*
* @param ack Acknowledged message context to be reset.
*/
static inline void bt_mesh_msg_ack_ctx_reset(struct bt_mesh_msg_ack_ctx *ack)
{
k_sem_reset(&ack->sem);
}
/** @brief Clear parameters of an acknowledged message context.
*
* This function clears the opcode, remote address and user data set
* by @ref bt_mesh_msg_ack_ctx_prepare.
*
* @param ack Acknowledged message context to be cleared.
*/
void bt_mesh_msg_ack_ctx_clear(struct bt_mesh_msg_ack_ctx *ack);
/** @brief Prepare an acknowledged message context for the incoming message to wait.
*
* This function sets the opcode, remote address of the incoming message and stores the user data.
* Use this function before calling @ref bt_mesh_msg_ack_ctx_wait.
*
* @param ack Acknowledged message context to prepare.
* @param op The message OpCode.
* @param dst Destination address of the message.
* @param user_data User data for the acknowledged message context.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_msg_ack_ctx_prepare(struct bt_mesh_msg_ack_ctx *ack,
uint32_t op, uint16_t dst, void *user_data);
/** @brief Check if the acknowledged message context is initialized with an opcode.
*
* @param ack Acknowledged message context.
*
* @return true if the acknowledged message context is initialized with an opcode,
* false otherwise.
*/
static inline bool bt_mesh_msg_ack_ctx_busy(struct bt_mesh_msg_ack_ctx *ack)
{
return (ack->op != 0);
}
/** @brief Wait for a message acknowledge.
*
* This function blocks execution until @ref bt_mesh_msg_ack_ctx_rx is called or by timeout.
*
* @param ack Acknowledged message context of the message to wait for.
* @param timeout Wait timeout.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_msg_ack_ctx_wait(struct bt_mesh_msg_ack_ctx *ack, k_timeout_t timeout);
/** @brief Mark a message as acknowledged.
*
* This function unblocks call to @ref bt_mesh_msg_ack_ctx_wait.
*
* @param ack Context of a message to be acknowledged.
*/
static inline void bt_mesh_msg_ack_ctx_rx(struct bt_mesh_msg_ack_ctx *ack)
{
k_sem_give(&ack->sem);
}
/** @brief Check if an opcode and address of a message matches the expected one.
*
* @param ack Acknowledged message context to be checked.
* @param op OpCode of the incoming message.
* @param addr Source address of the incoming message.
* @param user_data If not NULL, returns a user data stored in the acknowledged message context
* by @ref bt_mesh_msg_ack_ctx_prepare.
*
* @return true if the incoming message matches the expected one, false otherwise.
*/
bool bt_mesh_msg_ack_ctx_match(const struct bt_mesh_msg_ack_ctx *ack,
uint32_t op, uint16_t addr, void **user_data);
#ifdef __cplusplus
}
#endif
/**
* @}
*/
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_MESH_MSG_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/mesh/msg.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 2,092 |
```objective-c
/*
*
*/
#ifndef BT_MESH_LARGE_COMP_DATA_SRV_H__
#define BT_MESH_LARGE_COMP_DATA_SRV_H__
#include <zephyr/bluetooth/mesh.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup bt_mesh_large_comp_data_srv Large Composition Data Server model
* @ingroup bt_mesh
* @{
*/
/**
*
* @brief Large Composition Data Server model composition data entry.
*/
#define BT_MESH_MODEL_LARGE_COMP_DATA_SRV \
BT_MESH_MODEL_CB(BT_MESH_MODEL_ID_LARGE_COMP_DATA_SRV, \
_bt_mesh_large_comp_data_srv_op, NULL, NULL, \
&_bt_mesh_large_comp_data_srv_cb)
/** @cond INTERNAL_HIDDEN */
extern const struct bt_mesh_model_op _bt_mesh_large_comp_data_srv_op[];
extern const struct bt_mesh_model_cb _bt_mesh_large_comp_data_srv_cb;
/** @endcond */
#ifdef __cplusplus
}
#endif
#endif /* BT_MESH_LARGE_COMP_DATA_SRV_H__ */
/**
* @}
*/
``` | /content/code_sandbox/include/zephyr/bluetooth/mesh/large_comp_data_srv.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 204 |
```objective-c
/*
*
*/
/**
* @file
* @defgroup bt_mesh_dfu_srv Firmware Update Server model
* @ingroup bt_mesh_dfu
* @{
* @brief API for the Bluetooth Mesh Firmware Update Server model
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_MESH_DFU_SRV_H__
#define ZEPHYR_INCLUDE_BLUETOOTH_MESH_DFU_SRV_H__
#include <zephyr/bluetooth/mesh/dfu.h>
#include <zephyr/bluetooth/mesh/blob_srv.h>
#include <zephyr/bluetooth/mesh/access.h>
#ifdef __cplusplus
extern "C" {
#endif
struct bt_mesh_dfu_srv;
/**
*
* @brief Initialization parameters for @ref bt_mesh_dfu_srv.
*
* @param _handlers DFU handler function structure.
* @param _imgs List of @ref bt_mesh_dfu_img managed by this Server.
* @param _img_count Number of DFU images managed by this Server.
*/
#define BT_MESH_DFU_SRV_INIT(_handlers, _imgs, _img_count) \
{ \
.blob = { .cb = &_bt_mesh_dfu_srv_blob_cb }, .cb = _handlers, \
.imgs = _imgs, .img_count = _img_count, \
}
/**
*
* @brief Firmware Update Server model entry.
*
* @param _srv Pointer to a @ref bt_mesh_dfu_srv instance.
*/
#define BT_MESH_MODEL_DFU_SRV(_srv) \
BT_MESH_MODEL_BLOB_SRV(&(_srv)->blob), \
BT_MESH_MODEL_CB(BT_MESH_MODEL_ID_DFU_SRV, _bt_mesh_dfu_srv_op, NULL, \
_srv, &_bt_mesh_dfu_srv_cb)
/** @brief Firmware Update Server event callbacks. */
struct bt_mesh_dfu_srv_cb {
/** @brief Transfer check callback.
*
* The transfer check can be used to validate the incoming transfer
* before it starts. The contents of the metadata is implementation
* specific, and should contain all the information the application
* needs to determine whether this image should be accepted, and what
* the effect of the transfer would be.
*
* If applying the image will have an effect on the provisioning state
* of the mesh stack, this can be communicated through the @c effect
* return parameter.
*
* The metadata check can be performed both as part of starting a new
* transfer and as a separate procedure.
*
* This handler is optional.
*
* @param srv Firmware Update Server instance.
* @param img DFU image the metadata check is performed on.
* @param metadata Image metadata.
* @param effect Return parameter for the image effect on the
* provisioning state of the mesh stack.
*
* @return 0 on success, or (negative) error code otherwise.
*/
int (*check)(struct bt_mesh_dfu_srv *srv,
const struct bt_mesh_dfu_img *img,
struct net_buf_simple *metadata,
enum bt_mesh_dfu_effect *effect);
/** @brief Transfer start callback.
*
* Called when the Firmware Update Server is ready to start a new DFU transfer.
* The application must provide an initialized BLOB stream to be used
* during the DFU transfer.
*
* The following error codes are treated specially, and should be used
* to communicate these issues:
* - @c -ENOMEM: The device cannot fit this image.
* - @c -EBUSY: The application is temporarily unable to accept the
* transfer.
* - @c -EALREADY: The device has already received and verified this
* image, and there's no need to transfer it again. The Firmware Update model
* will skip the transfer phase, and mark the image as verified.
*
* This handler is mandatory.
*
* @param srv Firmware Update Server instance.
* @param img DFU image being updated.
* @param metadata Image metadata.
* @param io BLOB stream return parameter. Must be set to a
* valid BLOB stream by the callback.
*
* @return 0 on success, or (negative) error code otherwise. Return
* codes @c -ENOMEM, @c -EBUSY @c -EALREADY will be passed to
* the updater, other error codes are reported as internal
* errors.
*/
int (*start)(struct bt_mesh_dfu_srv *srv,
const struct bt_mesh_dfu_img *img,
struct net_buf_simple *metadata,
const struct bt_mesh_blob_io **io);
/** @brief Transfer end callback.
*
* This handler is optional.
*
* If the transfer is successful, the application should verify the
* firmware image, and call either @ref bt_mesh_dfu_srv_verified or
* @ref bt_mesh_dfu_srv_rejected depending on the outcome.
*
* If the transfer fails, the Firmware Update Server will be available for new
* transfers immediately after this function returns.
*
* @param srv Firmware Update Server instance.
* @param img DFU image that failed the update.
* @param success Whether the DFU transfer was successful.
*/
void (*end)(struct bt_mesh_dfu_srv *srv,
const struct bt_mesh_dfu_img *img, bool success);
/** @brief Transfer recovery callback.
*
* If the device reboots in the middle of a transfer, the Firmware Update Server
* calls this function when the Bluetooth Mesh subsystem is started.
*
* This callback is optional, but transfers will not be recovered after
* a reboot without it.
*
* @param srv Firmware Update Server instance.
* @param img DFU image being updated.
* @param io BLOB stream return parameter. Must be set to a valid BLOB
* stream by the callback.
*
* @return 0 on success, or (negative) error code to abandon the
* transfer.
*/
int (*recover)(struct bt_mesh_dfu_srv *srv,
const struct bt_mesh_dfu_img *img,
const struct bt_mesh_blob_io **io);
/** @brief Transfer apply callback.
*
* Called after a transfer has been validated, and the updater sends an
* apply message to the Target nodes.
*
* This handler is optional.
*
* @param srv Firmware Update Server instance.
* @param img DFU image that should be applied.
*
* @return 0 on success, or (negative) error code otherwise.
*/
int (*apply)(struct bt_mesh_dfu_srv *srv,
const struct bt_mesh_dfu_img *img);
};
/** @brief Firmware Update Server instance.
*
* Should be initialized with @ref BT_MESH_DFU_SRV_INIT.
*/
struct bt_mesh_dfu_srv {
/** Underlying BLOB Transfer Server. */
struct bt_mesh_blob_srv blob;
/** Callback structure. */
const struct bt_mesh_dfu_srv_cb *cb;
/** List of updatable images. */
const struct bt_mesh_dfu_img *imgs;
/** Number of updatable images. */
size_t img_count;
/* Runtime state */
const struct bt_mesh_model *mod;
struct {
/* Effect of transfer, @see bt_mesh_dfu_effect. */
uint8_t effect;
/* Current phase, @see bt_mesh_dfu_phase. */
uint8_t phase;
uint8_t ttl;
uint8_t idx;
uint16_t timeout_base;
uint16_t meta;
} update;
};
/** @brief Accept the received DFU transfer.
*
* Should be called at the end of a successful DFU transfer.
*
* If the DFU transfer completes successfully, the application should verify
* the image validity (including any image authentication or integrity checks),
* and call this function if the image is ready to be applied.
*
* @param srv Firmware Update Server instance.
*/
void bt_mesh_dfu_srv_verified(struct bt_mesh_dfu_srv *srv);
/** @brief Reject the received DFU transfer.
*
* Should be called at the end of a successful DFU transfer.
*
* If the DFU transfer completes successfully, the application should verify
* the image validity (including any image authentication or integrity checks),
* and call this function if one of the checks fail.
*
* @param srv Firmware Update Server instance.
*/
void bt_mesh_dfu_srv_rejected(struct bt_mesh_dfu_srv *srv);
/** @brief Cancel the ongoing DFU transfer.
*
* @param srv Firmware Update Server instance.
*/
void bt_mesh_dfu_srv_cancel(struct bt_mesh_dfu_srv *srv);
/** @brief Confirm that the received DFU transfer was applied.
*
* Should be called as a result of the @ref bt_mesh_dfu_srv_cb.apply callback.
*
* @param srv Firmware Update Server instance.
*/
void bt_mesh_dfu_srv_applied(struct bt_mesh_dfu_srv *srv);
/** @brief Check if the Firmware Update Server is busy processing a transfer.
*
* @param srv Firmware Update Server instance.
*
* @return true if a DFU procedure is in progress, false otherwise.
*/
bool bt_mesh_dfu_srv_is_busy(const struct bt_mesh_dfu_srv *srv);
/** @brief Get the progress of the current DFU procedure, in percent.
*
* @param srv Firmware Update Server instance.
*
* @return The current transfer progress in percent.
*/
uint8_t bt_mesh_dfu_srv_progress(const struct bt_mesh_dfu_srv *srv);
/** @cond INTERNAL_HIDDEN */
extern const struct bt_mesh_model_op _bt_mesh_dfu_srv_op[];
extern const struct bt_mesh_model_cb _bt_mesh_dfu_srv_cb;
extern const struct bt_mesh_blob_srv_cb _bt_mesh_dfu_srv_blob_cb;
/** @endcond */
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_MESH_DFU_SRV_H__ */
/** @} */
``` | /content/code_sandbox/include/zephyr/bluetooth/mesh/dfu_srv.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 2,220 |
```objective-c
/*
*
*/
#ifndef BT_MESH_LARGE_COMP_DATA_CLI_H__
#define BT_MESH_LARGE_COMP_DATA_CLI_H__
#include <zephyr/bluetooth/mesh.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup bt_mesh_large_comp_data_cli Large Composition Data Client model
* @ingroup bt_mesh
* @{
*/
struct bt_mesh_large_comp_data_cli;
/** Large Composition Data response. */
struct bt_mesh_large_comp_data_rsp {
/** Page number. */
uint8_t page;
/** Offset within the page. */
uint16_t offset;
/** Total size of the page. */
uint16_t total_size;
/** Pointer to allocated buffer for storing received data. */
struct net_buf_simple *data;
};
/** Large Composition Data Status messages callbacks */
struct bt_mesh_large_comp_data_cli_cb {
/** @brief Optional callback for Large Composition Data Status message.
*
* Handles received Large Composition Data Status messages from a Large Composition Data
* Server.
*
* If the content of @c rsp is needed after exiting this callback, a user should
* deep copy it.
*
* @param cli Large Composition Data Client context.
* @param addr Address of the sender.
* @param rsp Response received from the server.
*/
void (*large_comp_data_status)(struct bt_mesh_large_comp_data_cli *cli, uint16_t addr,
struct bt_mesh_large_comp_data_rsp *rsp);
/** @brief Optional callback for Models Metadata Status message.
*
* Handles received Models Metadata Status messages from a Large Composition Data
* Server.
*
* If the content of @c rsp is needed after exiting this callback, a user should
* deep copy it.
*
* @param cli Large Composition Data Client context.
* @param addr Address of the sender.
* @param rsp Response received from the server.
*/
void (*models_metadata_status)(struct bt_mesh_large_comp_data_cli *cli, uint16_t addr,
struct bt_mesh_large_comp_data_rsp *rsp);
};
/** Large Composition Data Client model context */
struct bt_mesh_large_comp_data_cli {
/** Model entry pointer. */
const struct bt_mesh_model *model;
/** Internal parameters for tracking message responses. */
struct bt_mesh_msg_ack_ctx ack_ctx;
/** Optional callback for Large Composition Data Status messages. */
const struct bt_mesh_large_comp_data_cli_cb *cb;
};
/**
*
* @brief Large Composition Data Client model Composition Data entry.
*
* @param cli_data Pointer to a @ref bt_mesh_large_comp_data_cli instance.
*/
#define BT_MESH_MODEL_LARGE_COMP_DATA_CLI(cli_data) \
BT_MESH_MODEL_CB(BT_MESH_MODEL_ID_LARGE_COMP_DATA_CLI, \
_bt_mesh_large_comp_data_cli_op, NULL, cli_data, \
&_bt_mesh_large_comp_data_cli_cb)
/** @brief Send Large Composition Data Get message.
*
* This API is used to read a portion of a Composition Data Page.
*
* This API can be used asynchronously by setting @p rsp as NULL. This way, the
* method will not wait for a response and will return immediately after sending
* the command.
*
* When @c rsp is set, the user is responsible for providing a buffer for the
* Composition Data in @ref bt_mesh_large_comp_data_rsp::data. If a buffer is
* not provided, the metadata won't be copied.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node element address.
* @param page Composition Data Page to read.
* @param offset Offset within the Composition Data Page.
* @param rsp Pointer to a struct storing the received response from
* the server, or NULL to not wait for a response.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_large_comp_data_get(uint16_t net_idx, uint16_t addr, uint8_t page,
size_t offset, struct bt_mesh_large_comp_data_rsp *rsp);
/** @brief Send Models Metadata Get message.
*
* This API is used to read a portion of a Models Metadata Page.
*
* This API can be used asynchronously by setting @p rsp as NULL. This way, the
* method will not wait for a response and will return immediately after sending
* the command.
*
* When @c rsp is set, a user is responsible for providing a buffer for
* metadata in @ref bt_mesh_large_comp_data_rsp::data. If a buffer is not
* provided, the metadata won't be copied.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node element address.
* @param page Models Metadata Page to read.
* @param offset Offset within the Models Metadata Page.
* @param rsp Pointer to a struct storing the received response from
* the server, or NULL to not wait for a response.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_models_metadata_get(uint16_t net_idx, uint16_t addr, uint8_t page,
size_t offset, struct bt_mesh_large_comp_data_rsp *rsp);
/** @cond INTERNAL_HIDDEN */
extern const struct bt_mesh_model_op _bt_mesh_large_comp_data_cli_op[];
extern const struct bt_mesh_model_cb _bt_mesh_large_comp_data_cli_cb;
/** @endcond */
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* BT_MESH_LARGE_COMP_DATA_CLI_H__ */
``` | /content/code_sandbox/include/zephyr/bluetooth/mesh/large_comp_data_cli.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 1,188 |
```objective-c
/*
*
*/
/**
* @file
* @defgroup bt_mesh_dfu_metadata Bluetooth Mesh Device Firmware Update (DFU) metadata
* @ingroup bt_mesh_dfu
* @{
* @brief Common types and functions for the Bluetooth Mesh DFU metadata.
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_MESH_DFU_METADATA_H__
#define ZEPHYR_INCLUDE_BLUETOOTH_MESH_DFU_METADATA_H__
#include <stdint.h>
#include <sys/types.h>
#include <zephyr/kernel.h>
#ifdef __cplusplus
extern "C" {
#endif
/** Firmware version. */
struct bt_mesh_dfu_metadata_fw_ver {
/** Firmware major version. */
uint8_t major;
/** Firmware minor version. */
uint8_t minor;
/** Firmware revision. */
uint16_t revision;
/** Firmware build number. */
uint32_t build_num;
};
/** Firmware core type. */
enum bt_mesh_dfu_metadata_fw_core_type {
/** Application core. */
BT_MESH_DFU_FW_CORE_TYPE_APP = BIT(0),
/** Network core. */
BT_MESH_DFU_FW_CORE_TYPE_NETWORK = BIT(1),
/** Application-specific BLOB. */
BT_MESH_DFU_FW_CORE_TYPE_APP_SPECIFIC_BLOB = BIT(2),
};
/** Firmware metadata. */
struct bt_mesh_dfu_metadata {
/** New firmware version. */
struct bt_mesh_dfu_metadata_fw_ver fw_ver;
/** New firmware size. */
uint32_t fw_size;
/** New firmware core type. */
enum bt_mesh_dfu_metadata_fw_core_type fw_core_type;
/** Hash of incoming Composition Data. */
uint32_t comp_hash;
/** New number of node elements. */
uint16_t elems;
/** Application-specific data for new firmware. This field is optional. */
uint8_t *user_data;
/** Length of the application-specific field. */
uint32_t user_data_len;
};
/** @brief Decode a firmware metadata from a network buffer.
*
* @param buf Buffer containing a raw metadata to be decoded.
* @param metadata Pointer to a metadata structure to be filled.
*
* @return 0 on success, or (negative) error code otherwise.
*/
int bt_mesh_dfu_metadata_decode(struct net_buf_simple *buf,
struct bt_mesh_dfu_metadata *metadata);
/** @brief Encode a firmware metadata into a network buffer.
*
* @param metadata Firmware metadata to be encoded.
* @param buf Buffer to store the encoded metadata.
*
* @return 0 on success, or (negative) error code otherwise.
*/
int bt_mesh_dfu_metadata_encode(const struct bt_mesh_dfu_metadata *metadata,
struct net_buf_simple *buf);
/** @brief Compute hash of the Composition Data state.
*
* The format of the Composition Data is defined in MshPRTv1.1: 4.2.2.1.
*
* @param buf Pointer to buffer holding Composition Data.
* @param key 128-bit key to be used in the hash computation.
* @param hash Pointer to a memory location to which the hash will be stored.
*
* @return 0 on success, or (negative) error code otherwise.
*/
int bt_mesh_dfu_metadata_comp_hash_get(struct net_buf_simple *buf, uint8_t *key, uint32_t *hash);
/** @brief Compute hash of the Composition Data Page 0 of this device.
*
* @param key 128-bit key to be used in the hash computation.
* @param hash Pointer to a memory location to which the hash will be stored.
*
* @return 0 on success, or (negative) error code otherwise.
*/
int bt_mesh_dfu_metadata_comp_hash_local_get(uint8_t *key, uint32_t *hash);
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_MESH_DFU_METADATA_H__ */
/** @} */
``` | /content/code_sandbox/include/zephyr/bluetooth/mesh/dfu_metadata.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 816 |
```objective-c
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_MESH_BLOB_SRV_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_MESH_BLOB_SRV_H_
#include <zephyr/bluetooth/mesh/access.h>
#include <zephyr/bluetooth/mesh/blob.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup bt_mesh_blob_srv Bluetooth Mesh BLOB Transfer Server model API
* @ingroup bt_mesh
* @{
*/
struct bt_mesh_blob_srv;
/**
*
* @brief Max number of blocks in a single transfer.
*/
#if defined(CONFIG_BT_MESH_BLOB_SRV)
#define BT_MESH_BLOB_BLOCKS_MAX \
(DIV_ROUND_UP(CONFIG_BT_MESH_BLOB_SIZE_MAX, \
CONFIG_BT_MESH_BLOB_BLOCK_SIZE_MIN))
#else
#define BT_MESH_BLOB_BLOCKS_MAX 1
#endif
/**
*
* @brief BLOB Transfer Server model composition data entry.
*
* @param _srv Pointer to a @ref bt_mesh_blob_srv instance.
*/
#define BT_MESH_MODEL_BLOB_SRV(_srv) \
BT_MESH_MODEL_CB(BT_MESH_MODEL_ID_BLOB_SRV, _bt_mesh_blob_srv_op, \
NULL, _srv, &_bt_mesh_blob_srv_cb)
/** @brief BLOB Transfer Server model event handlers.
*
* All callbacks are optional.
*/
struct bt_mesh_blob_srv_cb {
/** @brief Transfer start callback.
*
* Called when the transfer has started with the prepared BLOB ID.
*
* @param srv BLOB Transfer Server instance.
* @param ctx Message context for the incoming start message. The
* entire transfer will be sent from the same source
* address.
* @param xfer Transfer parameters.
*
* @return 0 on success, or (negative) error code to reject the
* transfer.
*/
int (*start)(struct bt_mesh_blob_srv *srv, struct bt_mesh_msg_ctx *ctx,
struct bt_mesh_blob_xfer *xfer);
/** @brief Transfer end callback.
*
* Called when the transfer ends, either because it was cancelled, or
* because it finished successfully. A new transfer may be prepared.
*
* @note The transfer may end before it's started if the start
* parameters are invalid.
*
* @param srv BLOB Transfer Server instance.
* @param id BLOB ID of the cancelled transfer.
* @param success Whether the transfer was successful.
*/
void (*end)(struct bt_mesh_blob_srv *srv, uint64_t id, bool success);
/** @brief Transfer suspended callback.
*
* Called if the Server timed out while waiting for a transfer packet.
* A suspended transfer may resume later from the start of the current
* block. Any received chunks in the current block should be discarded,
* they will be received again if the transfer resumes.
*
* The transfer will call @c resumed again when resuming.
*
* @note The BLOB Transfer Server does not run a timer in the suspended state,
* and it's up to the application to determine whether the
* transfer should be permanently cancelled. Without interaction,
* the transfer will be suspended indefinitely, and the BLOB Transfer
* Server will not accept any new transfers.
*
* @param srv BLOB Transfer Server instance.
*/
void (*suspended)(struct bt_mesh_blob_srv *srv);
/** @brief Transfer resume callback.
*
* Called if the transfer is resumed after being suspended.
*
* @param srv BLOB Transfer Server instance.
*/
void (*resume)(struct bt_mesh_blob_srv *srv);
/** @brief Transfer recovery callback.
*
* Called when the Bluetooth Mesh subsystem is started if the device is rebooted
* in the middle of a transfer.
*
* Transfers will not be resumed after a reboot if this callback is not
* defined.
*
* @param srv BLOB Transfer Server instance.
* @param xfer Transfer to resume.
* @param io BLOB stream return parameter. Must be set to a valid
* BLOB stream by the callback.
*
* @return 0 on success, or (negative) error code to abandon the
* transfer.
*/
int (*recover)(struct bt_mesh_blob_srv *srv,
struct bt_mesh_blob_xfer *xfer,
const struct bt_mesh_blob_io **io);
};
/** @brief BLOB Transfer Server model instance. */
struct bt_mesh_blob_srv {
/** Event handler callbacks. */
const struct bt_mesh_blob_srv_cb *cb;
/* Runtime state: */
const struct bt_mesh_blob_io *io;
struct k_work_delayable rx_timeout;
struct bt_mesh_blob_block block;
const struct bt_mesh_model *mod;
enum bt_mesh_blob_xfer_phase phase;
struct bt_mesh_blob_srv_state {
struct bt_mesh_blob_xfer xfer;
uint16_t cli;
uint16_t app_idx;
uint16_t timeout_base;
uint16_t mtu_size;
uint8_t ttl;
/* Bitfield of pending blocks. */
ATOMIC_DEFINE(blocks, BT_MESH_BLOB_BLOCKS_MAX);
} state;
/* Pull mode (Pull BLOB Transfer Mode) behavior. */
struct {
uint16_t chunk_idx;
struct k_work_delayable report;
} pull;
};
/** @brief Prepare BLOB Transfer Server for an incoming transfer.
*
* Before a BLOB Transfer Server can receive a transfer, the transfer must be prepared
* through some application level mechanism. The BLOB Transfer Server will only accept
* incoming transfers with a matching BLOB ID.
*
* @param srv BLOB Transfer Server instance.
* @param id BLOB ID to accept.
* @param io BLOB stream to write the incoming BLOB to.
* @param ttl Time to live value to use in responses to the BLOB Transfer Client.
* @param timeout_base Extra time for the Client to respond in addition to the
* base 10 seconds, in 10-second increments.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_blob_srv_recv(struct bt_mesh_blob_srv *srv, uint64_t id,
const struct bt_mesh_blob_io *io, uint8_t ttl,
uint16_t timeout_base);
/** @brief Cancel the current BLOB transfer.
*
* Tells the BLOB Transfer Client to drop this device from the list of Targets for the
* current transfer. Note that the client may continue sending the transfer to
* other Targets.
*
* @param srv BLOB Transfer Server instance.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_blob_srv_cancel(struct bt_mesh_blob_srv *srv);
/** @brief Get the current state of the BLOB Transfer Server.
*
* @param srv BLOB Transfer Server instance.
*
* @return true if the BLOB Transfer Server is currently participating in a transfer,
* false otherwise.
*/
bool bt_mesh_blob_srv_is_busy(const struct bt_mesh_blob_srv *srv);
/** @brief Get the current progress of the active transfer in percent.
*
* @param srv BLOB Transfer Server instance.
*
* @return The current transfer progress, or 0 if no transfer is active.
*/
uint8_t bt_mesh_blob_srv_progress(const struct bt_mesh_blob_srv *srv);
/** @cond INTERNAL_HIDDEN */
extern const struct bt_mesh_model_op _bt_mesh_blob_srv_op[];
extern const struct bt_mesh_model_cb _bt_mesh_blob_srv_cb;
/** @endcond */
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_MESH_BLOB_SRV_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/mesh/blob_srv.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 1,695 |
```objective-c
/** @file
* @brief Configuration Client Model APIs.
*/
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_MESH_CFG_CLI_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_MESH_CFG_CLI_H_
/**
* @brief Configuration Client Model
* @defgroup bt_mesh_cfg_cli Configuration Client Model
* @ingroup bt_mesh
* @{
*/
#include <stdint.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
struct bt_mesh_cfg_cli;
struct bt_mesh_cfg_cli_hb_pub;
struct bt_mesh_cfg_cli_hb_sub;
struct bt_mesh_cfg_cli_mod_pub;
/** Mesh Configuration Client Status messages callback */
struct bt_mesh_cfg_cli_cb {
/** @brief Optional callback for Composition data messages.
*
* Handles received Composition data messages from a server.
*
* @note For decoding @c buf, please refer to
* @ref bt_mesh_comp_p0_get and
* @ref bt_mesh_comp_p1_elem_pull.
*
* @param cli Client that received the status message.
* @param addr Address of the sender.
* @param page Composition data page.
* @param buf Composition data buffer.
*/
void (*comp_data)(struct bt_mesh_cfg_cli *cli, uint16_t addr, uint8_t page,
struct net_buf_simple *buf);
/** @brief Optional callback for Model Pub status messages.
*
* Handles received Model Pub status messages from a server.
*
* @param cli Client that received the status message.
* @param addr Address of the sender.
* @param status Status code for the message.
* @param elem_addr Address of the element.
* @param mod_id Model ID.
* @param cid Company ID.
* @param pub Publication configuration parameters.
*/
void (*mod_pub_status)(struct bt_mesh_cfg_cli *cli, uint16_t addr, uint8_t status,
uint16_t elem_addr, uint16_t mod_id, uint16_t cid,
struct bt_mesh_cfg_cli_mod_pub *pub);
/** @brief Optional callback for Model Sub Status messages.
*
* Handles received Model Sub Status messages from a server.
*
* @param cli Client that received the status message.
* @param addr Address of the sender.
* @param status Status Code for requesting message.
* @param elem_addr The unicast address of the element.
* @param sub_addr The sub address.
* @param mod_id The model ID within the element.
*/
void (*mod_sub_status)(struct bt_mesh_cfg_cli *cli, uint16_t addr,
uint8_t status, uint16_t elem_addr,
uint16_t sub_addr, uint32_t mod_id);
/** @brief Optional callback for Model Sub list messages.
*
* Handles received Model Sub list messages from a server.
*
* @note The @c buf parameter should be decoded using
* @ref net_buf_simple_pull_le16 in iteration, as long
* as @c buf->len is greater than or equal to 2.
*
* @param cli Client that received the status message.
* @param addr Address of the sender.
* @param status Status code for the message.
* @param elem_addr Address of the element.
* @param mod_id Model ID.
* @param cid Company ID.
* @param buf Message buffer containing subscription addresses.
*/
void (*mod_sub_list)(struct bt_mesh_cfg_cli *cli, uint16_t addr, uint8_t status,
uint16_t elem_addr, uint16_t mod_id, uint16_t cid,
struct net_buf_simple *buf);
/** @brief Optional callback for Node Reset Status messages.
*
* Handles received Node Reset Status messages from a server.
*
* @param cli Client that received the status message.
* @param addr Address of the sender.
*/
void (*node_reset_status)(struct bt_mesh_cfg_cli *cli, uint16_t addr);
/** @brief Optional callback for Beacon Status messages.
*
* Handles received Beacon Status messages from a server.
*
* @param cli Client that received the status message.
* @param addr Address of the sender.
* @param status Status Code for requesting message.
*/
void (*beacon_status)(struct bt_mesh_cfg_cli *cli, uint16_t addr,
uint8_t status);
/** @brief Optional callback for Default TTL Status messages.
*
* Handles received Default TTL Status messages from a server.
*
* @param cli Client that received the status message.
* @param addr Address of the sender.
* @param status Status Code for requesting message.
*/
void (*ttl_status)(struct bt_mesh_cfg_cli *cli, uint16_t addr,
uint8_t status);
/** @brief Optional callback for Friend Status messages.
*
* Handles received Friend Status messages from a server.
*
* @param cli Client that received the status message.
* @param addr Address of the sender.
* @param status Status Code for requesting message.
*/
void (*friend_status)(struct bt_mesh_cfg_cli *cli, uint16_t addr,
uint8_t status);
/** @brief Optional callback for GATT Proxy Status messages.
*
* Handles received GATT Proxy Status messages from a server.
*
* @param cli Client that received the status message.
* @param addr Address of the sender.
* @param status Status Code for requesting message.
*/
void (*gatt_proxy_status)(struct bt_mesh_cfg_cli *cli, uint16_t addr,
uint8_t status);
/** @brief Optional callback for Network Transmit Status messages.
*
* Handles received Network Transmit Status messages from a server.
*
* @param cli Client that received the status message.
* @param addr Address of the sender.
* @param status Status Code for requesting message.
*/
void (*network_transmit_status)(struct bt_mesh_cfg_cli *cli, uint16_t addr,
uint8_t status);
/** @brief Optional callback for Relay Status messages.
*
* Handles received Relay Status messages from a server.
*
* @param cli Client that received the status message.
* @param addr Address of the sender.
* @param status Status Code for requesting message.
* @param transmit The relay retransmit count and interval steps.
*/
void (*relay_status)(struct bt_mesh_cfg_cli *cli, uint16_t addr,
uint8_t status, uint8_t transmit);
/** @brief Optional callback for NetKey Status messages.
*
* Handles received NetKey Status messages from a server.
*
* @param cli Client that received the status message.
* @param addr Address of the sender.
* @param status Status Code for requesting message.
* @param net_idx The index of the NetKey.
*/
void (*net_key_status)(struct bt_mesh_cfg_cli *cli, uint16_t addr,
uint8_t status, uint16_t net_idx);
/** @brief Optional callback for Netkey list messages.
*
* Handles received Netkey list messages from a server.
*
* @note The @c buf parameter should be decoded using the
* @ref bt_mesh_key_idx_unpack_list helper function.
*
* @param cli Client that received the status message.
* @param addr Address of the sender.
* @param buf Message buffer containing key indexes.
*/
void (*net_key_list)(struct bt_mesh_cfg_cli *cli, uint16_t addr,
struct net_buf_simple *buf);
/** @brief Optional callback for AppKey Status messages.
*
* Handles received AppKey Status messages from a server.
*
* @param cli Client that received the status message.
* @param addr Address of the sender.
* @param status Status Code for requesting message.
* @param net_idx The index of the NetKey.
* @param app_idx The index of the AppKey.
*/
void (*app_key_status)(struct bt_mesh_cfg_cli *cli, uint16_t addr,
uint8_t status, uint16_t net_idx,
uint16_t app_idx);
/** @brief Optional callback for Appkey list messages.
*
* Handles received Appkey list messages from a server.
*
* @note The @c buf parameter should be decoded using the
* @ref bt_mesh_key_idx_unpack_list helper function.
*
* @param cli Client that received the status message.
* @param addr Address of the sender.
* @param status Status code for the message.
* @param net_idx The index of the NetKey.
* @param buf Message buffer containing key indexes.
*/
void (*app_key_list)(struct bt_mesh_cfg_cli *cli, uint16_t addr, uint8_t status,
uint16_t net_idx, struct net_buf_simple *buf);
/** @brief Optional callback for Model App Status messages.
*
* Handles received Model App Status messages from a server.
*
* @param cli Client that received the status message.
* @param addr Address of the sender.
* @param status Status Code for requesting message.
* @param elem_addr The unicast address of the element.
* @param app_idx The sub address.
* @param mod_id The model ID within the element.
*/
void (*mod_app_status)(struct bt_mesh_cfg_cli *cli, uint16_t addr,
uint8_t status, uint16_t elem_addr,
uint16_t app_idx, uint32_t mod_id);
/** @brief Optional callback for Model App list messages.
*
* Handles received Model App list messages from a server.
*
* @note The @c buf parameter should be decoded using the
* @ref bt_mesh_key_idx_unpack_list helper function.
*
* @param cli Client that received the status message.
* @param addr Address of the sender.
* @param status Status code for the message.
* @param elem_addr Address of the element.
* @param mod_id Model ID.
* @param cid Company ID.
* @param buf Message buffer containing key indexes.
*/
void (*mod_app_list)(struct bt_mesh_cfg_cli *cli, uint16_t addr, uint8_t status,
uint16_t elem_addr, uint16_t mod_id, uint16_t cid,
struct net_buf_simple *buf);
/** @brief Optional callback for Node Identity Status messages.
*
* Handles received Node Identity Status messages from a server.
*
* @param cli Client that received the status message.
* @param addr Address of the sender.
* @param status Status Code for requesting message.
* @param net_idx The index of the NetKey.
* @param identity The node identity state.
*/
void (*node_identity_status)(struct bt_mesh_cfg_cli *cli, uint16_t addr,
uint8_t status, uint16_t net_idx,
uint8_t identity);
/** @brief Optional callback for LPN PollTimeout Status messages.
*
* Handles received LPN PollTimeout Status messages from a server.
*
* @param cli Client that received the status message.
* @param addr Address of the sender.
* @param elem_addr The unicast address of the LPN.
* @param timeout Current value of PollTimeout timer of the LPN.
*/
void (*lpn_timeout_status)(struct bt_mesh_cfg_cli *cli, uint16_t addr,
uint16_t elem_addr, uint32_t timeout);
/** @brief Optional callback for Key Refresh Phase status messages.
*
* Handles received Key Refresh Phase status messages from a server.
*
* @param cli Client that received the status message.
* @param addr Address of the sender.
* @param status Status code for the message.
* @param net_idx The index of the NetKey.
* @param phase Phase of the KRP.
*/
void (*krp_status)(struct bt_mesh_cfg_cli *cli, uint16_t addr, uint8_t status,
uint16_t net_idx, uint8_t phase);
/** @brief Optional callback for Heartbeat pub status messages.
*
* Handles received Heartbeat pub status messages from a server.
*
* @param cli Client that received the status message.
* @param addr Address of the sender.
* @param status Status code for the message.
* @param pub HB publication configuration parameters.
*/
void (*hb_pub_status)(struct bt_mesh_cfg_cli *cli, uint16_t addr, uint8_t status,
struct bt_mesh_cfg_cli_hb_pub *pub);
/** @brief Optional callback for Heartbeat Sub status messages.
*
* Handles received Heartbeat Sub status messages from a server.
*
* @param cli Client that received the status message.
* @param addr Address of the sender.
* @param status Status code for the message.
* @param sub HB subscription configuration parameters.
*/
void (*hb_sub_status)(struct bt_mesh_cfg_cli *cli, uint16_t addr, uint8_t status,
struct bt_mesh_cfg_cli_hb_sub *sub);
};
/** Mesh Configuration Client Model Context */
struct bt_mesh_cfg_cli {
/** Composition data model entry pointer. */
const struct bt_mesh_model *model;
/** Optional callback for Mesh Configuration Client Status messages. */
const struct bt_mesh_cfg_cli_cb *cb;
/* Internal parameters for tracking message responses. */
struct bt_mesh_msg_ack_ctx ack_ctx;
};
/**
* @brief Generic Configuration Client model composition data entry.
*
* @param cli_data Pointer to a @ref bt_mesh_cfg_cli instance.
*/
#define BT_MESH_MODEL_CFG_CLI(cli_data) \
BT_MESH_MODEL_CNT_CB(BT_MESH_MODEL_ID_CFG_CLI, \
bt_mesh_cfg_cli_op, NULL, \
cli_data, 1, 0, &bt_mesh_cfg_cli_cb)
/**
*
* @brief Helper macro to encode model publication period in units of 100ms
*
* @param steps Number of 100ms steps.
*
* @return Encoded value that can be assigned to bt_mesh_cfg_cli_mod_pub.period
*/
#define BT_MESH_PUB_PERIOD_100MS(steps) ((steps) & BIT_MASK(6))
/**
* @brief Helper macro to encode model publication period in units of 1 second
*
* @param steps Number of 1 second steps.
*
* @return Encoded value that can be assigned to bt_mesh_cfg_cli_mod_pub.period
*/
#define BT_MESH_PUB_PERIOD_SEC(steps) (((steps) & BIT_MASK(6)) | (1 << 6))
/**
*
* @brief Helper macro to encode model publication period in units of 10
* seconds
*
* @param steps Number of 10 second steps.
*
* @return Encoded value that can be assigned to bt_mesh_cfg_cli_mod_pub.period
*/
#define BT_MESH_PUB_PERIOD_10SEC(steps) (((steps) & BIT_MASK(6)) | (2 << 6))
/**
*
* @brief Helper macro to encode model publication period in units of 10
* minutes
*
* @param steps Number of 10 minute steps.
*
* @return Encoded value that can be assigned to bt_mesh_cfg_cli_mod_pub.period
*/
#define BT_MESH_PUB_PERIOD_10MIN(steps) (((steps) & BIT_MASK(6)) | (3 << 6))
/** Model publication configuration parameters. */
struct bt_mesh_cfg_cli_mod_pub {
/** Publication destination address. */
uint16_t addr;
/** Virtual address UUID, or NULL if this is not a virtual address. */
const uint8_t *uuid;
/** Application index to publish with. */
uint16_t app_idx;
/** Friendship credential flag. */
bool cred_flag;
/** Time To Live to publish with. */
uint8_t ttl;
/**
* Encoded publish period.
* @see BT_MESH_PUB_PERIOD_100MS, BT_MESH_PUB_PERIOD_SEC,
* BT_MESH_PUB_PERIOD_10SEC,
* BT_MESH_PUB_PERIOD_10MIN
*/
uint8_t period;
/**
* Encoded transmit parameters.
* @see BT_MESH_TRANSMIT
*/
uint8_t transmit;
};
/** Heartbeat subscription configuration parameters. */
struct bt_mesh_cfg_cli_hb_sub {
/** Source address to receive Heartbeat messages from. */
uint16_t src;
/** Destination address to receive Heartbeat messages on. */
uint16_t dst;
/**
* Logarithmic subscription period to keep listening for.
* The decoded subscription period is (1 << (period - 1)) seconds, or 0
* seconds if period is 0.
*/
uint8_t period;
/**
* Logarithmic Heartbeat subscription receive count.
* The decoded Heartbeat count is (1 << (count - 1)) if count is
* between 1 and 0xfe, 0 if count is 0 and 0xffff if count is 0xff.
*
* Ignored in Heartbeat subscription set.
*/
uint8_t count;
/**
* Minimum hops in received messages, ie the shortest registered path
* from the publishing node to the subscribing node. A Heartbeat
* received from an immediate neighbor has hop count = 1.
*
* Ignored in Heartbeat subscription set.
*/
uint8_t min;
/**
* Maximum hops in received messages, ie the longest registered path
* from the publishing node to the subscribing node. A Heartbeat
* received from an immediate neighbor has hop count = 1.
*
* Ignored in Heartbeat subscription set.
*/
uint8_t max;
};
/** Heartbeat publication configuration parameters. */
struct bt_mesh_cfg_cli_hb_pub {
/** Heartbeat destination address. */
uint16_t dst;
/**
* Logarithmic Heartbeat count. Decoded as (1 << (count - 1)) if count
* is between 1 and 0x11, 0 if count is 0, or "indefinitely" if count is
* 0xff.
*
* When used in Heartbeat publication set, this parameter denotes the
* number of Heartbeat messages to send.
*
* When returned from Heartbeat publication get, this parameter denotes
* the number of Heartbeat messages remaining to be sent.
*/
uint8_t count;
/**
* Logarithmic Heartbeat publication transmit interval in seconds.
* Decoded as (1 << (period - 1)) if period is between 1 and 0x11.
* If period is 0, Heartbeat publication is disabled.
*/
uint8_t period;
/** Publication message Time To Live value. */
uint8_t ttl;
/**
* Bitmap of features that trigger Heartbeat publications.
* Legal values are @ref BT_MESH_FEAT_RELAY,
* @ref BT_MESH_FEAT_PROXY, @ref BT_MESH_FEAT_FRIEND and
* @ref BT_MESH_FEAT_LOW_POWER
*/
uint16_t feat;
/** Network index to publish with. */
uint16_t net_idx;
};
/** @brief Reset the target node and remove it from the network.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param status Status response parameter
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_node_reset(uint16_t net_idx, uint16_t addr, bool *status);
/** @brief Get the target node's composition data.
*
* If the other device does not have the given composition data page, it will
* return the largest page number it supports that is less than the requested
* page index. The actual page the device responds with is returned in @c rsp.
*
* This method can be used asynchronously by setting @p rsp and @p comp
* as NULL. This way the method will not wait for response and will return
* immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param page Composition data page, or 0xff to request the first available
* page.
* @param rsp Return parameter for the returned page number, or NULL.
* @param comp Composition data buffer to fill.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_comp_data_get(uint16_t net_idx, uint16_t addr, uint8_t page, uint8_t *rsp,
struct net_buf_simple *comp);
/** @brief Get the target node's network beacon state.
*
* This method can be used asynchronously by setting @p status
* as NULL. This way the method will not wait for response and will
* return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param status Status response parameter, returns one of
* @ref BT_MESH_BEACON_DISABLED or @ref BT_MESH_BEACON_ENABLED
* on success.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_beacon_get(uint16_t net_idx, uint16_t addr, uint8_t *status);
/** @brief Get the target node's network key refresh phase state.
*
* This method can be used asynchronously by setting @p status and @p phase
* as NULL. This way the method will not wait for response and will
* return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param key_net_idx Network key index.
* @param status Status response parameter.
* @param phase Pointer to the Key Refresh variable to fill.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_krp_get(uint16_t net_idx, uint16_t addr, uint16_t key_net_idx, uint8_t *status,
uint8_t *phase);
/** @brief Set the target node's network key refresh phase parameters.
*
* This method can be used asynchronously by setting @p status and @p phase
* as NULL. This way the method will not wait for response and will
* return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param key_net_idx Network key index.
* @param transition Transition parameter.
* @param status Status response parameter.
* @param phase Pointer to the new Key Refresh phase. Will return the actual
* Key Refresh phase after updating.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_krp_set(uint16_t net_idx, uint16_t addr, uint16_t key_net_idx,
uint8_t transition, uint8_t *status, uint8_t *phase);
/** @brief Set the target node's network beacon state.
*
* This method can be used asynchronously by setting @p status
* as NULL. This way the method will not wait for response and will
* return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param val New network beacon state, should be one of
* @ref BT_MESH_BEACON_DISABLED or @ref BT_MESH_BEACON_ENABLED.
* @param status Status response parameter. Returns one of
* @ref BT_MESH_BEACON_DISABLED or @ref BT_MESH_BEACON_ENABLED
* on success.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_beacon_set(uint16_t net_idx, uint16_t addr, uint8_t val, uint8_t *status);
/** @brief Get the target node's Time To Live value.
*
* This method can be used asynchronously by setting @p ttl
* as NULL. This way the method will not wait for response and will
* return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param ttl TTL response buffer.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_ttl_get(uint16_t net_idx, uint16_t addr, uint8_t *ttl);
/** @brief Set the target node's Time To Live value.
*
* This method can be used asynchronously by setting @p ttl
* as NULL. This way the method will not wait for response and will
* return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param val New Time To Live value.
* @param ttl TTL response buffer.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_ttl_set(uint16_t net_idx, uint16_t addr, uint8_t val, uint8_t *ttl);
/** @brief Get the target node's Friend feature status.
*
* This method can be used asynchronously by setting @p status
* as NULL. This way the method will not wait for response and will
* return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param status Status response parameter. Returns one of
* @ref BT_MESH_FRIEND_DISABLED, @ref BT_MESH_FRIEND_ENABLED or
* @ref BT_MESH_FRIEND_NOT_SUPPORTED on success.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_friend_get(uint16_t net_idx, uint16_t addr, uint8_t *status);
/** @brief Set the target node's Friend feature state.
*
* This method can be used asynchronously by setting @p status
* as NULL. This way the method will not wait for response and will
* return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param val New Friend feature state. Should be one of
* @ref BT_MESH_FRIEND_DISABLED or
* @ref BT_MESH_FRIEND_ENABLED.
* @param status Status response parameter. Returns one of
* @ref BT_MESH_FRIEND_DISABLED, @ref BT_MESH_FRIEND_ENABLED or
* @ref BT_MESH_FRIEND_NOT_SUPPORTED on success.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_friend_set(uint16_t net_idx, uint16_t addr, uint8_t val, uint8_t *status);
/** @brief Get the target node's Proxy feature state.
*
* This method can be used asynchronously by setting @p status
* as NULL. This way the method will not wait for response and will
* return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param status Status response parameter. Returns one of
* @ref BT_MESH_GATT_PROXY_DISABLED,
* @ref BT_MESH_GATT_PROXY_ENABLED or
* @ref BT_MESH_GATT_PROXY_NOT_SUPPORTED on success.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_gatt_proxy_get(uint16_t net_idx, uint16_t addr, uint8_t *status);
/** @brief Set the target node's Proxy feature state.
*
* This method can be used asynchronously by setting @p status
* as NULL. This way the method will not wait for response and will
* return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param val New Proxy feature state. Must be one of
* @ref BT_MESH_GATT_PROXY_DISABLED or
* @ref BT_MESH_GATT_PROXY_ENABLED.
* @param status Status response parameter. Returns one of
* @ref BT_MESH_GATT_PROXY_DISABLED,
* @ref BT_MESH_GATT_PROXY_ENABLED or
* @ref BT_MESH_GATT_PROXY_NOT_SUPPORTED on success.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_gatt_proxy_set(uint16_t net_idx, uint16_t addr, uint8_t val, uint8_t *status);
/** @brief Get the target node's network_transmit state.
*
* This method can be used asynchronously by setting @p transmit
* as NULL. This way the method will not wait for response and will
* return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param transmit Network transmit response parameter. Returns the encoded
* network transmission parameters on success. Decoded with
* @ref BT_MESH_TRANSMIT_COUNT and @ref BT_MESH_TRANSMIT_INT.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_net_transmit_get(uint16_t net_idx, uint16_t addr, uint8_t *transmit);
/** @brief Set the target node's network transmit parameters.
*
* This method can be used asynchronously by setting @p transmit
* as NULL. This way the method will not wait for response and will
* return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param val New encoded network transmit parameters.
* @see BT_MESH_TRANSMIT.
* @param transmit Network transmit response parameter. Returns the encoded
* network transmission parameters on success. Decoded with
* @ref BT_MESH_TRANSMIT_COUNT and @ref BT_MESH_TRANSMIT_INT.
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_net_transmit_set(uint16_t net_idx, uint16_t addr, uint8_t val,
uint8_t *transmit);
/** @brief Get the target node's Relay feature state.
*
* This method can be used asynchronously by setting @p status and @p transmit
* as NULL. This way the method will not wait for response and will
* return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param status Status response parameter. Returns one of
* @ref BT_MESH_RELAY_DISABLED, @ref BT_MESH_RELAY_ENABLED or
* @ref BT_MESH_RELAY_NOT_SUPPORTED on success.
* @param transmit Transmit response parameter. Returns the encoded relay
* transmission parameters on success. Decoded with
* @ref BT_MESH_TRANSMIT_COUNT and @ref BT_MESH_TRANSMIT_INT.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_relay_get(uint16_t net_idx, uint16_t addr, uint8_t *status, uint8_t *transmit);
/** @brief Set the target node's Relay parameters.
*
* This method can be used asynchronously by setting @p status
* and @p transmit as NULL. This way the method will not wait for
* response and will return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param new_relay New relay state. Must be one of
* @ref BT_MESH_RELAY_DISABLED or
* @ref BT_MESH_RELAY_ENABLED.
* @param new_transmit New encoded relay transmit parameters.
* @see BT_MESH_TRANSMIT.
* @param status Status response parameter. Returns one of
* @ref BT_MESH_RELAY_DISABLED, @ref BT_MESH_RELAY_ENABLED
* or @ref BT_MESH_RELAY_NOT_SUPPORTED on success.
* @param transmit Transmit response parameter. Returns the encoded relay
* transmission parameters on success. Decoded with
* @ref BT_MESH_TRANSMIT_COUNT and
* @ref BT_MESH_TRANSMIT_INT.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_relay_set(uint16_t net_idx, uint16_t addr, uint8_t new_relay,
uint8_t new_transmit, uint8_t *status, uint8_t *transmit);
/** @brief Add a network key to the target node.
*
* This method can be used asynchronously by setting @p status
* as NULL. This way the method will not wait for response and will
* return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param key_net_idx Network key index.
* @param net_key Network key.
* @param status Status response parameter.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_net_key_add(uint16_t net_idx, uint16_t addr, uint16_t key_net_idx,
const uint8_t net_key[16], uint8_t *status);
/** @brief Get a list of the target node's network key indexes.
*
* This method can be used asynchronously by setting @p keys
* or @p key_cnt as NULL. This way the method will not wait
* for response and will return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param keys Net key index list response parameter. Will be filled with
* all the returned network key indexes it can fill.
* @param key_cnt Net key index list length. Should be set to the
* capacity of the @c keys list when calling. Will return the
* number of returned network key indexes upon success.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_net_key_get(uint16_t net_idx, uint16_t addr, uint16_t *keys, size_t *key_cnt);
/** @brief Delete a network key from the target node.
*
* This method can be used asynchronously by setting @p status
* as NULL. This way the method will not wait for response and will
* return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param key_net_idx Network key index.
* @param status Status response parameter.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_net_key_del(uint16_t net_idx, uint16_t addr, uint16_t key_net_idx,
uint8_t *status);
/** @brief Add an application key to the target node.
*
* This method can be used asynchronously by setting @p status
* as NULL. This way the method will not wait for response and will
* return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param key_net_idx Network key index the application key belongs to.
* @param key_app_idx Application key index.
* @param app_key Application key.
* @param status Status response parameter.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_app_key_add(uint16_t net_idx, uint16_t addr, uint16_t key_net_idx,
uint16_t key_app_idx, const uint8_t app_key[16], uint8_t *status);
/** @brief Get a list of the target node's application key indexes for a
* specific network key.
*
* This method can be used asynchronously by setting @p status and
* ( @p keys or @p key_cnt ) as NULL. This way the method will not wait
* for response and will return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param key_net_idx Network key index to request the app key indexes of.
* @param status Status response parameter.
* @param keys App key index list response parameter. Will be filled
* with all the returned application key indexes it can
* fill.
* @param key_cnt App key index list length. Should be set to the
* capacity of the @c keys list when calling. Will return
* the number of returned application key indexes upon
* success.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_app_key_get(uint16_t net_idx, uint16_t addr, uint16_t key_net_idx,
uint8_t *status, uint16_t *keys, size_t *key_cnt);
/** @brief Delete an application key from the target node.
*
* This method can be used asynchronously by setting @p status
* as NULL. This way the method will not wait for response and will
* return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param key_net_idx Network key index the application key belongs to.
* @param key_app_idx Application key index.
* @param status Status response parameter.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_app_key_del(uint16_t net_idx, uint16_t addr, uint16_t key_net_idx,
uint16_t key_app_idx, uint8_t *status);
/** @brief Bind an application to a SIG model on the target node.
*
* This method can be used asynchronously by setting @p status
* as NULL. This way the method will not wait for response and will
* return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param elem_addr Element address the model is in.
* @param mod_app_idx Application index to bind.
* @param mod_id Model ID.
* @param status Status response parameter.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_mod_app_bind(uint16_t net_idx, uint16_t addr, uint16_t elem_addr,
uint16_t mod_app_idx, uint16_t mod_id, uint8_t *status);
/** @brief Unbind an application from a SIG model on the target node.
*
* This method can be used asynchronously by setting @p status
* as NULL. This way the method will not wait for response and will
* return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param elem_addr Element address the model is in.
* @param mod_app_idx Application index to unbind.
* @param mod_id Model ID.
* @param status Status response parameter.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_mod_app_unbind(uint16_t net_idx, uint16_t addr, uint16_t elem_addr,
uint16_t mod_app_idx, uint16_t mod_id, uint8_t *status);
/** @brief Bind an application to a vendor model on the target node.
*
* This method can be used asynchronously by setting @p status
* as NULL. This way the method will not wait for response and will
* return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param elem_addr Element address the model is in.
* @param mod_app_idx Application index to bind.
* @param mod_id Model ID.
* @param cid Company ID of the model.
* @param status Status response parameter.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_mod_app_bind_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr,
uint16_t mod_app_idx, uint16_t mod_id, uint16_t cid,
uint8_t *status);
/** @brief Unbind an application from a vendor model on the target node.
*
* This method can be used asynchronously by setting @p status
* as NULL. This way the method will not wait for response and will
* return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param elem_addr Element address the model is in.
* @param mod_app_idx Application index to unbind.
* @param mod_id Model ID.
* @param cid Company ID of the model.
* @param status Status response parameter.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_mod_app_unbind_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr,
uint16_t mod_app_idx, uint16_t mod_id, uint16_t cid,
uint8_t *status);
/** @brief Get a list of all applications bound to a SIG model on the target
* node.
*
* This method can be used asynchronously by setting @p status
* and ( @p apps or @p app_cnt ) as NULL. This way the method will
* not wait for response and will return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param elem_addr Element address the model is in.
* @param mod_id Model ID.
* @param status Status response parameter.
* @param apps App index list response parameter. Will be filled with all
* the returned application key indexes it can fill.
* @param app_cnt App index list length. Should be set to the capacity of the
* @c apps list when calling. Will return the number of
* returned application key indexes upon success.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_mod_app_get(uint16_t net_idx, uint16_t addr, uint16_t elem_addr,
uint16_t mod_id, uint8_t *status, uint16_t *apps, size_t *app_cnt);
/** @brief Get a list of all applications bound to a vendor model on the target
* node.
*
* This method can be used asynchronously by setting @p status
* and ( @p apps or @p app_cnt ) as NULL. This way the method will
* not wait for response and will return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param elem_addr Element address the model is in.
* @param mod_id Model ID.
* @param cid Company ID of the model.
* @param status Status response parameter.
* @param apps App index list response parameter. Will be filled with all
* the returned application key indexes it can fill.
* @param app_cnt App index list length. Should be set to the capacity of the
* @c apps list when calling. Will return the number of
* returned application key indexes upon success.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_mod_app_get_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr,
uint16_t mod_id, uint16_t cid, uint8_t *status, uint16_t *apps,
size_t *app_cnt);
/** @brief Get publish parameters for a SIG model on the target node.
*
* This method can be used asynchronously by setting @p status and
* @p pub as NULL. This way the method will not wait for response
* and will return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param elem_addr Element address the model is in.
* @param mod_id Model ID.
* @param pub Publication parameter return buffer.
* @param status Status response parameter.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_mod_pub_get(uint16_t net_idx, uint16_t addr, uint16_t elem_addr,
uint16_t mod_id, struct bt_mesh_cfg_cli_mod_pub *pub,
uint8_t *status);
/** @brief Get publish parameters for a vendor model on the target node.
*
* This method can be used asynchronously by setting @p status
* and @p pub as NULL. This way the method will not wait for response
* and will return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param elem_addr Element address the model is in.
* @param mod_id Model ID.
* @param cid Company ID of the model.
* @param pub Publication parameter return buffer.
* @param status Status response parameter.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_mod_pub_get_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr,
uint16_t mod_id, uint16_t cid,
struct bt_mesh_cfg_cli_mod_pub *pub, uint8_t *status);
/** @brief Set publish parameters for a SIG model on the target node.
*
* This method can be used asynchronously by setting @p status
* as NULL. This way the method will not wait for response
* and will return immediately after sending the command.
*
* @p pub shall not be NULL.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param elem_addr Element address the model is in.
* @param mod_id Model ID.
* @param pub Publication parameters.
* @param status Status response parameter.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_mod_pub_set(uint16_t net_idx, uint16_t addr, uint16_t elem_addr,
uint16_t mod_id, struct bt_mesh_cfg_cli_mod_pub *pub,
uint8_t *status);
/** @brief Set publish parameters for a vendor model on the target node.
*
* This method can be used asynchronously by setting @p status
* as NULL. This way the method will not wait for response
* and will return immediately after sending the command.
*
* @p pub shall not be NULL.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param elem_addr Element address the model is in.
* @param mod_id Model ID.
* @param cid Company ID of the model.
* @param pub Publication parameters.
* @param status Status response parameter.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_mod_pub_set_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr,
uint16_t mod_id, uint16_t cid,
struct bt_mesh_cfg_cli_mod_pub *pub, uint8_t *status);
/** @brief Add a group address to a SIG model's subscription list.
*
* This method can be used asynchronously by setting @p status
* as NULL. This way the method will not wait for response
* and will return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param elem_addr Element address the model is in.
* @param sub_addr Group address to add to the subscription list.
* @param mod_id Model ID.
* @param status Status response parameter.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_mod_sub_add(uint16_t net_idx, uint16_t addr, uint16_t elem_addr,
uint16_t sub_addr, uint16_t mod_id, uint8_t *status);
/** @brief Add a group address to a vendor model's subscription list.
*
* This method can be used asynchronously by setting @p status
* as NULL. This way the method will not wait for response
* and will return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param elem_addr Element address the model is in.
* @param sub_addr Group address to add to the subscription list.
* @param mod_id Model ID.
* @param cid Company ID of the model.
* @param status Status response parameter.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_mod_sub_add_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr,
uint16_t sub_addr, uint16_t mod_id, uint16_t cid,
uint8_t *status);
/** @brief Delete a group address in a SIG model's subscription list.
*
* This method can be used asynchronously by setting @p status
* as NULL. This way the method will not wait for response
* and will return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param elem_addr Element address the model is in.
* @param sub_addr Group address to add to the subscription list.
* @param mod_id Model ID.
* @param status Status response parameter.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_mod_sub_del(uint16_t net_idx, uint16_t addr, uint16_t elem_addr,
uint16_t sub_addr, uint16_t mod_id, uint8_t *status);
/** @brief Delete a group address in a vendor model's subscription list.
*
* This method can be used asynchronously by setting @p status
* as NULL. This way the method will not wait for response
* and will return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param elem_addr Element address the model is in.
* @param sub_addr Group address to add to the subscription list.
* @param mod_id Model ID.
* @param cid Company ID of the model.
* @param status Status response parameter.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_mod_sub_del_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr,
uint16_t sub_addr, uint16_t mod_id, uint16_t cid,
uint8_t *status);
/** @brief Overwrite all addresses in a SIG model's subscription list with a
* group address.
*
* Deletes all subscriptions in the model's subscription list, and adds a
* single group address instead.
*
* This method can be used asynchronously by setting @p status
* as NULL. This way the method will not wait for response
* and will return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param elem_addr Element address the model is in.
* @param sub_addr Group address to add to the subscription list.
* @param mod_id Model ID.
* @param status Status response parameter.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_mod_sub_overwrite(uint16_t net_idx, uint16_t addr, uint16_t elem_addr,
uint16_t sub_addr, uint16_t mod_id, uint8_t *status);
/** @brief Overwrite all addresses in a vendor model's subscription list with a
* group address.
*
* Deletes all subscriptions in the model's subscription list, and adds a
* single group address instead.
*
* This method can be used asynchronously by setting @p status
* as NULL. This way the method will not wait for response
* and will return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param elem_addr Element address the model is in.
* @param sub_addr Group address to add to the subscription list.
* @param mod_id Model ID.
* @param cid Company ID of the model.
* @param status Status response parameter.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_mod_sub_overwrite_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr,
uint16_t sub_addr, uint16_t mod_id, uint16_t cid,
uint8_t *status);
/** @brief Add a virtual address to a SIG model's subscription list.
*
* This method can be used asynchronously by setting @p status
* and @p virt_addr as NULL. This way the method will not wait
* for response and will return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param elem_addr Element address the model is in.
* @param label Virtual address label to add to the subscription list.
* @param mod_id Model ID.
* @param virt_addr Virtual address response parameter.
* @param status Status response parameter.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_mod_sub_va_add(uint16_t net_idx, uint16_t addr, uint16_t elem_addr,
const uint8_t label[16], uint16_t mod_id, uint16_t *virt_addr,
uint8_t *status);
/** @brief Add a virtual address to a vendor model's subscription list.
*
* This method can be used asynchronously by setting @p status
* and @p virt_addr as NULL. This way the method will not wait
* for response and will return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param elem_addr Element address the model is in.
* @param label Virtual address label to add to the subscription list.
* @param mod_id Model ID.
* @param cid Company ID of the model.
* @param virt_addr Virtual address response parameter.
* @param status Status response parameter.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_mod_sub_va_add_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr,
const uint8_t label[16], uint16_t mod_id, uint16_t cid,
uint16_t *virt_addr, uint8_t *status);
/** @brief Delete a virtual address in a SIG model's subscription list.
*
* This method can be used asynchronously by setting @p status
* and @p virt_addr as NULL. This way the method will not wait
* for response and will return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param elem_addr Element address the model is in.
* @param label Virtual address parameter to add to the subscription list.
* @param mod_id Model ID.
* @param virt_addr Virtual address response parameter.
* @param status Status response parameter.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_mod_sub_va_del(uint16_t net_idx, uint16_t addr, uint16_t elem_addr,
const uint8_t label[16], uint16_t mod_id, uint16_t *virt_addr,
uint8_t *status);
/** @brief Delete a virtual address in a vendor model's subscription list.
*
* This method can be used asynchronously by setting @p status
* and @p virt_addr as NULL. This way the method will not wait
* for response and will return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param elem_addr Element address the model is in.
* @param label Virtual address label to add to the subscription list.
* @param mod_id Model ID.
* @param cid Company ID of the model.
* @param virt_addr Virtual address response parameter.
* @param status Status response parameter.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_mod_sub_va_del_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr,
const uint8_t label[16], uint16_t mod_id, uint16_t cid,
uint16_t *virt_addr, uint8_t *status);
/** @brief Overwrite all addresses in a SIG model's subscription list with a
* virtual address.
*
* Deletes all subscriptions in the model's subscription list, and adds a
* single group address instead.
*
* This method can be used asynchronously by setting @p status
* and @p virt_addr as NULL. This way the method will not wait
* for response and will return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param elem_addr Element address the model is in.
* @param label Virtual address label to add to the subscription list.
* @param mod_id Model ID.
* @param virt_addr Virtual address response parameter.
* @param status Status response parameter.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_mod_sub_va_overwrite(uint16_t net_idx, uint16_t addr, uint16_t elem_addr,
const uint8_t label[16], uint16_t mod_id,
uint16_t *virt_addr, uint8_t *status);
/** @brief Overwrite all addresses in a vendor model's subscription list with a
* virtual address.
*
* Deletes all subscriptions in the model's subscription list, and adds a
* single group address instead.
*
* This method can be used asynchronously by setting @p status
* and @p virt_addr as NULL. This way the method will not wait
* for response and will return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param elem_addr Element address the model is in.
* @param label Virtual address label to add to the subscription list.
* @param mod_id Model ID.
* @param cid Company ID of the model.
* @param virt_addr Virtual address response parameter.
* @param status Status response parameter.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_mod_sub_va_overwrite_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr,
const uint8_t label[16], uint16_t mod_id, uint16_t cid,
uint16_t *virt_addr, uint8_t *status);
/** @brief Get the subscription list of a SIG model on the target node.
*
* This method can be used asynchronously by setting @p status and
* ( @p subs or @p sub_cnt ) as NULL. This way the method will
* not wait for response and will return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param elem_addr Element address the model is in.
* @param mod_id Model ID.
* @param status Status response parameter.
* @param subs Subscription list response parameter. Will be filled with
* all the returned subscriptions it can fill.
* @param sub_cnt Subscription list element count. Should be set to the
* capacity of the @c subs list when calling. Will return the
* number of returned subscriptions upon success.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_mod_sub_get(uint16_t net_idx, uint16_t addr, uint16_t elem_addr,
uint16_t mod_id, uint8_t *status, uint16_t *subs, size_t *sub_cnt);
/** @brief Get the subscription list of a vendor model on the target node.
*
* This method can be used asynchronously by setting @p status and
* ( @p subs or @p sub_cnt ) as NULL. This way the method will
* not wait for response and will return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param elem_addr Element address the model is in.
* @param mod_id Model ID.
* @param cid Company ID of the model.
* @param status Status response parameter.
* @param subs Subscription list response parameter. Will be filled with
* all the returned subscriptions it can fill.
* @param sub_cnt Subscription list element count. Should be set to the
* capacity of the @c subs list when calling. Will return the
* number of returned subscriptions upon success.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_mod_sub_get_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr,
uint16_t mod_id, uint16_t cid, uint8_t *status, uint16_t *subs,
size_t *sub_cnt);
/** @brief Set the target node's Heartbeat subscription parameters.
*
* This method can be used asynchronously by setting @p status
* as NULL. This way the method will not wait for response
* and will return immediately after sending the command.
*
* @p sub shall not be null.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param sub New Heartbeat subscription parameters.
* @param status Status response parameter.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_hb_sub_set(uint16_t net_idx, uint16_t addr, struct bt_mesh_cfg_cli_hb_sub *sub,
uint8_t *status);
/** @brief Get the target node's Heartbeat subscription parameters.
*
* This method can be used asynchronously by setting @p status
* and @p sub as NULL. This way the method will not wait for response
* and will return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param sub Heartbeat subscription parameter return buffer.
* @param status Status response parameter.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_hb_sub_get(uint16_t net_idx, uint16_t addr, struct bt_mesh_cfg_cli_hb_sub *sub,
uint8_t *status);
/** @brief Set the target node's Heartbeat publication parameters.
*
* @note The target node must already have received the specified network key.
*
* This method can be used asynchronously by setting @p status
* as NULL. This way the method will not wait for response
* and will return immediately after sending the command.
*
* @p pub shall not be NULL;
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param pub New Heartbeat publication parameters.
* @param status Status response parameter.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_hb_pub_set(uint16_t net_idx, uint16_t addr,
const struct bt_mesh_cfg_cli_hb_pub *pub, uint8_t *status);
/** @brief Get the target node's Heartbeat publication parameters.
*
* This method can be used asynchronously by setting @p status
* and @p pub as NULL. This way the method will not wait for response
* and will return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param pub Heartbeat publication parameter return buffer.
* @param status Status response parameter.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_hb_pub_get(uint16_t net_idx, uint16_t addr, struct bt_mesh_cfg_cli_hb_pub *pub,
uint8_t *status);
/** @brief Delete all group addresses in a SIG model's subscription list.
*
* This method can be used asynchronously by setting @p status
* as NULL. This way the method will not wait for response
* and will return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param elem_addr Element address the model is in.
* @param mod_id Model ID.
* @param status Status response parameter.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_mod_sub_del_all(uint16_t net_idx, uint16_t addr, uint16_t elem_addr,
uint16_t mod_id, uint8_t *status);
/** @brief Delete all group addresses in a vendor model's subscription list.
*
* This method can be used asynchronously by setting @p status
* as NULL. This way the method will not wait for response
* and will return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param elem_addr Element address the model is in.
* @param mod_id Model ID.
* @param cid Company ID of the model.
* @param status Status response parameter.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_mod_sub_del_all_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr,
uint16_t mod_id, uint16_t cid, uint8_t *status);
/** @brief Update a network key to the target node.
*
* This method can be used asynchronously by setting @p status
* as NULL. This way the method will not wait for response
* and will return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param key_net_idx Network key index.
* @param net_key Network key.
* @param status Status response parameter.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_net_key_update(uint16_t net_idx, uint16_t addr, uint16_t key_net_idx,
const uint8_t net_key[16], uint8_t *status);
/** @brief Update an application key to the target node.
*
* This method can be used asynchronously by setting @p status
* as NULL. This way the method will not wait for response
* and will return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param key_net_idx Network key index the application key belongs to.
* @param key_app_idx Application key index.
* @param app_key Application key.
* @param status Status response parameter.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_app_key_update(uint16_t net_idx, uint16_t addr, uint16_t key_net_idx,
uint16_t key_app_idx, const uint8_t app_key[16],
uint8_t *status);
/** @brief Set the Node Identity parameters.
*
* This method can be used asynchronously by setting @p status
* and @p identity as NULL. This way the method will not wait
* for response and will return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param new_identity New identity state. Must be one of
* @ref BT_MESH_NODE_IDENTITY_STOPPED or
* @ref BT_MESH_NODE_IDENTITY_RUNNING
* @param key_net_idx Network key index the application key belongs to.
* @param status Status response parameter.
* @param identity Identity response parameter.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_node_identity_set(uint16_t net_idx, uint16_t addr, uint16_t key_net_idx,
uint8_t new_identity, uint8_t *status, uint8_t *identity);
/** @brief Get the Node Identity parameters.
*
* This method can be used asynchronously by setting @p status
* and @p identity as NULL. This way the method will not wait
* for response and will return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param key_net_idx Network key index the application key belongs to.
* @param status Status response parameter.
* @param identity Identity response parameter. Must be one of
* @ref BT_MESH_NODE_IDENTITY_STOPPED or
* @ref BT_MESH_NODE_IDENTITY_RUNNING
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_node_identity_get(uint16_t net_idx, uint16_t addr, uint16_t key_net_idx,
uint8_t *status, uint8_t *identity);
/** @brief Get the Low Power Node Polltimeout parameters.
*
* This method can be used asynchronously by setting @p polltimeout
* as NULL. This way the method will not wait for response
* and will return immediately after sending the command.
*
* @param net_idx Network index to encrypt with.
* @param addr Target node address.
* @param unicast_addr LPN unicast address.
* @param polltimeout Poll timeout response parameter.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_cfg_cli_lpn_timeout_get(uint16_t net_idx, uint16_t addr, uint16_t unicast_addr,
int32_t *polltimeout);
/** @brief Get the current transmission timeout value.
*
* @return The configured transmission timeout in milliseconds.
*/
int32_t bt_mesh_cfg_cli_timeout_get(void);
/** @brief Set the transmission timeout value.
*
* @param timeout The new transmission timeout.
*/
void bt_mesh_cfg_cli_timeout_set(int32_t timeout);
/** Parsed Composition data page 0 representation.
*
* Should be pulled from the return buffer passed to
* @ref bt_mesh_cfg_cli_comp_data_get using
* @ref bt_mesh_comp_p0_get.
*/
struct bt_mesh_comp_p0 {
/** Company ID */
uint16_t cid;
/** Product ID */
uint16_t pid;
/** Version ID */
uint16_t vid;
/** Replay protection list size */
uint16_t crpl;
/** Supported features, see @ref BT_MESH_FEAT_SUPPORTED. */
uint16_t feat;
struct net_buf_simple *_buf;
};
/** Composition data page 0 element representation */
struct bt_mesh_comp_p0_elem {
/** Element location */
uint16_t loc;
/** The number of SIG models in this element */
size_t nsig;
/** The number of vendor models in this element */
size_t nvnd;
uint8_t *_buf;
};
/** @brief Create a composition data page 0 representation from a buffer.
*
* The composition data page object will take ownership over the buffer, which
* should not be manipulated directly after this call.
*
* This function can be used in combination with @ref bt_mesh_cfg_cli_comp_data_get
* to read out composition data page 0 from other devices:
*
* @code
* NET_BUF_SIMPLE_DEFINE(buf, BT_MESH_RX_SDU_MAX);
* struct bt_mesh_comp_p0 comp;
*
* err = bt_mesh_cfg_cli_comp_data_get(net_idx, addr, 0, &page, &buf);
* if (!err) {
* bt_mesh_comp_p0_get(&comp, &buf);
* }
* @endcode
*
* @param buf Network buffer containing composition data.
* @param comp Composition data structure to fill.
*
* @return 0 on success, or (negative) error code on failure.
*/
int bt_mesh_comp_p0_get(struct bt_mesh_comp_p0 *comp,
struct net_buf_simple *buf);
/** @brief Pull a composition data page 0 element from a composition data page 0
* instance.
*
* Each call to this function will pull out a new element from the composition
* data page, until all elements have been pulled.
*
* @param comp Composition data page
* @param elem Element to fill.
*
* @return A pointer to @c elem on success, or NULL if no more elements could
* be pulled.
*/
struct bt_mesh_comp_p0_elem *bt_mesh_comp_p0_elem_pull(const struct bt_mesh_comp_p0 *comp,
struct bt_mesh_comp_p0_elem *elem);
/** @brief Get a SIG model from the given composition data page 0 element.
*
* @param elem Element to read the model from.
* @param idx Index of the SIG model to read.
*
* @return The Model ID of the SIG model at the given index, or 0xffff if the
* index is out of bounds.
*/
uint16_t bt_mesh_comp_p0_elem_mod(struct bt_mesh_comp_p0_elem *elem, int idx);
/** @brief Get a vendor model from the given composition data page 0 element.
*
* @param elem Element to read the model from.
* @param idx Index of the vendor model to read.
*
* @return The model ID of the vendor model at the given index, or
* {0xffff, 0xffff} if the index is out of bounds.
*/
struct bt_mesh_mod_id_vnd bt_mesh_comp_p0_elem_mod_vnd(struct bt_mesh_comp_p0_elem *elem, int idx);
/** Composition data page 1 element representation */
struct bt_mesh_comp_p1_elem {
/** The number of SIG models in this element */
size_t nsig;
/** The number of vendor models in this element */
size_t nvnd;
/** Buffer containing SIG and Vendor Model Items */
struct net_buf_simple *_buf;
};
/** Composition data page 1 model item representation */
struct bt_mesh_comp_p1_model_item {
/** Corresponding_Group_ID field indicator */
bool cor_present;
/** Determines the format of Extended Model Item */
bool format;
/** Number of items in Extended Model Items*/
uint8_t ext_item_cnt : 6;
/** Buffer containing Extended Model Items.
* If cor_present is set to 1 it starts with
* Corresponding_Group_ID
*/
uint8_t cor_id;
struct net_buf_simple *_buf;
};
/** Extended Model Item in short representation */
struct bt_mesh_comp_p1_item_short {
/** Element address modifier */
uint8_t elem_offset : 3;
/** Model Index */
uint8_t mod_item_idx : 5;
};
/** Extended Model Item in long representation */
struct bt_mesh_comp_p1_item_long {
/** Element address modifier */
uint8_t elem_offset;
/** Model Index */
uint8_t mod_item_idx;
};
/** Extended Model Item */
struct bt_mesh_comp_p1_ext_item {
enum { SHORT, LONG } type;
union {
/** Item in short representation */
struct bt_mesh_comp_p1_item_short short_item;
/** Item in long representation */
struct bt_mesh_comp_p1_item_long long_item;
};
};
/** @brief Pull a Composition Data Page 1 Element from a composition data page 1
* instance.
*
* Each call to this function will pull out a new element from the composition
* data page, until all elements have been pulled.
*
* @param buf Composition data page 1 buffer
* @param elem Element to fill.
*
* @return A pointer to @c elem on success, or NULL if no more elements could
* be pulled.
*/
struct bt_mesh_comp_p1_elem *bt_mesh_comp_p1_elem_pull(
struct net_buf_simple *buf, struct bt_mesh_comp_p1_elem *elem);
/** @brief Pull a Composition Data Page 1 Model Item from a Composition Data
* Page 1 Element
*
* Each call to this function will pull out a new item from the Composition Data
* Page 1 Element, until all items have been pulled.
*
* @param elem Composition data page 1 Element
* @param item Model Item to fill.
*
* @return A pointer to @c item on success, or NULL if no more elements could
* be pulled.
*/
struct bt_mesh_comp_p1_model_item *bt_mesh_comp_p1_item_pull(
struct bt_mesh_comp_p1_elem *elem, struct bt_mesh_comp_p1_model_item *item);
/** @brief Pull Extended Model Item contained in Model Item
*
* Each call to this function will pull out a new element
* from the Extended Model Item, until all elements have been pulled.
*
* @param item Model Item to pull Extended Model Items from
* @param ext_item Extended Model Item to fill
*
* @return A pointer to @c ext_item on success, or NULL if item could not be pulled
*/
struct bt_mesh_comp_p1_ext_item *bt_mesh_comp_p1_pull_ext_item(
struct bt_mesh_comp_p1_model_item *item, struct bt_mesh_comp_p1_ext_item *ext_item);
/** Composition data page 2 record parsing structure. */
struct bt_mesh_comp_p2_record {
/** Mesh profile ID. */
uint16_t id;
/** Mesh Profile Version. */
struct {
/** Major version. */
uint8_t x;
/** Minor version. */
uint8_t y;
/** Z version. */
uint8_t z;
} version;
/** Element offset buffer. */
struct net_buf_simple *elem_buf;
/** Additional data buffer. */
struct net_buf_simple *data_buf;
};
/** @brief Pull a Composition Data Page 2 Record from a composition data page 2
* instance.
*
* Each call to this function will pull out a new element from the composition
* data page, until all elements have been pulled.
*
* @param buf Composition data page 2 buffer
* @param record Record to fill.
*
* @return A pointer to @c record on success, or NULL if no more elements could
* be pulled.
*/
struct bt_mesh_comp_p2_record *bt_mesh_comp_p2_record_pull(struct net_buf_simple *buf,
struct bt_mesh_comp_p2_record *record);
/** @brief Unpack a list of key index entries from a buffer.
*
* On success, @c dst_cnt is set to the amount of unpacked key index entries.
*
* @param buf Message buffer containing encoded AppKey or NetKey Indexes.
* @param dst_arr Destination array for the unpacked list.
* @param dst_cnt Size of the destination array.
*
* @return 0 on success.
* @return -EMSGSIZE if dst_arr size is to small to parse full message.
*/
int bt_mesh_key_idx_unpack_list(struct net_buf_simple *buf, uint16_t *dst_arr, size_t *dst_cnt);
/** @cond INTERNAL_HIDDEN */
extern const struct bt_mesh_model_op bt_mesh_cfg_cli_op[];
extern const struct bt_mesh_model_cb bt_mesh_cfg_cli_cb;
/** @endcond */
#ifdef __cplusplus
}
#endif
/**
* @}
*/
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_MESH_CFG_CLI_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/mesh/cfg_cli.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 18,021 |
```objective-c
/*
*
*/
#ifndef BT_MESH_OP_AGG_SRV_H__
#define BT_MESH_OP_AGG_SRV_H__
#include <zephyr/bluetooth/mesh.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup bt_mesh_op_agg_srv Opcodes Aggregator Server model
* @ingroup bt_mesh
* @{
*/
/**
*
* @brief Opcodes Aggretator Server model composition data entry.
*
* @note The Opcodes Aggregator Server handles aggregated messages
* and dispatches them to the respective models and their message
* handlers. Current implementation assumes that responses are sent
* from the same execution context as the received message and
* doesn't allow to send a postponed response, e.g. from workqueue.
*/
#define BT_MESH_MODEL_OP_AGG_SRV \
BT_MESH_MODEL_CB(BT_MESH_MODEL_ID_OP_AGG_SRV, _bt_mesh_op_agg_srv_op, \
NULL, NULL, &_bt_mesh_op_agg_srv_cb)
/** @cond INTERNAL_HIDDEN */
extern const struct bt_mesh_model_op _bt_mesh_op_agg_srv_op[];
extern const struct bt_mesh_model_cb _bt_mesh_op_agg_srv_cb;
/** @endcond */
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* BT_MESH_OP_AGG_SRV_H__ */
``` | /content/code_sandbox/include/zephyr/bluetooth/mesh/op_agg_srv.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 272 |
```objective-c
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_MESH_BLOB_IO_FLASH_H__
#define ZEPHYR_INCLUDE_BLUETOOTH_MESH_BLOB_IO_FLASH_H__
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup bt_mesh_blob_io_flash Bluetooth Mesh BLOB flash stream
* @ingroup bt_mesh
* @{
*/
/** BLOB flash stream. */
struct bt_mesh_blob_io_flash {
/** Flash area ID to write the BLOB to. */
uint8_t area_id;
/** Active stream mode. */
enum bt_mesh_blob_io_mode mode;
/** Offset into the flash area to place the BLOB at (in bytes). */
off_t offset;
/* Internal flash area pointer. */
const struct flash_area *area;
/* BLOB stream. */
struct bt_mesh_blob_io io;
};
/** @brief Initialize a flash stream.
*
* @param flash Flash stream.
* @param area_id Flash partition identifier. See @ref flash_area_open.
* @param offset Offset into the flash area, in bytes.
*
* @return 0 on success or (negative) error code otherwise.
*/
int bt_mesh_blob_io_flash_init(struct bt_mesh_blob_io_flash *flash,
uint8_t area_id, off_t offset);
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_MESH_BLOB_IO_FLASH_H__ */
``` | /content/code_sandbox/include/zephyr/bluetooth/mesh/blob_io_flash.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 304 |
```objective-c
/** @file
* @brief Advance Audio Distribution Profile - SBC Codec header.
*/
/*
*
*
* path_to_url
*
* Unless required by applicable law or agreed to in writing, software
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_A2DP_CODEC_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_A2DP_CODEC_H_
#ifdef __cplusplus
extern "C" {
#endif
/* Sampling Frequency */
#define A2DP_SBC_SAMP_FREQ_16000 BIT(7)
#define A2DP_SBC_SAMP_FREQ_32000 BIT(6)
#define A2DP_SBC_SAMP_FREQ_44100 BIT(5)
#define A2DP_SBC_SAMP_FREQ_48000 BIT(4)
/* Channel Mode */
#define A2DP_SBC_CH_MODE_MONO BIT(3)
#define A2DP_SBC_CH_MODE_DUAL BIT(2)
#define A2DP_SBC_CH_MODE_STREO BIT(1)
#define A2DP_SBC_CH_MODE_JOINT BIT(0)
/* Block Length */
#define A2DP_SBC_BLK_LEN_4 BIT(7)
#define A2DP_SBC_BLK_LEN_8 BIT(6)
#define A2DP_SBC_BLK_LEN_12 BIT(5)
#define A2DP_SBC_BLK_LEN_16 BIT(4)
/* Subbands */
#define A2DP_SBC_SUBBAND_4 BIT(3)
#define A2DP_SBC_SUBBAND_8 BIT(2)
/* Allocation Method */
#define A2DP_SBC_ALLOC_MTHD_SNR BIT(1)
#define A2DP_SBC_ALLOC_MTHD_LOUDNESS BIT(0)
#define BT_A2DP_SBC_SAMP_FREQ(cap) ((cap->config[0] >> 4) & 0x0f)
#define BT_A2DP_SBC_CHAN_MODE(cap) ((cap->config[0]) & 0x0f)
#define BT_A2DP_SBC_BLK_LEN(cap) ((cap->config[1] >> 4) & 0x0f)
#define BT_A2DP_SBC_SUB_BAND(cap) ((cap->config[1] >> 2) & 0x03)
#define BT_A2DP_SBC_ALLOC_MTHD(cap) ((cap->config[1]) & 0x03)
/** @brief SBC Codec */
struct bt_a2dp_codec_sbc_params {
/** First two octets of configuration */
uint8_t config[2];
/** Minimum Bitpool Value */
uint8_t min_bitpool;
/** Maximum Bitpool Value */
uint8_t max_bitpool;
} __packed;
/** If the F bit is set to 0, this field indicates the number of frames contained
* in this packet. If the F bit is set to 1, this field indicates the number
* of remaining fragments, including the current fragment.
* Therefore, the last counter value shall be one.
*/
#define BT_A2DP_SBC_MEDIA_HDR_NUM_FRAMES_GET(hdr) FIELD_GET(GENMASK(3, 0), (hdr))
/** Set to 1 for the last packet of a fragmented SBC frame, otherwise set to 0. */
#define BT_A2DP_SBC_MEDIA_HDR_L_GET(hdr) FIELD_GET(BIT(5), (hdr))
/** Set to 1 for the starting packet of a fragmented SBC frame, otherwise set to 0. */
#define BT_A2DP_SBC_MEDIA_HDR_S_GET(hdr) FIELD_GET(BIT(6), (hdr))
/** Set to 1 if the SBC frame is fragmented, otherwise set to 0. */
#define BT_A2DP_SBC_MEDIA_HDR_F_GET(hdr) FIELD_GET(BIT(7), (hdr))
/** If the F bit is set to 0, this field indicates the number of frames contained
* in this packet. If the F bit is set to 1, this field indicates the number
* of remaining fragments, including the current fragment.
* Therefore, the last counter value shall be one.
*/
#define BT_A2DP_SBC_MEDIA_HDR_NUM_FRAMES_SET(hdr, val)\
hdr = ((hdr) & ~GENMASK(3, 0)) | FIELD_PREP(GENMASK(3, 0), (val))
/** Set to 1 for the last packet of a fragmented SBC frame, otherwise set to 0. */
#define BT_A2DP_SBC_MEDIA_HDR_L_SET(hdr, val)\
hdr = ((hdr) & ~BIT(5)) | FIELD_PREP(BIT(5), (val))
/** Set to 1 for the starting packet of a fragmented SBC frame, otherwise set to 0. */
#define BT_A2DP_SBC_MEDIA_HDR_S_SET(hdr, val)\
hdr = ((hdr) & ~BIT(6)) | FIELD_PREP(BIT(6), (val))
/** Set to 1 if the SBC frame is fragmented, otherwise set to 0. */
#define BT_A2DP_SBC_MEDIA_HDR_F_SET(hdr, val)\
hdr = ((hdr) & ~BIT(7)) | FIELD_PREP(BIT(7), (val))
#define BT_A2DP_SBC_MEDIA_HDR_ENCODE(num_frames, l, s, f)\
FIELD_PREP(GENMASK(3, 0), num_frames) | FIELD_PREP(BIT(5), l) |\
FIELD_PREP(BIT(6), s) | FIELD_PREP(BIT(7), f)
/** @brief get channel num of a2dp sbc config.
*
* @param sbc_codec The a2dp sbc parameter.
*
* @return the channel num.
*/
uint8_t bt_a2dp_sbc_get_channel_num(struct bt_a2dp_codec_sbc_params *sbc_codec);
/** @brief get sample rate of a2dp sbc config.
*
* @param sbc_codec The a2dp sbc parameter.
*
* @return the sample rate.
*/
uint32_t bt_a2dp_sbc_get_sampling_frequency(struct bt_a2dp_codec_sbc_params *sbc_codec);
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_A2DP_CODEC_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/classic/a2dp_codec_sbc.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 1,332 |
```objective-c
/** @file
* @brief Handsfree Profile handling.
*/
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_HFP_HF_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_HFP_HF_H_
/**
* @brief Hands Free Profile (HFP)
* @defgroup bt_hfp Hands Free Profile (HFP)
* @ingroup bluetooth
* @{
*/
#include <zephyr/bluetooth/bluetooth.h>
#ifdef __cplusplus
extern "C" {
#endif
/* AT Commands */
enum bt_hfp_hf_at_cmd {
BT_HFP_HF_ATA,
BT_HFP_HF_AT_CHUP,
};
/*
* Command complete types for the application
*/
#define HFP_HF_CMD_OK 0
#define HFP_HF_CMD_ERROR 1
#define HFP_HF_CMD_CME_ERROR 2
#define HFP_HF_CMD_UNKNOWN_ERROR 4
/** @brief HFP HF Command completion field */
struct bt_hfp_hf_cmd_complete {
/* Command complete status */
uint8_t type;
/* CME error number to be added */
uint8_t cme;
};
/** @brief HFP profile application callback */
struct bt_hfp_hf_cb {
/** HF connected callback to application
*
* If this callback is provided it will be called whenever the
* connection completes.
*
* @param conn Connection object.
*/
void (*connected)(struct bt_conn *conn);
/** HF disconnected callback to application
*
* If this callback is provided it will be called whenever the
* connection gets disconnected, including when a connection gets
* rejected or cancelled or any error in SLC establishment.
*
* @param conn Connection object.
*/
void (*disconnected)(struct bt_conn *conn);
/** HF SCO/eSCO connected Callback
*
* If this callback is provided it will be called whenever the
* SCO/eSCO connection completes.
*
* @param conn Connection object.
* @param sco_conn SCO/eSCO Connection object.
*/
void (*sco_connected)(struct bt_conn *conn, struct bt_conn *sco_conn);
/** HF SCO/eSCO disconnected Callback
*
* If this callback is provided it will be called whenever the
* SCO/eSCO connection gets disconnected.
*
* @param conn Connection object.
* @param reason BT_HCI_ERR_* reason for the disconnection.
*/
void (*sco_disconnected)(struct bt_conn *sco_conn, uint8_t reason);
/** HF indicator Callback
*
* This callback provides service indicator value to the application
*
* @param conn Connection object.
* @param value service indicator value received from the AG.
*/
void (*service)(struct bt_conn *conn, uint32_t value);
/** HF indicator Callback
*
* This callback provides call indicator value to the application
*
* @param conn Connection object.
* @param value call indicator value received from the AG.
*/
void (*call)(struct bt_conn *conn, uint32_t value);
/** HF indicator Callback
*
* This callback provides call setup indicator value to the application
*
* @param conn Connection object.
* @param value call setup indicator value received from the AG.
*/
void (*call_setup)(struct bt_conn *conn, uint32_t value);
/** HF indicator Callback
*
* This callback provides call held indicator value to the application
*
* @param conn Connection object.
* @param value call held indicator value received from the AG.
*/
void (*call_held)(struct bt_conn *conn, uint32_t value);
/** HF indicator Callback
*
* This callback provides signal indicator value to the application
*
* @param conn Connection object.
* @param value signal indicator value received from the AG.
*/
void (*signal)(struct bt_conn *conn, uint32_t value);
/** HF indicator Callback
*
* This callback provides roaming indicator value to the application
*
* @param conn Connection object.
* @param value roaming indicator value received from the AG.
*/
void (*roam)(struct bt_conn *conn, uint32_t value);
/** HF indicator Callback
*
* This callback battery service indicator value to the application
*
* @param conn Connection object.
* @param value battery indicator value received from the AG.
*/
void (*battery)(struct bt_conn *conn, uint32_t value);
/** HF incoming call Ring indication callback to application
*
* If this callback is provided it will be called whenever there
* is an incoming call.
*
* @param conn Connection object.
*/
void (*ring_indication)(struct bt_conn *conn);
/** HF notify command completed callback to application
*
* The command sent from the application is notified about its status
*
* @param conn Connection object.
* @param cmd structure contains status of the command including cme.
*/
void (*cmd_complete_cb)(struct bt_conn *conn,
struct bt_hfp_hf_cmd_complete *cmd);
};
/** @brief Register HFP HF profile
*
* Register Handsfree profile callbacks to monitor the state and get the
* required HFP details to display.
*
* @param cb callback structure.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_hfp_hf_register(struct bt_hfp_hf_cb *cb);
/** @brief Handsfree client Send AT
*
* Send specific AT commands to handsfree client profile.
*
* @param conn Connection object.
* @param cmd AT command to be sent.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_hfp_hf_send_cmd(struct bt_conn *conn, enum bt_hfp_hf_at_cmd cmd);
#ifdef __cplusplus
}
#endif
/**
* @}
*/
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_HFP_HF_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/classic/hfp_hf.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 1,342 |
```objective-c
/** @file
* @brief Runtime configuration APIs.
*/
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_MESH_CFG_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_MESH_CFG_H_
#include <stdbool.h>
#include <stddef.h>
#include <sys/types.h>
/**
* @brief Runtime Configuration
* @defgroup bt_mesh_cfg Runtime Configuration
* @ingroup bt_mesh
* @{
*/
#ifdef __cplusplus
extern "C" {
#endif
/** Bluetooth Mesh feature states */
enum bt_mesh_feat_state {
/** Feature is supported, but disabled. */
BT_MESH_FEATURE_DISABLED,
/** Feature is supported and enabled. */
BT_MESH_FEATURE_ENABLED,
/** Feature is not supported, and cannot be enabled. */
BT_MESH_FEATURE_NOT_SUPPORTED,
};
/* Key Refresh Phase */
#define BT_MESH_KR_NORMAL 0x00
#define BT_MESH_KR_PHASE_1 0x01
#define BT_MESH_KR_PHASE_2 0x02
#define BT_MESH_KR_PHASE_3 0x03
/* Legacy feature defines */
#define BT_MESH_RELAY_DISABLED BT_MESH_FEATURE_DISABLED
#define BT_MESH_RELAY_ENABLED BT_MESH_FEATURE_ENABLED
#define BT_MESH_RELAY_NOT_SUPPORTED BT_MESH_FEATURE_NOT_SUPPORTED
#define BT_MESH_BEACON_DISABLED BT_MESH_FEATURE_DISABLED
#define BT_MESH_BEACON_ENABLED BT_MESH_FEATURE_ENABLED
#define BT_MESH_PRIV_BEACON_DISABLED BT_MESH_FEATURE_DISABLED
#define BT_MESH_PRIV_BEACON_ENABLED BT_MESH_FEATURE_ENABLED
#define BT_MESH_GATT_PROXY_DISABLED BT_MESH_FEATURE_DISABLED
#define BT_MESH_GATT_PROXY_ENABLED BT_MESH_FEATURE_ENABLED
#define BT_MESH_GATT_PROXY_NOT_SUPPORTED BT_MESH_FEATURE_NOT_SUPPORTED
#define BT_MESH_PRIV_GATT_PROXY_DISABLED BT_MESH_FEATURE_DISABLED
#define BT_MESH_PRIV_GATT_PROXY_ENABLED BT_MESH_FEATURE_ENABLED
#define BT_MESH_PRIV_GATT_PROXY_NOT_SUPPORTED BT_MESH_FEATURE_NOT_SUPPORTED
#define BT_MESH_FRIEND_DISABLED BT_MESH_FEATURE_DISABLED
#define BT_MESH_FRIEND_ENABLED BT_MESH_FEATURE_ENABLED
#define BT_MESH_FRIEND_NOT_SUPPORTED BT_MESH_FEATURE_NOT_SUPPORTED
#define BT_MESH_NODE_IDENTITY_STOPPED BT_MESH_FEATURE_DISABLED
#define BT_MESH_NODE_IDENTITY_RUNNING BT_MESH_FEATURE_ENABLED
#define BT_MESH_NODE_IDENTITY_NOT_SUPPORTED BT_MESH_FEATURE_NOT_SUPPORTED
/** @brief Enable or disable sending of the Secure Network Beacon.
*
* @param beacon New Secure Network Beacon state.
*/
void bt_mesh_beacon_set(bool beacon);
/** @brief Get the current Secure Network Beacon state.
*
* @returns Whether the Secure Network Beacon feature is enabled.
*/
bool bt_mesh_beacon_enabled(void);
/** @brief Enable or disable sending of the Mesh Private beacon.
*
* Support for the Private beacon state must be enabled with @c
* CONFIG_BT_MESH_PRIV_BEACONS.
*
* @param priv_beacon New Mesh Private beacon state. Must be one of
* @ref BT_MESH_FEATURE_ENABLED and
* @ref BT_MESH_FEATURE_DISABLED.
*
* @retval 0 Successfully changed the Mesh Private beacon feature state.
* @retval -ENOTSUP The Mesh Private beacon feature is not supported.
* @retval -EINVAL Invalid parameter.
* @retval -EALREADY Already in the given state.
*/
int bt_mesh_priv_beacon_set(enum bt_mesh_feat_state priv_beacon);
/** @brief Get the current Mesh Private beacon state.
*
* @returns The Mesh Private beacon feature state.
*/
enum bt_mesh_feat_state bt_mesh_priv_beacon_get(void);
/** @brief Set the current Mesh Private beacon update interval.
*
* The Mesh Private beacon's randomization value is updated regularly to
* maintain the node's privacy. The update interval controls how often
* the beacon is updated, in 10 second increments.
*
* @param interval Private beacon update interval in 10 second steps, or 0 to
* update on every beacon transmission.
*/
void bt_mesh_priv_beacon_update_interval_set(uint8_t interval);
/** @brief Get the current Mesh Private beacon update interval.
*
* The Mesh Private beacon's randomization value is updated regularly to
* maintain the node's privacy. The update interval controls how often
* the beacon is updated, in 10 second increments.
*
* @returns The Private beacon update interval in 10 second steps, or 0 if
* the beacon is updated every time it's transmitted.
*/
uint8_t bt_mesh_priv_beacon_update_interval_get(void);
/** @brief Set the default TTL value.
*
* The default TTL value is used when no explicit TTL value is set. Models will
* use the default TTL value when @ref bt_mesh_msg_ctx::send_ttl is
* @ref BT_MESH_TTL_DEFAULT.
*
* @param default_ttl The new default TTL value. Valid values are 0x00 and 0x02
* to @ref BT_MESH_TTL_MAX.
*
* @retval 0 Successfully set the default TTL value.
* @retval -EINVAL Invalid TTL value.
*/
int bt_mesh_default_ttl_set(uint8_t default_ttl);
/** @brief Get the current default TTL value.
*
* @return The current default TTL value.
*/
uint8_t bt_mesh_default_ttl_get(void);
/** @brief Get the current Mesh On-Demand Private Proxy state.
*
* @retval 0 or positive value represents On-Demand Private Proxy feature state
* @retval -ENOTSUP The On-Demand Private Proxy feature is not supported.
*/
int bt_mesh_od_priv_proxy_get(void);
/** @brief Set state of Mesh On-Demand Private Proxy.
*
* Support for the On-Demand Private Proxy state must be enabled with @c
* BT_MESH_OD_PRIV_PROXY_SRV.
*
* @param on_demand_proxy New Mesh On-Demand Private Proxy state. Value of 0x00 means that
* advertising with Private Network Identity cannot be enabled on demand.
* Values in range 0x01 - 0xFF set interval of this advertising after
* valid Solicitation PDU is received or client disconnects.
*
* @retval 0 Successfully changed the Mesh On-Demand Private Proxy feature state.
* @retval -ENOTSUP The On-Demand Private Proxy feature is not supported.
* @retval -EINVAL Invalid parameter.
* @retval -EALREADY Already in the given state.
*/
int bt_mesh_od_priv_proxy_set(uint8_t on_demand_proxy);
/** @brief Set the Network Transmit parameters.
*
* The Network Transmit parameters determine the parameters local messages are
* transmitted with.
*
* @see BT_MESH_TRANSMIT
*
* @param xmit New Network Transmit parameters. Use @ref BT_MESH_TRANSMIT for
* encoding.
*/
void bt_mesh_net_transmit_set(uint8_t xmit);
/** @brief Get the current Network Transmit parameters.
*
* The @ref BT_MESH_TRANSMIT_COUNT and @ref BT_MESH_TRANSMIT_INT macros can be
* used to decode the Network Transmit parameters.
*
* @return The current Network Transmit parameters.
*/
uint8_t bt_mesh_net_transmit_get(void);
/** @brief Configure the Relay feature.
*
* Enable or disable the Relay feature, and configure the parameters to
* transmit relayed messages with.
*
* Support for the Relay feature must be enabled through the
* @c CONFIG_BT_MESH_RELAY configuration option.
*
* @see BT_MESH_TRANSMIT
*
* @param relay New Relay feature state. Must be one of
* @ref BT_MESH_FEATURE_ENABLED and
* @ref BT_MESH_FEATURE_DISABLED.
* @param xmit New Relay retransmit parameters. Use @ref BT_MESH_TRANSMIT for
* encoding.
*
* @retval 0 Successfully changed the Relay configuration.
* @retval -ENOTSUP The Relay feature is not supported.
* @retval -EINVAL Invalid parameter.
* @retval -EALREADY Already using the given parameters.
*/
int bt_mesh_relay_set(enum bt_mesh_feat_state relay, uint8_t xmit);
/** @brief Get the current Relay feature state.
*
* @returns The Relay feature state.
*/
enum bt_mesh_feat_state bt_mesh_relay_get(void);
/** @brief Get the current Relay Retransmit parameters.
*
* The @ref BT_MESH_TRANSMIT_COUNT and @ref BT_MESH_TRANSMIT_INT macros can be
* used to decode the Relay Retransmit parameters.
*
* @return The current Relay Retransmit parameters, or 0 if relay is not
* supported.
*/
uint8_t bt_mesh_relay_retransmit_get(void);
/** @brief Enable or disable the GATT Proxy feature.
*
* Support for the GATT Proxy feature must be enabled through the
* @c CONFIG_BT_MESH_GATT_PROXY configuration option.
*
* @note The GATT Proxy feature only controls a Proxy node's ability to relay
* messages to the mesh network. A node that supports GATT Proxy will
* still advertise Connectable Proxy beacons, even if the feature is
* disabled. The Proxy feature can only be fully disabled through compile
* time configuration.
*
* @param gatt_proxy New GATT Proxy state. Must be one of
* @ref BT_MESH_FEATURE_ENABLED and
* @ref BT_MESH_FEATURE_DISABLED.
*
* @retval 0 Successfully changed the GATT Proxy feature state.
* @retval -ENOTSUP The GATT Proxy feature is not supported.
* @retval -EINVAL Invalid parameter.
* @retval -EALREADY Already in the given state.
*/
int bt_mesh_gatt_proxy_set(enum bt_mesh_feat_state gatt_proxy);
/** @brief Get the current GATT Proxy state.
*
* @returns The GATT Proxy feature state.
*/
enum bt_mesh_feat_state bt_mesh_gatt_proxy_get(void);
/** @brief Enable or disable the Private GATT Proxy feature.
*
* Support for the Private GATT Proxy feature must be enabled through the
* @kconfig{CONFIG_BT_MESH_PRIV_BEACONS} and @kconfig{CONFIG_BT_MESH_GATT_PROXY}
* configuration options.
*
* @param priv_gatt_proxy New Private GATT Proxy state. Must be one of
* @ref BT_MESH_FEATURE_ENABLED and
* @ref BT_MESH_FEATURE_DISABLED.
*
* @retval 0 Successfully changed the Private GATT Proxy feature state.
* @retval -ENOTSUP The Private GATT Proxy feature is not supported.
* @retval -EINVAL Invalid parameter.
* @retval -EALREADY Already in the given state.
*/
int bt_mesh_priv_gatt_proxy_set(enum bt_mesh_feat_state priv_gatt_proxy);
/** @brief Get the current Private GATT Proxy state.
*
* @returns The Private GATT Proxy feature state.
*/
enum bt_mesh_feat_state bt_mesh_priv_gatt_proxy_get(void);
/** @brief Enable or disable the Friend feature.
*
* Any active friendships will be terminated immediately if the Friend feature
* is disabled.
*
* Support for the Friend feature must be enabled through the
* @c CONFIG_BT_MESH_FRIEND configuration option.
*
* @param friendship New Friend feature state. Must be one of
* @ref BT_MESH_FEATURE_ENABLED and
* @ref BT_MESH_FEATURE_DISABLED.
*
* @retval 0 Successfully changed the Friend feature state.
* @retval -ENOTSUP The Friend feature is not supported.
* @retval -EINVAL Invalid parameter.
* @retval -EALREADY Already in the given state.
*/
int bt_mesh_friend_set(enum bt_mesh_feat_state friendship);
/** @brief Get the current Friend state.
*
* @returns The Friend feature state.
*/
enum bt_mesh_feat_state bt_mesh_friend_get(void);
/**
* @brief Subnet Configuration
* @defgroup bt_mesh_cfg_subnet Subnet Configuration
* @{
*/
/** @brief Add a Subnet.
*
* Adds a subnet with the given network index and network key to the list of
* known Subnets. All messages sent on the given Subnet will be processed by
* this node, and the node may send and receive Network Beacons on the given
* Subnet.
*
* @param net_idx Network index.
* @param key Root network key of the Subnet. All other keys are derived
* from this.
*
* @retval STATUS_SUCCESS The Subnet was successfully added.
* @retval STATUS_INSUFF_RESOURCES No room for this Subnet.
* @retval STATUS_UNSPECIFIED The Subnet couldn't be created for some reason.
*/
uint8_t bt_mesh_subnet_add(uint16_t net_idx, const uint8_t key[16]);
/** @brief Update the given Subnet.
*
* Starts the Key Refresh procedure for this Subnet by adding a second set of
* encryption keys. The Subnet will continue sending with the old key (but
* receiving messages using both) until the Subnet enters Key Refresh phase 2.
*
* This allows a network configurator to replace old network and application
* keys for the entire network, effectively removing access for all nodes that
* aren't given the new keys.
*
* @param net_idx Network index.
* @param key New root network key of the Subnet.
*
* @retval STATUS_SUCCESS The Subnet was updated with a second key.
* @retval STATUS_INVALID_NETKEY The NetIdx is unknown.
* @retval STATUS_IDX_ALREADY_STORED The @c key value is the same as the
* current key.
* @retval STATUS_CANNOT_UPDATE The Subnet cannot be updated for some reason.
*/
uint8_t bt_mesh_subnet_update(uint16_t net_idx, const uint8_t key[16]);
/** @brief Delete a Subnet.
*
* Removes the Subnet with the given network index from the node. The node will
* stop sending Network Beacons with the given Subnet, and can no longer
* process messages on this Subnet.
*
* All Applications bound to this Subnet are also deleted.
*
* @param net_idx Network index.
*
* @retval STATUS_SUCCESS The Subnet was deleted.
* @retval STATUS_INVALID_NETKEY The NetIdx is unknown.
*/
uint8_t bt_mesh_subnet_del(uint16_t net_idx);
/** @brief Check whether a Subnet is known.
*
* @param net_idx Network index
*
* @return true if a Subnet with the given index exists, false otherwise.
*/
bool bt_mesh_subnet_exists(uint16_t net_idx);
/** @brief Set the Subnet's Key Refresh phase.
*
* The Key Refresh procedure is started by updating the Subnet keys through
* @ref bt_mesh_subnet_update. This puts the Subnet in Key Refresh Phase 1.
* Once all nodes have received the new Subnet key, Key Refresh Phase 2 can be
* activated through this function to start transmitting with the new network
* key. Finally, to revoke the old key, set the Key Refresh Phase to 3. This
* removes the old keys from the node, and returns the Subnet back to normal
* single-key operation with the new key set.
*
* @param net_idx Network index.
* @param phase Pointer to the new Key Refresh phase. Will return the actual
* Key Refresh phase after updating.
*
* @retval STATUS_SUCCESS The Key Refresh phase of the Subnet was successfully
* changed.
* @retval STATUS_INVALID_NETKEY The NetIdx is unknown.
* @retval STATUS_CANNOT_UPDATE The given phase change is invalid.
*/
uint8_t bt_mesh_subnet_kr_phase_set(uint16_t net_idx, uint8_t *phase);
/** @brief Get the Subnet's Key Refresh phase.
*
* @param net_idx Network index.
* @param phase Pointer to the Key Refresh variable to fill.
*
* @retval STATUS_SUCCESS Successfully populated the @c phase variable.
* @retval STATUS_INVALID_NETKEY The NetIdx is unknown.
*/
uint8_t bt_mesh_subnet_kr_phase_get(uint16_t net_idx, uint8_t *phase);
/** @brief Set the Node Identity state of the Subnet.
*
* The Node Identity state of a Subnet determines whether the Subnet advertises
* connectable Node Identity beacons for Proxy Clients to connect to.
* Once started, the Node Identity beacon runs for 60 seconds, or until it is
* stopped.
*
* This function serves the same purpose as @ref bt_mesh_proxy_identity_enable,
* but only acts on a single Subnet.
*
* GATT Proxy support must be enabled through
* @kconfig{CONFIG_BT_MESH_GATT_PROXY}.
*
* @param net_idx Network index.
* @param node_id New Node Identity state, must be either @ref
* BT_MESH_FEATURE_ENABLED or @ref BT_MESH_FEATURE_DISABLED.
*
* @retval STATUS_SUCCESS Successfully set the Node Identity state of the
* Subnet.
* @retval STATUS_INVALID_NETKEY The NetIdx is unknown.
* @retval STATUS_FEAT_NOT_SUPP The Node Identity feature is not supported.
* @retval STATUS_CANNOT_SET Couldn't set the Node Identity state.
*/
uint8_t bt_mesh_subnet_node_id_set(uint16_t net_idx,
enum bt_mesh_feat_state node_id);
/** @brief Get the Node Identity state of the Subnet.
*
* @param net_idx Network index.
* @param node_id Node Identity variable to fill.
*
* @retval STATUS_SUCCESS Successfully populated the @c node_id variable.
* @retval STATUS_INVALID_NETKEY The NetIdx is unknown.
*/
uint8_t bt_mesh_subnet_node_id_get(uint16_t net_idx,
enum bt_mesh_feat_state *node_id);
/** @brief Set the Private Node Identity state of the Subnet.
*
* The Private Node Identity state of a Subnet determines whether the Subnet
* advertises connectable Private Node Identity beacons for Proxy Clients to
* connect to. Once started, the Node Identity beacon runs for 60 seconds,
* or until it is stopped.
*
* Private Node Identity can only be enabled if regular Node Identity is not
* enabled for any subnet.
*
* GATT Proxy and Private Beacon support must be enabled through
* @kconfig{CONFIG_BT_MESH_GATT_PROXY} and
* @kconfig{CONFIG_BT_MESH_PRIV_BEACONS}.
*
* @param net_idx Network index.
* @param priv_node_id New Private Node Identity state, must be either @ref
* BT_MESH_FEATURE_ENABLED or @ref BT_MESH_FEATURE_DISABLED.
*
* @retval STATUS_SUCCESS Successfully set the Private Node Identity state of the Subnet.
* @retval STATUS_INVALID_NETKEY The NetIdx is unknown.
* @retval STATUS_FEAT_NOT_SUPP The Private Node Identity feature is not supported.
* @retval STATUS_TEMP_STATE_CHG_FAIL The Private Node Identity state cannot be enabled, because
* Node Identity state is already enabled.
* @retval STATUS_CANNOT_SET Couldn't set the Private Node Identity state.
*/
uint8_t bt_mesh_subnet_priv_node_id_set(uint16_t net_idx,
enum bt_mesh_feat_state priv_node_id);
/** @brief Get the Private Node Identity state of the Subnet.
*
* @param net_idx Network index.
* @param priv_node_id Private Node Identity variable to fill.
*
* @retval STATUS_SUCCESS Successfully populated the @c priv_node_id variable.
* @retval STATUS_INVALID_NETKEY The NetIdx is unknown.
*/
uint8_t bt_mesh_subnet_priv_node_id_get(uint16_t net_idx,
enum bt_mesh_feat_state *priv_node_id);
/** @brief Get a list of all known Subnet indexes.
*
* Builds a list of all known Subnet indexes in the @c net_idxs array.
* If the @c net_idxs array is smaller than the list of known Subnets, this
* function fills all available entries and returns @c -ENOMEM. In this
* case, the next @c max entries of the list can be read out by calling
* @code
* bt_mesh_subnets_get(list, max, max);
* @endcode
*
* Note that any changes to the Subnet list between calls to this function
* could change the order and number of entries in the list.
*
* @param net_idxs Array to fill.
* @param max Max number of indexes to return.
* @param skip Number of indexes to skip. Enables batched processing of the
* list.
*
* @return The number of indexes added to the @c net_idxs array, or @c -ENOMEM
* if the number of known Subnets exceeds the @c max parameter.
*/
ssize_t bt_mesh_subnets_get(uint16_t net_idxs[], size_t max, off_t skip);
/**
* @}
*/
/**
* @brief Application Configuration
* @defgroup bt_mesh_cfg_app Application Configuration
* @{
*/
/** @brief Add an Application key.
*
* Adds the Application with the given index to the list of known applications.
* Allows the node to send and receive model messages encrypted with this
* Application key.
*
* Every Application is bound to a specific Subnet. The node must know the
* Subnet the Application is bound to before it can add the Application.
*
* @param app_idx Application index.
* @param net_idx Network index the Application is bound to.
* @param key Application key value.
*
* @retval STATUS_SUCCESS The Application was successfully added.
* @retval STATUS_INVALID_NETKEY The NetIdx is unknown.
* @retval STATUS_INSUFF_RESOURCES There's no room for storing this
* Application.
* @retval STATUS_INVALID_BINDING This AppIdx is already bound to another
* Subnet.
* @retval STATUS_IDX_ALREADY_STORED This AppIdx is already stored with a
* different key value.
* @retval STATUS_CANNOT_SET Cannot set the Application key for some reason.
*/
uint8_t bt_mesh_app_key_add(uint16_t app_idx, uint16_t net_idx,
const uint8_t key[16]);
/** @brief Update an Application key.
*
* Update an Application with a second Application key, as part of the
* Key Refresh procedure of the bound Subnet. The node will continue
* transmitting with the old application key (but receiving on both) until the
* Subnet enters Key Refresh phase 2. Once the Subnet enters Key Refresh phase
* 3, the old application key will be deleted.
*
* @note The Application key can only be updated if the bound Subnet is in Key
* Refresh phase 1.
*
* @param app_idx Application index.
* @param net_idx Network index the Application is bound to, or
* @ref BT_MESH_KEY_ANY to skip the binding check.
* @param key New key value.
*
* @retval STATUS_SUCCESS The Application key was successfully updated.
* @retval STATUS_INVALID_NETKEY The NetIdx is unknown.
* @retval STATUS_INVALID_BINDING This AppIdx is not bound to the given NetIdx.
* @retval STATUS_CANNOT_UPDATE The Application key cannot be updated for some
* reason.
* @retval STATUS_IDX_ALREADY_STORED This AppIdx is already updated with a
* different key value.
*/
uint8_t bt_mesh_app_key_update(uint16_t app_idx, uint16_t net_idx,
const uint8_t key[16]);
/** @brief Delete an Application key.
*
* All models bound to this application will remove this binding.
* All models publishing with this application will stop publishing.
*
* @param app_idx Application index.
* @param net_idx Network index.
*
* @retval STATUS_SUCCESS The Application key was successfully deleted.
* @retval STATUS_INVALID_NETKEY The NetIdx is unknown.
* @retval STATUS_INVALID_BINDING This AppIdx is not bound to the given NetIdx.
*/
uint8_t bt_mesh_app_key_del(uint16_t app_idx, uint16_t net_idx);
/** @brief Check if an Application key is known.
*
* @param app_idx Application index.
*
* @return true if the Application is known, false otherwise.
*/
bool bt_mesh_app_key_exists(uint16_t app_idx);
/** @brief Get a list of all known Application key indexes.
*
* Builds a list of all Application indexes for the given network index in the
* @c app_idxs array. If the @c app_idxs array cannot fit all bound
* Applications, this function fills all available entries and returns @c
* -ENOMEM. In this case, the next @c max entries of the list can be read out
* by calling
* @code
* bt_mesh_app_keys_get(net_idx, list, max, max);
* @endcode
*
* Note that any changes to the Application key list between calls to this
* function could change the order and number of entries in the list.
*
* @param net_idx Network Index to get the Applications of, or @ref
* BT_MESH_KEY_ANY to get all Applications.
* @param app_idxs Array to fill.
* @param max Max number of indexes to return.
* @param skip Number of indexes to skip. Enables batched processing of the
* list.
*
* @return The number of indexes added to the @c app_idxs array, or @c -ENOMEM
* if the number of known Applications exceeds the @c max parameter.
*/
ssize_t bt_mesh_app_keys_get(uint16_t net_idx, uint16_t app_idxs[], size_t max,
off_t skip);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
/**
* @}
*/
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_MESH_CFG_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/mesh/cfg.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 5,527 |
```objective-c
/** @file
* @brief Advanced Audio Distribution Profile header.
*/
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_A2DP_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_A2DP_H_
#include <stdint.h>
#include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/l2cap.h>
#include <zephyr/bluetooth/classic/avdtp.h>
#ifdef __cplusplus
extern "C" {
#endif
#define BT_A2DP_STREAM_BUF_RESERVE (12u + BT_L2CAP_BUF_SIZE(0))
/** SBC IE length */
#define BT_A2DP_SBC_IE_LENGTH (4u)
/** MPEG1,2 IE length */
#define BT_A2DP_MPEG_1_2_IE_LENGTH (4u)
/** MPEG2,4 IE length */
#define BT_A2DP_MPEG_2_4_IE_LENGTH (6u)
/** The max IE (Codec Info Element) length */
#define A2DP_MAX_IE_LENGTH (8U)
/** @brief define the audio endpoint
* @param _role BT_AVDTP_SOURCE or BT_AVDTP_SINK.
* @param _codec value of enum bt_a2dp_codec_id.
* @param _capability the codec capability.
*/
#define BT_A2DP_EP_INIT(_role, _codec, _capability)\
{\
.codec_type = _codec,\
.sep = {.sep_info = {.media_type = BT_AVDTP_AUDIO, .tsep = _role}},\
.codec_cap = _capability,\
.stream = NULL,\
}
/** @brief define the audio sink endpoint
* @param _codec value of enum bt_a2dp_codec_id.
* @param _capability the codec capability.
*/
#define BT_A2DP_SINK_EP_INIT(_codec, _capability)\
BT_A2DP_EP_INIT(BT_AVDTP_SINK, _codec, _capability)
/** @brief define the audio source endpoint
* @param _codec value of enum bt_a2dp_codec_id.
* @param _capability the codec capability.
*/
#define BT_A2DP_SOURCE_EP_INIT(_codec, _capability)\
BT_A2DP_EP_INIT(BT_AVDTP_SOURCE, _codec, _capability)
/** @brief define the SBC sink endpoint that can be used as
* bt_a2dp_register_endpoint's parameter.
*
* SBC is mandatory as a2dp specification, BT_A2DP_SBC_SINK_EP_DEFAULT
* is more convenient for user to register SBC endpoint.
*
* @param _name unique structure name postfix.
* @param _freq sbc codec frequency.
* for example: A2DP_SBC_SAMP_FREQ_44100 | A2DP_SBC_SAMP_FREQ_48000
* @param _ch_mode sbc codec channel mode.
* for example: A2DP_SBC_CH_MODE_MONO | A2DP_SBC_CH_MODE_STREO
* @param _blk_len sbc codec block length.
* for example: A2DP_SBC_BLK_LEN_16
* @param _subband sbc codec subband.
* for example: A2DP_SBC_SUBBAND_8
* @param _alloc_mthd sbc codec allocate method.
* for example: A2DP_SBC_ALLOC_MTHD_LOUDNESS
* @param _min_bitpool sbc codec min bit pool. for example: 18
* @param _max_bitpool sbc codec max bit pool. for example: 35
* @
*/
#define BT_A2DP_SBC_SINK_EP(_name, _freq, _ch_mode, _blk_len, _subband,\
_alloc_mthd, _min_bitpool, _max_bitpool)\
static struct bt_a2dp_codec_ie bt_a2dp_ep_cap_ie##_name =\
{.len = BT_A2DP_SBC_IE_LENGTH, .codec_ie = {_freq | _ch_mode,\
_blk_len | _subband | _alloc_mthd, _min_bitpool, _max_bitpool}};\
static struct bt_a2dp_ep _name = BT_A2DP_SINK_EP_INIT(BT_A2DP_SBC,\
(&bt_a2dp_ep_cap_ie##_name))
/** @brief define the SBC source endpoint that can be used as bt_a2dp_register_endpoint's
* parameter.
*
* SBC is mandatory as a2dp specification, BT_A2DP_SBC_SOURCE_EP_DEFAULT
* is more convenient for user to register SBC endpoint.
*
* @param _name the endpoint variable name.
* @param _freq sbc codec frequency.
* for example: A2DP_SBC_SAMP_FREQ_44100 | A2DP_SBC_SAMP_FREQ_48000
* @param _ch_mode sbc codec channel mode.
* for example: A2DP_SBC_CH_MODE_MONO | A2DP_SBC_CH_MODE_STREO
* @param _blk_len sbc codec block length.
* for example: A2DP_SBC_BLK_LEN_16
* @param _subband sbc codec subband.
* for example: A2DP_SBC_SUBBAND_8
* @param _alloc_mthd sbc codec allocate method.
* for example: A2DP_SBC_ALLOC_MTHD_LOUDNESS
* @param _min_bitpool sbc codec min bit pool. for example: 18
* @param _max_bitpool sbc codec max bit pool. for example: 35
*/
#define BT_A2DP_SBC_SOURCE_EP(_name, _freq, _ch_mode, _blk_len, _subband,\
_alloc_mthd, _min_bitpool, _max_bitpool)\
static struct bt_a2dp_codec_ie bt_a2dp_ep_cap_ie##_name =\
{.len = BT_A2DP_SBC_IE_LENGTH, .codec_ie = {_freq | _ch_mode,\
_blk_len | _subband | _alloc_mthd, _min_bitpool, _max_bitpool}};\
static struct bt_a2dp_ep _name = BT_A2DP_SOURCE_EP_INIT(BT_A2DP_SBC,\
&bt_a2dp_ep_cap_ie##_name)
/** @brief define the default SBC sink endpoint that can be used as
* bt_a2dp_register_endpoint's parameter.
*
* SBC is mandatory as a2dp specification, BT_A2DP_SBC_SINK_EP_DEFAULT
* is more convenient for user to register SBC endpoint.
*
* @param _name the endpoint variable name.
*/
#define BT_A2DP_SBC_SINK_EP_DEFAULT(_name)\
static struct bt_a2dp_codec_ie bt_a2dp_ep_cap_ie##_name =\
{.len = BT_A2DP_SBC_IE_LENGTH, .codec_ie = {A2DP_SBC_SAMP_FREQ_44100 |\
A2DP_SBC_SAMP_FREQ_48000 | A2DP_SBC_CH_MODE_MONO | A2DP_SBC_CH_MODE_STREO |\
A2DP_SBC_CH_MODE_JOINT, A2DP_SBC_BLK_LEN_16 |\
A2DP_SBC_SUBBAND_8 | A2DP_SBC_ALLOC_MTHD_LOUDNESS, 18U, 35U}};\
static struct bt_a2dp_ep _name = BT_A2DP_SINK_EP_INIT(BT_A2DP_SBC,\
&bt_a2dp_ep_cap_ie##_name)
/** @brief define the default SBC source endpoint that can be used as bt_a2dp_register_endpoint's
* parameter.
*
* SBC is mandatory as a2dp specification, BT_A2DP_SBC_SOURCE_EP_DEFAULT
* is more convenient for user to register SBC endpoint.
*
* @param _name the endpoint variable name.
*/
#define BT_A2DP_SBC_SOURCE_EP_DEFAULT(_name)\
static struct bt_a2dp_codec_ie bt_a2dp_ep_cap_ie##_name =\
{.len = BT_A2DP_SBC_IE_LENGTH, .codec_ie = {A2DP_SBC_SAMP_FREQ_44100 | \
A2DP_SBC_SAMP_FREQ_48000 | A2DP_SBC_CH_MODE_MONO | A2DP_SBC_CH_MODE_STREO | \
A2DP_SBC_CH_MODE_JOINT, A2DP_SBC_BLK_LEN_16 | A2DP_SBC_SUBBAND_8 | A2DP_SBC_ALLOC_MTHD_LOUDNESS,\
18U, 35U},};\
static struct bt_a2dp_ep _name = BT_A2DP_SOURCE_EP_INIT(BT_A2DP_SBC,\
&bt_a2dp_ep_cap_ie##_name)
/** @brief define the SBC default configuration.
*
* @param _name unique structure name postfix.
* @param _freq_cfg sbc codec frequency.
* for example: A2DP_SBC_SAMP_FREQ_44100
* @param _ch_mode_cfg sbc codec channel mode.
* for example: A2DP_SBC_CH_MODE_JOINT
* @param _blk_len_cfg sbc codec block length.
* for example: A2DP_SBC_BLK_LEN_16
* @param _subband_cfg sbc codec subband.
* for example: A2DP_SBC_SUBBAND_8
* @param _alloc_mthd_cfg sbc codec allocate method.
* for example: A2DP_SBC_ALLOC_MTHD_LOUDNESS
* @param _min_bitpool_cfg sbc codec min bit pool. for example: 18
* @param _max_bitpool_cfg sbc codec max bit pool. for example: 35
*/
#define BT_A2DP_SBC_EP_CFG(_name, _freq_cfg, _ch_mode_cfg, _blk_len_cfg, _subband_cfg,\
_alloc_mthd_cfg, _min_bitpool_cfg, _max_bitpool_cfg)\
static struct bt_a2dp_codec_ie bt_a2dp_codec_ie##_name = {\
.len = BT_A2DP_SBC_IE_LENGTH, .codec_ie = {_freq_cfg | _ch_mode_cfg,\
_blk_len_cfg | _subband_cfg | _alloc_mthd_cfg, _min_bitpool_cfg, _max_bitpool_cfg},};\
struct bt_a2dp_codec_cfg _name = {.codec_config = &bt_a2dp_codec_ie##_name,}
/** @brief define the SBC default configuration.
*
* @param _name unique structure name postfix.
* @param _freq_cfg the frequency to configure the remote same codec type endpoint.
*/
#define BT_A2DP_SBC_EP_CFG_DEFAULT(_name, _freq_cfg)\
static struct bt_a2dp_codec_ie bt_a2dp_codec_ie##_name = {\
.len = BT_A2DP_SBC_IE_LENGTH, .codec_ie = {_freq_cfg | A2DP_SBC_CH_MODE_JOINT,\
A2DP_SBC_BLK_LEN_16 | A2DP_SBC_SUBBAND_8 | A2DP_SBC_ALLOC_MTHD_LOUDNESS, 18U, 35U},};\
struct bt_a2dp_codec_cfg _name = {.codec_config = &bt_a2dp_codec_ie##_name,}
/**
* @brief A2DP error code
*/
enum bt_a2dp_err_code {
/** Media Codec Type is not valid */
BT_A2DP_INVALID_CODEC_TYPE = 0xC1,
/** Media Codec Type is not supported */
BT_A2DP_NOT_SUPPORTED_CODEC_TYPE = 0xC2,
/** Sampling Frequency is not valid or multiple values have been selected */
BT_A2DP_INVALID_SAMPLING_FREQUENCY = 0xC3,
/** Sampling Frequency is not supported */
BT_A2DP_NOT_SUPPORTED_SAMPLING_FREQUENCY = 0xC4,
/** Channel Mode is not valid or multiple values have been selected */
BT_A2DP_INVALID_CHANNEL_MODE = 0xC5,
/** Channel Mode is not supported */
BT_A2DP_NOT_SUPPORTED_CHANNEL_MODE = 0xC6,
/** None or multiple values have been selected for Number of Subbands */
BT_A2DP_INVALID_SUBBANDS = 0xC7,
/** Number of Subbands is not supported */
BT_A2DP_NOT_SUPPORTED_SUBBANDS = 0xC8,
/** None or multiple values have been selected for Allocation Method */
BT_A2DP_INVALID_ALLOCATION_METHOD = 0xC9,
/** Allocation Method is not supported */
BT_A2DP_NOT_SUPPORTED_ALLOCATION_METHOD = 0xCA,
/** Minimum Bitpool Value is not valid */
BT_A2DP_INVALID_MINIMUM_BITPOOL_VALUE = 0xCB,
/** Minimum Bitpool Value is not supported */
BT_A2DP_NOT_SUPPORTED_MINIMUM_BITPOOL_VALUE = 0xCC,
/** Maximum Bitpool Value is not valid */
BT_A2DP_INVALID_MAXIMUM_BITPOOL_VALUE = 0xCD,
/** Maximum Bitpool Value is not supported */
BT_A2DP_NOT_SUPPORTED_MAXIMUM_BITPOOL_VALUE = 0xCE,
/** None or multiple values have been selected for Layer */
BT_A2DP_INVALID_LAYER = 0xCF,
/** Layer is not supported */
BT_A2DP_NOT_SUPPORTED_LAYER = 0xD0,
/** CRC is not supported */
BT_A2DP_NOT_SUPPORTED_CRC = 0xD1,
/** MPF-2 is not supported */
BT_A2DP_NOT_SUPPORTED_MPF = 0xD2,
/** VBR is not supported */
BT_A2DP_NOT_SUPPORTED_VBR = 0xD3,
/** None or multiple values have been selected for Bit Rate */
BT_A2DP_INVALID_BIT_RATE = 0xD4,
/** Bit Rate is not supported */
BT_A2DP_NOT_SUPPORTED_BIT_RATE = 0xD5,
/** Either 1) Object type is not valid or
* 2) None or multiple values have been selected for Object Type
*/
BT_A2DP_INVALID_OBJECT_TYPE = 0xD6,
/** Object Type is not supported */
BT_A2DP_NOT_SUPPORTED_OBJECT_TYPE = 0xD7,
/** Either 1) Channels is not valid or
* 2) None or multiple values have been selected for Channels
*/
BT_A2DP_INVALID_CHANNELS = 0xD8,
/** Channels is not supported */
BT_A2DP_NOT_SUPPORTED_CHANNELS = 0xD9,
/** Version is not valid */
BT_A2DP_INVALID_VERSION = 0xDA,
/** Version is not supported */
BT_A2DP_NOT_SUPPORTED_VERSION = 0xDB,
/** Maximum SUL is not acceptable for the Decoder in the SNK */
BT_A2DP_NOT_SUPPORTED_MAXIMUM_SUL = 0xDC,
/** None or multiple values have been selected for Block Length */
BT_A2DP_INVALID_BLOCK_LENGTH = 0xDD,
/** The requested CP Type is not supported */
BT_A2DP_INVALID_CP_TYPE = 0xE0,
/** The format of Content Protection Service Capability/Content
* Protection Scheme Dependent Data is not correct
*/
BT_A2DP_INVALID_CP_FORMAT = 0xE1,
/** The codec parameter is invalid.
* Used if a more specific error code does not exist for the codec in use
*/
BT_A2DP_INVALID_CODEC_PARAMETER = 0xE2,
/** The codec parameter is not supported.
* Used if a more specific error code does not exist for the codec in use
*/
BT_A2DP_NOT_SUPPORTED_CODEC_PARAMETER = 0xE3,
/** Combination of Object Type and DRC is invalid */
BT_A2DP_INVALID_DRC = 0xE4,
/** DRC is not supported */
BT_A2DP_NOT_SUPPORTED_DRC = 0xE5,
};
/** @brief Codec Type */
enum bt_a2dp_codec_type {
/** Codec SBC */
BT_A2DP_SBC = 0x00,
/** Codec MPEG-1 */
BT_A2DP_MPEG1 = 0x01,
/** Codec MPEG-2 */
BT_A2DP_MPEG2 = 0x02,
/** Codec ATRAC */
BT_A2DP_ATRAC = 0x04,
/** Codec Non-A2DP */
BT_A2DP_VENDOR = 0xff
};
/** @brief A2DP structure */
struct bt_a2dp;
/* Internal to pass build */
struct bt_a2dp_stream;
/** @brief codec information elements for the endpoint */
struct bt_a2dp_codec_ie {
/** Length of codec_cap */
uint8_t len;
/** codec information element */
uint8_t codec_ie[A2DP_MAX_IE_LENGTH];
};
/** @brief The endpoint configuration */
struct bt_a2dp_codec_cfg {
/** The media codec configuration content */
struct bt_a2dp_codec_ie *codec_config;
};
/** @brief Stream End Point */
struct bt_a2dp_ep {
/** Code Type @ref bt_a2dp_codec_type */
uint8_t codec_type;
/** Capabilities */
struct bt_a2dp_codec_ie *codec_cap;
/** AVDTP Stream End Point Identifier */
struct bt_avdtp_sep sep;
/* Internally used stream object pointer */
struct bt_a2dp_stream *stream;
};
struct bt_a2dp_ep_info {
/** Code Type @ref bt_a2dp_codec_type */
uint8_t codec_type;
/** Codec capabilities, if SBC, use function of a2dp_codec_sbc.h to parse it */
struct bt_a2dp_codec_ie codec_cap;
/** Stream End Point Information */
struct bt_avdtp_sep_info sep_info;
};
/** @brief Helper enum to be used as return value of bt_a2dp_discover_ep_cb.
* The value informs the caller to perform further pending actions or stop them.
*/
enum {
BT_A2DP_DISCOVER_EP_STOP = 0,
BT_A2DP_DISCOVER_EP_CONTINUE,
};
/** @typedef bt_a2dp_discover_ep_cb
*
* @brief Called when a stream endpoint is discovered.
*
* A function of this type is given by the user to the bt_a2dp_discover_param
* object. It'll be called on each valid stream endpoint discovery completion.
* When no more endpoint then NULL is passed to the user. Otherwise user can get
* valid endpoint information from parameter info, user can set parameter ep to
* get the endpoint after the callback is return.
* The returned function value allows the user to control retrieving follow-up
* endpoints if any. If the user doesn't want to read more endpoints since
* current found endpoints fulfill its requirements then should return
* BT_A2DP_DISCOVER_EP_STOP. Otherwise returned value means
* more subcall iterations are allowable.
*
* @param a2dp a2dp connection object identifying a2dp connection to queried remote.
* @param info Object pointing to the information of the callbacked endpoint.
* @param ep If the user want to use this found endpoint, user can set value to it
* to get the endpoint that can be used further in other A2DP APIs. It is NULL if info
* is NULL (no more endpoint is found).
*
* @return BT_A2DP_DISCOVER_EP_STOP in case of no more need to continue discovery
* for next endpoint. By returning BT_A2DP_DISCOVER_EP_STOP user allows this
* discovery continuation.
*/
typedef uint8_t (*bt_a2dp_discover_ep_cb)(struct bt_a2dp *a2dp,
struct bt_a2dp_ep_info *info, struct bt_a2dp_ep **ep);
struct bt_a2dp_discover_param {
/** discover callback */
bt_a2dp_discover_ep_cb cb;
/** The discovered endpoint info that is callbacked by cb */
struct bt_a2dp_ep_info info;
/** The max count of remote endpoints that can be got,
* it save endpoint info internally.
*/
struct bt_avdtp_sep_info *seps_info;
/** The max count of seps (stream endpoint) that can be got in this call route */
uint8_t sep_count;
};
/** @brief The connecting callback */
struct bt_a2dp_cb {
/** @brief A a2dp connection has been established.
*
* This callback notifies the application of a a2dp connection.
* It means the AVDTP L2CAP connection.
* In case the err parameter is non-zero it means that the
* connection establishment failed.
*
* @param a2dp a2dp connection object.
* @param err error code.
*/
void (*connected)(struct bt_a2dp *a2dp, int err);
/** @brief A a2dp connection has been disconnected.
*
* This callback notifies the application that a a2dp connection
* has been disconnected.
*
* @param a2dp a2dp connection object.
*/
void (*disconnected)(struct bt_a2dp *a2dp);
/**
* @brief Endpoint config request callback
*
* The callback is called whenever an endpoint is requested to be
* configured.
*
* @param a2dp a2dp connection object.
* @param[in] ep Local Audio Endpoint being configured.
* @param[in] codec_cfg Codec configuration.
* @param[out] stream Pointer to stream that will be configured for the endpoint.
* @param[out] rsp_err_code give the error code if response error.
* bt_a2dp_err_code or bt_avdtp_err_code
*
* @return 0 in case of success or negative value in case of error.
*/
int (*config_req)(struct bt_a2dp *a2dp, struct bt_a2dp_ep *ep,
struct bt_a2dp_codec_cfg *codec_cfg, struct bt_a2dp_stream **stream,
uint8_t *rsp_err_code);
/** @brief Callback function for bt_a2dp_stream_config()
*
* Called when the codec configure operation is completed.
*
* @param[in] stream Pointer to stream object.
* @param[in] rsp_err_code the remote responded error code
* bt_a2dp_err_code or bt_avdtp_err_code
*/
void (*config_rsp)(struct bt_a2dp_stream *stream, uint8_t rsp_err_code);
/**
* @brief stream establishment request callback
*
* The callback is called whenever an stream is requested to be
* established (open cmd and create the stream l2cap channel).
*
* @param[in] stream Pointer to stream object.
* @param[out] rsp_err_code give the error code if response error.
* bt_a2dp_err_code or bt_avdtp_err_code
*
* @return 0 in case of success or negative value in case of error.
*/
int (*establish_req)(struct bt_a2dp_stream *stream, uint8_t *rsp_err_code);
/** @brief Callback function for bt_a2dp_stream_establish()
*
* Called when the establishment operation is completed.
* (open cmd and create the stream l2cap channel).
*
* @param[in] stream Pointer to stream object.
* @param[in] rsp_err_code the remote responded error code
* bt_a2dp_err_code or bt_avdtp_err_code
*/
void (*establish_rsp)(struct bt_a2dp_stream *stream, uint8_t rsp_err_code);
/**
* @brief stream release request callback
*
* The callback is called whenever an stream is requested to be
* released (release cmd and release the l2cap channel)
*
* @param[in] stream Pointer to stream object.
* @param[out] rsp_err_code give the error code if response error.
* bt_a2dp_err_code or bt_avdtp_err_code
*
* @return 0 in case of success or negative value in case of error.
*/
int (*release_req)(struct bt_a2dp_stream *stream, uint8_t *rsp_err_code);
/** @brief Callback function for bt_a2dp_stream_release()
*
* Called when the release operation is completed.
* (release cmd and release the l2cap channel)
*
* @param[in] stream Pointer to stream object.
* @param[in] rsp_err_code the remote responded error code
* bt_a2dp_err_code or bt_avdtp_err_code
*/
void (*release_rsp)(struct bt_a2dp_stream *stream, uint8_t rsp_err_code);
/**
* @brief stream start request callback
*
* The callback is called whenever an stream is requested to be
* started.
*
* @param[in] stream Pointer to stream object.
* @param[out] rsp_err_code give the error code if response error.
* bt_a2dp_err_code or bt_avdtp_err_code
*
* @return 0 in case of success or negative value in case of error.
*/
int (*start_req)(struct bt_a2dp_stream *stream, uint8_t *rsp_err_code);
/** @brief Callback function for bt_a2dp_stream_start()
*
* Called when the start operation is completed.
*
* @param[in] stream Pointer to stream object.
* @param[in] rsp_err_code the remote responded error code
* bt_a2dp_err_code or bt_avdtp_err_code
*/
void (*start_rsp)(struct bt_a2dp_stream *stream, uint8_t rsp_err_code);
/**
* @brief Endpoint suspend request callback
*
* The callback is called whenever an stream is requested to be
* suspended.
*
* @param[in] stream Pointer to stream object.
* @param[out] rsp_err_code give the error code if response error.
* bt_a2dp_err_code or bt_avdtp_err_code
*
* @return 0 in case of success or negative value in case of error.
*/
int (*suspend_req)(struct bt_a2dp_stream *stream, uint8_t *rsp_err_code);
/** @brief Callback function for bt_a2dp_stream_suspend()
*
* Called when the suspend operation is completed.
*
* @param[in] stream Pointer to stream object.
* @param[in] rsp_err_code the remote responded error code
* bt_a2dp_err_code or bt_avdtp_err_code
*/
void (*suspend_rsp)(struct bt_a2dp_stream *stream, uint8_t rsp_err_code);
/**
* @brief Endpoint config request callback
*
* The callback is called whenever an endpoint is requested to be
* reconfigured.
*
* @param[in] stream Pointer to stream object.
* @param[out] rsp_err_code give the error code if response error.
* bt_a2dp_err_code or bt_avdtp_err_code
*
* @return 0 in case of success or negative value in case of error.
*/
int (*reconfig_req)(struct bt_a2dp_stream *stream, uint8_t *rsp_err_code);
/** @brief Callback function for bt_a2dp_stream_reconfig()
*
* Called when the reconfig operation is completed.
*
* @param[in] stream Pointer to stream object.
* @param[in] rsp_err_code the remote responded error code
* bt_a2dp_err_code or bt_avdtp_err_code
*/
void (*reconfig_rsp)(struct bt_a2dp_stream *stream, uint8_t rsp_err_code);
};
/** @brief A2DP Connect.
*
* This function is to be called after the conn parameter is obtained by
* performing a GAP procedure. The API is to be used to establish A2DP
* connection between devices.
* This function only establish AVDTP L2CAP Signaling connection.
* After connection success, the callback that is registered by
* bt_a2dp_register_connect_callback is called.
*
* @param conn Pointer to bt_conn structure.
*
* @return pointer to struct bt_a2dp in case of success or NULL in case
* of error.
*/
struct bt_a2dp *bt_a2dp_connect(struct bt_conn *conn);
/** @brief disconnect l2cap a2dp
*
* This function close AVDTP L2CAP Signaling connection.
* It closes the AVDTP L2CAP Media connection too if it is established.
*
* @param a2dp The a2dp instance.
*
* @return 0 in case of success and error code in case of error.
*/
int bt_a2dp_disconnect(struct bt_a2dp *a2dp);
/** @brief Endpoint Registration.
*
* @param ep Pointer to bt_a2dp_ep structure.
* @param media_type Media type that the Endpoint is.
* @param role Role of Endpoint.
*
* @return 0 in case of success and error code in case of error.
*/
int bt_a2dp_register_ep(struct bt_a2dp_ep *ep, uint8_t media_type, uint8_t role);
/** @brief register callback.
*
* The cb is called when bt_a2dp_connect is called or it is operated by remote device.
*
* @param cb The callback function.
*
* @return 0 in case of success and error code in case of error.
*/
int bt_a2dp_register_cb(struct bt_a2dp_cb *cb);
/** @brief Discover remote endpoints.
*
* @param a2dp The a2dp instance.
* @param param the discover used param.
*
* @return 0 in case of success and error code in case of error.
*/
int bt_a2dp_discover(struct bt_a2dp *a2dp, struct bt_a2dp_discover_param *param);
/** @brief A2DP Stream */
struct bt_a2dp_stream {
/** local endpoint */
struct bt_a2dp_ep *local_ep;
/** remote endpoint */
struct bt_a2dp_ep *remote_ep;
/** remote endpoint's Stream End Point ID */
uint8_t remote_ep_id;
/** Audio stream operations */
struct bt_a2dp_stream_ops *ops;
/** the a2dp connection */
struct bt_a2dp *a2dp;
/** the stream current configuration */
struct bt_a2dp_codec_ie codec_config;
};
/** @brief The stream endpoint related operations */
struct bt_a2dp_stream_ops {
/**
* @brief Stream configured callback
*
* The callback is called whenever an Audio Stream has been configured.
*
* @param stream Stream object that has been configured.
*/
void (*configured)(struct bt_a2dp_stream *stream);
/**
* @brief Stream establishment callback
*
* The callback is called whenever an Audio Stream has been established.
*
* @param stream Stream object that has been established.
*/
void (*established)(struct bt_a2dp_stream *stream);
/**
* @brief Stream release callback
*
* The callback is called whenever an Audio Stream has been released.
*
* @param stream Stream object that has been released.
*/
void (*released)(struct bt_a2dp_stream *stream);
/**
* @brief Stream start callback
*
* The callback is called whenever an Audio Stream has been started.
*
* @param stream Stream object that has been started.
*/
void (*started)(struct bt_a2dp_stream *stream);
/**
* @brief Stream suspend callback
*
* The callback is called whenever an Audio Stream has been suspended.
*
* @param stream Stream object that has been suspended.
*/
void (*suspended)(struct bt_a2dp_stream *stream);
/**
* @brief Stream reconfigured callback
*
* The callback is called whenever an Audio Stream has been reconfigured.
*
* @param stream Stream object that has been reconfigured.
*/
void (*reconfigured)(struct bt_a2dp_stream *stream);
#if defined(CONFIG_BT_A2DP_SINK)
/** @brief the media streaming data, only for sink
*
* @param buf the data buf
* @param seq_num the sequence number
* @param ts the time stamp
*/
void (*recv)(struct bt_a2dp_stream *stream,
struct net_buf *buf, uint16_t seq_num, uint32_t ts);
#endif
#if defined(CONFIG_BT_A2DP_SOURCE)
/**
* @brief Stream audio HCI sent callback
*
* This callback will be called once the controller marks the SDU
* as completed. When the controller does so is implementation
* dependent. It could be after the SDU is enqueued for transmission,
* or after it is sent on air or flushed.
*
* This callback is only used if the ISO data path is HCI.
*
* @param stream Stream object.
*/
void (*sent)(struct bt_a2dp_stream *stream);
#endif
};
/**
* @brief Register Audio callbacks for a stream.
*
* Register Audio callbacks for a stream.
*
* @param stream Stream object.
* @param ops Stream operations structure.
*/
void bt_a2dp_stream_cb_register(struct bt_a2dp_stream *stream, struct bt_a2dp_stream_ops *ops);
/** @brief configure endpoint.
*
* bt_a2dp_discover can be used to find remote's endpoints.
* This function to configure the selected endpoint that is found by
* bt_a2dp_discover.
* This function sends AVDTP_SET_CONFIGURATION.
*
* @param a2dp The a2dp instance.
* @param stream Stream object.
* @param local_ep The configured endpoint that is registered.
* @param remote_ep The remote endpoint.
* @param config The config to configure the endpoint.
*
* @return 0 in case of success and error code in case of error.
*/
int bt_a2dp_stream_config(struct bt_a2dp *a2dp, struct bt_a2dp_stream *stream,
struct bt_a2dp_ep *local_ep, struct bt_a2dp_ep *remote_ep,
struct bt_a2dp_codec_cfg *config);
/** @brief establish a2dp streamer.
*
* This function sends the AVDTP_OPEN command and create the l2cap channel.
*
* @param stream The stream object.
*
* @return 0 in case of success and error code in case of error.
*/
int bt_a2dp_stream_establish(struct bt_a2dp_stream *stream);
/** @brief release a2dp streamer.
*
* This function sends the AVDTP_CLOSE command and release the l2cap channel.
*
* @param stream The stream object.
*
* @return 0 in case of success and error code in case of error.
*/
int bt_a2dp_stream_release(struct bt_a2dp_stream *stream);
/** @brief start a2dp streamer.
*
* This function sends the AVDTP_START command.
*
* @param stream The stream object.
*
* @return 0 in case of success and error code in case of error.
*/
int bt_a2dp_stream_start(struct bt_a2dp_stream *stream);
/** @brief suspend a2dp streamer.
*
* This function sends the AVDTP_SUSPEND command.
*
* @param stream The stream object.
*
* @return 0 in case of success and error code in case of error.
*/
int bt_a2dp_stream_suspend(struct bt_a2dp_stream *stream);
/** @brief re-configure a2dp streamer
*
* This function sends the AVDTP_RECONFIGURE command.
*
* @param stream The stream object.
* @param config The config to configure the stream.
*
* @return 0 in case of success and error code in case of error.
*/
int bt_a2dp_stream_reconfig(struct bt_a2dp_stream *stream, struct bt_a2dp_codec_cfg *config);
/** @brief get the stream l2cap mtu
*
* @param stream The stream object.
*
* @return mtu value
*/
uint32_t bt_a2dp_get_mtu(struct bt_a2dp_stream *stream);
#if defined(CONFIG_BT_A2DP_SOURCE)
/** @brief send a2dp media data
*
* Only A2DP source side can call this function.
*
* @param stream The stream object.
* @param buf The data.
* @param seq_num The sequence number.
* @param ts The time stamp.
*
* @return 0 in case of success and error code in case of error.
*/
int bt_a2dp_stream_send(struct bt_a2dp_stream *stream, struct net_buf *buf,
uint16_t seq_num, uint32_t ts);
#endif
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_A2DP_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/classic/a2dp.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 8,003 |
```objective-c
/** @file
* @brief Service Discovery Protocol handling.
*/
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_SDP_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_SDP_H_
/**
* @file
* @brief Service Discovery Protocol (SDP)
* @defgroup bt_sdp Service Discovery Protocol (SDP)
* @ingroup bluetooth
* @{
*/
#include <zephyr/bluetooth/uuid.h>
#include <zephyr/bluetooth/conn.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* All definitions are based on Bluetooth Assigned Numbers
* of the Bluetooth Specification
*/
/**
* @name Service class identifiers of standard services and service groups
* @{
*/
#define BT_SDP_SDP_SERVER_SVCLASS 0x1000 /**< Service Discovery Server */
#define BT_SDP_BROWSE_GRP_DESC_SVCLASS 0x1001 /**< Browse Group Descriptor */
#define BT_SDP_PUBLIC_BROWSE_GROUP 0x1002 /**< Public Browse Group */
#define BT_SDP_SERIAL_PORT_SVCLASS 0x1101 /**< Serial Port */
#define BT_SDP_LAN_ACCESS_SVCLASS 0x1102 /**< LAN Access Using PPP */
#define BT_SDP_DIALUP_NET_SVCLASS 0x1103 /**< Dialup Networking */
#define BT_SDP_IRMC_SYNC_SVCLASS 0x1104 /**< IrMC Sync */
#define BT_SDP_OBEX_OBJPUSH_SVCLASS 0x1105 /**< OBEX Object Push */
#define BT_SDP_OBEX_FILETRANS_SVCLASS 0x1106 /**< OBEX File Transfer */
#define BT_SDP_IRMC_SYNC_CMD_SVCLASS 0x1107 /**< IrMC Sync Command */
#define BT_SDP_HEADSET_SVCLASS 0x1108 /**< Headset */
#define BT_SDP_CORDLESS_TELEPHONY_SVCLASS 0x1109 /**< Cordless Telephony */
#define BT_SDP_AUDIO_SOURCE_SVCLASS 0x110a /**< Audio Source */
#define BT_SDP_AUDIO_SINK_SVCLASS 0x110b /**< Audio Sink */
#define BT_SDP_AV_REMOTE_TARGET_SVCLASS 0x110c /**< A/V Remote Control Target */
#define BT_SDP_ADVANCED_AUDIO_SVCLASS 0x110d /**< Advanced Audio Distribution */
#define BT_SDP_AV_REMOTE_SVCLASS 0x110e /**< A/V Remote Control */
#define BT_SDP_AV_REMOTE_CONTROLLER_SVCLASS 0x110f /**< A/V Remote Control Controller */
#define BT_SDP_INTERCOM_SVCLASS 0x1110 /**< Intercom */
#define BT_SDP_FAX_SVCLASS 0x1111 /**< Fax */
#define BT_SDP_HEADSET_AGW_SVCLASS 0x1112 /**< Headset AG */
#define BT_SDP_WAP_SVCLASS 0x1113 /**< WAP */
#define BT_SDP_WAP_CLIENT_SVCLASS 0x1114 /**< WAP Client */
#define BT_SDP_PANU_SVCLASS 0x1115 /**< Personal Area Networking User */
#define BT_SDP_NAP_SVCLASS 0x1116 /**< Network Access Point */
#define BT_SDP_GN_SVCLASS 0x1117 /**< Group Network */
#define BT_SDP_DIRECT_PRINTING_SVCLASS 0x1118 /**< Direct Printing */
#define BT_SDP_REFERENCE_PRINTING_SVCLASS 0x1119 /**< Reference Printing */
#define BT_SDP_IMAGING_SVCLASS 0x111a /**< Basic Imaging Profile */
#define BT_SDP_IMAGING_RESPONDER_SVCLASS 0x111b /**< Imaging Responder */
#define BT_SDP_IMAGING_ARCHIVE_SVCLASS 0x111c /**< Imaging Automatic Archive */
#define BT_SDP_IMAGING_REFOBJS_SVCLASS 0x111d /**< Imaging Referenced Objects */
#define BT_SDP_HANDSFREE_SVCLASS 0x111e /**< Handsfree */
#define BT_SDP_HANDSFREE_AGW_SVCLASS 0x111f /**< Handsfree Audio Gateway */
#define BT_SDP_DIRECT_PRT_REFOBJS_SVCLASS 0x1120 /**< Direct Printing Reference Objects Service */
#define BT_SDP_REFLECTED_UI_SVCLASS 0x1121 /**< Reflected UI */
#define BT_SDP_BASIC_PRINTING_SVCLASS 0x1122 /**< Basic Printing */
#define BT_SDP_PRINTING_STATUS_SVCLASS 0x1123 /**< Printing Status */
#define BT_SDP_HID_SVCLASS 0x1124 /**< Human Interface Device Service */
#define BT_SDP_HCR_SVCLASS 0x1125 /**< Hardcopy Cable Replacement */
#define BT_SDP_HCR_PRINT_SVCLASS 0x1126 /**< HCR Print */
#define BT_SDP_HCR_SCAN_SVCLASS 0x1127 /**< HCR Scan */
#define BT_SDP_CIP_SVCLASS 0x1128 /**< Common ISDN Access */
#define BT_SDP_VIDEO_CONF_GW_SVCLASS 0x1129 /**< Video Conferencing Gateway */
#define BT_SDP_UDI_MT_SVCLASS 0x112a /**< UDI MT */
#define BT_SDP_UDI_TA_SVCLASS 0x112b /**< UDI TA */
#define BT_SDP_AV_SVCLASS 0x112c /**< Audio/Video */
#define BT_SDP_SAP_SVCLASS 0x112d /**< SIM Access */
#define BT_SDP_PBAP_PCE_SVCLASS 0x112e /**< Phonebook Access Client */
#define BT_SDP_PBAP_PSE_SVCLASS 0x112f /**< Phonebook Access Server */
#define BT_SDP_PBAP_SVCLASS 0x1130 /**< Phonebook Access */
#define BT_SDP_MAP_MSE_SVCLASS 0x1132 /**< Message Access Server */
#define BT_SDP_MAP_MCE_SVCLASS 0x1133 /**< Message Notification Server */
#define BT_SDP_MAP_SVCLASS 0x1134 /**< Message Access Profile */
#define BT_SDP_GNSS_SVCLASS 0x1135 /**< GNSS */
#define BT_SDP_GNSS_SERVER_SVCLASS 0x1136 /**< GNSS Server */
#define BT_SDP_MPS_SC_SVCLASS 0x113a /**< MPS SC */
#define BT_SDP_MPS_SVCLASS 0x113b /**< MPS */
#define BT_SDP_PNP_INFO_SVCLASS 0x1200 /**< PnP Information */
#define BT_SDP_GENERIC_NETWORKING_SVCLASS 0x1201 /**< Generic Networking */
#define BT_SDP_GENERIC_FILETRANS_SVCLASS 0x1202 /**< Generic File Transfer */
#define BT_SDP_GENERIC_AUDIO_SVCLASS 0x1203 /**< Generic Audio */
#define BT_SDP_GENERIC_TELEPHONY_SVCLASS 0x1204 /**< Generic Telephony */
#define BT_SDP_UPNP_SVCLASS 0x1205 /**< UPnP Service */
#define BT_SDP_UPNP_IP_SVCLASS 0x1206 /**< UPnP IP Service */
#define BT_SDP_UPNP_PAN_SVCLASS 0x1300 /**< UPnP IP PAN */
#define BT_SDP_UPNP_LAP_SVCLASS 0x1301 /**< UPnP IP LAP */
#define BT_SDP_UPNP_L2CAP_SVCLASS 0x1302 /**< UPnP IP L2CAP */
#define BT_SDP_VIDEO_SOURCE_SVCLASS 0x1303 /**< Video Source */
#define BT_SDP_VIDEO_SINK_SVCLASS 0x1304 /**< Video Sink */
#define BT_SDP_VIDEO_DISTRIBUTION_SVCLASS 0x1305 /**< Video Distribution */
#define BT_SDP_HDP_SVCLASS 0x1400 /**< HDP */
#define BT_SDP_HDP_SOURCE_SVCLASS 0x1401 /**< HDP Source */
#define BT_SDP_HDP_SINK_SVCLASS 0x1402 /**< HDP Sink */
#define BT_SDP_GENERIC_ACCESS_SVCLASS 0x1800 /**< Generic Access Profile */
#define BT_SDP_GENERIC_ATTRIB_SVCLASS 0x1801 /**< Generic Attribute Profile */
#define BT_SDP_APPLE_AGENT_SVCLASS 0x2112 /**< Apple Agent */
/**
* @}
*/
#define BT_SDP_SERVER_RECORD_HANDLE 0x0000
/**
* @name Attribute identifier codes
*
* Possible values for attribute-id are listed below.
* See SDP Spec, section "Service Attribute Definitions" for more details.
*
* @{
*/
#define BT_SDP_ATTR_RECORD_HANDLE 0x0000 /**< Service Record Handle */
#define BT_SDP_ATTR_SVCLASS_ID_LIST 0x0001 /**< Service Class ID List */
#define BT_SDP_ATTR_RECORD_STATE 0x0002 /**< Service Record State */
#define BT_SDP_ATTR_SERVICE_ID 0x0003 /**< Service ID */
#define BT_SDP_ATTR_PROTO_DESC_LIST 0x0004 /**< Protocol Descriptor List */
#define BT_SDP_ATTR_BROWSE_GRP_LIST 0x0005 /**< Browse Group List */
#define BT_SDP_ATTR_LANG_BASE_ATTR_ID_LIST 0x0006 /**< Language Base Attribute ID List */
#define BT_SDP_ATTR_SVCINFO_TTL 0x0007 /**< Service Info Time to Live */
#define BT_SDP_ATTR_SERVICE_AVAILABILITY 0x0008 /**< Service Availability */
#define BT_SDP_ATTR_PROFILE_DESC_LIST 0x0009 /**< Bluetooth Profile Descriptor List */
#define BT_SDP_ATTR_DOC_URL 0x000a /**< Documentation URL */
#define BT_SDP_ATTR_CLNT_EXEC_URL 0x000b /**< Client Executable URL */
#define BT_SDP_ATTR_ICON_URL 0x000c /**< Icon URL */
#define BT_SDP_ATTR_ADD_PROTO_DESC_LIST 0x000d /**< Additional Protocol Descriptor List */
#define BT_SDP_ATTR_GROUP_ID 0x0200 /**< Group ID */
#define BT_SDP_ATTR_IP_SUBNET 0x0200 /**< IP Subnet */
#define BT_SDP_ATTR_VERSION_NUM_LIST 0x0200 /**< Version Number List */
#define BT_SDP_ATTR_SUPPORTED_FEATURES_LIST 0x0200 /**< Supported Features List */
#define BT_SDP_ATTR_GOEP_L2CAP_PSM 0x0200 /**< GOEP L2CAP PSM */
#define BT_SDP_ATTR_SVCDB_STATE 0x0201 /**< Service Database State */
#define BT_SDP_ATTR_MPSD_SCENARIOS 0x0200 /**< MPSD Scenarios */
#define BT_SDP_ATTR_MPMD_SCENARIOS 0x0201 /**< MPMD Scenarios */
#define BT_SDP_ATTR_MPS_DEPENDENCIES 0x0202 /**< Supported Profiles & Protocols */
#define BT_SDP_ATTR_SERVICE_VERSION 0x0300 /**< Service Version */
#define BT_SDP_ATTR_EXTERNAL_NETWORK 0x0301 /**< External Network */
#define BT_SDP_ATTR_SUPPORTED_DATA_STORES_LIST 0x0301 /**< Supported Data Stores List */
#define BT_SDP_ATTR_DATA_EXCHANGE_SPEC 0x0301 /**< Data Exchange Specification */
#define BT_SDP_ATTR_NETWORK 0x0301 /**< Network */
#define BT_SDP_ATTR_FAX_CLASS1_SUPPORT 0x0302 /**< Fax Class 1 Support */
#define BT_SDP_ATTR_REMOTE_AUDIO_VOLUME_CONTROL 0x0302 /**< Remote Audio Volume Control */
#define BT_SDP_ATTR_MCAP_SUPPORTED_PROCEDURES 0x0302 /**< MCAP Supported Procedures */
#define BT_SDP_ATTR_FAX_CLASS20_SUPPORT 0x0303 /**< Fax Class 2.0 Support */
#define BT_SDP_ATTR_SUPPORTED_FORMATS_LIST 0x0303 /**< Supported Formats List */
#define BT_SDP_ATTR_FAX_CLASS2_SUPPORT 0x0304 /**< Fax Class 2 Support (vendor-specific)*/
#define BT_SDP_ATTR_AUDIO_FEEDBACK_SUPPORT 0x0305 /**< Audio Feedback Support */
#define BT_SDP_ATTR_NETWORK_ADDRESS 0x0306 /**< Network Address */
#define BT_SDP_ATTR_WAP_GATEWAY 0x0307 /**< WAP Gateway */
#define BT_SDP_ATTR_HOMEPAGE_URL 0x0308 /**< Homepage URL */
#define BT_SDP_ATTR_WAP_STACK_TYPE 0x0309 /**< WAP Stack Type */
#define BT_SDP_ATTR_SECURITY_DESC 0x030a /**< Security Description */
#define BT_SDP_ATTR_NET_ACCESS_TYPE 0x030b /**< Net Access Type */
#define BT_SDP_ATTR_MAX_NET_ACCESSRATE 0x030c /**< Max Net Access Rate */
#define BT_SDP_ATTR_IP4_SUBNET 0x030d /**< IPv4 Subnet */
#define BT_SDP_ATTR_IP6_SUBNET 0x030e /**< IPv6 Subnet */
#define BT_SDP_ATTR_SUPPORTED_CAPABILITIES 0x0310 /**< BIP Supported Capabilities */
#define BT_SDP_ATTR_SUPPORTED_FEATURES 0x0311 /**< BIP Supported Features */
#define BT_SDP_ATTR_SUPPORTED_FUNCTIONS 0x0312 /**< BIP Supported Functions */
#define BT_SDP_ATTR_TOTAL_IMAGING_DATA_CAPACITY 0x0313 /**< BIP Total Imaging Data Capacity */
#define BT_SDP_ATTR_SUPPORTED_REPOSITORIES 0x0314 /**< Supported Repositories */
#define BT_SDP_ATTR_MAS_INSTANCE_ID 0x0315 /**< MAS Instance ID */
#define BT_SDP_ATTR_SUPPORTED_MESSAGE_TYPES 0x0316 /**< Supported Message Types */
#define BT_SDP_ATTR_PBAP_SUPPORTED_FEATURES 0x0317 /**< PBAP Supported Features */
#define BT_SDP_ATTR_MAP_SUPPORTED_FEATURES 0x0317 /**< MAP Supported Features */
#define BT_SDP_ATTR_SPECIFICATION_ID 0x0200 /**< Specification ID */
#define BT_SDP_ATTR_VENDOR_ID 0x0201 /**< Vendor ID */
#define BT_SDP_ATTR_PRODUCT_ID 0x0202 /**< Product ID */
#define BT_SDP_ATTR_VERSION 0x0203 /**< Version */
#define BT_SDP_ATTR_PRIMARY_RECORD 0x0204 /**< Primary Record */
#define BT_SDP_ATTR_VENDOR_ID_SOURCE 0x0205 /**< Vendor ID Source */
#define BT_SDP_ATTR_HID_DEVICE_RELEASE_NUMBER 0x0200 /**< HID Device Release Number */
#define BT_SDP_ATTR_HID_PARSER_VERSION 0x0201 /**< HID Parser Version */
#define BT_SDP_ATTR_HID_DEVICE_SUBCLASS 0x0202 /**< HID Device Subclass */
#define BT_SDP_ATTR_HID_COUNTRY_CODE 0x0203 /**< HID Country Code */
#define BT_SDP_ATTR_HID_VIRTUAL_CABLE 0x0204 /**< HID Virtual Cable */
#define BT_SDP_ATTR_HID_RECONNECT_INITIATE 0x0205 /**< HID Reconnect Initiate */
#define BT_SDP_ATTR_HID_DESCRIPTOR_LIST 0x0206 /**< HID Descriptor List */
#define BT_SDP_ATTR_HID_LANG_ID_BASE_LIST 0x0207 /**< HID Language ID Base List */
#define BT_SDP_ATTR_HID_SDP_DISABLE 0x0208 /**< HID SDP Disable */
#define BT_SDP_ATTR_HID_BATTERY_POWER 0x0209 /**< HID Battery Power */
#define BT_SDP_ATTR_HID_REMOTE_WAKEUP 0x020a /**< HID Remote Wakeup */
#define BT_SDP_ATTR_HID_PROFILE_VERSION 0x020b /**< HID Profile Version */
#define BT_SDP_ATTR_HID_SUPERVISION_TIMEOUT 0x020c /**< HID Supervision Timeout */
#define BT_SDP_ATTR_HID_NORMALLY_CONNECTABLE 0x020d /**< HID Normally Connectable */
#define BT_SDP_ATTR_HID_BOOT_DEVICE 0x020e /**< HID Boot Device */
/**
* @}
*/
/*
* These identifiers are based on the SDP spec stating that
* "base attribute id of the primary (universal) language must be 0x0100"
*
* Other languages should have their own offset; e.g.:
* #define XXXLangBase yyyy
* #define AttrServiceName_XXX 0x0000+XXXLangBase
*/
#define BT_SDP_PRIMARY_LANG_BASE 0x0100
#define BT_SDP_ATTR_SVCNAME_PRIMARY (0x0000 + BT_SDP_PRIMARY_LANG_BASE)
#define BT_SDP_ATTR_SVCDESC_PRIMARY (0x0001 + BT_SDP_PRIMARY_LANG_BASE)
#define BT_SDP_ATTR_PROVNAME_PRIMARY (0x0002 + BT_SDP_PRIMARY_LANG_BASE)
/**
* @name The Data representation in SDP PDUs (pps 339, 340 of BT SDP Spec)
*
* These are the exact data type+size descriptor values
* that go into the PDU buffer.
*
* The datatype (leading 5bits) + size descriptor (last 3 bits)
* is 8 bits. The size descriptor is critical to extract the
* right number of bytes for the data value from the PDU.
*
* For most basic types, the datatype+size descriptor is
* straightforward. However for constructed types and strings,
* the size of the data is in the next "n" bytes following the
* 8 bits (datatype+size) descriptor. Exactly what the "n" is
* specified in the 3 bits of the data size descriptor.
*
* TextString and URLString can be of size 2^{8, 16, 32} bytes
* DataSequence and DataSequenceAlternates can be of size 2^{8, 16, 32}
* The size are computed post-facto in the API and are not known apriori.
* @{
*/
#define BT_SDP_DATA_NIL 0x00 /**< Nil, the null type */
#define BT_SDP_UINT8 0x08 /**< Unsigned 8-bit integer */
#define BT_SDP_UINT16 0x09 /**< Unsigned 16-bit integer */
#define BT_SDP_UINT32 0x0a /**< Unsigned 32-bit integer */
#define BT_SDP_UINT64 0x0b /**< Unsigned 64-bit integer */
#define BT_SDP_UINT128 0x0c /**< Unsigned 128-bit integer */
#define BT_SDP_INT8 0x10 /**< Signed 8-bit integer */
#define BT_SDP_INT16 0x11 /**< Signed 16-bit integer */
#define BT_SDP_INT32 0x12 /**< Signed 32-bit integer */
#define BT_SDP_INT64 0x13 /**< Signed 64-bit integer */
#define BT_SDP_INT128 0x14 /**< Signed 128-bit integer */
#define BT_SDP_UUID_UNSPEC 0x18 /**< UUID, unspecified size */
#define BT_SDP_UUID16 0x19 /**< UUID, 16-bit */
#define BT_SDP_UUID32 0x1a /**< UUID, 32-bit */
#define BT_SDP_UUID128 0x1c /**< UUID, 128-bit */
#define BT_SDP_TEXT_STR_UNSPEC 0x20 /**< Text string, unspecified size */
#define BT_SDP_TEXT_STR8 0x25 /**< Text string, 8-bit length */
#define BT_SDP_TEXT_STR16 0x26 /**< Text string, 16-bit length */
#define BT_SDP_TEXT_STR32 0x27 /**< Text string, 32-bit length */
#define BT_SDP_BOOL 0x28 /**< Boolean */
#define BT_SDP_SEQ_UNSPEC 0x30 /**< Data element sequence, unspecified size */
#define BT_SDP_SEQ8 0x35 /**< Data element sequence, 8-bit length */
#define BT_SDP_SEQ16 0x36 /**< Data element sequence, 16-bit length */
#define BT_SDP_SEQ32 0x37 /**< Data element sequence, 32-bit length */
#define BT_SDP_ALT_UNSPEC 0x38 /**< Data element alternative, unspecified size */
#define BT_SDP_ALT8 0x3d /**< Data element alternative, 8-bit length */
#define BT_SDP_ALT16 0x3e /**< Data element alternative, 16-bit length */
#define BT_SDP_ALT32 0x3f /**< Data element alternative, 32-bit length */
#define BT_SDP_URL_STR_UNSPEC 0x40 /**< URL string, unspecified size */
#define BT_SDP_URL_STR8 0x45 /**< URL string, 8-bit length */
#define BT_SDP_URL_STR16 0x46 /**< URL string, 16-bit length */
#define BT_SDP_URL_STR32 0x47 /**< URL string, 32-bit length */
/**
* @}
*/
#define BT_SDP_TYPE_DESC_MASK 0xf8
#define BT_SDP_SIZE_DESC_MASK 0x07
#define BT_SDP_SIZE_INDEX_OFFSET 5
/** @brief SDP Generic Data Element Value. */
struct bt_sdp_data_elem {
uint8_t type; /**< Type of the data element */
uint32_t data_size; /**< Size of the data element */
uint32_t total_size; /**< Total size of the data element */
const void *data;
};
/** @brief SDP Attribute Value. */
struct bt_sdp_attribute {
uint16_t id; /**< Attribute ID */
struct bt_sdp_data_elem val; /**< Attribute data */
};
/** @brief SDP Service Record Value. */
struct bt_sdp_record {
uint32_t handle; /**< Redundant, for quick ref */
struct bt_sdp_attribute *attrs; /**< Base addr of attr array */
size_t attr_count; /**< Number of attributes */
uint8_t index; /**< Index of the record in LL */
struct bt_sdp_record *next; /**< Next service record */
};
/*
* --------------------------------------------------- ------------------
* | Service Hdl | Attr list ptr | Attr count | Next | -> | Service Hdl | ...
* --------------------------------------------------- ------------------
*/
/**
* @brief Declare an array of 8-bit elements in an attribute.
*/
#define BT_SDP_ARRAY_8(...) ((uint8_t[]) {__VA_ARGS__})
/**
* @brief Declare an array of 16-bit elements in an attribute.
*/
#define BT_SDP_ARRAY_16(...) ((uint16_t[]) {__VA_ARGS__})
/**
* @brief Declare an array of 32-bit elements in an attribute.
*/
#define BT_SDP_ARRAY_32(...) ((uint32_t[]) {__VA_ARGS__})
/**
* @brief Declare a fixed-size data element header.
*
* @param _type Data element header containing type and size descriptors.
*/
#define BT_SDP_TYPE_SIZE(_type) .type = _type, \
.data_size = BIT(_type & BT_SDP_SIZE_DESC_MASK), \
.total_size = BIT(_type & BT_SDP_SIZE_DESC_MASK) + 1
/**
* @brief Declare a variable-size data element header.
*
* @param _type Data element header containing type and size descriptors.
* @param _size The actual size of the data.
*/
#define BT_SDP_TYPE_SIZE_VAR(_type, _size) .type = _type, \
.data_size = _size, \
.total_size = BIT((_type & BT_SDP_SIZE_DESC_MASK) - \
BT_SDP_SIZE_INDEX_OFFSET) + _size + 1
/**
* @brief Declare a list of data elements.
*/
#define BT_SDP_DATA_ELEM_LIST(...) ((struct bt_sdp_data_elem[]) {__VA_ARGS__})
/**
* @brief SDP New Service Record Declaration Macro.
*
* Helper macro to declare a new service record.
* Default attributes: Record Handle, Record State,
* Language Base, Root Browse Group
*
*/
#define BT_SDP_NEW_SERVICE \
{ \
BT_SDP_ATTR_RECORD_HANDLE, \
{ BT_SDP_TYPE_SIZE(BT_SDP_UINT32), BT_SDP_ARRAY_32(0) } \
}, \
{ \
BT_SDP_ATTR_RECORD_STATE, \
{ BT_SDP_TYPE_SIZE(BT_SDP_UINT32), BT_SDP_ARRAY_32(0) } \
}, \
{ \
BT_SDP_ATTR_LANG_BASE_ATTR_ID_LIST, \
{ BT_SDP_TYPE_SIZE_VAR(BT_SDP_SEQ8, 9), \
BT_SDP_DATA_ELEM_LIST( \
{ BT_SDP_TYPE_SIZE(BT_SDP_UINT16), BT_SDP_ARRAY_8('n', 'e') }, \
{ BT_SDP_TYPE_SIZE(BT_SDP_UINT16), BT_SDP_ARRAY_16(106) }, \
{ BT_SDP_TYPE_SIZE(BT_SDP_UINT16), \
BT_SDP_ARRAY_16(BT_SDP_PRIMARY_LANG_BASE) } \
), \
} \
}, \
{ \
BT_SDP_ATTR_BROWSE_GRP_LIST, \
{ BT_SDP_TYPE_SIZE_VAR(BT_SDP_SEQ8, 3), \
BT_SDP_DATA_ELEM_LIST( \
{ BT_SDP_TYPE_SIZE(BT_SDP_UUID16), \
BT_SDP_ARRAY_16(BT_SDP_PUBLIC_BROWSE_GROUP) }, \
), \
} \
}
/**
* @brief Generic SDP List Attribute Declaration Macro.
*
* Helper macro to declare a list attribute.
*
* @param _att_id List Attribute ID.
* @param _data_elem_seq Data element sequence for the list.
* @param _type_size SDP type and size descriptor.
*/
#define BT_SDP_LIST(_att_id, _type_size, _data_elem_seq) \
{ \
_att_id, { _type_size, _data_elem_seq } \
}
/**
* @brief SDP Service ID Attribute Declaration Macro.
*
* Helper macro to declare a service ID attribute.
*
* @param _uuid Service ID 16bit UUID.
*/
#define BT_SDP_SERVICE_ID(_uuid) \
{ \
BT_SDP_ATTR_SERVICE_ID, \
{ BT_SDP_TYPE_SIZE(BT_SDP_UUID16), &((struct bt_uuid_16) _uuid) } \
}
/**
* @brief SDP Name Attribute Declaration Macro.
*
* Helper macro to declare a service name attribute.
*
* @param _name Service name as a string (up to 256 chars).
*/
#define BT_SDP_SERVICE_NAME(_name) \
{ \
BT_SDP_ATTR_SVCNAME_PRIMARY, \
{ BT_SDP_TYPE_SIZE_VAR(BT_SDP_TEXT_STR8, (sizeof(_name)-1)), _name } \
}
/**
* @brief SDP Supported Features Attribute Declaration Macro.
*
* Helper macro to declare supported features of a profile/protocol.
*
* @param _features Feature mask as 16bit unsigned integer.
*/
#define BT_SDP_SUPPORTED_FEATURES(_features) \
{ \
BT_SDP_ATTR_SUPPORTED_FEATURES, \
{ BT_SDP_TYPE_SIZE(BT_SDP_UINT16), BT_SDP_ARRAY_16(_features) } \
}
/**
* @brief SDP Service Declaration Macro.
*
* Helper macro to declare a service.
*
* @param _attrs List of attributes for the service record.
*/
#define BT_SDP_RECORD(_attrs) \
{ \
.attrs = _attrs, \
.attr_count = ARRAY_SIZE((_attrs)), \
}
/* Server API */
/** @brief Register a Service Record.
*
* Register a Service Record. Applications can make use of
* macros such as BT_SDP_DECLARE_SERVICE, BT_SDP_LIST,
* BT_SDP_SERVICE_ID, BT_SDP_SERVICE_NAME, etc.
* A service declaration must start with BT_SDP_NEW_SERVICE.
*
* @param service Service record declared using BT_SDP_DECLARE_SERVICE.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_sdp_register_service(struct bt_sdp_record *service);
/* Client API */
/** @brief Generic SDP Client Query Result data holder */
struct bt_sdp_client_result {
/** buffer containing unparsed SDP record result for given UUID */
struct net_buf *resp_buf;
/** flag pointing that there are more result chunks for given UUID */
bool next_record_hint;
/** Reference to UUID object on behalf one discovery was started */
const struct bt_uuid *uuid;
};
/** @brief Helper enum to be used as return value of bt_sdp_discover_func_t.
* The value informs the caller to perform further pending actions or stop them.
*/
enum {
BT_SDP_DISCOVER_UUID_STOP = 0,
BT_SDP_DISCOVER_UUID_CONTINUE,
};
/** @typedef bt_sdp_discover_func_t
*
* @brief Callback type reporting to user that there is a resolved result
* on remote for given UUID and the result record buffer can be used by user
* for further inspection.
*
* A function of this type is given by the user to the bt_sdp_discover_params
* object. It'll be called on each valid record discovery completion for given
* UUID. When UUID resolution gives back no records then NULL is passed
* to the user. Otherwise user can get valid record(s) and then the internal
* hint 'next record' is set to false saying the UUID resolution is complete or
* the hint can be set by caller to true meaning that next record is available
* for given UUID.
* The returned function value allows the user to control retrieving follow-up
* resolved records if any. If the user doesn't want to read more resolved
* records for given UUID since current record data fulfills its requirements
* then should return BT_SDP_DISCOVER_UUID_STOP. Otherwise returned value means
* more subcall iterations are allowable.
*
* @param conn Connection object identifying connection to queried remote.
* @param result Object pointing to logical unparsed SDP record collected on
* base of response driven by given UUID.
*
* @return BT_SDP_DISCOVER_UUID_STOP in case of no more need to read next
* record data and continue discovery for given UUID. By returning
* BT_SDP_DISCOVER_UUID_CONTINUE user allows this discovery continuation.
*/
typedef uint8_t (*bt_sdp_discover_func_t)
(struct bt_conn *conn, struct bt_sdp_client_result *result);
/** @brief Main user structure used in SDP discovery of remote. */
struct bt_sdp_discover_params {
sys_snode_t _node;
/** UUID (service) to be discovered on remote SDP entity */
const struct bt_uuid *uuid;
/** Discover callback to be called on resolved SDP record */
bt_sdp_discover_func_t func;
/** Memory buffer enabled by user for SDP query results */
struct net_buf_pool *pool;
};
/** @brief Allows user to start SDP discovery session.
*
* The function performs SDP service discovery on remote server driven by user
* delivered discovery parameters. Discovery session is made as soon as
* no SDP transaction is ongoing between peers and if any then this one
* is queued to be processed at discovery completion of previous one.
* On the service discovery completion the callback function will be
* called to get feedback to user about findings.
*
* @param conn Object identifying connection to remote.
* @param params SDP discovery parameters.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_sdp_discover(struct bt_conn *conn,
const struct bt_sdp_discover_params *params);
/** @brief Release waiting SDP discovery request.
*
* It can cancel valid waiting SDP client request identified by SDP discovery
* parameters object.
*
* @param conn Object identifying connection to remote.
* @param params SDP discovery parameters.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_sdp_discover_cancel(struct bt_conn *conn,
const struct bt_sdp_discover_params *params);
/* Helper types & functions for SDP client to get essential data from server */
/** @brief Protocols to be asked about specific parameters */
enum bt_sdp_proto {
BT_SDP_PROTO_RFCOMM = 0x0003,
BT_SDP_PROTO_L2CAP = 0x0100,
};
/** @brief Give to user parameter value related to given stacked protocol UUID.
*
* API extracts specific parameter associated with given protocol UUID
* available in Protocol Descriptor List attribute.
*
* @param buf Original buffered raw record data.
* @param proto Known protocol to be checked like RFCOMM or L2CAP.
* @param param On success populated by found parameter value.
*
* @return 0 on success when specific parameter associated with given protocol
* value is found, or negative if error occurred during processing.
*/
int bt_sdp_get_proto_param(const struct net_buf *buf, enum bt_sdp_proto proto,
uint16_t *param);
/** @brief Get additional parameter value related to given stacked protocol UUID.
*
* API extracts specific parameter associated with given protocol UUID
* available in Additional Protocol Descriptor List attribute.
*
* @param buf Original buffered raw record data.
* @param proto Known protocol to be checked like RFCOMM or L2CAP.
* @param param_index There may be more than one parameter related to the
* given protocol UUID. This function returns the result that is
* indexed by this parameter. It's value is from 0, 0 means the
* first matched result, 1 means the second matched result.
* @param[out] param On success populated by found parameter value.
*
* @return 0 on success when a specific parameter associated with a given protocol
* value is found, or negative if error occurred during processing.
*/
int bt_sdp_get_addl_proto_param(const struct net_buf *buf, enum bt_sdp_proto proto,
uint8_t param_index, uint16_t *param);
/** @brief Get profile version.
*
* Helper API extracting remote profile version number. To get it proper
* generic profile parameter needs to be selected usually listed in SDP
* Interoperability Requirements section for given profile specification.
*
* @param buf Original buffered raw record data.
* @param profile Profile family identifier the profile belongs.
* @param version On success populated by found version number.
*
* @return 0 on success, negative value if error occurred during processing.
*/
int bt_sdp_get_profile_version(const struct net_buf *buf, uint16_t profile,
uint16_t *version);
/** @brief Get SupportedFeatures attribute value
*
* Allows if exposed by remote retrieve SupportedFeature attribute.
*
* @param buf Buffer holding original raw record data from remote.
* @param features On success object to be populated with SupportedFeature
* mask.
*
* @return 0 on success if feature found and valid, negative in case any error
*/
int bt_sdp_get_features(const struct net_buf *buf, uint16_t *features);
#ifdef __cplusplus
}
#endif
/**
* @}
*/
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_SDP_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/classic/sdp.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 7,480 |
```objective-c
/** @file
* @brief Audio/Video Distribution Transport Protocol header.
*/
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_AVDTP_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_AVDTP_H_
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief AVDTP error code
*/
enum bt_avdtp_err_code {
/** The response is success, it is not from avdtp spec. */
BT_AVDTP_SUCCESS = 0x00,
/** The request is time out without response, it is not from avdtp spec. */
BT_AVDTP_TIME_OUT = 0xFF,
/** The request packet header format error */
BT_AVDTP_BAD_HEADER_FORMAT = 0x01,
/** The request packet length is not match the assumed length */
BT_AVDTP_BAD_LENGTH = 0x11,
/** The requested command indicates an invalid ACP SEID (not addressable) */
BT_AVDTP_BAD_ACP_SEID = 0x12,
/** The SEP is in use */
BT_AVDTP_SEP_IN_USE = 0x13,
/** The SEP is not in use */
BT_AVDTP_SEP_NOT_IN_USE = 0x14,
/** The value of Service Category in the request packet is not defined in AVDTP */
BT_AVDTP_BAD_SERV_CATEGORY = 0x17,
/** The requested command has an incorrect payload format */
BT_AVDTP_BAD_PAYLOAD_FORMAT = 0x18,
/** The requested command is not supported by the device */
BT_AVDTP_NOT_SUPPORTED_COMMAND = 0x19,
/** The reconfigure command is an attempt to reconfigure a transport service codec_cap
* of the SEP. Reconfigure is only permitted for application service codec_cap
*/
BT_AVDTP_INVALID_CAPABILITIES = 0x1A,
/** The requested Recovery Type is not defined in AVDTP */
BT_AVDTP_BAD_RECOVERY_TYPE = 0x22,
/** The format of Media Transport Capability is not correct */
BT_AVDTP_BAD_MEDIA_TRANSPORT_FORMAT = 0x23,
/** The format of Recovery Service Capability is not correct */
BT_AVDTP_BAD_RECOVERY_FORMAT = 0x25,
/** The format of Header Compression Service Capability is not correct */
BT_AVDTP_BAD_ROHC_FORMAT = 0x26,
/** The format of Content Protection Service Capability is not correct */
BT_AVDTP_BAD_CP_FORMAT = 0x27,
/** The format of Multiplexing Service Capability is not correct */
BT_AVDTP_BAD_MULTIPLEXING_FORMAT = 0x28,
/** Configuration not supported */
BT_AVDTP_UNSUPPORTED_CONFIGURAION = 0x29,
/** Indicates that the ACP state machine is in an invalid state in order to process the
* signal. This also includes the situation when an INT receives a request for the
* same command that it is currently expecting a response
*/
BT_AVDTP_BAD_STATE = 0x31,
};
/** @brief Stream End Point Type */
enum bt_avdtp_sep_type {
/** Source Role */
BT_AVDTP_SOURCE = 0,
/** Sink Role */
BT_AVDTP_SINK = 1
};
/** @brief Stream End Point Media Type */
enum bt_avdtp_media_type {
/** Audio Media Type */
BT_AVDTP_AUDIO = 0x00,
/** Video Media Type */
BT_AVDTP_VIDEO = 0x01,
/** Multimedia Media Type */
BT_AVDTP_MULTIMEDIA = 0x02
};
/** @brief AVDTP stream endpoint information.
* Don't need to care endianness because it is not used for data parsing.
*/
struct bt_avdtp_sep_info {
/** End Point usage status */
uint8_t inuse:1;
/** Stream End Point ID that is the identifier of the stream endpoint */
uint8_t id:6;
/** Reserved */
uint8_t reserved:1;
/** Stream End-point Type that indicates if the stream end-point is SNK or SRC */
enum bt_avdtp_sep_type tsep;
/** Media-type of the End Point
* Only @ref BT_AVDTP_AUDIO is supported now.
*/
enum bt_avdtp_media_type media_type;
};
/** @brief service category Type */
enum bt_avdtp_service_category {
/** Media Transport */
BT_AVDTP_SERVICE_MEDIA_TRANSPORT = 0x01,
/** Reporting */
BT_AVDTP_SERVICE_REPORTING = 0x02,
/** Recovery */
BT_AVDTP_SERVICE_MEDIA_RECOVERY = 0x03,
/** Content Protection */
BT_AVDTP_SERVICE_CONTENT_PROTECTION = 0x04,
/** Header Compression */
BT_AVDTP_SERVICE_HEADER_COMPRESSION = 0x05,
/** Multiplexing */
BT_AVDTP_SERVICE_MULTIPLEXING = 0x06,
/** Media Codec */
BT_AVDTP_SERVICE_MEDIA_CODEC = 0x07,
/** Delay Reporting */
BT_AVDTP_SERVICE_DELAY_REPORTING = 0x08,
};
/** @brief AVDTP Stream End Point */
struct bt_avdtp_sep {
/** Stream End Point information */
struct bt_avdtp_sep_info sep_info;
/** Media Transport Channel*/
struct bt_l2cap_br_chan chan;
/** the endpoint media data */
void (*media_data_cb)(struct bt_avdtp_sep *sep,
struct net_buf *buf);
/** avdtp session */
struct bt_avdtp *session;
/** SEP state */
uint8_t state;
/* Internally used list node */
sys_snode_t _node;
};
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_AVDTP_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/classic/avdtp.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 1,255 |
```objective-c
/** @file
* @brief Handsfree Profile Audio Gateway handling.
*/
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_HFP_AG_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_HFP_AG_H_
/**
* @brief Hands Free Profile - Audio Gateway (HFP-AG)
* @defgroup bt_hfp_ag Hands Free Profile - Audio Gateway (HFP-AG)
* @ingroup bluetooth
* @{
*/
#include <zephyr/bluetooth/bluetooth.h>
#ifdef __cplusplus
extern "C" {
#endif
/* HFP AG Indicators */
enum bt_hfp_ag_indicator {
BT_HFP_AG_SERVICE_IND = 0, /* Service availability indicator */
BT_HFP_AG_CALL_IND = 1, /* call status indicator */
BT_HFP_AG_CALL_SETUP_IND = 2, /* Call set up status indicator */
BT_HFP_AG_CALL_HELD_IND = 3, /* Call hold status indicator */
BT_HFP_AG_SIGNAL_IND = 4, /* Signal strength indicator */
BT_HFP_AG_ROAM_IND = 5, /* Roaming status indicator */
BT_HFP_AG_BATTERY_IND = 6, /* Battery change indicator */
BT_HFP_AG_IND_MAX /* Indicator MAX value */
};
/* HFP CODEC */
#define BT_HFP_AG_CODEC_CVSD 0x01
#define BT_HFP_AG_CODEC_MSBC 0x02
#define BT_HFP_AG_CODEC_LC3_SWB 0x03
struct bt_hfp_ag;
/** @brief HFP profile AG application callback */
struct bt_hfp_ag_cb {
/** HF AG connected callback to application
*
* If this callback is provided it will be called whenever the
* AG connection completes.
*
* @param ag HFP AG object.
*/
void (*connected)(struct bt_hfp_ag *ag);
/** HF disconnected callback to application
*
* If this callback is provided it will be called whenever the
* connection gets disconnected, including when a connection gets
* rejected or cancelled or any error in SLC establishment.
*
* @param ag HFP AG object.
*/
void (*disconnected)(struct bt_hfp_ag *ag);
/** HF SCO/eSCO connected Callback
*
* If this callback is provided it will be called whenever the
* SCO/eSCO connection completes.
*
* @param ag HFP AG object.
* @param sco_conn SCO/eSCO Connection object.
*/
void (*sco_connected)(struct bt_hfp_ag *ag, struct bt_conn *sco_conn);
/** HF SCO/eSCO disconnected Callback
*
* If this callback is provided it will be called whenever the
* SCO/eSCO connection gets disconnected.
*
* @param ag HFP AG object.
* @param sco_conn SCO/eSCO Connection object.
*/
void (*sco_disconnected)(struct bt_hfp_ag *ag);
/** HF memory dialing request Callback
*
* If this callback is provided it will be called whenever a
* new call is requested with memory dialing from HFP unit.
* Get the phone number according to the given AG memory location.
*
* @param ag HFP AG object.
* @param location AG memory location
* @param number Dailing number
*
* @return 0 in case of success or negative value in case of error.
*/
int (*memory_dial)(struct bt_hfp_ag *ag, const char *location, char **number);
/** HF outgoing Callback
*
* If this callback is provided it will be called whenever a
* new call is outgoing.
*
* @param ag HFP AG object.
* @param number Dailing number
*/
void (*outgoing)(struct bt_hfp_ag *ag, const char *number);
/** HF incoming Callback
*
* If this callback is provided it will be called whenever a
* new call is incoming.
*
* @param ag HFP AG object.
* @param number Incoming number
*/
void (*incoming)(struct bt_hfp_ag *ag, const char *number);
/** HF ringing Callback
*
* If this callback is provided it will be called whenever the
* call is in the ringing
*
* @param ag HFP AG object.
* @param in_bond true - in-bond ringing, false - No in-bond ringing
*/
void (*ringing)(struct bt_hfp_ag *ag, bool in_band);
/** HF call accept Callback
*
* If this callback is provided it will be called whenever the
* call is accepted.
*
* @param ag HFP AG object.
*/
void (*accept)(struct bt_hfp_ag *ag);
/** HF call reject Callback
*
* If this callback is provided it will be called whenever the
* call is rejected.
*
* @param ag HFP AG object.
*/
void (*reject)(struct bt_hfp_ag *ag);
/** HF call terminate Callback
*
* If this callback is provided it will be called whenever the
* call is terminated.
*
* @param ag HFP AG object.
*/
void (*terminate)(struct bt_hfp_ag *ag);
/** Supported codec Ids callback
*
* If this callback is provided it will be called whenever the
* supported codec ids are updated.
*
* @param ag HFP AG object.
*/
void (*codec)(struct bt_hfp_ag *ag, uint32_t ids);
};
/** @brief Register HFP AG profile
*
* Register Handsfree profile AG callbacks to monitor the state and get the
* required HFP details to display.
*
* @param cb callback structure.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_hfp_ag_register(struct bt_hfp_ag_cb *cb);
/** @brief Create the hfp ag session
*
* Create the hfp ag session
*
* @param conn ACL connection object.
* @param ag Created HFP AG object.
* @param channel Peer rfcomm channel to be connected.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_hfp_ag_connect(struct bt_conn *conn, struct bt_hfp_ag **ag, uint8_t channel);
/** @brief Disconnect the hfp ag session
*
* Disconnect the hfp ag session
*
* @param ag HFP AG object.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_hfp_ag_disconnect(struct bt_hfp_ag *ag);
/** @brief Notify HFP Unit of an incoming call
*
* Notify HFP Unit of an incoming call.
*
* @param ag HFP AG object.
* @param number Dailing number.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_hfp_ag_remote_incoming(struct bt_hfp_ag *ag, const char *number);
/** @brief Reject the incoming call
*
* Reject the incoming call.
*
* @param ag HFP AG object.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_hfp_ag_reject(struct bt_hfp_ag *ag);
/** @brief Accept the incoming call
*
* Accept the incoming call.
*
* @param ag HFP AG object.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_hfp_ag_accept(struct bt_hfp_ag *ag);
/** @brief Terminate the active/hold call
*
* Terminate the active/hold call.
*
* @param ag HFP AG object.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_hfp_ag_terminate(struct bt_hfp_ag *ag);
/** @brief Dial a call
*
* Dial a call.
*
* @param ag HFP AG object.
* @param number Dailing number.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_hfp_ag_outgoing(struct bt_hfp_ag *ag, const char *number);
/** @brief Notify HFP Unit that the remote starts ringing
*
* Notify HFP Unit that the remote starts ringing.
*
* @param ag HFP AG object.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_hfp_ag_remote_ringing(struct bt_hfp_ag *ag);
/** @brief Notify HFP Unit that the remote rejects the call
*
* Notify HFP Unit that the remote rejects the call.
*
* @param ag HFP AG object.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_hfp_ag_remote_reject(struct bt_hfp_ag *ag);
/** @brief Notify HFP Unit that the remote accepts the call
*
* Notify HFP Unit that the remote accepts the call.
*
* @param ag HFP AG object.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_hfp_ag_remote_accept(struct bt_hfp_ag *ag);
/** @brief Notify HFP Unit that the remote terminates the active/hold call
*
* Notify HFP Unit that the remote terminates the active/hold call.
*
* @param ag HFP AG object.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_hfp_ag_remote_terminate(struct bt_hfp_ag *ag);
#ifdef __cplusplus
}
#endif
/**
* @}
*/
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_HFP_HF_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/classic/hfp_ag.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 2,184 |
```objective-c
/** @file
* @brief Bluetooth RFCOMM handling
*/
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_RFCOMM_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_RFCOMM_H_
/**
* @brief RFCOMM
* @defgroup bt_rfcomm RFCOMM
* @ingroup bluetooth
* @{
*/
#include <zephyr/bluetooth/buf.h>
#include <zephyr/bluetooth/conn.h>
#ifdef __cplusplus
extern "C" {
#endif
/* RFCOMM channels (1-30): pre-allocated for profiles to avoid conflicts */
enum {
BT_RFCOMM_CHAN_HFP_HF = 1,
BT_RFCOMM_CHAN_HFP_AG,
BT_RFCOMM_CHAN_HSP_AG,
BT_RFCOMM_CHAN_HSP_HS,
BT_RFCOMM_CHAN_SPP,
};
struct bt_rfcomm_dlc;
/** @brief RFCOMM DLC operations structure. */
struct bt_rfcomm_dlc_ops {
/** DLC connected callback
*
* If this callback is provided it will be called whenever the
* connection completes.
*
* @param dlc The dlc that has been connected
*/
void (*connected)(struct bt_rfcomm_dlc *dlc);
/** DLC disconnected callback
*
* If this callback is provided it will be called whenever the
* dlc is disconnected, including when a connection gets
* rejected or cancelled (both incoming and outgoing)
*
* @param dlc The dlc that has been Disconnected
*/
void (*disconnected)(struct bt_rfcomm_dlc *dlc);
/** DLC recv callback
*
* @param dlc The dlc receiving data.
* @param buf Buffer containing incoming data.
*/
void (*recv)(struct bt_rfcomm_dlc *dlc, struct net_buf *buf);
/** DLC sent callback
*
* @param dlc The dlc which has sent data.
* @param err Sent result.
*/
void (*sent)(struct bt_rfcomm_dlc *dlc, int err);
};
/** @brief Role of RFCOMM session and dlc. Used only by internal APIs
*/
typedef enum bt_rfcomm_role {
BT_RFCOMM_ROLE_ACCEPTOR,
BT_RFCOMM_ROLE_INITIATOR
} __packed bt_rfcomm_role_t;
/** @brief RFCOMM DLC structure. */
struct bt_rfcomm_dlc {
/* Response Timeout eXpired (RTX) timer */
struct k_work_delayable rtx_work;
/* Queue for outgoing data */
struct k_fifo tx_queue;
/* TX credits, Reuse as a binary sem for MSC FC if CFC is not enabled */
struct k_sem tx_credits;
struct bt_rfcomm_session *session;
struct bt_rfcomm_dlc_ops *ops;
struct bt_rfcomm_dlc *_next;
bt_security_t required_sec_level;
bt_rfcomm_role_t role;
uint16_t mtu;
uint8_t dlci;
uint8_t state;
uint8_t rx_credit;
/* Stack & kernel data for TX thread */
struct k_thread tx_thread;
#if defined(CONFIG_BT_RFCOMM_DLC_STACK_SIZE)
K_KERNEL_STACK_MEMBER(stack, CONFIG_BT_RFCOMM_DLC_STACK_SIZE);
#endif /* CONFIG_BT_RFCOMM_DLC_STACK_SIZE */
};
struct bt_rfcomm_server {
/** Server Channel */
uint8_t channel;
/** Server accept callback
*
* This callback is called whenever a new incoming connection requires
* authorization.
*
* @param conn The connection that is requesting authorization
* @param dlc Pointer to received the allocated dlc
*
* @return 0 in case of success or negative value in case of error.
*/
int (*accept)(struct bt_conn *conn, struct bt_rfcomm_dlc **dlc);
struct bt_rfcomm_server *_next;
};
/** @brief Register RFCOMM server
*
* Register RFCOMM server for a channel, each new connection is authorized
* using the accept() callback which in case of success shall allocate the dlc
* structure to be used by the new connection.
*
* @param server Server structure.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_rfcomm_server_register(struct bt_rfcomm_server *server);
/** @brief Connect RFCOMM channel
*
* Connect RFCOMM dlc by channel, once the connection is completed dlc
* connected() callback will be called. If the connection is rejected
* disconnected() callback is called instead.
*
* @param conn Connection object.
* @param dlc Dlc object.
* @param channel Server channel to connect to.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_rfcomm_dlc_connect(struct bt_conn *conn, struct bt_rfcomm_dlc *dlc,
uint8_t channel);
/** @brief Send data to RFCOMM
*
* Send data from buffer to the dlc. Length should be less than or equal to
* mtu.
*
* @param dlc Dlc object.
* @param buf Data buffer.
*
* @return Bytes sent in case of success or negative value in case of error.
*/
int bt_rfcomm_dlc_send(struct bt_rfcomm_dlc *dlc, struct net_buf *buf);
/** @brief Disconnect RFCOMM dlc
*
* Disconnect RFCOMM dlc, if the connection is pending it will be
* canceled and as a result the dlc disconnected() callback is called.
*
* @param dlc Dlc object.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_rfcomm_dlc_disconnect(struct bt_rfcomm_dlc *dlc);
/** @brief Allocate the buffer from pool after reserving head room for RFCOMM,
* L2CAP and ACL headers.
*
* @param pool Which pool to take the buffer from.
*
* @return New buffer.
*/
struct net_buf *bt_rfcomm_create_pdu(struct net_buf_pool *pool);
#ifdef __cplusplus
}
#endif
/**
* @}
*/
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_RFCOMM_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/classic/rfcomm.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 1,386 |
```objective-c
/**
* @file
* @brief Header for Bluetooth GMAP LC3 presets.
*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_GMAP_LC3_PRESET_
#define ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_GMAP_LC3_PRESET_
/**
* @brief Gaming Audio Profile (GMAP) LC3 Presets
*
* @defgroup bt_gmap_lc3_preset Gaming Audio Profile (GMAP) LC3 Presets
*
* @since 3.5
* @version 0.8.0
*
* @ingroup bluetooth
* @{
*
* These APIs provide presets for codec configuration and codec QoS based on values supplied by the
* codec configurations from table 3.16 in the GMAP v1.0 specification
*/
#include <zephyr/bluetooth/audio/audio.h>
#include <zephyr/bluetooth/audio/bap_lc3_preset.h>
#include <zephyr/bluetooth/audio/lc3.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Helper to declare LC3 32_1_gr codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_GMAP_LC3_PRESET_32_1_GR(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_32KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_7_5, _loc, 60U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(7500u, 60U, 1U, 15U, 10000U))
/**
* @brief Helper to declare LC3 32_2_gr codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_GMAP_LC3_PRESET_32_2_GR(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_32KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_10, _loc, 80U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(10000u, 80U, 1U, 20U, 10000U))
/**
* @brief Helper to declare LC3 48_1_gr codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_GMAP_LC3_PRESET_48_1_GR(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_48KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_7_5, _loc, 75U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(7500u, 75U, 1U, 15U, 10000U))
/**
* @brief Helper to declare LC3 48_2_gr codec configuration
*
* Mandatory to support as both unicast client and server
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_GMAP_LC3_PRESET_48_2_GR(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_48KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_10, _loc, 100U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(10000u, 100U, 1U, 20U, 10000U))
/**
* @brief Helper to declare LC3 48_3_gr codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_GMAP_LC3_PRESET_48_3_GR(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_48KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_7_5, _loc, 90U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(7500u, 90U, 1U, 15U, 10000U))
/**
* @brief Helper to declare LC3 48_4_gr codec configuration
*
* Mandatory to support as unicast server
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_GMAP_LC3_PRESET_48_4_GR(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_48KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_10, _loc, 120u, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(10000u, 120U, 1U, 20U, 10000U))
/**
* @brief Helper to declare LC3 16_1_gs codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_GMAP_LC3_PRESET_16_1_GS(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_16KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_7_5, _loc, 30U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(7500u, 30U, 1U, 15U, 60000U))
/**
* @brief Helper to declare LC3 16_2_gs codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_GMAP_LC3_PRESET_16_2_GS(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_16KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_10, _loc, 40U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(10000u, 40U, 1U, 20U, 60000U))
/**
* @brief Helper to declare LC3 32_1_gs codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_GMAP_LC3_PRESET_32_1_GS(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_32KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_7_5, _loc, 60U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(7500u, 60U, 1U, 15U, 60000U))
/**
* @brief Helper to declare LC3 32_2_gs codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_GMAP_LC3_PRESET_32_2_GS(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_32KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_10, _loc, 80U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(10000u, 80U, 1U, 20U, 60000U))
/**
* @brief Helper to declare LC3 48_1_gs codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_GMAP_LC3_PRESET_48_1_GS(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_48KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_7_5, _loc, 75U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(7500u, 75U, 1U, 15U, 60000U))
/**
* @brief Helper to declare LC3 48_2_gs codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_GMAP_LC3_PRESET_48_2_GS(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_48KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_10, _loc, 100U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(10000u, 100U, 1U, 20U, 60000U))
/* GMAP LC3 broadcast presets defined by table 3.22 in the GMAP v1.0 specification */
/**
* @brief Helper to declare LC3 48_1_g codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_GMAP_LC3_PRESET_48_1_G(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_48KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_7_5, _loc, 75U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(7500u, 75U, 1U, 8U, 10000U))
/**
* @brief Helper to declare LC3 48_2_g codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_GMAP_LC3_PRESET_48_2_G(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_48KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_10, _loc, 100U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(10000u, 100U, 1U, 10U, 10000U))
/**
* @brief Helper to declare LC3 48_3_g codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_GMAP_LC3_PRESET_48_3_G(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_48KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_7_5, _loc, 90U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(7500u, 90U, 1U, 8U, 10000U))
/**
* @brief Helper to declare LC3 48_4_g codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_GMAP_LC3_PRESET_48_4_G(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_48KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_10, _loc, 120u, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(10000u, 120U, 1U, 10U, 10000U))
#ifdef __cplusplus
}
#endif
/** @} */
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_GMAP_LC3_PRESET_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/audio/gmap_lc3_preset.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 2,945 |
```objective-c
/**
* @file
* @brief Bluetooth Audio Input Control Service APIs.
*/
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_AICS_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_AICS_H_
/**
* @brief Audio Input Control Service (AICS)
*
* @defgroup bt_gatt_aics Audio Input Control Service (AICS)
*
* @since 2.6
* @version 0.8.0
*
* @ingroup bluetooth
* @{
*
* The Audio Input Control Service is a secondary service, and as such should not be used on its
* own, but rather in the context of another (primary) service.
*
* This API implements both the server and client functionality.
* Note that the API abstracts away the change counter in the audio input control state and will
* automatically handle any changes to that. If out of date, the client implementation will
* autonomously read the change counter value when executing a write request.
*
*/
#include <stdint.h>
#include <stdbool.h>
#include <zephyr/autoconf.h>
#include <zephyr/bluetooth/bluetooth.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @name Audio Input Control Service mute states
* @{
*/
/** The mute state is unmuted */
#define BT_AICS_STATE_UNMUTED 0x00
/** The mute state is muted */
#define BT_AICS_STATE_MUTED 0x01
/** The mute state is disabled */
#define BT_AICS_STATE_MUTE_DISABLED 0x02
/** @} */
/**
* @name Audio Input Control Service input modes
* @{
*/
/**
* @brief The gain mode is manual only and cannot be changed to automatic.
*
* The gain can be controlled by the client.
*/
#define BT_AICS_MODE_MANUAL_ONLY 0x00
/**
* @brief The gain mode is automatic only and cannot be changed to manual.
*
* The gain cannot be controlled by the client.
*/
#define BT_AICS_MODE_AUTO_ONLY 0x01
/**
* @brief The gain mode is manual.
*
* The gain can be controlled by the client.
*/
#define BT_AICS_MODE_MANUAL 0x02
/**
* @brief The gain mode is automatic.
*
* The gain cannot be controlled by the client.
*/
#define BT_AICS_MODE_AUTO 0x03
/** @} */
/**
* @name Audio Input Control Service input types
* @{
*/
/** The input is unspecified */
#define BT_AICS_INPUT_TYPE_UNSPECIFIED 0x00
/** The input is a Bluetooth Audio Stream */
#define BT_AICS_INPUT_TYPE_BLUETOOTH 0x01
/** The input is a microphone */
#define BT_AICS_INPUT_TYPE_MICROPHONE 0x02
/** The input is analog */
#define BT_AICS_INPUT_TYPE_ANALOG 0x03
/** The input is digital */
#define BT_AICS_INPUT_TYPE_DIGITAL 0x04
/** The input is a radio (AM/FM/XM/etc.) */
#define BT_AICS_INPUT_TYPE_RADIO 0x05
/** The input is a Streaming Audio Source */
#define BT_AICS_INPUT_TYPE_STREAMING 0x06
/** The input is transparent / pass-through */
#define BT_AICS_INPUT_TYPE_AMBIENT 0x07
/** @} */
/**
* @name Audio Input Control Service Error codes
* @{
*/
/**
* The Change_Counter operand value does not match the Change_Counter field value of the
* Audio Input State characteristic.
*/
#define BT_AICS_ERR_INVALID_COUNTER 0x80
/** An invalid opcode has been used in a control point procedure */
#define BT_AICS_ERR_OP_NOT_SUPPORTED 0x81
/** Mute/unmute commands are disabled.(see @ref BT_AICS_STATE_MUTE_DISABLED) */
#define BT_AICS_ERR_MUTE_DISABLED 0x82
/** An operand value used in a control point procedure is outside the permissible range */
#define BT_AICS_ERR_OUT_OF_RANGE 0x83
/** A requested gain mode change is not allowed */
#define BT_AICS_ERR_GAIN_MODE_NOT_ALLOWED 0x84
/** @} */
/** @brief Opaque Audio Input Control Service instance. */
struct bt_aics;
/** @brief Structure for initializing a Audio Input Control Service instance. */
struct bt_aics_register_param {
/** Initial audio input gain (-128 to 127) */
int8_t gain;
/** Initial audio input mute state */
uint8_t mute;
/** Initial audio input mode */
uint8_t gain_mode;
/** Initial audio input gain units (N * 0.1 dB) */
uint8_t units;
/** Initial audio input minimum gain */
int8_t min_gain;
/** Initial audio input maximum gain */
int8_t max_gain;
/** Initial audio input type */
uint8_t type;
/** Initial audio input status (active/inactive) */
bool status;
/** Boolean to set whether the description is writable by clients */
bool desc_writable;
/** Initial audio input description */
char *description;
/** Pointer to the callback structure. */
struct bt_aics_cb *cb;
};
/** @brief Structure for discovering a Audio Input Control Service instance. */
struct bt_aics_discover_param {
/**
* @brief The start handle of the discovering.
*
* Typically the @p start_handle of a @ref bt_gatt_include.
*/
uint16_t start_handle;
/**
* @brief The end handle of the discovering.
*
* Typically the @p end_handle of a @ref bt_gatt_include.
*/
uint16_t end_handle;
};
/**
* @brief Get a free instance of Audio Input Control Service from the pool.
*
* @return Audio Input Control Service instance in case of success or NULL in case of error.
*/
struct bt_aics *bt_aics_free_instance_get(void);
/**
* @brief Get the service declaration attribute.
*
* The first service attribute returned can be included in any other GATT service.
*
* @param aics Audio Input Control Service instance.
*
* @return Pointer to the attributes of the service.
*/
void *bt_aics_svc_decl_get(struct bt_aics *aics);
/**
* @brief Get the connection pointer of a client instance
*
* Get the Bluetooth connection pointer of a Audio Input Control Service
* client instance.
*
* @param aics Audio Input Control Service client instance pointer.
* @param conn Connection pointer.
*
* @return 0 if success, errno on failure.
*/
int bt_aics_client_conn_get(const struct bt_aics *aics, struct bt_conn **conn);
/**
* @brief Initialize the Audio Input Control Service instance.
*
* @param aics Audio Input Control Service instance.
* @param param Audio Input Control Service register parameters.
*
* @return 0 if success, errno on failure.
*/
int bt_aics_register(struct bt_aics *aics, struct bt_aics_register_param *param);
/**
* @brief Callback function for writes.
*
* @param inst The instance pointer.
* @param err Error value. 0 on success, GATT error on positive value
* or errno on negative value.
*/
typedef void (*bt_aics_write_cb)(struct bt_aics *inst, int err);
/**
* @brief Callback function for the input state.
*
* Called when the value is read,
* or if the value is changed by either the server or client.
*
* @param inst The instance pointer.
* @param err Error value. 0 on success, GATT error on positive value
* or errno on negative value.
* For notifications, this will always be 0.
* @param gain The gain setting value.
* @param mute The mute value.
* @param mode The mode value.
*/
typedef void (*bt_aics_state_cb)(struct bt_aics *inst, int err, int8_t gain,
uint8_t mute, uint8_t mode);
/**
* @brief Callback function for the gain settings.
*
* Called when the value is read,
* or if the value is changed by either the server or client.
*
* @param inst The instance pointer.
* @param err Error value. 0 on success, GATT error on positive value
* or errno on negative value.
* For notifications, this will always be 0.
* @param units The value that reflect the size of a single increment or decrement of the
* Gain Setting value in 0.1 decibel units.
* @param minimum The minimum gain allowed for the gain setting.
* @param maximum The maximum gain allowed for the gain setting.
*/
typedef void (*bt_aics_gain_setting_cb)(struct bt_aics *inst, int err,
uint8_t units, int8_t minimum,
int8_t maximum);
/**
* @brief Callback function for the input type.
*
* Called when the value is read, or if the value is changed by either the server or client.
*
* @param inst The instance pointer.
* @param err Error value. 0 on success, GATT error on positive value
* or errno on negative value.
* For notifications, this will always be 0.
* @param type The input type.
*/
typedef void (*bt_aics_type_cb)(struct bt_aics *inst, int err, uint8_t type);
/**
* @brief Callback function for the input status.
*
* Called when the value is read, or if the value is changed by either the server or client.
*
* @param inst The instance pointer.
* @param err Error value. 0 on success, GATT error on positive value
* or errno on negative value.
* For notifications, this will always be 0.
* @param active Whether the instance is active or inactive.
*/
typedef void (*bt_aics_status_cb)(struct bt_aics *inst, int err, bool active);
/**
* @brief Callback function for the description.
*
* Called when the value is read, or if the value is changed by either the server or client.
*
* @param inst The instance pointer.
* @param err Error value. 0 on success, GATT error on positive value
* or errno on negative value.
* For notifications, this will always be 0.
* @param description The description as an UTF-8 encoded string (may have been clipped).
*/
typedef void (*bt_aics_description_cb)(struct bt_aics *inst, int err,
char *description);
/**
* @brief Callback function for bt_aics_discover.
*
* This callback will usually be overwritten by the primary service that
* includes the Audio Input Control Service client.
*
* @param inst The instance pointer.
* @param err Error value. 0 on success, GATT error on positive value
* or errno on negative value.
* For notifications, this will always be 0.
*/
typedef void (*bt_aics_discover_cb)(struct bt_aics *inst, int err);
/**
* @brief Struct to hold callbacks for the Audio Input Control Service.
*
* Used by both clients and servers
*/
struct bt_aics_cb {
/** The audio input state has changed */
bt_aics_state_cb state;
/** The gain setting has changed */
bt_aics_gain_setting_cb gain_setting;
/** The audio input type has changed */
bt_aics_type_cb type;
/** The audio input status has changed */
bt_aics_status_cb status;
/** The audio input decscription has changed */
bt_aics_description_cb description;
#if defined(CONFIG_BT_AICS_CLIENT) || defined(__DOXYGEN__)
/** The discovery has completed */
bt_aics_discover_cb discover;
/** The set gain operation has completed */
bt_aics_write_cb set_gain;
/** The unmute operation has completed */
bt_aics_write_cb unmute;
/** The mut operation has completed */
bt_aics_write_cb mute;
/** The set manual mode operation has completed */
bt_aics_write_cb set_manual_mode;
/** The set automatic mode has completed */
bt_aics_write_cb set_auto_mode;
#endif /* CONFIG_BT_AICS_CLIENT */
};
/**
* @brief Discover a Audio Input Control Service.
*
* Attempts to discover a Audio Input Control Service on a server given the
* @p param.
*
* @param conn Connection to the peer with the Audio Input Control Service.
* @param inst The instance pointer.
* @param param Pointer to the parameters.
*
* @return 0 on success, errno on fail.
*/
int bt_aics_discover(struct bt_conn *conn, struct bt_aics *inst,
const struct bt_aics_discover_param *param);
/**
* @brief Deactivates a Audio Input Control Service instance.
*
* Audio Input Control Services are activated by default, but this will allow
* the server to deactivate an Audio Input Control Service.
*
* @param inst The instance pointer.
*
* @return 0 if success, errno on failure.
*/
int bt_aics_deactivate(struct bt_aics *inst);
/**
* @brief Activates a Audio Input Control Service instance.
*
* Audio Input Control Services are activated by default, but this will allow
* the server reactivate a Audio Input Control Service instance after it has
* been deactivated with @ref bt_aics_deactivate.
*
* @param inst The instance pointer.
*
* @return 0 if success, errno on failure.
*/
int bt_aics_activate(struct bt_aics *inst);
/**
* @brief Read the Audio Input Control Service input state.
*
* @param inst The instance pointer.
*
* @return 0 on success, GATT error value on fail.
*/
int bt_aics_state_get(struct bt_aics *inst);
/**
* @brief Read the Audio Input Control Service gain settings.
*
* @param inst The instance pointer.
*
* @return 0 on success, GATT error value on fail.
*/
int bt_aics_gain_setting_get(struct bt_aics *inst);
/**
* @brief Read the Audio Input Control Service input type.
*
* @param inst The instance pointer.
*
* @return 0 on success, GATT error value on fail.
*/
int bt_aics_type_get(struct bt_aics *inst);
/**
* @brief Read the Audio Input Control Service input status.
*
* @param inst The instance pointer.
*
* @return 0 on success, GATT error value on fail.
*/
int bt_aics_status_get(struct bt_aics *inst);
/**
* @brief Disable mute in the Audio Input Control Service.
*
* Calling bt_aics_unmute() or bt_aics_mute() will enable
* mute again and set the mute state to either unmuted or muted.
*
* @param inst The instance pointer.
*
* @return 0 on success, errno value on fail.
*/
int bt_aics_disable_mute(struct bt_aics *inst);
/**
* @brief Unmute the Audio Input Control Service input.
*
* @param inst The instance pointer.
*
* @return 0 on success, GATT error value on fail.
*/
int bt_aics_unmute(struct bt_aics *inst);
/**
* @brief Mute the Audio Input Control Service input.
*
* @param inst The instance pointer.
*
* @return 0 on success, GATT error value on fail.
*/
int bt_aics_mute(struct bt_aics *inst);
/**
* @brief Set manual only gain mode in Audio Input Control Service.
*
* @param inst The instance pointer.
*
* @return 0 on success, errno value on fail.
*/
int bt_aics_gain_set_manual_only(struct bt_aics *inst);
/**
* @brief Set automatic only gain mode in Audio Input Control Service.
*
* Using this function and enabling automatic only gain disables
* setting the gain with bt_aics_gain_set
*
* @param inst The instance pointer.
*
* @return 0 on success, errno value on fail.
*/
int bt_aics_gain_set_auto_only(struct bt_aics *inst);
/**
* @brief Set input gain to manual.
*
* @param inst The instance pointer.
*
* @return 0 on success, GATT error value on fail.
*/
int bt_aics_manual_gain_set(struct bt_aics *inst);
/**
* @brief Set the input gain to automatic.
*
* @param inst The instance pointer.
*
* @return 0 on success, GATT error value on fail.
*/
int bt_aics_automatic_gain_set(struct bt_aics *inst);
/**
* @brief Set the input gain.
*
* @param inst The instance pointer.
* @param gain The gain to set (-128 to 127) in gain setting units
* (see @ref bt_aics_gain_setting_cb).
*
* @return 0 on success, GATT error value on fail.
*/
int bt_aics_gain_set(struct bt_aics *inst, int8_t gain);
/**
* @brief Read the Audio Input Control Service description.
*
* @param inst The instance pointer.
*
* @return 0 on success, GATT error value on fail.
*/
int bt_aics_description_get(struct bt_aics *inst);
/**
* @brief Set the Audio Input Control Service description.
*
* @param inst The instance pointer.
* @param description The description as an UTF-8 encoded string.
*
* @return 0 on success, GATT error value on fail.
*/
int bt_aics_description_set(struct bt_aics *inst, const char *description);
/**
* @brief Get a new Audio Input Control Service client instance.
*
* @return Pointer to the instance, or NULL if no free instances are left.
*/
struct bt_aics *bt_aics_client_free_instance_get(void);
/**
* @brief Registers the callbacks for the Audio Input Control Service client.
*
* @param inst The instance pointer.
* @param cb Pointer to the callback structure.
*/
void bt_aics_client_cb_register(struct bt_aics *inst, struct bt_aics_cb *cb);
#ifdef __cplusplus
}
#endif
/**
* @}
*/
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_AICS_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/audio/aics.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 3,859 |
```objective-c
/**
* @file
* @brief Bluetooth Hearing Access Service (HAS) APIs.
*/
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_HAS_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_HAS_H_
/**
* @brief Hearing Access Service (HAS)
*
* @defgroup bt_has Hearing Access Service (HAS)
*
* @since 3.1
* @version 0.8.0
*
* @ingroup bluetooth
* @{
*
* The Hearing Access Service is used to identify a hearing aid and optionally
* to control hearing aid presets.
*/
#include <stdint.h>
#include <stdbool.h>
#include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/sys/util.h>
#include <zephyr/sys/util_macro.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @name Preset index definitions
* @{
*/
/** No index */
#define BT_HAS_PRESET_INDEX_NONE 0x00
/** First preset index */
#define BT_HAS_PRESET_INDEX_FIRST 0x01
/** Last preset index */
#define BT_HAS_PRESET_INDEX_LAST 0xFF
/** @} */
/** Preset name minimum length */
#define BT_HAS_PRESET_NAME_MIN 1
/** Preset name maximum length */
#define BT_HAS_PRESET_NAME_MAX 40
/** @brief Opaque Hearing Access Service object. */
struct bt_has;
/** Hearing Aid device type */
enum bt_has_hearing_aid_type {
/**
* Two hearing aids that form a Coordinated Set, one for the right ear and one for the left
* ear of the user. Typically used by a user with bilateral hearing loss.
*/
BT_HAS_HEARING_AID_TYPE_BINAURAL = 0x00,
/**
* A single hearing aid for the left or the right ear. Typically used by a user with
* unilateral hearing loss.
*/
BT_HAS_HEARING_AID_TYPE_MONAURAL = 0x01,
/**
* Two hearing aids with a connection to one another that expose a single Bluetooth radio
* interface.
*/
BT_HAS_HEARING_AID_TYPE_BANDED = 0x02,
};
/** Preset Properties values */
enum bt_has_properties {
/** No properties set */
BT_HAS_PROP_NONE = 0,
/** Preset name can be written by the client */
BT_HAS_PROP_WRITABLE = BIT(0),
/** Preset availability */
BT_HAS_PROP_AVAILABLE = BIT(1),
};
/** Hearing Aid device capabilities */
enum bt_has_capabilities {
/** Indicate support for presets */
BT_HAS_PRESET_SUPPORT = BIT(0),
};
/** @brief Structure for registering features of a Hearing Access Service instance. */
struct bt_has_features_param {
/** Hearing Aid Type value */
enum bt_has_hearing_aid_type type;
/**
* @brief Preset Synchronization Support.
*
* Only applicable if @p type is @ref BT_HAS_HEARING_AID_TYPE_BINAURAL
* and @kconfig{CONFIG_BT_HAS_PRESET_COUNT} is non-zero.
*/
bool preset_sync_support;
/**
* @brief Independent Presets.
*
* Only applicable if @p type is @ref BT_HAS_HEARING_AID_TYPE_BINAURAL
* and @kconfig{CONFIG_BT_HAS_PRESET_COUNT} is non-zero.
*/
bool independent_presets;
};
/** @brief Preset record definition */
struct bt_has_preset_record {
/** Unique preset index. */
uint8_t index;
/** Bitfield of preset properties. */
enum bt_has_properties properties;
/** Preset name. */
const char *name;
};
/** @brief Hearing Access Service Client callback structure. */
struct bt_has_client_cb {
/**
* @brief Callback function for bt_has_discover.
*
* This callback is called when discovery procedure is complete.
*
* @param conn Bluetooth connection object.
* @param err 0 on success, ATT error or negative errno otherwise.
* @param has Pointer to the Hearing Access Service object or NULL on errors.
* @param type Hearing Aid type.
* @param caps Hearing Aid capabilities.
*/
void (*discover)(struct bt_conn *conn, int err, struct bt_has *has,
enum bt_has_hearing_aid_type type, enum bt_has_capabilities caps);
/**
* @brief Callback function for Hearing Access Service active preset changes.
*
* Optional callback called when the active preset is changed by the remote server when the
* preset switch procedure is complete. The callback must be set to receive active preset
* changes and enable support for switching presets. If the callback is not set, the Active
* Index and Control Point characteristics will not be discovered by
* @ref bt_has_client_discover.
*
* @param has Pointer to the Hearing Access Service object.
* @param err 0 on success, ATT error or negative errno otherwise.
* @param index Active preset index.
*/
void (*preset_switch)(struct bt_has *has, int err, uint8_t index);
/**
* @brief Callback function for presets read operation.
*
* The callback is called when the preset read response is sent by the remote server.
* The record object as well as its members are temporary and must be copied to in order
* to cache its information.
*
* @param has Pointer to the Hearing Access Service object.
* @param err 0 on success, ATT error or negative errno otherwise.
* @param record Preset record or NULL on errors.
* @param is_last True if Read Presets operation can be considered concluded.
*/
void (*preset_read_rsp)(struct bt_has *has, int err,
const struct bt_has_preset_record *record, bool is_last);
/**
* @brief Callback function for preset update notifications.
*
* The callback is called when the preset record update is notified by the remote server.
* The record object as well as its objects are temporary and must be copied to in order
* to cache its information.
*
* @param has Pointer to the Hearing Access Service object.
* @param index_prev Index of the previous preset in the list.
* @param record Preset record.
* @param is_last True if preset list update operation can be considered concluded.
*/
void (*preset_update)(struct bt_has *has, uint8_t index_prev,
const struct bt_has_preset_record *record, bool is_last);
/**
* @brief Callback function for preset deletion notifications.
*
* The callback is called when the preset has been deleted by the remote server.
*
* @param has Pointer to the Hearing Access Service object.
* @param index Preset index.
* @param is_last True if preset list update operation can be considered concluded.
*/
void (*preset_deleted)(struct bt_has *has, uint8_t index, bool is_last);
/**
* @brief Callback function for preset availability notifications.
*
* The callback is called when the preset availability change is notified by the remote
* server.
*
* @param has Pointer to the Hearing Access Service object.
* @param index Preset index.
* @param available True if available, false otherwise.
* @param is_last True if preset list update operation can be considered concluded.
*/
void (*preset_availability)(struct bt_has *has, uint8_t index, bool available,
bool is_last);
};
/**
* @brief Registers the callbacks used by the Hearing Access Service client.
*
* @param cb The callback structure.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_has_client_cb_register(const struct bt_has_client_cb *cb);
/**
* @brief Discover Hearing Access Service on a remote device.
*
* Client method to find a Hearing Access Service on a server identified by @p conn.
* The @ref bt_has_client_cb.discover callback will be called when the discovery procedure
* is complete to provide user a @ref bt_has object.
*
* @param conn Bluetooth connection object.
*
* @return 0 if success, errno on failure.
*/
int bt_has_client_discover(struct bt_conn *conn);
/**
* @brief Get the Bluetooth connection object of the service object.
*
* The caller gets a new reference to the connection object which must be
* released with bt_conn_unref() once done using the object.
*
* @param[in] has Pointer to the Hearing Access Service object.
* @param[out] conn Connection object.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_has_client_conn_get(const struct bt_has *has, struct bt_conn **conn);
/**
* @brief Read Preset Records.
*
* Client method to read up to @p max_count presets starting from given @p index.
* The preset records are returned in the @ref bt_has_client_cb.preset_read_rsp callback
* (called once for each preset).
*
* @param has Pointer to the Hearing Access Service object.
* @param index The index to start with.
* @param max_count Maximum number of presets to read.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_has_client_presets_read(struct bt_has *has, uint8_t index, uint8_t max_count);
/**
* @brief Set Active Preset.
*
* Client procedure to set preset identified by @p index as active.
* The status is returned in the @ref bt_has_client_cb.preset_switch callback.
*
* @param has Pointer to the Hearing Access Service object.
* @param index Preset index to activate.
* @param sync Request active preset synchronization in set.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_has_client_preset_set(struct bt_has *has, uint8_t index, bool sync);
/**
* @brief Activate Next Preset.
*
* Client procedure to set next available preset as active.
* The status is returned in the @ref bt_has_client_cb.preset_switch callback.
*
* @param has Pointer to the Hearing Access Service object.
* @param sync Request active preset synchronization in set.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_has_client_preset_next(struct bt_has *has, bool sync);
/**
* @brief Activate Previous Preset.
*
* Client procedure to set previous available preset as active.
* The status is returned in the @ref bt_has_client_cb.preset_switch callback.
*
* @param has Pointer to the Hearing Access Service object.
* @param sync Request active preset synchronization in set.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_has_client_preset_prev(struct bt_has *has, bool sync);
/** @brief Preset operations structure. */
struct bt_has_preset_ops {
/**
* @brief Preset select callback.
*
* This callback is called when the client requests to select preset identified by
* @p index.
*
* @param index Preset index requested to activate.
* @param sync Whether the server must relay this change to the other member of the
* Binaural Hearing Aid Set.
*
* @return 0 in case of success or negative value in case of error.
* @return -EBUSY if operation cannot be performed at the time.
* @return -EINPROGRESS in case where user has to confirm once the requested preset
* becomes active by calling @ref bt_has_preset_active_set.
*/
int (*select)(uint8_t index, bool sync);
/**
* @brief Preset name changed callback
*
* This callback is called when the name of the preset identified by @p index has changed.
*
* @param index Preset index that name has been changed.
* @param name Preset current name.
*/
void (*name_changed)(uint8_t index, const char *name);
};
/** @brief Register structure for preset. */
struct bt_has_preset_register_param {
/**
* @brief Preset index.
*
* Unique preset identifier. The value shall be other than @ref BT_HAS_PRESET_INDEX_NONE.
*/
uint8_t index;
/**
* @brief Preset properties.
*
* Bitfield of preset properties.
*/
enum bt_has_properties properties;
/**
* @brief Preset name.
*
* Preset name that further can be changed by either server or client if
* @kconfig{CONFIG_BT_HAS_PRESET_NAME_DYNAMIC} configuration option has been enabled.
* It's length shall be greater than @ref BT_HAS_PRESET_NAME_MIN. If the length exceeds
* @ref BT_HAS_PRESET_NAME_MAX, the name will be truncated.
*/
const char *name;
/** Preset operations structure. */
const struct bt_has_preset_ops *ops;
};
/**
* @brief Register the Hearing Access Service instance.
*
* @param features Hearing Access Service register parameters.
*
* @return 0 if success, errno on failure.
*/
int bt_has_register(const struct bt_has_features_param *features);
/**
* @brief Register preset.
*
* Register preset. The preset will be a added to the list of exposed preset records.
* This symbol is linkable if @kconfig{CONFIG_BT_HAS_PRESET_COUNT} is non-zero.
*
* @param param Preset registration parameter.
*
* @return 0 if success, errno on failure.
*/
int bt_has_preset_register(const struct bt_has_preset_register_param *param);
/**
* @brief Unregister Preset.
*
* Unregister preset. The preset will be removed from the list of preset records.
*
* @param index The index of preset that's being requested to unregister.
*
* @return 0 if success, errno on failure.
*/
int bt_has_preset_unregister(uint8_t index);
/**
* @brief Set the preset as available.
*
* Set the @ref BT_HAS_PROP_AVAILABLE property bit. This will notify preset availability
* to peer devices. Only available preset can be selected as active preset.
*
* @param index The index of preset that's became available.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_has_preset_available(uint8_t index);
/**
* @brief Set the preset as unavailable.
*
* Clear the @ref BT_HAS_PROP_AVAILABLE property bit. This will notify preset availability
* to peer devices. Unavailable preset cannot be selected as active preset.
*
* @param index The index of preset that's became unavailable.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_has_preset_unavailable(uint8_t index);
/** Enum for return values for @ref bt_has_preset_func_t functions */
enum {
/** Stop iterating */
BT_HAS_PRESET_ITER_STOP = 0,
/** Continue iterating */
BT_HAS_PRESET_ITER_CONTINUE,
};
/**
* @typedef bt_has_preset_func_t
* @brief Preset iterator callback.
*
* @param index The index of preset found.
* @param properties Preset properties.
* @param name Preset name.
* @param user_data Data given.
*
* @return BT_HAS_PRESET_ITER_CONTINUE if should continue to the next preset.
* @return BT_HAS_PRESET_ITER_STOP to stop.
*/
typedef uint8_t (*bt_has_preset_func_t)(uint8_t index, enum bt_has_properties properties,
const char *name, void *user_data);
/**
* @brief Preset iterator.
*
* Iterate presets. Optionally, match non-zero index if given.
*
* @param index Preset index, passing @ref BT_HAS_PRESET_INDEX_NONE skips index matching.
* @param func Callback function.
* @param user_data Data to pass to the callback.
*/
void bt_has_preset_foreach(uint8_t index, bt_has_preset_func_t func, void *user_data);
/**
* @brief Set active preset.
*
* Function used to set the preset identified by the @p index as the active preset.
* The preset index will be notified to peer devices.
*
* @param index Preset index.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_has_preset_active_set(uint8_t index);
/**
* @brief Get active preset.
*
* Function used to get the currently active preset index.
*
* @return Active preset index.
*/
uint8_t bt_has_preset_active_get(void);
/**
* @brief Clear out active preset.
*
* Used by server to deactivate currently active preset.
*
* @return 0 in case of success or negative value in case of error.
*/
static inline int bt_has_preset_active_clear(void)
{
return bt_has_preset_active_set(BT_HAS_PRESET_INDEX_NONE);
}
/**
* @brief Change the Preset Name.
*
* Change the name of the preset identified by @p index.
*
* @param index The index of the preset to change the name of.
* @param name Name to write.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_has_preset_name_change(uint8_t index, const char *name);
/**
* @brief Change the Hearing Aid Features.
*
* Change the hearing aid features.
*
* @param features The features to be set.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_has_features_set(const struct bt_has_features_param *features);
#ifdef __cplusplus
}
#endif
/**
* @}
*/
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_HAS_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/audio/has.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 3,756 |
```objective-c
/**
* @file
* @brief Bluetooth Media Control Client (MCC) APIs.
*/
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_MCC_
#define ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_MCC_
/**
* @brief Bluetooth Media Control Client (MCC) interface
*
* Updated to the Media Control Profile specification revision 1.0
*
* @defgroup bt_gatt_mcc Media Control Client (MCC)
*
* @since 3.0
* @version 0.8.0
*
* @ingroup bluetooth
* @{
*/
#include <stdint.h>
#include <stdbool.h>
#include <zephyr/bluetooth/conn.h>
#include <zephyr/net/buf.h>
#include <zephyr/bluetooth/audio/media_proxy.h>
#ifdef __cplusplus
extern "C" {
#endif
/**** Callback functions ******************************************************/
/**
* @brief Callback function for bt_mcc_discover_mcs()
*
* Called when a media control server is discovered
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
*/
typedef void (*bt_mcc_discover_mcs_cb)(struct bt_conn *conn, int err);
/**
* @brief Callback function for bt_mcc_read_player_name()
*
* Called when the player name is read or notified
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param name Player name
*/
typedef void (*bt_mcc_read_player_name_cb)(struct bt_conn *conn, int err, const char *name);
/**
* @brief Callback function for bt_mcc_read_icon_obj_id()
*
* Called when the icon object ID is read
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param icon_id The ID of the Icon Object. This is a UINT48 in a uint64_t
*/
typedef void (*bt_mcc_read_icon_obj_id_cb)(struct bt_conn *conn, int err, uint64_t icon_id);
/**
* @brief Callback function for bt_mcc_read_icon_url()
*
* Called when the icon URL is read
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param icon_url The URL of the Icon
*/
typedef void (*bt_mcc_read_icon_url_cb)(struct bt_conn *conn, int err, const char *icon_url);
/**
* @brief Callback function for track changed notifications
*
* Called when a track change is notified.
*
* The track changed characteristic is a special case. It can not be read or
* set, it can only be notified.
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
*/
typedef void (*bt_mcc_track_changed_ntf_cb)(struct bt_conn *conn, int err);
/**
* @brief Callback function for bt_mcc_read_track_title()
*
* Called when the track title is read or notified
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param title The title of the track
*/
typedef void (*bt_mcc_read_track_title_cb)(struct bt_conn *conn, int err, const char *title);
/**
* @brief Callback function for bt_mcc_read_track_duration()
*
* Called when the track duration is read or notified
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param dur The duration of the track
*/
typedef void (*bt_mcc_read_track_duration_cb)(struct bt_conn *conn, int err, int32_t dur);
/**
* @brief Callback function for bt_mcc_read_track_position()
*
* Called when the track position is read or notified
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param pos The Track Position
*/
typedef void (*bt_mcc_read_track_position_cb)(struct bt_conn *conn, int err, int32_t pos);
/**
* @brief Callback function for bt_mcc_set_track_position()
*
* Called when the track position is set
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param pos The Track Position set (or attempted to set)
*/
typedef void (*bt_mcc_set_track_position_cb)(struct bt_conn *conn, int err, int32_t pos);
/**
* @brief Callback function for bt_mcc_read_playback_speed()
*
* Called when the playback speed is read or notified
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param speed The Playback Speed
*/
typedef void (*bt_mcc_read_playback_speed_cb)(struct bt_conn *conn, int err, int8_t speed);
/**
* @brief Callback function for bt_mcc_set_playback_speed()
*
* Called when the playback speed is set
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param speed The Playback Speed set (or attempted to set)
*/
typedef void (*bt_mcc_set_playback_speed_cb)(struct bt_conn *conn, int err, int8_t speed);
/**
* @brief Callback function for bt_mcc_read_seeking_speed()
*
* Called when the seeking speed is read or notified
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param speed The Seeking Speed
*/
typedef void (*bt_mcc_read_seeking_speed_cb)(struct bt_conn *conn, int err, int8_t speed);
/**
* @brief Callback function for bt_mcc_read_segments_obj_id()
*
* Called when the track segments object ID is read
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param id The Track Segments Object ID (UINT48)
*/
typedef void (*bt_mcc_read_segments_obj_id_cb)(struct bt_conn *conn, int err, uint64_t id);
/**
* @brief Callback function for bt_mcc_read_current_track_obj_id()
*
* Called when the current track object ID is read or notified
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param id The Current Track Object ID (UINT48)
*/
typedef void (*bt_mcc_read_current_track_obj_id_cb)(struct bt_conn *conn, int err, uint64_t id);
/**
* @brief Callback function for bt_mcc_set_current_track_obj_id()
*
* Called when the current track object ID is set
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param id The Object ID (UINT48) set (or attempted to set)
*/
typedef void (*bt_mcc_set_current_track_obj_id_cb)(struct bt_conn *conn, int err, uint64_t id);
/**
* @brief Callback function for bt_mcc_read_next_track_obj_id_obj()
*
* Called when the next track object ID is read or notified
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param id The Next Track Object ID (UINT48)
*/
typedef void (*bt_mcc_read_next_track_obj_id_cb)(struct bt_conn *conn, int err, uint64_t id);
/**
* @brief Callback function for bt_mcc_set_next_track_obj_id()
*
* Called when the next track object ID is set
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param id The Object ID (UINT48) set (or attempted to set)
*/
typedef void (*bt_mcc_set_next_track_obj_id_cb)(struct bt_conn *conn, int err, uint64_t id);
/**
* @brief Callback function for bt_mcc_read_parent_group_obj_id()
*
* Called when the parent group object ID is read or notified
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param id The Parent Group Object ID (UINT48)
*/
typedef void (*bt_mcc_read_parent_group_obj_id_cb)(struct bt_conn *conn, int err, uint64_t id);
/**
* @brief Callback function for bt_mcc_read_current_group_obj_id()
*
* Called when the current group object ID is read or notified
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param id The Current Group Object ID (UINT48)
*/
typedef void (*bt_mcc_read_current_group_obj_id_cb)(struct bt_conn *conn, int err, uint64_t id);
/**
* @brief Callback function for bt_mcc_set_current_group_obj_id()
*
* Called when the current group object ID is set
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param obj_id The Object ID (UINT48) set (or attempted to set)
*/
typedef void (*bt_mcc_set_current_group_obj_id_cb)(struct bt_conn *conn, int err, uint64_t obj_id);
/**
* @brief Callback function for bt_mcc_read_playing_order()
*
* Called when the playing order is read or notified
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param order The playback order
*/
typedef void (*bt_mcc_read_playing_order_cb)(struct bt_conn *conn, int err, uint8_t order);
/**
* @brief Callback function for bt_mcc_set_playing_order()
*
* Called when the playing order is set
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param order The Playing Order set (or attempted to set)
*/
typedef void (*bt_mcc_set_playing_order_cb)(struct bt_conn *conn, int err, uint8_t order);
/**
* @brief Callback function for bt_mcc_read_playing_orders_supported()
*
* Called when the supported playing orders are read or notified
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param orders The playing orders supported (bitmap)
*/
typedef void (*bt_mcc_read_playing_orders_supported_cb)(struct bt_conn *conn, int err,
uint16_t orders);
/**
* @brief Callback function for bt_mcc_read_media_state()
*
* Called when the media state is read or notified
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param state The Media State
*/
typedef void (*bt_mcc_read_media_state_cb)(struct bt_conn *conn, int err, uint8_t state);
/**
* @brief Callback function for bt_mcc_send_cmd()
*
* Called when a command is sent, i.e. when the media control point is set
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param cmd The command sent
*/
typedef void (*bt_mcc_send_cmd_cb)(struct bt_conn *conn, int err, const struct mpl_cmd *cmd);
/**
* @brief Callback function for command notifications
*
* Called when the media control point is notified
*
* Notifications for commands (i.e. for writes to the media control point) use a
* different parameter structure than what is used for sending commands (writing
* to the media control point)
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param ntf The command notification
*/
typedef void (*bt_mcc_cmd_ntf_cb)(struct bt_conn *conn, int err, const struct mpl_cmd_ntf *ntf);
/**
* @brief Callback function for bt_mcc_read_opcodes_supported()
*
* Called when the supported opcodes (commands) are read or notified
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param opcodes The supported opcodes
*/
typedef void (*bt_mcc_read_opcodes_supported_cb)(struct bt_conn *conn, int err,
uint32_t opcodes);
/**
* @brief Callback function for bt_mcc_send_search()
*
* Called when a search is sent, i.e. when the search control point is set
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param search The search set (or attempted to set)
*/
typedef void (*bt_mcc_send_search_cb)(struct bt_conn *conn, int err,
const struct mpl_search *search);
/**
* @brief Callback function for search notifications
*
* Called when the search control point is notified
*
* Notifications for searches (i.e. for writes to the search control point) use a
* different parameter structure than what is used for sending searches (writing
* to the search control point)
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param result_code The search notification
*/
typedef void (*bt_mcc_search_ntf_cb)(struct bt_conn *conn, int err,
uint8_t result_code);
/**
* @brief Callback function for bt_mcc_read_search_results_obj_id()
*
* Called when the search results object ID is read or notified
*
* Note that the Search Results Object ID value may be zero, in case the
* characteristic does not exist on the server. (This will be the case if
* there has not been a successful search.)
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param id The Search Results Object ID (UINT48)
*/
typedef void (*bt_mcc_read_search_results_obj_id_cb)(struct bt_conn *conn,
int err, uint64_t id);
/**
* @brief Callback function for bt_mcc_read_content_control_id()
*
* Called when the content control ID is read
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param ccid The Content Control ID
*/
typedef void (*bt_mcc_read_content_control_id_cb)(struct bt_conn *conn,
int err, uint8_t ccid);
/**** Callback functions for the included Object Transfer service *************/
/**
* @brief Callback function for object selected
*
* Called when an object is selected
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
*/
typedef void (*bt_mcc_otc_obj_selected_cb)(struct bt_conn *conn, int err);
/**
* @brief Callback function for bt_mcc_otc_read_object_metadata()
*
* Called when object metadata is read
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
*/
typedef void (*bt_mcc_otc_obj_metadata_cb)(struct bt_conn *conn, int err);
/**
* @brief Callback function for bt_mcc_otc_read_icon_object()
*
* Called when the icon object is read
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param buf Buffer containing the object contents
*
* If err is EMSGSIZE, the object contents have been truncated.
*/
typedef void (*bt_mcc_otc_read_icon_object_cb)(struct bt_conn *conn, int err,
struct net_buf_simple *buf);
/**
* @brief Callback function for bt_mcc_otc_read_track_segments_object()
*
* Called when the track segments object is read
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param buf Buffer containing the object contents
*
* If err is EMSGSIZE, the object contents have been truncated.
*/
typedef void (*bt_mcc_otc_read_track_segments_object_cb)(struct bt_conn *conn, int err,
struct net_buf_simple *buf);
/**
* @brief Callback function for bt_mcc_otc_read_current_track_object()
*
* Called when the current track object is read
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param buf Buffer containing the object contents
*
* If err is EMSGSIZE, the object contents have been truncated.
*/
typedef void (*bt_mcc_otc_read_current_track_object_cb)(struct bt_conn *conn, int err,
struct net_buf_simple *buf);
/**
* @brief Callback function for bt_mcc_otc_read_next_track_object()
*
* Called when the next track object is read
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param buf Buffer containing the object contents
*
* If err is EMSGSIZE, the object contents have been truncated.
*/
typedef void (*bt_mcc_otc_read_next_track_object_cb)(struct bt_conn *conn, int err,
struct net_buf_simple *buf);
/**
* @brief Callback function for bt_mcc_otc_read_parent_group_object()
*
* Called when the parent group object is read
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param buf Buffer containing the object contents
*
* If err is EMSGSIZE, the object contents have been truncated.
*/
typedef void (*bt_mcc_otc_read_parent_group_object_cb)(struct bt_conn *conn, int err,
struct net_buf_simple *buf);
/**
* @brief Callback function for bt_mcc_otc_read_current_group_object()
*
* Called when the current group object is read
*
* @param conn The connection that was used to initialise the media control client
* @param err Error value. 0 on success, GATT error or errno on fail
* @param buf Buffer containing the object contents
*
* If err is EMSGSIZE, the object contents have been truncated.
*/
typedef void (*bt_mcc_otc_read_current_group_object_cb)(struct bt_conn *conn, int err,
struct net_buf_simple *buf);
/**
* @brief Media control client callbacks
*/
struct bt_mcc_cb {
/** Callback when discovery has finished */
bt_mcc_discover_mcs_cb discover_mcs;
/** Callback when reading the player name */
bt_mcc_read_player_name_cb read_player_name;
#if defined(CONFIG_BT_OTS_CLIENT) || defined(__DOXYGEN__)
/** Callback when reading the icon object ID */
bt_mcc_read_icon_obj_id_cb read_icon_obj_id;
#endif /* CONFIG_BT_OTS_CLIENT */
#if defined(CONFIG_BT_MCC_READ_MEDIA_PLAYER_ICON_URL) || defined(__DOXYGEN__)
/** Callback when reading the icon URL */
bt_mcc_read_icon_url_cb read_icon_url;
#endif /* defined(CONFIG_BT_MCC_READ_MEDIA_PLAYER_ICON_URL) */
/** Callback when getting a track changed notification */
bt_mcc_track_changed_ntf_cb track_changed_ntf;
#if defined(CONFIG_BT_MCC_READ_TRACK_TITLE) || defined(__DOXYGEN__)
/** Callback when reading the track title */
bt_mcc_read_track_title_cb read_track_title;
#endif /* defined(CONFIG_BT_MCC_READ_TRACK_TITLE) */
#if defined(CONFIG_BT_MCC_READ_TRACK_DURATION) || defined(__DOXYGEN__)
/** Callback when reading the track duration */
bt_mcc_read_track_duration_cb read_track_duration;
#endif /* defined(CONFIG_BT_MCC_READ_TRACK_DURATION) */
#if defined(CONFIG_BT_MCC_READ_TRACK_POSITION) || defined(__DOXYGEN__)
/** Callback when reading the track position */
bt_mcc_read_track_position_cb read_track_position;
#endif /* defined(CONFIG_BT_MCC_READ_TRACK_POSITION) */
#if defined(CONFIG_BT_MCC_SET_TRACK_POSITION) || defined(__DOXYGEN__)
/** Callback when setting the track position */
bt_mcc_set_track_position_cb set_track_position;
#endif /* defined(CONFIG_BT_MCC_SET_TRACK_POSITION) */
#if defined(CONFIG_BT_MCC_READ_PLAYBACK_SPEED) || defined(__DOXYGEN__)
/** Callback when reading the playback speed */
bt_mcc_read_playback_speed_cb read_playback_speed;
#endif /* defined (CONFIG_BT_MCC_READ_PLAYBACK_SPEED) */
#if defined(CONFIG_BT_MCC_SET_PLAYBACK_SPEED) || defined(__DOXYGEN__)
/** Callback when setting the playback speed */
bt_mcc_set_playback_speed_cb set_playback_speed;
#endif /* defined (CONFIG_BT_MCC_SET_PLAYBACK_SPEED) */
#if defined(CONFIG_BT_MCC_READ_SEEKING_SPEED) || defined(__DOXYGEN__)
/** Callback when reading the seeking speed */
bt_mcc_read_seeking_speed_cb read_seeking_speed;
#endif /* defined (CONFIG_BT_MCC_READ_SEEKING_SPEED) */
#if defined(CONFIG_BT_OTS_CLIENT) || defined(__DOXYGEN__)
/** Callback when reading the segments object ID */
bt_mcc_read_segments_obj_id_cb read_segments_obj_id;
/** Callback when reading the current track object ID */
bt_mcc_read_current_track_obj_id_cb read_current_track_obj_id;
/** Callback when setting the current track object ID */
bt_mcc_set_current_track_obj_id_cb set_current_track_obj_id;
/** Callback when reading the next track object ID */
bt_mcc_read_next_track_obj_id_cb read_next_track_obj_id;
/** Callback when setting the next track object ID */
bt_mcc_set_next_track_obj_id_cb set_next_track_obj_id;
/** Callback when reading the current group object ID */
bt_mcc_read_current_group_obj_id_cb read_current_group_obj_id;
/** Callback when setting the current group object ID */
bt_mcc_set_current_group_obj_id_cb set_current_group_obj_id;
/** Callback when reading the parent group object ID */
bt_mcc_read_parent_group_obj_id_cb read_parent_group_obj_id;
#endif /* CONFIG_BT_OTS_CLIENT */
#if defined(CONFIG_BT_MCC_READ_PLAYING_ORDER) || defined(__DOXYGEN__)
/** Callback when reading the playing order */
bt_mcc_read_playing_order_cb read_playing_order;
#endif /* defined(CONFIG_BT_MCC_READ_PLAYING_ORDER) */
#if defined(CONFIG_BT_MCC_SET_PLAYING_ORDER) || defined(__DOXYGEN__)
/** Callback when setting the playing order */
bt_mcc_set_playing_order_cb set_playing_order;
#endif /* defined(CONFIG_BT_MCC_SET_PLAYING_ORDER) */
#if defined(CONFIG_BT_MCC_READ_PLAYING_ORDER_SUPPORTED) || defined(__DOXYGEN__)
/** Callback when reading the supported playing orders */
bt_mcc_read_playing_orders_supported_cb read_playing_orders_supported;
#endif /* defined(CONFIG_BT_MCC_READ_PLAYING_ORDER_SUPPORTED) */
#if defined(CONFIG_BT_MCC_READ_MEDIA_STATE) || defined(__DOXYGEN__)
/** Callback when reading the media state */
bt_mcc_read_media_state_cb read_media_state;
#endif /* defined(CONFIG_BT_MCC_READ_MEDIA_STATE) */
#if defined(CONFIG_BT_MCC_SET_MEDIA_CONTROL_POINT) || defined(__DOXYGEN__)
/** Callback when sending a command */
bt_mcc_send_cmd_cb send_cmd;
#endif /* defined(CONFIG_BT_MCC_SET_MEDIA_CONTROL_POINT) */
/** Callback command notifications */
bt_mcc_cmd_ntf_cb cmd_ntf;
#if defined(CONFIG_BT_MCC_READ_MEDIA_CONTROL_POINT_OPCODES_SUPPORTED) || defined(__DOXYGEN__)
/** Callback when reading the supported opcodes */
bt_mcc_read_opcodes_supported_cb read_opcodes_supported;
#endif /* defined(CONFIG_BT_MCC_READ_MEDIA_CONTROL_POINT_OPCODES_SUPPORTED) */
#if defined(CONFIG_BT_OTS_CLIENT) || defined(__DOXYGEN__)
/** Callback when sending the a search query */
bt_mcc_send_search_cb send_search;
/** Callback when receiving a search notification */
bt_mcc_search_ntf_cb search_ntf;
/** Callback when reading the search results object ID */
bt_mcc_read_search_results_obj_id_cb read_search_results_obj_id;
#endif /* CONFIG_BT_OTS_CLIENT */
#if defined(CONFIG_BT_MCC_READ_CONTENT_CONTROL_ID) || defined(__DOXYGEN__)
/** Callback when reading the content control ID */
bt_mcc_read_content_control_id_cb read_content_control_id;
#endif /* defined(CONFIG_BT_MCC_READ_CONTENT_CONTROL_ID) */
#if defined(CONFIG_BT_OTS_CLIENT) || defined(__DOXYGEN__)
/** Callback when selecting an object */
bt_mcc_otc_obj_selected_cb otc_obj_selected;
/** Callback when receiving the current object metadata */
bt_mcc_otc_obj_metadata_cb otc_obj_metadata;
/** Callback when reading the current icon object */
bt_mcc_otc_read_icon_object_cb otc_icon_object;
/** Callback when reading the track segments object */
bt_mcc_otc_read_track_segments_object_cb otc_track_segments_object;
/** Callback when reading the current track object */
bt_mcc_otc_read_current_track_object_cb otc_current_track_object;
/** Callback when reading the next track object */
bt_mcc_otc_read_next_track_object_cb otc_next_track_object;
/** Callback when reading the current group object */
bt_mcc_otc_read_current_group_object_cb otc_current_group_object;
/** Callback when reading the parent group object */
bt_mcc_otc_read_parent_group_object_cb otc_parent_group_object;
#endif /* CONFIG_BT_OTS_CLIENT */
};
/**** Functions ***************************************************************/
/**
* @brief Initialize Media Control Client
*
* @param cb Callbacks to be used
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_init(struct bt_mcc_cb *cb);
/**
* @brief Discover Media Control Service
*
* Discover Media Control Service (MCS) on the server given by the connection
* Optionally subscribe to notifications.
*
* Shall be called once, after media control client initialization and before
* using other media control client functionality.
*
* @param conn Connection to the peer device
* @param subscribe Whether to subscribe to notifications
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_discover_mcs(struct bt_conn *conn, bool subscribe);
/**
* @brief Read Media Player Name
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_read_player_name(struct bt_conn *conn);
/**
* @brief Read Icon Object ID
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_read_icon_obj_id(struct bt_conn *conn);
/**
* @brief Read Icon Object URL
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_read_icon_url(struct bt_conn *conn);
/**
* @brief Read Track Title
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_read_track_title(struct bt_conn *conn);
/**
* @brief Read Track Duration
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_read_track_duration(struct bt_conn *conn);
/**
* @brief Read Track Position
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_read_track_position(struct bt_conn *conn);
/**
* @brief Set Track position
*
* @param conn Connection to the peer device
* @param pos Track position
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_set_track_position(struct bt_conn *conn, int32_t pos);
/**
* @brief Read Playback speed
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_read_playback_speed(struct bt_conn *conn);
/**
* @brief Set Playback Speed
*
* @param conn Connection to the peer device
* @param speed Playback speed
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_set_playback_speed(struct bt_conn *conn, int8_t speed);
/**
* @brief Read Seeking speed
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_read_seeking_speed(struct bt_conn *conn);
/**
* @brief Read Track Segments Object ID
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_read_segments_obj_id(struct bt_conn *conn);
/**
* @brief Read Current Track Object ID
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_read_current_track_obj_id(struct bt_conn *conn);
/**
* @brief Set Current Track Object ID
*
* Set the Current Track to the track given by the @p id parameter
*
* @param conn Connection to the peer device
* @param id Object Transfer Service ID (UINT48) of the track to set as the current track
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_set_current_track_obj_id(struct bt_conn *conn, uint64_t id);
/**
* @brief Read Next Track Object ID
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_read_next_track_obj_id(struct bt_conn *conn);
/**
* @brief Set Next Track Object ID
*
* Set the Next Track to the track given by the @p id parameter
*
* @param conn Connection to the peer device
* @param id Object Transfer Service ID (UINT48) of the track to set as the next track
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_set_next_track_obj_id(struct bt_conn *conn, uint64_t id);
/**
* @brief Read Current Group Object ID
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_read_current_group_obj_id(struct bt_conn *conn);
/**
* @brief Set Current Group Object ID
*
* Set the Current Group to the group given by the @p id parameter
*
* @param conn Connection to the peer device
* @param id Object Transfer Service ID (UINT48) of the group to set as the current group
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_set_current_group_obj_id(struct bt_conn *conn, uint64_t id);
/**
* @brief Read Parent Group Object ID
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_read_parent_group_obj_id(struct bt_conn *conn);
/**
* @brief Read Playing Order
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_read_playing_order(struct bt_conn *conn);
/**
* @brief Set Playing Order
*
* @param conn Connection to the peer device
* @param order Playing order
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_set_playing_order(struct bt_conn *conn, uint8_t order);
/**
* @brief Read Playing Orders Supported
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_read_playing_orders_supported(struct bt_conn *conn);
/**
* @brief Read Media State
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_read_media_state(struct bt_conn *conn);
/**
* @brief Send a command
*
* Write a command (e.g. "play", "pause") to the server's media control point.
*
* @param conn Connection to the peer device
* @param cmd The command to send
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_send_cmd(struct bt_conn *conn, const struct mpl_cmd *cmd);
/**
* @brief Read Opcodes Supported
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_read_opcodes_supported(struct bt_conn *conn);
/**
* @brief Send a Search command
*
* Write a search to the server's search control point.
*
* @param conn Connection to the peer device
* @param search The search
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_send_search(struct bt_conn *conn, const struct mpl_search *search);
/**
* @brief Search Results Group Object ID
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_read_search_results_obj_id(struct bt_conn *conn);
/**
* @brief Read Content Control ID
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_read_content_control_id(struct bt_conn *conn);
/**
* @brief Read the current object metadata
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_otc_read_object_metadata(struct bt_conn *conn);
/**
* @brief Read the Icon Object
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_otc_read_icon_object(struct bt_conn *conn);
/**
* @brief Read the Track Segments Object
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_otc_read_track_segments_object(struct bt_conn *conn);
/**
* @brief Read the Current Track Object
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_otc_read_current_track_object(struct bt_conn *conn);
/**
* @brief Read the Next Track Object
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_otc_read_next_track_object(struct bt_conn *conn);
/**
* @brief Read the Current Group Object
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_otc_read_current_group_object(struct bt_conn *conn);
/**
* @brief Read the Parent Group Object
*
* @param conn Connection to the peer device
*
* @return 0 if success, errno on failure.
*/
int bt_mcc_otc_read_parent_group_object(struct bt_conn *conn);
/**
* @brief Look up MCC OTC instance
*
* @param conn The connection to the MCC server.
*
* @return Pointer to a MCC OTC instance if found else NULL.
*
*/
struct bt_ots_client *bt_mcc_otc_inst(struct bt_conn *conn);
#ifdef __cplusplus
}
#endif
/**
* @}
*/
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_MCC__ */
``` | /content/code_sandbox/include/zephyr/bluetooth/audio/mcc.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 8,202 |
```objective-c
/**
* @file
* @brief Bluetooth LC3 codec handling
*/
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_LC3_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_LC3_H_
/**
* @brief LC3
* @defgroup BT_AUDIO_CODEC_LC3 AUDIO
* @ingroup bluetooth
* @{
*/
#include <zephyr/sys/util_macro.h>
#include <zephyr/bluetooth/byteorder.h>
#include <zephyr/bluetooth/hci_types.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Helper to declare LC3 codec capability
*
* @p _max_frames_per_sdu is optional and will be included only if != 1
*
* @ref COND_CODE_1 is used to omit an LTV entry in case the @p _frames_per_sdu is 1.
* @ref COND_CODE_1 will evaluate to second argument if the flag parameter(first argument) is 1
* - removing one layer of paranteses.
* If the flags argument is != 1 it will evaluate to the third argument which inserts a LTV
* entry for the max_frames_per_sdu value.
* @param _freq Supported Sampling Frequencies bitfield (see ``BT_AUDIO_CODEC_CAP_FREQ_*``)
* @param _duration Supported Frame Durations bitfield (see ``BT_AUDIO_CODEC_CAP_DURATION_*``)
* @param _chan_count Supported channels (see @ref BT_AUDIO_CODEC_CAP_CHAN_COUNT_SUPPORT)
* @param _len_min Minimum number of octets supported per codec frame
* @param _len_max Maximum number of octets supported per codec frame
* @param _max_frames_per_sdu Supported maximum codec frames per SDU
*/
#define BT_AUDIO_CODEC_CAP_LC3_DATA(_freq, _duration, _chan_count, _len_min, _len_max, \
_max_frames_per_sdu) \
{ \
BT_AUDIO_CODEC_DATA(BT_AUDIO_CODEC_CAP_TYPE_FREQ, BT_BYTES_LIST_LE16(_freq)), \
BT_AUDIO_CODEC_DATA(BT_AUDIO_CODEC_CAP_TYPE_DURATION, (_duration)), \
BT_AUDIO_CODEC_DATA(BT_AUDIO_CODEC_CAP_TYPE_CHAN_COUNT, (_chan_count)), \
BT_AUDIO_CODEC_DATA(BT_AUDIO_CODEC_CAP_TYPE_FRAME_LEN, \
BT_BYTES_LIST_LE16(_len_min), \
BT_BYTES_LIST_LE16(_len_max)), \
COND_CODE_1(_max_frames_per_sdu, (), \
(BT_AUDIO_CODEC_DATA(BT_AUDIO_CODEC_CAP_TYPE_FRAME_COUNT, \
(_max_frames_per_sdu)))) \
}
/**
* @brief Helper to declare LC3 codec metadata
*
* @param _prefer_context Preferred contexts (@ref bt_audio_context)
*/
#define BT_AUDIO_CODEC_CAP_LC3_META(_prefer_context) \
{ \
BT_AUDIO_CODEC_DATA(BT_AUDIO_METADATA_TYPE_PREF_CONTEXT, \
BT_BYTES_LIST_LE16(_prefer_context)) \
}
/**
* @brief Helper to declare LC3 codec
*
* @param _freq Supported Sampling Frequencies bitfield (see ``BT_AUDIO_CODEC_CAP_FREQ_*``)
* @param _duration Supported Frame Durations bitfield (see ``BT_AUDIO_CODEC_CAP_DURATION_*``)
* @param _chan_count Supported channels (see @ref BT_AUDIO_CODEC_CAP_CHAN_COUNT_SUPPORT)
* @param _len_min Minimum number of octets supported per codec frame
* @param _len_max Maximum number of octets supported per codec frame
* @param _max_frames_per_sdu Supported maximum codec frames per SDU
* @param _prefer_context Preferred contexts (@ref bt_audio_context)
*/
#define BT_AUDIO_CODEC_CAP_LC3(_freq, _duration, _chan_count, _len_min, _len_max, \
_max_frames_per_sdu, _prefer_context) \
BT_AUDIO_CODEC_CAP(BT_HCI_CODING_FORMAT_LC3, 0x0000, 0x0000, \
BT_AUDIO_CODEC_CAP_LC3_DATA(_freq, _duration, _chan_count, _len_min, \
_len_max, _max_frames_per_sdu), \
BT_AUDIO_CODEC_CAP_LC3_META(_prefer_context))
/**
* @brief Helper to declare LC3 codec data configuration
*
* @param _freq Sampling frequency (``BT_AUDIO_CODEC_CFG_FREQ_*``)
* @param _duration Frame duration (``BT_AUDIO_CODEC_CFG_DURATION_*``)
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _len Octets per frame (16-bit integer)
* @param _frames_per_sdu Frames per SDU (8-bit integer). This value is optional and will be
* included only if != 1
*/
#define BT_AUDIO_CODEC_CFG_LC3_DATA(_freq, _duration, _loc, _len, _frames_per_sdu) \
{ \
BT_AUDIO_CODEC_DATA(BT_AUDIO_CODEC_CFG_FREQ, (_freq)), \
BT_AUDIO_CODEC_DATA(BT_AUDIO_CODEC_CFG_DURATION, (_duration)), \
BT_AUDIO_CODEC_DATA(BT_AUDIO_CODEC_CFG_CHAN_ALLOC, BT_BYTES_LIST_LE32(_loc)), \
BT_AUDIO_CODEC_DATA(BT_AUDIO_CODEC_CFG_FRAME_LEN, BT_BYTES_LIST_LE16(_len)), \
COND_CODE_1(_frames_per_sdu, (), \
(BT_AUDIO_CODEC_DATA(BT_AUDIO_CODEC_CFG_FRAME_BLKS_PER_SDU, \
(_frames_per_sdu)))) \
}
/** @brief Helper to declare LC3 codec metadata configuration */
#define BT_AUDIO_CODEC_CFG_LC3_META(_stream_context) \
{ \
BT_AUDIO_CODEC_DATA(BT_AUDIO_METADATA_TYPE_STREAM_CONTEXT, \
BT_BYTES_LIST_LE16(_stream_context)) \
}
/**
* @brief Helper to declare LC3 codec configuration.
*
* @param _freq Sampling frequency (``BT_AUDIO_CODEC_CFG_FREQ_*``)
* @param _duration Frame duration (``BT_AUDIO_CODEC_CFG_DURATION_*``)
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _len Octets per frame (16-bit integer)
* @param _frames_per_sdu Frames per SDU (8-bit integer)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_AUDIO_CODEC_LC3_CONFIG(_freq, _duration, _loc, _len, _frames_per_sdu, _stream_context) \
BT_AUDIO_CODEC_CFG( \
BT_HCI_CODING_FORMAT_LC3, 0x0000, 0x0000, \
BT_AUDIO_CODEC_CFG_LC3_DATA(_freq, _duration, _loc, _len, _frames_per_sdu), \
BT_AUDIO_CODEC_CFG_LC3_META(_stream_context))
#ifdef __cplusplus
}
#endif
/**
* @}
*/
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_LC3_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/audio/lc3.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 1,506 |
```objective-c
/**
* @file
* @brief Header for Bluetooth TMAP.
*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_TMAP_
#define ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_TMAP_
#include <zephyr/autoconf.h>
#include <zephyr/bluetooth/conn.h>
#include <zephyr/sys/util.h>
#include <zephyr/sys/util_macro.h>
/** Call Gateway (CG) supported */
#define BT_TMAP_CG_SUPPORTED \
(IS_ENABLED(CONFIG_BT_CAP_INITIATOR) && IS_ENABLED(CONFIG_BT_BAP_UNICAST_CLIENT) && \
IS_ENABLED(CONFIG_BT_TBS) && IS_ENABLED(CONFIG_BT_VCP_VOL_CTLR))
/** Call Terminal (CT) supported */
#define BT_TMAP_CT_SUPPORTED \
(IS_ENABLED(CONFIG_BT_CAP_ACCEPTOR) && IS_ENABLED(CONFIG_BT_BAP_UNICAST_SERVER) && \
IS_ENABLED(CONFIG_BT_TBS_CLIENT) && \
(IS_ENABLED(CONFIG_BT_ASCS_ASE_SNK) && \
IS_ENABLED(CONFIG_BT_VCP_VOL_REND) == IS_ENABLED(CONFIG_BT_ASCS_ASE_SNK)))
/** Unicast Media Sender (UMS) supported */
#define BT_TMAP_UMS_SUPPORTED \
(IS_ENABLED(CONFIG_BT_CAP_INITIATOR) && \
IS_ENABLED(CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SNK) && IS_ENABLED(CONFIG_BT_VCP_VOL_CTLR) && \
IS_ENABLED(CONFIG_BT_MCS))
/** Unicast Media Receiver (UMR) supported */
#define BT_TMAP_UMR_SUPPORTED \
(IS_ENABLED(CONFIG_BT_CAP_ACCEPTOR) && IS_ENABLED(CONFIG_BT_ASCS_ASE_SNK) && \
IS_ENABLED(CONFIG_BT_VCP_VOL_REND))
/** Broadcast Media Sender (BMS) supported */
#define BT_TMAP_BMS_SUPPORTED \
(IS_ENABLED(CONFIG_BT_CAP_INITIATOR) && IS_ENABLED(CONFIG_BT_BAP_BROADCAST_SOURCE))
/** Broadcast Media Receiver (BMR) supported */
#define BT_TMAP_BMR_SUPPORTED \
(IS_ENABLED(CONFIG_BT_CAP_ACCEPTOR) && IS_ENABLED(CONFIG_BT_BAP_BROADCAST_SINK))
/** @brief TMAP Role characteristic */
enum bt_tmap_role {
/**
* @brief TMAP Call Gateway role
*
* This role is defined to telephone and VoIP applications using the Call Control Profile
* to control calls on a remote TMAP Call Terminal.
* Audio streams in this role are typically bi-directional.
*/
BT_TMAP_ROLE_CG = BIT(0),
/**
* @brief TMAP Call Terminal role
*
* This role is defined to telephone and VoIP applications using the Call Control Profile
* to expose calls to remote TMAP Call Gateways.
* Audio streams in this role are typically bi-directional.
*/
BT_TMAP_ROLE_CT = BIT(1),
/**
* @brief TMAP Unicast Media Sender role
*
* This role is defined send media audio to TMAP Unicast Media Receivers.
* Audio streams in this role are typically uni-directional.
*/
BT_TMAP_ROLE_UMS = BIT(2),
/**
* @brief TMAP Unicast Media Receiver role
*
* This role is defined receive media audio to TMAP Unicast Media Senders.
* Audio streams in this role are typically uni-directional.
*/
BT_TMAP_ROLE_UMR = BIT(3),
/**
* @brief TMAP Broadcast Media Sender role
*
* This role is defined send media audio to TMAP Broadcast Media Receivers.
* Audio streams in this role are always uni-directional.
*/
BT_TMAP_ROLE_BMS = BIT(4),
/**
* @brief TMAP Broadcast Media Receiver role
*
* This role is defined send media audio to TMAP Broadcast Media Senders.
* Audio streams in this role are always uni-directional.
*/
BT_TMAP_ROLE_BMR = BIT(5),
};
/** @brief TMAP callback structure. */
struct bt_tmap_cb {
/**
* @brief TMAP discovery complete callback
*
* This callback notifies the application about the value of the
* TMAP Role characteristic on the peer.
*
* @param role Peer TMAP role(s).
* @param conn Pointer to the connection
* @param err 0 if success, ATT error received from server otherwise.
*/
void (*discovery_complete)(enum bt_tmap_role role, struct bt_conn *conn, int err);
};
/**
* @brief Adds TMAS instance to database and sets the received TMAP role(s).
*
* @param role TMAP role(s) of the device (one or multiple).
*
* @return 0 on success or negative error value on failure.
*/
int bt_tmap_register(enum bt_tmap_role role);
/**
* @brief Perform service discovery as TMAP Client
*
* @param conn Pointer to the connection.
* @param tmap_cb Pointer to struct of TMAP callbacks.
*
* @return 0 on success or negative error value on failure.
*/
int bt_tmap_discover(struct bt_conn *conn, const struct bt_tmap_cb *tmap_cb);
/**
* @brief Set one or multiple TMAP roles dynamically.
* Previously registered value will be overwritten.
*
* @param role TMAP role(s).
*
*/
void bt_tmap_set_role(enum bt_tmap_role role);
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_TMAP_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/audio/tmap.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 1,167 |
```objective-c
/**
* @file
* @brief Bluetooth Volume Offset Control Service (VOCS) APIs.
*/
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_VOCS_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_VOCS_H_
/**
* @brief Volume Offset Control Service (VOCS)
*
* @defgroup bt_gatt_vocs Volume Offset Control Service (VOCS)
*
* @since 2.6
* @version 0.8.0
*
* @ingroup bluetooth
* @{
*
* The Volume Offset Control Service is a secondary service, and as such should not be used own its
* own, but rather in the context of another (primary) service.
*
* This API implements both the server and client functionality.
* Note that the API abstracts away the change counter in the volume offset control state and will
* automatically handle any changes to that. If out of date, the client implementation will
* autonomously read the change counter value when executing a write request.
*/
#include <stdint.h>
#include <stdbool.h>
#include <zephyr/bluetooth/conn.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @name Volume Offset Control Service Error codes
* @{
*/
/**
* The Change_Counter operand value does not match the Change_Counter field value of the Volume
* Offset State characteristic.
*/
#define BT_VOCS_ERR_INVALID_COUNTER 0x80
/** An invalid opcode has been used in a control point procedure. */
#define BT_VOCS_ERR_OP_NOT_SUPPORTED 0x81
/** An operand value used in a control point procedure is outside the permissible range. */
#define BT_VOCS_ERR_OUT_OF_RANGE 0x82
/** @} */
/**
* @name Volume Offset Control Service offset limits
* @{
*/
/** Minimum offset value */
#define BT_VOCS_MIN_OFFSET -255
/** Maximum offset value */
#define BT_VOCS_MAX_OFFSET 255
/** @} */
/** @brief Opaque Volume Offset Control Service instance. */
struct bt_vocs;
/** @brief Structure for registering a Volume Offset Control Service instance. */
struct bt_vocs_register_param {
/** Audio Location bitmask */
uint32_t location;
/** Boolean to set whether the location is writable by clients */
bool location_writable;
/** Initial volume offset (-255 to 255) */
int16_t offset;
/** Initial audio output description */
char *output_desc;
/** Boolean to set whether the description is writable by clients */
bool desc_writable;
/** Pointer to the callback structure. */
struct bt_vocs_cb *cb;
};
/** @brief Structure for discovering a Volume Offset Control Service instance. */
struct bt_vocs_discover_param {
/**
* @brief The start handle of the discovering.
*
* Typically the @p start_handle of a @ref bt_gatt_include.
*/
uint16_t start_handle;
/**
* @brief The end handle of the discovering.
*
* Typically the @p end_handle of a @ref bt_gatt_include.
*/
uint16_t end_handle;
};
/**
* @brief Get a free service instance of Volume Offset Control Service from the pool.
*
* @return Volume Offset Control Service instance in case of success or NULL in case of error.
*/
struct bt_vocs *bt_vocs_free_instance_get(void);
/**
* @brief Get the service declaration attribute.
*
* The first service attribute returned can be included in any other GATT service.
*
* @param vocs Volume Offset Control Service instance.
*
* @return Pointer to the attributes of the service.
*/
void *bt_vocs_svc_decl_get(struct bt_vocs *vocs);
/**
* @brief Get the connection pointer of a client instance
*
* Get the Bluetooth connection pointer of a Audio Input Control Service
* client instance.
*
* @param vocs Audio Input Control Service client instance pointer.
* @param conn Connection pointer.
*
* @return 0 if success, errno on failure.
*/
int bt_vocs_client_conn_get(const struct bt_vocs *vocs, struct bt_conn **conn);
/**
* @brief Register the Volume Offset Control Service instance.
*
* @param vocs Volume Offset Control Service instance.
* @param param Volume Offset Control Service register parameters.
*
* @return 0 if success, errno on failure.
*/
int bt_vocs_register(struct bt_vocs *vocs,
const struct bt_vocs_register_param *param);
/**
* @brief Callback function for the offset state.
*
* Called when the value is read, or if the value is changed by either the server or client.
*
* @param inst The instance pointer.
* @param err Error value. 0 on success, GATT error on positive value
* or errno on negative value.
* For notifications, this will always be 0.
* @param offset The offset value.
*/
typedef void (*bt_vocs_state_cb)(struct bt_vocs *inst, int err, int16_t offset);
/**
* @brief Callback function for setting offset.
*
* @param inst The instance pointer.
* @param err Error value. 0 on success, GATT error on positive value
* or errno on negative value.
*/
typedef void (*bt_vocs_set_offset_cb)(struct bt_vocs *inst, int err);
/**
* @brief Callback function for the location.
*
* Called when the value is read, or if the value is changed by either the server or client.
*
* @param inst The instance pointer.
* @param err Error value. 0 on success, GATT error on positive value
* or errno on negative value.
* For notifications, this will always be 0.
* @param location The location value.
*/
typedef void (*bt_vocs_location_cb)(struct bt_vocs *inst, int err,
uint32_t location);
/**
* @brief Callback function for the description.
*
* Called when the value is read, or if the value is changed by either the server or client.
*
* @param inst The instance pointer.
* @param err Error value. 0 on success, GATT error on positive value
* or errno on negative value.
* For notifications, this will always be 0.
* @param description The description as an UTF-8 encoded string.
*/
typedef void (*bt_vocs_description_cb)(struct bt_vocs *inst, int err,
char *description);
/**
* @brief Callback function for bt_vocs_discover.
*
* This callback should be overwritten by the primary service that
* includes the Volume Control Offset Service client, and should thus not be
* set by the application.
*
* @param inst The instance pointer.
* @param err Error value. 0 on success, GATT error on positive value
* or errno on negative value.
* For notifications, this will always be 0.
*/
typedef void (*bt_vocs_discover_cb)(struct bt_vocs *inst, int err);
/**
* @brief Struct to hold the Volume Offset Control Service callbacks
*
* These can be registered for usage with bt_vocs_client_cb_register() or bt_vocs_register()
* depending on the role.
*/
struct bt_vocs_cb {
/** The offset state has changed */
bt_vocs_state_cb state;
/** The location has changed */
bt_vocs_location_cb location;
/** The Description has changed */
bt_vocs_description_cb description;
#if defined(CONFIG_BT_VOCS_CLIENT) || defined(__DOXYGEN__)
/**
* The discovery procedure has completed
*
* Only settable for the client and requires enabling@kconfig{CONFIG_BT_VOCS_CLIENT}.
*/
bt_vocs_discover_cb discover;
/**
* The set offset procedure has completed
*
* Only settable for the client and requires enabling@kconfig{CONFIG_BT_VOCS_CLIENT}.
*/
bt_vocs_set_offset_cb set_offset;
#endif /* CONFIG_BT_VOCS_CLIENT */
};
/**
* @brief Read the Volume Offset Control Service offset state.
*
* The value is returned in the bt_vocs_cb.state callback.
*
* @param inst Pointer to the Volume Offset Control Service instance.
*
* @return 0 on success, GATT error value on fail.
*/
int bt_vocs_state_get(struct bt_vocs *inst);
/**
* @brief Set the Volume Offset Control Service offset state.
*
* @param inst Pointer to the Volume Offset Control Service instance.
* @param offset The offset to set (-255 to 255).
*
* @return 0 on success, GATT error value on fail.
*/
int bt_vocs_state_set(struct bt_vocs *inst, int16_t offset);
/**
* @brief Read the Volume Offset Control Service location.
*
* The value is returned in the bt_vocs_cb.location callback.
*
* @param inst Pointer to the Volume Offset Control Service instance.
*
* @return 0 on success, GATT error value on fail.
*/
int bt_vocs_location_get(struct bt_vocs *inst);
/**
* @brief Set the Volume Offset Control Service location.
*
* @param inst Pointer to the Volume Offset Control Service instance.
* @param location The location to set.
*
* @return 0 on success, GATT error value on fail.
*/
int bt_vocs_location_set(struct bt_vocs *inst, uint32_t location);
/**
* @brief Read the Volume Offset Control Service output description.
*
* The value is returned in the bt_vocs_cb.description callback.
*
* @param inst Pointer to the Volume Offset Control Service instance.
*
* @return 0 on success, GATT error value on fail.
*/
int bt_vocs_description_get(struct bt_vocs *inst);
/**
* @brief Set the Volume Offset Control Service description.
*
* @param inst Pointer to the Volume Offset Control Service instance.
* @param description The UTF-8 encoded string description to set.
*
* @return 0 on success, GATT error value on fail.
*/
int bt_vocs_description_set(struct bt_vocs *inst, const char *description);
/**
* @brief Registers the callbacks for the Volume Offset Control Service client.
*
* @param inst Pointer to the Volume Offset Control Service client instance.
* @param cb Pointer to the callback structure.
*/
void bt_vocs_client_cb_register(struct bt_vocs *inst, struct bt_vocs_cb *cb);
/**
* @brief Returns a pointer to a Volume Offset Control Service client instance.
*
* @return Pointer to the instance, or NULL if no free instances are left.
*/
struct bt_vocs *bt_vocs_client_free_instance_get(void);
/**
* @brief Discover a Volume Offset Control Service.
*
* Attempts to discover a Volume Offset Control Service on a server given the @p param.
*
* @param conn Connection to the peer with the Volume Offset Control Service.
* @param inst Pointer to the Volume Offset Control Service client instance.
* @param param Pointer to the parameters.
*
* @return 0 on success, errno on fail.
*/
int bt_vocs_discover(struct bt_conn *conn, struct bt_vocs *inst,
const struct bt_vocs_discover_param *param);
#ifdef __cplusplus
}
#endif
/**
* @}
*/
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_VOCS_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/audio/vocs.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 2,386 |
```objective-c
/**
* @file
* @brief Bluetooth Coordinated Set Identification Profile (CSIP) APIs.
*/
/*
*
*/
#ifndef ZEPHYR_SUBSYS_BLUETOOTH_AUDIO_CSIP_H_
#define ZEPHYR_SUBSYS_BLUETOOTH_AUDIO_CSIP_H_
/**
* @brief Coordinated Set Identification Profile (CSIP)
*
* @defgroup bt_gatt_csip Coordinated Set Identification Profile (CSIP)
*
* @since 3.0
* @version 0.8.0
*
* @ingroup bluetooth
* @{
*
* The Coordinated Set Identification Profile (CSIP) provides procedures to discover and coordinate
* sets of devices.
*/
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <zephyr/autoconf.h>
#include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/conn.h>
#include <zephyr/bluetooth/gap.h>
#include <zephyr/kernel.h>
#include <zephyr/sys/slist.h>
#ifdef __cplusplus
extern "C" {
#endif
/** Recommended timer for member discovery */
#define BT_CSIP_SET_COORDINATOR_DISCOVER_TIMER_VALUE K_SECONDS(10)
/**
* Defines the maximum number of Coordinated Set Identification service instances for the
* Coordinated Set Identification Set Coordinator
*/
#if defined(CONFIG_BT_CSIP_SET_COORDINATOR)
#define BT_CSIP_SET_COORDINATOR_MAX_CSIS_INSTANCES CONFIG_BT_CSIP_SET_COORDINATOR_MAX_CSIS_INSTANCES
#else
#define BT_CSIP_SET_COORDINATOR_MAX_CSIS_INSTANCES 0
#endif /* CONFIG_BT_CSIP_SET_COORDINATOR */
/** Accept the request to read the SIRK as plaintext */
#define BT_CSIP_READ_SIRK_REQ_RSP_ACCEPT 0x00
/** Accept the request to read the SIRK, but return encrypted SIRK */
#define BT_CSIP_READ_SIRK_REQ_RSP_ACCEPT_ENC 0x01
/** Reject the request to read the SIRK */
#define BT_CSIP_READ_SIRK_REQ_RSP_REJECT 0x02
/** SIRK is available only via an OOB procedure */
#define BT_CSIP_READ_SIRK_REQ_RSP_OOB_ONLY 0x03
/** Size of the Set Identification Resolving Key (SIRK) */
#define BT_CSIP_SIRK_SIZE 16
/** Size of the Resolvable Set Identifier (RSI) */
#define BT_CSIP_RSI_SIZE 6
/* Coordinate Set Identification Service Error codes */
/** Service is already locked */
#define BT_CSIP_ERROR_LOCK_DENIED 0x80
/** Service is not locked */
#define BT_CSIP_ERROR_LOCK_RELEASE_DENIED 0x81
/** Invalid lock value */
#define BT_CSIP_ERROR_LOCK_INVAL_VALUE 0x82
/** SIRK only available out-of-band */
#define BT_CSIP_ERROR_SIRK_OOB_ONLY 0x83
/** Client is already owner of the lock */
#define BT_CSIP_ERROR_LOCK_ALREADY_GRANTED 0x84
/**
* @brief Helper to declare bt_data array including RSI
*
* This macro is mainly for creating an array of struct bt_data
* elements which is then passed to e.g. @ref bt_le_ext_adv_start().
*
* @param _rsi Pointer to the RSI value
*/
#define BT_CSIP_DATA_RSI(_rsi) BT_DATA(BT_DATA_CSIS_RSI, _rsi, BT_CSIP_RSI_SIZE)
/** @brief Opaque Coordinated Set Identification Service instance. */
struct bt_csip_set_member_svc_inst;
/** Callback structure for the Coordinated Set Identification Service */
struct bt_csip_set_member_cb {
/**
* @brief Callback whenever the lock changes on the server.
*
* @param conn The connection to the client that changed the lock.
* NULL if server changed it, either by calling
* bt_csip_set_member_lock() or by timeout.
* @param svc_inst Pointer to the Coordinated Set Identification
* Service.
* @param locked Whether the lock was locked or released.
*
*/
void (*lock_changed)(struct bt_conn *conn,
struct bt_csip_set_member_svc_inst *svc_inst,
bool locked);
/**
* @brief Request from a peer device to read the sirk.
*
* If this callback is not set, all clients will be allowed to read
* the SIRK unencrypted.
*
* @param conn The connection to the client that requested to read
* the SIRK.
* @param svc_inst Pointer to the Coordinated Set Identification
* Service.
*
* @return A BT_CSIP_READ_SIRK_REQ_RSP_* response code.
*/
uint8_t (*sirk_read_req)(struct bt_conn *conn,
struct bt_csip_set_member_svc_inst *svc_inst);
};
/** Register structure for Coordinated Set Identification Service */
struct bt_csip_set_member_register_param {
/**
* @brief Size of the set.
*
* If set to 0, the set size characteristic won't be initialized.
*/
uint8_t set_size;
/**
* @brief The unique Set Identity Resolving Key (SIRK)
*
* This shall be unique between different sets, and shall be the same
* for each set member for each set.
*/
uint8_t sirk[BT_CSIP_SIRK_SIZE];
/**
* @brief Boolean to set whether the set is lockable by clients
*
* Setting this to false will disable the lock characteristic.
*/
bool lockable;
/**
* @brief Rank of this device in this set.
*
* If the lockable parameter is set to true, this shall be > 0 and
* <= to the set_size. If the lockable parameter is set to false, this
* may be set to 0 to disable the rank characteristic.
*/
uint8_t rank;
/** Pointer to the callback structure. */
struct bt_csip_set_member_cb *cb;
#if CONFIG_BT_CSIP_SET_MEMBER_MAX_INSTANCE_COUNT > 1 || defined(__DOXYGEN__)
/**
* @brief Parent service pointer
*
* Mandatory parent service pointer if this CSIS instance is included
* by another service. All CSIS instances when
* @kconfig{CONFIG_BT_CSIP_SET_MEMBER_MAX_INSTANCE_COUNT} is above 1
* shall be included by another service, as per the
* Coordinated Set Identification Profile (CSIP).
*/
const struct bt_gatt_service *parent;
#endif /* CONFIG_BT_CSIP_SET_MEMBER_MAX_INSTANCE_COUNT > 1 */
};
/**
* @brief Get the service declaration attribute.
*
* The first service attribute can be included in any other GATT service.
*
* @param svc_inst Pointer to the Coordinated Set Identification Service.
*
* @return The first CSIS attribute instance.
*/
void *bt_csip_set_member_svc_decl_get(const struct bt_csip_set_member_svc_inst *svc_inst);
/**
* @brief Register a Coordinated Set Identification Service instance.
*
* This will register and enable the service and make it discoverable by
* clients.
*
* This shall only be done as a server.
*
* @param param Coordinated Set Identification Service register
* parameters.
* @param[out] svc_inst Pointer to the registered Coordinated Set
* Identification Service.
*
* @return 0 if success, errno on failure.
*/
int bt_csip_set_member_register(const struct bt_csip_set_member_register_param *param,
struct bt_csip_set_member_svc_inst **svc_inst);
/**
* @brief Unregister a Coordinated Set Identification Service instance.
*
* This will unregister and disable the service instance.
*
* @param svc_inst Pointer to the registered Coordinated Set Identification Service.
*
* @return 0 if success, errno on failure.
*/
int bt_csip_set_member_unregister(struct bt_csip_set_member_svc_inst *svc_inst);
/**
* @brief Set the SIRK of a service instance
*
* @param svc_inst Pointer to the registered Coordinated Set Identification Service.
* @param sirk The new SIRK.
*/
int bt_csip_set_member_sirk(struct bt_csip_set_member_svc_inst *svc_inst,
const uint8_t sirk[BT_CSIP_SIRK_SIZE]);
/**
* @brief Get the SIRK of a service instance
*
* @param[in] svc_inst Pointer to the registered Coordinated Set Identification Service.
* @param[out] sirk Array to store the SIRK in.
*/
int bt_csip_set_member_get_sirk(struct bt_csip_set_member_svc_inst *svc_inst,
uint8_t sirk[BT_CSIP_SIRK_SIZE]);
/**
* @brief Generate the Resolvable Set Identifier (RSI) value.
*
* This will generate RSI for given @p svc_inst instance.
*
* @param svc_inst Pointer to the Coordinated Set Identification Service.
* @param rsi Pointer to the 6-octet newly generated RSI data in little-endian.
*
* @return int 0 if on success, errno on error.
*/
int bt_csip_set_member_generate_rsi(const struct bt_csip_set_member_svc_inst *svc_inst,
uint8_t rsi[BT_CSIP_RSI_SIZE]);
/**
* @brief Locks a specific Coordinated Set Identification Service instance on the server.
*
* @param svc_inst Pointer to the Coordinated Set Identification Service.
* @param lock If true lock the set, if false release the set.
* @param force This argument only have meaning when @p lock is false
* (release) and will force release the lock, regardless of who
* took the lock.
*
* @return 0 on success, GATT error on error.
*/
int bt_csip_set_member_lock(struct bt_csip_set_member_svc_inst *svc_inst,
bool lock, bool force);
/** Information about a specific set */
struct bt_csip_set_coordinator_set_info {
/**
* @brief The 16 octet set Set Identity Resolving Key (SIRK)
*
* The SIRK may not be exposed by the server over Bluetooth, and
* may require an out-of-band solution.
*/
uint8_t sirk[BT_CSIP_SIRK_SIZE];
/**
* @brief The size of the set
*
* Will be 0 if not exposed by the server.
*/
uint8_t set_size;
/**
* @brief The rank of the set on the remote device
*
* Will be 0 if not exposed by the server.
*/
uint8_t rank;
/** Whether or not the set can be locked on this device */
bool lockable;
};
/**
* @brief Struct representing a coordinated set instance on a remote device
*
* The values in this struct will be populated during discovery of sets
* (bt_csip_set_coordinator_discover()).
*/
struct bt_csip_set_coordinator_csis_inst {
/** Information about the coordinated set */
struct bt_csip_set_coordinator_set_info info;
/** Internally used pointer value */
void *svc_inst;
};
/** Struct representing a remote device as a set member */
struct bt_csip_set_coordinator_set_member {
/** Array of Coordinated Set Identification Service instances for the remote device */
struct bt_csip_set_coordinator_csis_inst insts[BT_CSIP_SET_COORDINATOR_MAX_CSIS_INSTANCES];
};
/**
* @typedef bt_csip_set_coordinator_discover_cb
* @brief Callback for discovering Coordinated Set Identification Services.
*
* @param conn Pointer to the remote device.
* @param member Pointer to the set member.
* @param err 0 on success, or an errno value on error.
* @param set_count Number of sets on the member.
*/
typedef void (*bt_csip_set_coordinator_discover_cb)(
struct bt_conn *conn,
const struct bt_csip_set_coordinator_set_member *member,
int err, size_t set_count);
/**
* @brief Initialise the csip_set_coordinator instance for a connection. This will do a
* discovery on the device and prepare the instance for following commands.
*
* @param conn Pointer to remote device to perform discovery on.
*
* @return int Return 0 on success, or an errno value on error.
*/
int bt_csip_set_coordinator_discover(struct bt_conn *conn);
/**
* @brief Get the set member from a connection pointer
*
* Get the Coordinated Set Identification Profile Set Coordinator pointer from a connection pointer.
* Only Set Coordinators that have been initiated via bt_csip_set_coordinator_discover() can be
* retrieved.
*
* @param conn Connection pointer.
*
* @retval Pointer to a Coordinated Set Identification Profile Set Coordinator instance
* @retval NULL if @p conn is NULL or if the connection has not done discovery yet
*/
struct bt_csip_set_coordinator_set_member *
bt_csip_set_coordinator_set_member_by_conn(const struct bt_conn *conn);
/**
* @typedef bt_csip_set_coordinator_lock_set_cb
* @brief Callback for locking a set across one or more devices
*
* @param err 0 on success, or an errno value on error.
*/
typedef void (*bt_csip_set_coordinator_lock_set_cb)(int err);
/**
* @typedef bt_csip_set_coordinator_lock_changed_cb
* @brief Callback when the lock value on a set of a connected device changes.
*
* @param inst The Coordinated Set Identification Service instance that was
* changed.
* @param locked Whether the lock is locked or release.
*
* @return int Return 0 on success, or an errno value on error.
*/
typedef void (*bt_csip_set_coordinator_lock_changed_cb)(
struct bt_csip_set_coordinator_csis_inst *inst, bool locked);
/**
* @typedef bt_csip_set_coordinator_sirk_changed_cb
* @brief Callback when the SIRK value of a set of a connected device changes.
*
* @param inst The Coordinated Set Identification Service instance that was changed.
* The new SIRK can be accessed via the @p inst.info.
*/
typedef void (*bt_csip_set_coordinator_sirk_changed_cb)(
struct bt_csip_set_coordinator_csis_inst *inst);
/**
* @typedef bt_csip_set_coordinator_ordered_access_cb_t
* @brief Callback for bt_csip_set_coordinator_ordered_access()
*
* If any of the set members supplied to bt_csip_set_coordinator_ordered_access() is
* in the locked state, this will be called with @p locked true and @p member
* will be the locked member, and the ordered access procedure is cancelled.
* Likewise, if any error occurs, the procedure will also be aborted.
*
* @param set_info Pointer to the a specific set_info struct.
* @param err Error value. 0 on success, GATT error or errno on fail.
* @param locked Whether the lock is locked or release.
* @param member The locked member if @p locked is true, otherwise NULL.
*/
typedef void (*bt_csip_set_coordinator_ordered_access_cb_t)(
const struct bt_csip_set_coordinator_set_info *set_info,
int err, bool locked,
struct bt_csip_set_coordinator_set_member *member);
/**
* @brief Struct to hold the Coordinated Set Identification Profile Set Coordinator callbacks
*
* These can be registered for usage with bt_csip_set_coordinator_register_cb().
*/
struct bt_csip_set_coordinator_cb {
/** Callback when discovery has finished */
bt_csip_set_coordinator_discover_cb discover;
/** Callback when locking a set has finished */
bt_csip_set_coordinator_lock_set_cb lock_set;
/** Callback when unlocking a set has finished */
bt_csip_set_coordinator_lock_set_cb release_set;
/** Callback when a set's lock state has changed */
bt_csip_set_coordinator_lock_changed_cb lock_changed;
/** Callback when a set's SIRK has changed */
bt_csip_set_coordinator_sirk_changed_cb sirk_changed;
/** Callback for the ordered access procedure */
bt_csip_set_coordinator_ordered_access_cb_t ordered_access;
/** @internal Internally used field for list handling */
sys_snode_t _node;
};
/**
* @brief Check if advertising data indicates a set member
*
* @param sirk The SIRK of the set to check against
* @param data The advertising data
*
* @return true if the advertising data indicates a set member, false otherwise
*/
bool bt_csip_set_coordinator_is_set_member(const uint8_t sirk[BT_CSIP_SIRK_SIZE],
struct bt_data *data);
/**
* @brief Registers callbacks for csip_set_coordinator.
*
* @param cb Pointer to the callback structure.
*
* @return Return 0 on success, or an errno value on error.
*/
int bt_csip_set_coordinator_register_cb(struct bt_csip_set_coordinator_cb *cb);
/**
* @brief Callback function definition for bt_csip_set_coordinator_ordered_access()
*
* @param set_info Pointer to the a specific set_info struct.
* @param members Array of members ordered by rank. The procedure shall be
* done on the members in ascending order.
* @param count Number of members in @p members.
*
* @return true if the procedures can be successfully done, or false to stop the
* procedure.
*/
typedef bool (*bt_csip_set_coordinator_ordered_access_t)(
const struct bt_csip_set_coordinator_set_info *set_info,
struct bt_csip_set_coordinator_set_member *members[],
size_t count);
/**
* @brief Access Coordinated Set devices in an ordered manner as a client
*
* This function will read the lock state of all devices and if all devices are
* in the unlocked state, then @p cb will be called with the same members as
* provided by @p members, but where the members are ordered by rank
* (if present). Once this procedure is finished or an error occurs,
* @ref bt_csip_set_coordinator_cb.ordered_access will be called.
*
* This procedure only works if all the members have the lock characteristic,
* and all either has rank = 0 or unique ranks.
*
* If any of the members are in the locked state, the procedure will be
* cancelled.
*
* This can only be done on members that are bonded.
*
* @param members Array of set members to access.
* @param count Number of set members in @p members.
* @param set_info Pointer to the a specific set_info struct, as a member may
* be part of multiple sets.
* @param cb The callback function to be called for each member.
*/
int bt_csip_set_coordinator_ordered_access(
const struct bt_csip_set_coordinator_set_member *members[],
uint8_t count,
const struct bt_csip_set_coordinator_set_info *set_info,
bt_csip_set_coordinator_ordered_access_t cb);
/**
* @brief Lock an array of set members
*
* The members will be locked starting from lowest rank going up.
*
* TODO: If locking fails, the already locked members will not be unlocked.
*
* @param members Array of set members to lock.
* @param count Number of set members in @p members.
* @param set_info Pointer to the a specific set_info struct, as a member may
* be part of multiple sets.
*
* @return Return 0 on success, or an errno value on error.
*/
int bt_csip_set_coordinator_lock(const struct bt_csip_set_coordinator_set_member **members,
uint8_t count,
const struct bt_csip_set_coordinator_set_info *set_info);
/**
* @brief Release an array of set members
*
* The members will be released starting from highest rank going down.
*
* @param members Array of set members to lock.
* @param count Number of set members in @p members.
* @param set_info Pointer to the a specific set_info struct, as a member may
* be part of multiple sets.
*
* @return Return 0 on success, or an errno value on error.
*/
int bt_csip_set_coordinator_release(const struct bt_csip_set_coordinator_set_member **members,
uint8_t count,
const struct bt_csip_set_coordinator_set_info *set_info);
#ifdef __cplusplus
}
#endif
/**
* @}
*/
#endif /* ZEPHYR_SUBSYS_BLUETOOTH_AUDIO_CSIP_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/audio/csip.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 4,377 |
```objective-c
/**
* @file
* @brief Bluetooth Microphone Control Profile (MICP) APIs.
*/
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_MICP_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_MICP_H_
/**
* @brief Microphone Control Profile (MICP)
*
* @defgroup bt_gatt_micp Microphone Control Profile (MICP)
*
* @since 2.7
* @version 0.8.0
*
* @ingroup bluetooth
* @{
*/
#include <stdint.h>
#include <zephyr/bluetooth/audio/aics.h>
#include <zephyr/bluetooth/conn.h>
#include <zephyr/sys/slist.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* Defines the maximum number of Microphone Control Service instances for the
* Microphone Control Profile Microphone Device
*/
#if defined(CONFIG_BT_MICP_MIC_DEV)
#define BT_MICP_MIC_DEV_AICS_CNT CONFIG_BT_MICP_MIC_DEV_AICS_INSTANCE_COUNT
#else
#define BT_MICP_MIC_DEV_AICS_CNT 0
#endif /* CONFIG_BT_MICP_MIC_DEV */
/**
* @name Application error codes
* @{
*/
/** Mute/unmute commands are disabled. */
#define BT_MICP_ERR_MUTE_DISABLED 0x80
/** @} */
/**
* @name Microphone Control Profile mute states
* @{
*/
/** The microphone state is unmuted */
#define BT_MICP_MUTE_UNMUTED 0x00
/** The microphone state is muted */
#define BT_MICP_MUTE_MUTED 0x01
/** The microphone state is disabled and cannot be muted or unmuted */
#define BT_MICP_MUTE_DISABLED 0x02
/** @} */
/** @brief Opaque Microphone Controller instance. */
struct bt_micp_mic_ctlr;
/** @brief Register parameters structure for Microphone Control Service */
struct bt_micp_mic_dev_register_param {
#if defined(CONFIG_BT_MICP_MIC_DEV_AICS) || defined(__DOXYGEN__)
/** Register parameter structure for Audio Input Control Services */
struct bt_aics_register_param aics_param[BT_MICP_MIC_DEV_AICS_CNT];
#endif /* CONFIG_BT_MICP_MIC_DEV_AICS */
/** Microphone Control Profile callback structure. */
struct bt_micp_mic_dev_cb *cb;
};
/**
* @brief Microphone Control Profile included services
*
* Used for to represent the Microphone Control Profile included service
* instances, for either a Microphone Controller or a Microphone Device.
* The instance pointers either represent local service instances,
* or remote service instances.
*/
struct bt_micp_included {
/** Number of Audio Input Control Service instances */
uint8_t aics_cnt;
/** Array of pointers to Audio Input Control Service instances */
struct bt_aics **aics;
};
/**
* @brief Initialize the Microphone Control Profile Microphone Device
*
* This will enable the Microphone Control Service instance and make it
* discoverable by Microphone Controllers.
*
* @param param Pointer to an initialization structure.
*
* @return 0 if success, errno on failure.
*/
int bt_micp_mic_dev_register(struct bt_micp_mic_dev_register_param *param);
/**
* @brief Get Microphone Device included services
*
* Returns a pointer to a struct that contains information about the
* Microphone Device included Audio Input Control Service instances.
*
* Requires that @kconfig{CONFIG_BT_MICP_MIC_DEV_AICS} is enabled.
*
* @param included Pointer to store the result in.
*
* @return 0 if success, errno on failure.
*/
int bt_micp_mic_dev_included_get(struct bt_micp_included *included);
/**
* @brief Struct to hold the Microphone Device callbacks
*
* These can be registered for usage with bt_micp_mic_dev_register().
*/
struct bt_micp_mic_dev_cb {
/**
* @brief Callback function for Microphone Device mute.
*
* Called when the value is read with bt_micp_mic_dev_mute_get(),
* or if the value is changed by either the Microphone Device or a
* Microphone Controller.
*
* @param mute The mute setting of the Microphone Control Service.
*/
void (*mute)(uint8_t mute);
};
/**
* @brief Unmute the Microphone Device.
*
* @return 0 on success, GATT error value on fail.
*/
int bt_micp_mic_dev_unmute(void);
/**
* @brief Mute the Microphone Device.
*
* @return 0 on success, GATT error value on fail.
*/
int bt_micp_mic_dev_mute(void);
/**
* @brief Disable the mute functionality on the Microphone Device.
*
* Can be reenabled by called @ref bt_micp_mic_dev_mute or @ref bt_micp_mic_dev_unmute.
*
* @return 0 on success, GATT error value on fail.
*/
int bt_micp_mic_dev_mute_disable(void);
/**
* @brief Read the mute state on the Microphone Device.
*
* @return 0 on success, GATT error value on fail.
*/
int bt_micp_mic_dev_mute_get(void);
/**
* @brief Struct to hold the Microphone Controller callbacks
*
* These can be registered for usage with bt_micp_mic_ctlr_cb_register().
*/
struct bt_micp_mic_ctlr_cb {
/**
* @brief Callback function for Microphone Control Profile mute.
*
* Called when the value is read,
* or if the value is changed by either the Microphone Device or a
* Microphone Controller.
*
* @param mic_ctlr Microphone Controller instance pointer.
* @param err Error value. 0 on success, GATT error or errno on fail.
* For notifications, this will always be 0.
* @param mute The mute setting of the Microphone Control Service.
*/
void (*mute)(struct bt_micp_mic_ctlr *mic_ctlr, int err, uint8_t mute);
/**
* @brief Callback function for bt_micp_mic_ctlr_discover().
*
* @param mic_ctlr Microphone Controller instance pointer.
* @param err Error value. 0 on success, GATT error or errno on fail.
* @param aics_count Number of Audio Input Control Service instances on
* peer device.
*/
void (*discover)(struct bt_micp_mic_ctlr *mic_ctlr, int err,
uint8_t aics_count);
/**
* @brief Callback function for Microphone Control Profile mute/unmute.
*
* @param mic_ctlr Microphone Controller instance pointer.
* @param err Error value. 0 on success, GATT error or errno on fail.
*/
void (*mute_written)(struct bt_micp_mic_ctlr *mic_ctlr, int err);
/**
* @brief Callback function for Microphone Control Profile mute/unmute.
*
* @param mic_ctlr Microphone Controller instance pointer.
* @param err Error value. 0 on success, GATT error or errno on fail.
*/
void (*unmute_written)(struct bt_micp_mic_ctlr *mic_ctlr, int err);
#if defined(CONFIG_BT_MICP_MIC_CTLR_AICS)
/** Audio Input Control Service client callback */
struct bt_aics_cb aics_cb;
#endif /* CONFIG_BT_MICP_MIC_CTLR_AICS */
/** @internal Internally used field for list handling */
sys_snode_t _node;
};
/**
* @brief Get Microphone Control Profile included services
*
* Returns a pointer to a struct that contains information about the
* Microphone Control Profile included services instances, such as
* pointers to the Audio Input Control Service instances.
*
* Requires that @kconfig{CONFIG_BT_MICP_MIC_CTLR_AICS} is enabled.
*
* @param mic_ctlr Microphone Controller instance pointer.
* @param[out] included Pointer to store the result in.
*
* @return 0 if success, errno on failure.
*/
int bt_micp_mic_ctlr_included_get(struct bt_micp_mic_ctlr *mic_ctlr,
struct bt_micp_included *included);
/**
* @brief Get the connection pointer of a Microphone Controller instance
*
* Get the Bluetooth connection pointer of a Microphone Controller instance.
*
* @param mic_ctlr Microphone Controller instance pointer.
* @param conn Connection pointer.
*
* @return 0 if success, errno on failure.
*/
int bt_micp_mic_ctlr_conn_get(const struct bt_micp_mic_ctlr *mic_ctlr,
struct bt_conn **conn);
/**
* @brief Get the volume controller from a connection pointer
*
* Get the Volume Control Profile Volume Controller pointer from a connection pointer.
* Only volume controllers that have been initiated via bt_micp_mic_ctlr_discover() can be
* retrieved.
*
* @param conn Connection pointer.
*
* @retval Pointer to a Microphone Control Profile Microphone Controller instance
* @retval NULL if @p conn is NULL or if the connection has not done discovery yet
*/
struct bt_micp_mic_ctlr *bt_micp_mic_ctlr_get_by_conn(const struct bt_conn *conn);
/**
* @brief Discover Microphone Control Service
*
* This will start a GATT discovery and setup handles and subscriptions.
* This shall be called once before any other actions can be executed for the
* peer device, and the @ref bt_micp_mic_ctlr_cb.discover callback will notify
* when it is possible to start remote operations.
* *
* @param conn The connection to initialize the profile for.
* @param[out] mic_ctlr Valid remote instance object on success.
*
* @return 0 on success, GATT error value on fail.
*/
int bt_micp_mic_ctlr_discover(struct bt_conn *conn,
struct bt_micp_mic_ctlr **mic_ctlr);
/**
* @brief Unmute a remote Microphone Device.
*
* @param mic_ctlr Microphone Controller instance pointer.
*
* @return 0 on success, GATT error value on fail.
*/
int bt_micp_mic_ctlr_unmute(struct bt_micp_mic_ctlr *mic_ctlr);
/**
* @brief Mute a remote Microphone Device.
*
* @param mic_ctlr Microphone Controller instance pointer.
*
* @return 0 on success, GATT error value on fail.
*/
int bt_micp_mic_ctlr_mute(struct bt_micp_mic_ctlr *mic_ctlr);
/**
* @brief Read the mute state of a remote Microphone Device.
*
* @param mic_ctlr Microphone Controller instance pointer.
*
* @return 0 on success, GATT error value on fail.
*/
int bt_micp_mic_ctlr_mute_get(struct bt_micp_mic_ctlr *mic_ctlr);
/**
* @brief Registers the callbacks used by Microphone Controller.
*
* This can only be done as the client.
*
* @param cb The callback structure.
*
* @return 0 if success, errno on failure.
*/
int bt_micp_mic_ctlr_cb_register(struct bt_micp_mic_ctlr_cb *cb);
#ifdef __cplusplus
}
#endif
/**
* @}
*/
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_MICP_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/audio/micp.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 2,466 |
```objective-c
/**
* @file
* @brief Bluetooth Audio handling
*/
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_AUDIO_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_AUDIO_H_
/**
* @brief Bluetooth Audio
* @defgroup bt_audio Bluetooth Audio
* @ingroup bluetooth
* @{
*/
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <zephyr/autoconf.h>
#include <zephyr/bluetooth/audio/lc3.h>
#include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/buf.h>
#include <zephyr/bluetooth/conn.h>
#include <zephyr/bluetooth/gatt.h>
#include <zephyr/bluetooth/hci.h>
#include <zephyr/bluetooth/iso.h>
#include <zephyr/sys/atomic.h>
#include <zephyr/sys/util.h>
#include <zephyr/sys/util_macro.h>
#ifdef __cplusplus
extern "C" {
#endif
/** Size of the broadcast ID in octets */
#define BT_AUDIO_BROADCAST_ID_SIZE 3
/** Maximum broadcast ID value */
#define BT_AUDIO_BROADCAST_ID_MAX 0xFFFFFFU
/** Indicates that the server have no preference for the presentation delay */
#define BT_AUDIO_PD_PREF_NONE 0x000000U
/** Maximum presentation delay in microseconds */
#define BT_AUDIO_PD_MAX 0xFFFFFFU
/** Maximum size of the broadcast code in octets */
#define BT_AUDIO_BROADCAST_CODE_SIZE 16
/** The minimum size of a Broadcast Name as defined by Bluetooth Assigned Numbers */
#define BT_AUDIO_BROADCAST_NAME_LEN_MIN 4
/** The maximum size of a Broadcast Name as defined by Bluetooth Assigned Numbers */
#define BT_AUDIO_BROADCAST_NAME_LEN_MAX 128
/** Size of the stream language value, e.g. "eng" */
#define BT_AUDIO_LANG_SIZE 3
/**
* @brief Codec capability types
*
* Used to build and parse codec capabilities as specified in the PAC specification.
* Source is assigned numbers for Generic Audio, bluetooth.com.
*/
enum bt_audio_codec_cap_type {
/** Supported sampling frequencies */
BT_AUDIO_CODEC_CAP_TYPE_FREQ = 0x01,
/** Supported frame durations */
BT_AUDIO_CODEC_CAP_TYPE_DURATION = 0x02,
/** Supported audio channel counts */
BT_AUDIO_CODEC_CAP_TYPE_CHAN_COUNT = 0x03,
/** Supported octets per codec frame */
BT_AUDIO_CODEC_CAP_TYPE_FRAME_LEN = 0x04,
/** Supported maximum codec frames per SDU */
BT_AUDIO_CODEC_CAP_TYPE_FRAME_COUNT = 0x05,
};
/** @brief Supported frequencies bitfield */
enum bt_audio_codec_cap_freq {
/** 8 Khz sampling frequency */
BT_AUDIO_CODEC_CAP_FREQ_8KHZ = BIT(0),
/** 11.025 Khz sampling frequency */
BT_AUDIO_CODEC_CAP_FREQ_11KHZ = BIT(1),
/** 16 Khz sampling frequency */
BT_AUDIO_CODEC_CAP_FREQ_16KHZ = BIT(2),
/** 22.05 Khz sampling frequency */
BT_AUDIO_CODEC_CAP_FREQ_22KHZ = BIT(3),
/** 24 Khz sampling frequency */
BT_AUDIO_CODEC_CAP_FREQ_24KHZ = BIT(4),
/** 32 Khz sampling frequency */
BT_AUDIO_CODEC_CAP_FREQ_32KHZ = BIT(5),
/** 44.1 Khz sampling frequency */
BT_AUDIO_CODEC_CAP_FREQ_44KHZ = BIT(6),
/** 48 Khz sampling frequency */
BT_AUDIO_CODEC_CAP_FREQ_48KHZ = BIT(7),
/** 88.2 Khz sampling frequency */
BT_AUDIO_CODEC_CAP_FREQ_88KHZ = BIT(8),
/** 96 Khz sampling frequency */
BT_AUDIO_CODEC_CAP_FREQ_96KHZ = BIT(9),
/** 176.4 Khz sampling frequency */
BT_AUDIO_CODEC_CAP_FREQ_176KHZ = BIT(10),
/** 192 Khz sampling frequency */
BT_AUDIO_CODEC_CAP_FREQ_192KHZ = BIT(11),
/** 384 Khz sampling frequency */
BT_AUDIO_CODEC_CAP_FREQ_384KHZ = BIT(12),
/** Any frequency capability */
BT_AUDIO_CODEC_CAP_FREQ_ANY =
(BT_AUDIO_CODEC_CAP_FREQ_8KHZ | BT_AUDIO_CODEC_CAP_FREQ_11KHZ |
BT_AUDIO_CODEC_CAP_FREQ_16KHZ | BT_AUDIO_CODEC_CAP_FREQ_22KHZ |
BT_AUDIO_CODEC_CAP_FREQ_24KHZ | BT_AUDIO_CODEC_CAP_FREQ_32KHZ |
BT_AUDIO_CODEC_CAP_FREQ_44KHZ | BT_AUDIO_CODEC_CAP_FREQ_48KHZ |
BT_AUDIO_CODEC_CAP_FREQ_88KHZ | BT_AUDIO_CODEC_CAP_FREQ_96KHZ |
BT_AUDIO_CODEC_CAP_FREQ_176KHZ | BT_AUDIO_CODEC_CAP_FREQ_192KHZ |
BT_AUDIO_CODEC_CAP_FREQ_384KHZ),
};
/** @brief Supported frame durations bitfield */
enum bt_audio_codec_cap_frame_dur {
/** 7.5 msec frame duration capability */
BT_AUDIO_CODEC_CAP_DURATION_7_5 = BIT(0),
/** 10 msec frame duration capability */
BT_AUDIO_CODEC_CAP_DURATION_10 = BIT(1),
/** Any frame duration capability */
BT_AUDIO_CODEC_CAP_DURATION_ANY =
(BT_AUDIO_CODEC_CAP_DURATION_7_5 | BT_AUDIO_CODEC_CAP_DURATION_10),
/**
* @brief 7.5 msec preferred frame duration capability.
*
* This shall only be set if @ref BT_AUDIO_CODEC_CAP_DURATION_7_5 is also set, and if @ref
* BT_AUDIO_CODEC_CAP_DURATION_PREFER_10 is not set.
*/
BT_AUDIO_CODEC_CAP_DURATION_PREFER_7_5 = BIT(4),
/**
* @brief 10 msec preferred frame duration capability
*
* This shall only be set if @ref BT_AUDIO_CODEC_CAP_DURATION_10 is also set, and if @ref
* BT_AUDIO_CODEC_CAP_DURATION_PREFER_7_5 is not set.
*/
BT_AUDIO_CODEC_CAP_DURATION_PREFER_10 = BIT(5),
};
/** Supported audio capabilities channel count bitfield */
enum bt_audio_codec_cap_chan_count {
/** Supporting 1 channel */
BT_AUDIO_CODEC_CAP_CHAN_COUNT_1 = BIT(0),
/** Supporting 2 channel */
BT_AUDIO_CODEC_CAP_CHAN_COUNT_2 = BIT(1),
/** Supporting 3 channel */
BT_AUDIO_CODEC_CAP_CHAN_COUNT_3 = BIT(2),
/** Supporting 4 channel */
BT_AUDIO_CODEC_CAP_CHAN_COUNT_4 = BIT(3),
/** Supporting 5 channel */
BT_AUDIO_CODEC_CAP_CHAN_COUNT_5 = BIT(4),
/** Supporting 6 channel */
BT_AUDIO_CODEC_CAP_CHAN_COUNT_6 = BIT(5),
/** Supporting 7 channel */
BT_AUDIO_CODEC_CAP_CHAN_COUNT_7 = BIT(6),
/** Supporting 8 channel */
BT_AUDIO_CODEC_CAP_CHAN_COUNT_8 = BIT(7),
/** Supporting all channels */
BT_AUDIO_CODEC_CAP_CHAN_COUNT_ANY =
(BT_AUDIO_CODEC_CAP_CHAN_COUNT_1 | BT_AUDIO_CODEC_CAP_CHAN_COUNT_2 |
BT_AUDIO_CODEC_CAP_CHAN_COUNT_3 | BT_AUDIO_CODEC_CAP_CHAN_COUNT_4 |
BT_AUDIO_CODEC_CAP_CHAN_COUNT_5 | BT_AUDIO_CODEC_CAP_CHAN_COUNT_6 |
BT_AUDIO_CODEC_CAP_CHAN_COUNT_7 | BT_AUDIO_CODEC_CAP_CHAN_COUNT_8),
};
/** Minimum supported channel counts */
#define BT_AUDIO_CODEC_CAP_CHAN_COUNT_MIN 1
/** Maximum supported channel counts */
#define BT_AUDIO_CODEC_CAP_CHAN_COUNT_MAX 8
/**
* @brief Channel count support capability
*
* Macro accepts variable number of channel counts.
* The allowed channel counts are defined by specification and have to be in range from
* @ref BT_AUDIO_CODEC_CAP_CHAN_COUNT_MIN to @ref BT_AUDIO_CODEC_CAP_CHAN_COUNT_MAX inclusive.
*
* Example to support 1 and 3 channels:
* BT_AUDIO_CODEC_CAP_CHAN_COUNT_SUPPORT(1, 3)
*/
#define BT_AUDIO_CODEC_CAP_CHAN_COUNT_SUPPORT(...) \
((enum bt_audio_codec_cap_chan_count)((FOR_EACH(BIT, (|), __VA_ARGS__)) >> 1))
/** struct to hold minimum and maximum supported codec frame sizes */
struct bt_audio_codec_octets_per_codec_frame {
/** Minimum number of octets supported per codec frame */
uint16_t min;
/** Maximum number of octets supported per codec frame */
uint16_t max;
};
/**
* @brief Codec configuration types
*
* Used to build and parse codec configurations as specified in the ASCS and BAP specifications.
* Source is assigned numbers for Generic Audio, bluetooth.com.
*/
enum bt_audio_codec_cfg_type {
/** Sampling frequency */
BT_AUDIO_CODEC_CFG_FREQ = 0x01,
/** Frame duration */
BT_AUDIO_CODEC_CFG_DURATION = 0x02,
/** Audio channel allocation */
BT_AUDIO_CODEC_CFG_CHAN_ALLOC = 0x03,
/** Octets per codec frame */
BT_AUDIO_CODEC_CFG_FRAME_LEN = 0x04,
/** Codec frame blocks per SDU */
BT_AUDIO_CODEC_CFG_FRAME_BLKS_PER_SDU = 0x05,
};
/** Codec configuration sampling freqency */
enum bt_audio_codec_cfg_freq {
/** 8 Khz codec sampling frequency */
BT_AUDIO_CODEC_CFG_FREQ_8KHZ = 0x01,
/** 11.025 Khz codec sampling frequency */
BT_AUDIO_CODEC_CFG_FREQ_11KHZ = 0x02,
/** 16 Khz codec sampling frequency */
BT_AUDIO_CODEC_CFG_FREQ_16KHZ = 0x03,
/** 22.05 Khz codec sampling frequency */
BT_AUDIO_CODEC_CFG_FREQ_22KHZ = 0x04,
/** 24 Khz codec sampling frequency */
BT_AUDIO_CODEC_CFG_FREQ_24KHZ = 0x05,
/** 32 Khz codec sampling frequency */
BT_AUDIO_CODEC_CFG_FREQ_32KHZ = 0x06,
/** 44.1 Khz codec sampling frequency */
BT_AUDIO_CODEC_CFG_FREQ_44KHZ = 0x07,
/** 48 Khz codec sampling frequency */
BT_AUDIO_CODEC_CFG_FREQ_48KHZ = 0x08,
/** 88.2 Khz codec sampling frequency */
BT_AUDIO_CODEC_CFG_FREQ_88KHZ = 0x09,
/** 96 Khz codec sampling frequency */
BT_AUDIO_CODEC_CFG_FREQ_96KHZ = 0x0a,
/** 176.4 Khz codec sampling frequency */
BT_AUDIO_CODEC_CFG_FREQ_176KHZ = 0x0b,
/** 192 Khz codec sampling frequency */
BT_AUDIO_CODEC_CFG_FREQ_192KHZ = 0x0c,
/** 384 Khz codec sampling frequency */
BT_AUDIO_CODEC_CFG_FREQ_384KHZ = 0x0d,
};
/** Codec configuration frame duration */
enum bt_audio_codec_cfg_frame_dur {
/** 7.5 msec Frame Duration configuration */
BT_AUDIO_CODEC_CFG_DURATION_7_5 = 0x00,
/** 10 msec Frame Duration configuration */
BT_AUDIO_CODEC_CFG_DURATION_10 = 0x01,
};
/**
* @brief Audio Context Type for Generic Audio
*
* These values are defined by the Generic Audio Assigned Numbers, bluetooth.com
*/
enum bt_audio_context {
/** Prohibited */
BT_AUDIO_CONTEXT_TYPE_PROHIBITED = 0,
/**
* Identifies audio where the use case context does not match any other defined value,
* or where the context is unknown or cannot be determined.
*/
BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED = BIT(0),
/**
* Conversation between humans, for example, in telephony or video calls, including
* traditional cellular as well as VoIP and Push-to-Talk
*/
BT_AUDIO_CONTEXT_TYPE_CONVERSATIONAL = BIT(1),
/** Media, for example, music playback, radio, podcast or movie soundtrack, or tv audio */
BT_AUDIO_CONTEXT_TYPE_MEDIA = BIT(2),
/**
* Audio associated with video gaming, for example gaming media; gaming effects; music
* and in-game voice chat between participants; or a mix of all the above
*/
BT_AUDIO_CONTEXT_TYPE_GAME = BIT(3),
/** Instructional audio, for example, in navigation, announcements, or user guidance */
BT_AUDIO_CONTEXT_TYPE_INSTRUCTIONAL = BIT(4),
/** Man-machine communication, for example, with voice recognition or virtual assistants */
BT_AUDIO_CONTEXT_TYPE_VOICE_ASSISTANTS = BIT(5),
/**
* Live audio, for example, from a microphone where audio is perceived both through a
* direct acoustic path and through an LE Audio Stream
*/
BT_AUDIO_CONTEXT_TYPE_LIVE = BIT(6),
/**
* Sound effects including keyboard and touch feedback; menu and user interface sounds;
* and other system sounds
*/
BT_AUDIO_CONTEXT_TYPE_SOUND_EFFECTS = BIT(7),
/**
* Notification and reminder sounds; attention-seeking audio, for example,
* in beeps signaling the arrival of a message
*/
BT_AUDIO_CONTEXT_TYPE_NOTIFICATIONS = BIT(8),
/**
* Alerts the user to an incoming call, for example, an incoming telephony or video call,
* including traditional cellular as well as VoIP and Push-to-Talk
*/
BT_AUDIO_CONTEXT_TYPE_RINGTONE = BIT(9),
/**
* Alarms and timers; immediate alerts, for example, in a critical battery alarm,
* timer expiry or alarm clock, toaster, cooker, kettle, microwave, etc.
*/
BT_AUDIO_CONTEXT_TYPE_ALERTS = BIT(10),
/** Emergency alarm Emergency sounds, for example, fire alarms or other urgent alerts */
BT_AUDIO_CONTEXT_TYPE_EMERGENCY_ALARM = BIT(11),
};
/**
* Any known context.
*/
#define BT_AUDIO_CONTEXT_TYPE_ANY (BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED | \
BT_AUDIO_CONTEXT_TYPE_CONVERSATIONAL | \
BT_AUDIO_CONTEXT_TYPE_MEDIA | \
BT_AUDIO_CONTEXT_TYPE_GAME | \
BT_AUDIO_CONTEXT_TYPE_INSTRUCTIONAL | \
BT_AUDIO_CONTEXT_TYPE_VOICE_ASSISTANTS | \
BT_AUDIO_CONTEXT_TYPE_LIVE | \
BT_AUDIO_CONTEXT_TYPE_SOUND_EFFECTS | \
BT_AUDIO_CONTEXT_TYPE_NOTIFICATIONS | \
BT_AUDIO_CONTEXT_TYPE_RINGTONE | \
BT_AUDIO_CONTEXT_TYPE_ALERTS | \
BT_AUDIO_CONTEXT_TYPE_EMERGENCY_ALARM)
/**
* @brief Parental rating defined by the Generic Audio assigned numbers (bluetooth.com).
*
* The numbering scheme is aligned with Annex F of EN 300 707 v1.2.1 which
* defined parental rating for viewing.
*/
enum bt_audio_parental_rating {
/** No rating */
BT_AUDIO_PARENTAL_RATING_NO_RATING = 0x00,
/** For all ages */
BT_AUDIO_PARENTAL_RATING_AGE_ANY = 0x01,
/** Recommended for listeners of age 5 and above */
BT_AUDIO_PARENTAL_RATING_AGE_5_OR_ABOVE = 0x02,
/** Recommended for listeners of age 6 and above */
BT_AUDIO_PARENTAL_RATING_AGE_6_OR_ABOVE = 0x03,
/** Recommended for listeners of age 7 and above */
BT_AUDIO_PARENTAL_RATING_AGE_7_OR_ABOVE = 0x04,
/** Recommended for listeners of age 8 and above */
BT_AUDIO_PARENTAL_RATING_AGE_8_OR_ABOVE = 0x05,
/** Recommended for listeners of age 9 and above */
BT_AUDIO_PARENTAL_RATING_AGE_9_OR_ABOVE = 0x06,
/** Recommended for listeners of age 10 and above */
BT_AUDIO_PARENTAL_RATING_AGE_10_OR_ABOVE = 0x07,
/** Recommended for listeners of age 11 and above */
BT_AUDIO_PARENTAL_RATING_AGE_11_OR_ABOVE = 0x08,
/** Recommended for listeners of age 12 and above */
BT_AUDIO_PARENTAL_RATING_AGE_12_OR_ABOVE = 0x09,
/** Recommended for listeners of age 13 and above */
BT_AUDIO_PARENTAL_RATING_AGE_13_OR_ABOVE = 0x0A,
/** Recommended for listeners of age 14 and above */
BT_AUDIO_PARENTAL_RATING_AGE_14_OR_ABOVE = 0x0B,
/** Recommended for listeners of age 15 and above */
BT_AUDIO_PARENTAL_RATING_AGE_15_OR_ABOVE = 0x0C,
/** Recommended for listeners of age 16 and above */
BT_AUDIO_PARENTAL_RATING_AGE_16_OR_ABOVE = 0x0D,
/** Recommended for listeners of age 17 and above */
BT_AUDIO_PARENTAL_RATING_AGE_17_OR_ABOVE = 0x0E,
/** Recommended for listeners of age 18 and above */
BT_AUDIO_PARENTAL_RATING_AGE_18_OR_ABOVE = 0x0F
};
/** @brief Audio Active State defined by the Generic Audio assigned numbers (bluetooth.com). */
enum bt_audio_active_state {
/** No audio data is being transmitted */
BT_AUDIO_ACTIVE_STATE_DISABLED = 0x00,
/** Audio data is being transmitted */
BT_AUDIO_ACTIVE_STATE_ENABLED = 0x01,
};
/**
* @brief Codec metadata type IDs
*
* Metadata types defined by the Generic Audio assigned numbers (bluetooth.com).
*/
enum bt_audio_metadata_type {
/**
* @brief Preferred audio context.
*
* Bitfield of preferred audio contexts.
*
* If 0, the context type is not a preferred use case for this codec
* configuration.
*
* See the BT_AUDIO_CONTEXT_* for valid values.
*/
BT_AUDIO_METADATA_TYPE_PREF_CONTEXT = 0x01,
/**
* @brief Streaming audio context.
*
* Bitfield of streaming audio contexts.
*
* If 0, the context type is not a preferred use case for this codec
* configuration.
*
* See the BT_AUDIO_CONTEXT_* for valid values.
*/
BT_AUDIO_METADATA_TYPE_STREAM_CONTEXT = 0x02,
/** UTF-8 encoded title or summary of stream content */
BT_AUDIO_METADATA_TYPE_PROGRAM_INFO = 0x03,
/**
* @brief Language
*
* 3 octet lower case language code defined by ISO 639-3
* Possible values can be found at path_to_url
*/
BT_AUDIO_METADATA_TYPE_LANG = 0x04,
/** Array of 8-bit CCID values */
BT_AUDIO_METADATA_TYPE_CCID_LIST = 0x05,
/**
* @brief Parental rating
*
* See @ref bt_audio_parental_rating for valid values.
*/
BT_AUDIO_METADATA_TYPE_PARENTAL_RATING = 0x06,
/** UTF-8 encoded URI for additional Program information */
BT_AUDIO_METADATA_TYPE_PROGRAM_INFO_URI = 0x07,
/**
* @brief Audio active state
*
* See @ref bt_audio_active_state for valid values.
*/
BT_AUDIO_METADATA_TYPE_AUDIO_STATE = 0x08,
/** Broadcast Audio Immediate Rendering flag */
BT_AUDIO_METADATA_TYPE_BROADCAST_IMMEDIATE = 0x09,
/** Extended metadata */
BT_AUDIO_METADATA_TYPE_EXTENDED = 0xFE,
/** Vendor specific metadata */
BT_AUDIO_METADATA_TYPE_VENDOR = 0xFF,
};
/**
* @brief Helper to check whether metadata type is known by the stack.
*
* @note @p _type is evaluated thrice.
*/
#define BT_AUDIO_METADATA_TYPE_IS_KNOWN(_type) \
(IN_RANGE((_type), BT_AUDIO_METADATA_TYPE_PREF_CONTEXT, \
BT_AUDIO_METADATA_TYPE_BROADCAST_IMMEDIATE) || \
(_type) == BT_AUDIO_METADATA_TYPE_EXTENDED || (_type) == BT_AUDIO_METADATA_TYPE_VENDOR)
/**
* @name Unicast Announcement Type
* @{
*/
/** Unicast Server is connectable and is requesting a connection. */
#define BT_AUDIO_UNICAST_ANNOUNCEMENT_GENERAL 0x00
/** Unicast Server is connectable but is not requesting a connection. */
#define BT_AUDIO_UNICAST_ANNOUNCEMENT_TARGETED 0x01
/** @} */
/**
* @brief Helper to declare elements of bt_audio_codec_cap arrays
*
* This macro is mainly for creating an array of struct bt_audio_codec_cap data arrays.
*
* @param _type Type of advertising data field
* @param _bytes Variable number of single-byte parameters
*/
#define BT_AUDIO_CODEC_DATA(_type, _bytes...) \
(sizeof((uint8_t)_type) + sizeof((uint8_t[]){_bytes})), (_type), _bytes
/**
* @brief Helper to declare @ref bt_audio_codec_cfg
*
* @param _id Codec ID
* @param _cid Company ID
* @param _vid Vendor ID
* @param _data Codec Specific Data in LVT format
* @param _meta Codec Specific Metadata in LVT format
*/
#define BT_AUDIO_CODEC_CFG(_id, _cid, _vid, _data, _meta) \
((struct bt_audio_codec_cfg){ \
/* Use HCI data path as default, can be overwritten by application */ \
.path_id = BT_ISO_DATA_PATH_HCI, \
.ctlr_transcode = false, \
.id = _id, \
.cid = _cid, \
.vid = _vid, \
.data_len = sizeof((uint8_t[])_data), \
.data = _data, \
.meta_len = sizeof((uint8_t[])_meta), \
.meta = _meta, \
})
/**
* @brief Helper to declare @ref bt_audio_codec_cap structure
*
* @param _id Codec ID
* @param _cid Company ID
* @param _vid Vendor ID
* @param _data Codec Specific Data in LVT format
* @param _meta Codec Specific Metadata in LVT format
*/
#define BT_AUDIO_CODEC_CAP(_id, _cid, _vid, _data, _meta) \
((struct bt_audio_codec_cap){ \
/* Use HCI data path as default, can be overwritten by application */ \
.path_id = BT_ISO_DATA_PATH_HCI, \
.ctlr_transcode = false, \
.id = (_id), \
.cid = (_cid), \
.vid = (_vid), \
.data_len = sizeof((uint8_t[])_data), \
.data = _data, \
.meta_len = sizeof((uint8_t[])_meta), \
.meta = _meta, \
})
/**
* @brief Location values for BT Audio.
*
* These values are defined by the Generic Audio Assigned Numbers, bluetooth.com
*/
enum bt_audio_location {
/** Mono Audio (no specified Audio Location) */
BT_AUDIO_LOCATION_MONO_AUDIO = 0,
/** Front Left */
BT_AUDIO_LOCATION_FRONT_LEFT = BIT(0),
/** Front Right */
BT_AUDIO_LOCATION_FRONT_RIGHT = BIT(1),
/** Front Center */
BT_AUDIO_LOCATION_FRONT_CENTER = BIT(2),
/** Low Frequency Effects 1 */
BT_AUDIO_LOCATION_LOW_FREQ_EFFECTS_1 = BIT(3),
/** Back Left */
BT_AUDIO_LOCATION_BACK_LEFT = BIT(4),
/** Back Right */
BT_AUDIO_LOCATION_BACK_RIGHT = BIT(5),
/** Front Left of Center */
BT_AUDIO_LOCATION_FRONT_LEFT_OF_CENTER = BIT(6),
/** Front Right of Center */
BT_AUDIO_LOCATION_FRONT_RIGHT_OF_CENTER = BIT(7),
/** Back Center */
BT_AUDIO_LOCATION_BACK_CENTER = BIT(8),
/** Low Frequency Effects 2 */
BT_AUDIO_LOCATION_LOW_FREQ_EFFECTS_2 = BIT(9),
/** Side Left */
BT_AUDIO_LOCATION_SIDE_LEFT = BIT(10),
/** Side Right */
BT_AUDIO_LOCATION_SIDE_RIGHT = BIT(11),
/** Top Front Left */
BT_AUDIO_LOCATION_TOP_FRONT_LEFT = BIT(12),
/** Top Front Right */
BT_AUDIO_LOCATION_TOP_FRONT_RIGHT = BIT(13),
/** Top Front Center */
BT_AUDIO_LOCATION_TOP_FRONT_CENTER = BIT(14),
/** Top Center */
BT_AUDIO_LOCATION_TOP_CENTER = BIT(15),
/** Top Back Left */
BT_AUDIO_LOCATION_TOP_BACK_LEFT = BIT(16),
/** Top Back Right */
BT_AUDIO_LOCATION_TOP_BACK_RIGHT = BIT(17),
/** Top Side Left */
BT_AUDIO_LOCATION_TOP_SIDE_LEFT = BIT(18),
/** Top Side Right */
BT_AUDIO_LOCATION_TOP_SIDE_RIGHT = BIT(19),
/** Top Back Center */
BT_AUDIO_LOCATION_TOP_BACK_CENTER = BIT(20),
/** Bottom Front Center */
BT_AUDIO_LOCATION_BOTTOM_FRONT_CENTER = BIT(21),
/** Bottom Front Left */
BT_AUDIO_LOCATION_BOTTOM_FRONT_LEFT = BIT(22),
/** Bottom Front Right */
BT_AUDIO_LOCATION_BOTTOM_FRONT_RIGHT = BIT(23),
/** Front Left Wide */
BT_AUDIO_LOCATION_FRONT_LEFT_WIDE = BIT(24),
/** Front Right Wide */
BT_AUDIO_LOCATION_FRONT_RIGHT_WIDE = BIT(25),
/** Left Surround */
BT_AUDIO_LOCATION_LEFT_SURROUND = BIT(26),
/** Right Surround */
BT_AUDIO_LOCATION_RIGHT_SURROUND = BIT(27),
};
/**
* Any known location.
*/
#define BT_AUDIO_LOCATION_ANY (BT_AUDIO_LOCATION_FRONT_LEFT | \
BT_AUDIO_LOCATION_FRONT_RIGHT | \
BT_AUDIO_LOCATION_FRONT_CENTER | \
BT_AUDIO_LOCATION_LOW_FREQ_EFFECTS_1 | \
BT_AUDIO_LOCATION_BACK_LEFT | \
BT_AUDIO_LOCATION_BACK_RIGHT | \
BT_AUDIO_LOCATION_FRONT_LEFT_OF_CENTER | \
BT_AUDIO_LOCATION_FRONT_RIGHT_OF_CENTER | \
BT_AUDIO_LOCATION_BACK_CENTER | \
BT_AUDIO_LOCATION_LOW_FREQ_EFFECTS_2 | \
BT_AUDIO_LOCATION_SIDE_LEFT | \
BT_AUDIO_LOCATION_SIDE_RIGHT | \
BT_AUDIO_LOCATION_TOP_FRONT_LEFT | \
BT_AUDIO_LOCATION_TOP_FRONT_RIGHT | \
BT_AUDIO_LOCATION_TOP_FRONT_CENTER | \
BT_AUDIO_LOCATION_TOP_CENTER | \
BT_AUDIO_LOCATION_TOP_BACK_LEFT | \
BT_AUDIO_LOCATION_TOP_BACK_RIGHT | \
BT_AUDIO_LOCATION_TOP_SIDE_LEFT | \
BT_AUDIO_LOCATION_TOP_SIDE_RIGHT | \
BT_AUDIO_LOCATION_TOP_BACK_CENTER | \
BT_AUDIO_LOCATION_BOTTOM_FRONT_CENTER | \
BT_AUDIO_LOCATION_BOTTOM_FRONT_LEFT | \
BT_AUDIO_LOCATION_BOTTOM_FRONT_RIGHT | \
BT_AUDIO_LOCATION_FRONT_LEFT_WIDE | \
BT_AUDIO_LOCATION_FRONT_RIGHT_WIDE | \
BT_AUDIO_LOCATION_LEFT_SURROUND | \
BT_AUDIO_LOCATION_RIGHT_SURROUND)
/** @brief Codec capability structure. */
struct bt_audio_codec_cap {
/** Data path ID
*
* @ref BT_ISO_DATA_PATH_HCI for HCI path, or any other value for
* vendor specific ID.
*/
uint8_t path_id;
/** Whether or not the local controller should transcode
*
* This effectively sets the coding format for the ISO data path to @ref
* BT_HCI_CODING_FORMAT_TRANSPARENT if false, else uses the @ref bt_audio_codec_cfg.id.
*/
bool ctlr_transcode;
/** Codec ID */
uint8_t id;
/** Codec Company ID */
uint16_t cid;
/** Codec Company Vendor ID */
uint16_t vid;
#if CONFIG_BT_AUDIO_CODEC_CAP_MAX_DATA_SIZE > 0 || defined(__DOXYGEN__)
/** Codec Specific Capabilities Data count */
size_t data_len;
/** Codec Specific Capabilities Data */
uint8_t data[CONFIG_BT_AUDIO_CODEC_CAP_MAX_DATA_SIZE];
#endif /* CONFIG_BT_AUDIO_CODEC_CAP_MAX_DATA_SIZE > 0 */
#if defined(CONFIG_BT_AUDIO_CODEC_CAP_MAX_METADATA_SIZE) || defined(__DOXYGEN__)
/** Codec Specific Capabilities Metadata count */
size_t meta_len;
/** Codec Specific Capabilities Metadata */
uint8_t meta[CONFIG_BT_AUDIO_CODEC_CAP_MAX_METADATA_SIZE];
#endif /* CONFIG_BT_AUDIO_CODEC_CAP_MAX_METADATA_SIZE */
};
/** @brief Codec specific configuration structure. */
struct bt_audio_codec_cfg {
/** Data path ID
*
* @ref BT_ISO_DATA_PATH_HCI for HCI path, or any other value for
* vendor specific ID.
*/
uint8_t path_id;
/** Whether or not the local controller should transcode
*
* This effectively sets the coding format for the ISO data path to @ref
* BT_HCI_CODING_FORMAT_TRANSPARENT if false, else uses the @ref bt_audio_codec_cfg.id.
*/
bool ctlr_transcode;
/** Codec ID */
uint8_t id;
/** Codec Company ID */
uint16_t cid;
/** Codec Company Vendor ID */
uint16_t vid;
#if CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_SIZE > 0 || defined(__DOXYGEN__)
/** Codec Specific Capabilities Data count */
size_t data_len;
/** Codec Specific Capabilities Data */
uint8_t data[CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_SIZE];
#endif /* CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_SIZE > 0 */
#if CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_SIZE > 0 || defined(__DOXYGEN__)
/** Codec Specific Capabilities Metadata count */
size_t meta_len;
/** Codec Specific Capabilities Metadata */
uint8_t meta[CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_SIZE];
#endif /* CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_SIZE > 0 */
};
/**
* @brief Helper for parsing length-type-value data.
*
* @param ltv Length-type-value (LTV) encoded data.
* @param size Size of the @p ltv data.
* @param func Callback function which will be called for each element
* that's found in the data. The callback should return
* true to continue parsing, or false to stop parsing.
* @param user_data User data to be passed to the callback.
*
* @retval 0 if all entries were parsed.
* @retval -EINVAL if the data is incorrectly encoded
* @retval -ECANCELED if parsing was prematurely cancelled by the callback
*/
int bt_audio_data_parse(const uint8_t ltv[], size_t size,
bool (*func)(struct bt_data *data, void *user_data), void *user_data);
/**
* @brief Function to get the number of channels from the channel allocation
*
* @param chan_allocation The channel allocation
*
* @return The number of channels
*/
uint8_t bt_audio_get_chan_count(enum bt_audio_location chan_allocation);
/** @brief Audio direction from the perspective of the BAP Unicast Server / BAP Broadcast Sink */
enum bt_audio_dir {
/**
* @brief Audio direction sink
*
* For a BAP Unicast Client or Broadcast Source this is considered outgoing audio (TX).
* For a BAP Unicast Server or Broadcast Sink this is considered incoming audio (RX).
*/
BT_AUDIO_DIR_SINK = 0x01,
/**
* @brief Audio direction source
*
* For a BAP Unicast Client or Broadcast Source this is considered incoming audio (RX).
* For a BAP Unicast Server or Broadcast Sink this is considered outgoing audio (TX).
*/
BT_AUDIO_DIR_SOURCE = 0x02,
};
/**
* @brief Helper to declare elements of bt_audio_codec_qos
*
* @param _interval SDU interval (usec)
* @param _framing Framing
* @param _phy Target PHY
* @param _sdu Maximum SDU Size
* @param _rtn Retransmission number
* @param _latency Maximum Transport Latency (msec)
* @param _pd Presentation Delay (usec)
*/
#define BT_AUDIO_CODEC_QOS(_interval, _framing, _phy, _sdu, _rtn, _latency, _pd) \
((struct bt_audio_codec_qos){ \
.interval = _interval, \
.framing = _framing, \
.phy = _phy, \
.sdu = _sdu, \
.rtn = _rtn, \
IF_ENABLED(UTIL_OR(IS_ENABLED(CONFIG_BT_BAP_BROADCAST_SOURCE), \
IS_ENABLED(CONFIG_BT_BAP_UNICAST)), \
(.latency = _latency,)) \
.pd = _pd, \
})
/** @brief Codec QoS Framing */
enum bt_audio_codec_qos_framing {
/** Packets may be framed or unframed */
BT_AUDIO_CODEC_QOS_FRAMING_UNFRAMED = 0x00,
/** Packets are always framed */
BT_AUDIO_CODEC_QOS_FRAMING_FRAMED = 0x01,
};
/** @brief Codec QoS Preferred PHY */
enum {
/** LE 1M PHY */
BT_AUDIO_CODEC_QOS_1M = BIT(0),
/** LE 2M PHY */
BT_AUDIO_CODEC_QOS_2M = BIT(1),
/** LE Coded PHY */
BT_AUDIO_CODEC_QOS_CODED = BIT(2),
};
/**
* @brief Helper to declare Input Unframed bt_audio_codec_qos
*
* @param _interval SDU interval (usec)
* @param _sdu Maximum SDU Size
* @param _rtn Retransmission number
* @param _latency Maximum Transport Latency (msec)
* @param _pd Presentation Delay (usec)
*/
#define BT_AUDIO_CODEC_QOS_UNFRAMED(_interval, _sdu, _rtn, _latency, _pd) \
BT_AUDIO_CODEC_QOS(_interval, BT_AUDIO_CODEC_QOS_FRAMING_UNFRAMED, BT_AUDIO_CODEC_QOS_2M, \
_sdu, _rtn, _latency, _pd)
/**
* @brief Helper to declare Input Framed bt_audio_codec_qos
*
* @param _interval SDU interval (usec)
* @param _sdu Maximum SDU Size
* @param _rtn Retransmission number
* @param _latency Maximum Transport Latency (msec)
* @param _pd Presentation Delay (usec)
*/
#define BT_AUDIO_CODEC_QOS_FRAMED(_interval, _sdu, _rtn, _latency, _pd) \
BT_AUDIO_CODEC_QOS(_interval, BT_AUDIO_CODEC_QOS_FRAMING_FRAMED, BT_AUDIO_CODEC_QOS_2M, \
_sdu, _rtn, _latency, _pd)
/** @brief Codec QoS structure. */
struct bt_audio_codec_qos {
/**
* @brief Presentation Delay in microseconds
*
* This value can be changed up and until bt_bap_stream_qos() has been called.
* Once a stream has been QoS configured, modifying this field does not modify the value.
* It is however possible to modify this field and call bt_bap_stream_qos() again to update
* the value, assuming that the stream is in the correct state.
*
* Value range 0 to @ref BT_AUDIO_PD_MAX.
*/
uint32_t pd;
/**
* @brief Connected Isochronous Group (CIG) parameters
*
* The fields in this struct affect the value sent to the controller via HCI
* when creating the CIG. Once the group has been created with
* bt_bap_unicast_group_create(), modifying these fields will not affect the group.
*/
struct {
/** QoS Framing */
enum bt_audio_codec_qos_framing framing;
/**
* @brief PHY
*
* Allowed values are @ref BT_AUDIO_CODEC_QOS_1M, @ref BT_AUDIO_CODEC_QOS_2M and
* @ref BT_AUDIO_CODEC_QOS_CODED.
*/
uint8_t phy;
/**
* @brief Retransmission Number
*
* This a recommendation to the controller, and the actual retransmission number
* may be different than this.
*/
uint8_t rtn;
/**
* @brief Maximum SDU size
*
* Value range @ref BT_ISO_MIN_SDU to @ref BT_ISO_MAX_SDU.
*/
uint16_t sdu;
#if defined(CONFIG_BT_BAP_BROADCAST_SOURCE) || defined(CONFIG_BT_BAP_UNICAST) || \
defined(__DOXYGEN__)
/**
* @brief Maximum Transport Latency
*
* Not used for the @kconfig{CONFIG_BT_BAP_BROADCAST_SINK} role.
*/
uint16_t latency;
#endif /* CONFIG_BT_BAP_BROADCAST_SOURCE || CONFIG_BT_BAP_UNICAST */
/**
* @brief SDU Interval
*
* Value range @ref BT_ISO_SDU_INTERVAL_MIN to @ref BT_ISO_SDU_INTERVAL_MAX
*/
uint32_t interval;
#if defined(CONFIG_BT_ISO_TEST_PARAMS) || defined(__DOXYGEN__)
/**
* @brief Maximum PDU size
*
* Maximum size, in octets, of the payload from link layer to link layer.
*
* Value range @ref BT_ISO_CONNECTED_PDU_MIN to @ref BT_ISO_PDU_MAX for
* connected ISO.
*
* Value range @ref BT_ISO_BROADCAST_PDU_MIN to @ref BT_ISO_PDU_MAX for
* broadcast ISO.
*/
uint16_t max_pdu;
/**
* @brief Burst number
*
* Value range @ref BT_ISO_BN_MIN to @ref BT_ISO_BN_MAX.
*/
uint8_t burst_number;
/**
* @brief Number of subevents
*
* Maximum number of subevents in each CIS or BIS event.
*
* Value range @ref BT_ISO_NSE_MIN to @ref BT_ISO_NSE_MAX.
*/
uint8_t num_subevents;
#endif /* CONFIG_BT_ISO_TEST_PARAMS */
};
};
/**
* @brief Helper to declare elements of @ref bt_audio_codec_qos_pref
*
* @param _unframed_supported Unframed PDUs supported
* @param _phy Preferred Target PHY
* @param _rtn Preferred Retransmission number
* @param _latency Preferred Maximum Transport Latency (msec)
* @param _pd_min Minimum Presentation Delay (usec)
* @param _pd_max Maximum Presentation Delay (usec)
* @param _pref_pd_min Preferred Minimum Presentation Delay (usec)
* @param _pref_pd_max Preferred Maximum Presentation Delay (usec)
*/
#define BT_AUDIO_CODEC_QOS_PREF(_unframed_supported, _phy, _rtn, _latency, _pd_min, _pd_max, \
_pref_pd_min, _pref_pd_max) \
{ \
.unframed_supported = _unframed_supported, \
.phy = _phy, \
.rtn = _rtn, \
.latency = _latency, \
.pd_min = _pd_min, \
.pd_max = _pd_max, \
.pref_pd_min = _pref_pd_min, \
.pref_pd_max = _pref_pd_max, \
}
/** @brief Audio Stream Quality of Service Preference structure. */
struct bt_audio_codec_qos_pref {
/**
* @brief Unframed PDUs supported
*
* Unlike the other fields, this is not a preference but whether
* the codec supports unframed ISOAL PDUs.
*/
bool unframed_supported;
/** Preferred PHY */
uint8_t phy;
/** Preferred Retransmission Number */
uint8_t rtn;
/** Preferred Transport Latency */
uint16_t latency;
/**
* @brief Minimum Presentation Delay in microseconds
*
* Unlike the other fields, this is not a preference but a minimum requirement.
*
* Value range 0 to @ref BT_AUDIO_PD_MAX, or @ref BT_AUDIO_PD_PREF_NONE
* to indicate no preference.
*/
uint32_t pd_min;
/**
* @brief Maximum Presentation Delay
*
* Unlike the other fields, this is not a preference but a maximum requirement.
*
* Value range 0 to @ref BT_AUDIO_PD_MAX, or @ref BT_AUDIO_PD_PREF_NONE
* to indicate no preference.
*/
uint32_t pd_max;
/**
* @brief Preferred minimum Presentation Delay
*
* Value range 0 to @ref BT_AUDIO_PD_MAX.
*/
uint32_t pref_pd_min;
/**
* @brief Preferred maximum Presentation Delay
*
* Value range 0 to @ref BT_AUDIO_PD_MAX.
*/
uint32_t pref_pd_max;
};
/**
* @brief Audio codec Config APIs
* @defgroup bt_audio_codec_cfg Codec config parsing APIs
*
* Functions to parse codec config data when formatted as LTV wrapped into @ref bt_audio_codec_cfg.
*
* @{
*/
/**
* @brief Convert assigned numbers frequency to frequency value.
*
* @param freq The assigned numbers frequency to convert.
*
* @retval -EINVAL if arguments are invalid.
* @retval The converted frequency value in Hz.
*/
int bt_audio_codec_cfg_freq_to_freq_hz(enum bt_audio_codec_cfg_freq freq);
/**
* @brief Convert frequency value to assigned numbers frequency.
*
* @param freq_hz The frequency value to convert.
*
* @retval -EINVAL if arguments are invalid.
* @retval The assigned numbers frequency (@ref bt_audio_codec_cfg_freq).
*/
int bt_audio_codec_cfg_freq_hz_to_freq(uint32_t freq_hz);
/**
* @brief Extract the frequency from a codec configuration.
*
* @param codec_cfg The codec configuration to extract data from.
*
* @retval A @ref bt_audio_codec_cfg_freq value
* @retval -EINVAL if arguments are invalid
* @retval -ENODATA if not found
* @retval -EBADMSG if found value has invalid size or value
*/
int bt_audio_codec_cfg_get_freq(const struct bt_audio_codec_cfg *codec_cfg);
/**
* @brief Set the frequency of a codec configuration.
*
* @param codec_cfg The codec configuration to set data for.
* @param freq The assigned numbers frequency to set.
*
* @retval The data_len of @p codec_cfg on success
* @retval -EINVAL if arguments are invalid
* @retval -ENOMEM if the new value could not set or added due to memory
*/
int bt_audio_codec_cfg_set_freq(struct bt_audio_codec_cfg *codec_cfg,
enum bt_audio_codec_cfg_freq freq);
/**
* @brief Convert assigned numbers frame duration to duration in microseconds.
*
* @param frame_dur The assigned numbers frame duration to convert.
*
* @retval -EINVAL if arguments are invalid.
* @retval The converted frame duration value in microseconds.
*/
int bt_audio_codec_cfg_frame_dur_to_frame_dur_us(enum bt_audio_codec_cfg_frame_dur frame_dur);
/**
* @brief Convert frame duration in microseconds to assigned numbers frame duration.
*
* @param frame_dur_us The frame duration in microseconds to convert.
*
* @retval -EINVAL if arguments are invalid.
* @retval The assigned numbers frame duration (@ref bt_audio_codec_cfg_frame_dur).
*/
int bt_audio_codec_cfg_frame_dur_us_to_frame_dur(uint32_t frame_dur_us);
/**
* @brief Extract frame duration from BT codec config
*
* @param codec_cfg The codec configuration to extract data from.
*
* @retval A @ref bt_audio_codec_cfg_frame_dur value
* @retval -EINVAL if arguments are invalid
* @retval -ENODATA if not found
* @retval -EBADMSG if found value has invalid size or value
*/
int bt_audio_codec_cfg_get_frame_dur(const struct bt_audio_codec_cfg *codec_cfg);
/**
* @brief Set the frame duration of a codec configuration.
*
* @param codec_cfg The codec configuration to set data for.
* @param frame_dur The assigned numbers frame duration to set.
*
* @retval The data_len of @p codec_cfg on success
* @retval -EINVAL if arguments are invalid
* @retval -ENOMEM if the new value could not set or added due to memory
*/
int bt_audio_codec_cfg_set_frame_dur(struct bt_audio_codec_cfg *codec_cfg,
enum bt_audio_codec_cfg_frame_dur frame_dur);
/**
* @brief Extract channel allocation from BT codec config
*
* The value returned is a bit field representing one or more audio locations as
* specified by @ref bt_audio_location
* Shall match one or more of the bits set in BT_PAC_SNK_LOC/BT_PAC_SRC_LOC.
*
* Up to the configured @ref BT_AUDIO_CODEC_CAP_TYPE_CHAN_COUNT number of channels can be present.
*
* @param codec_cfg The codec configuration to extract data from.
* @param chan_allocation Pointer to the variable to store the extracted value in.
* @param fallback_to_default If true this function will provide the default value of
* @ref BT_AUDIO_LOCATION_MONO_AUDIO if the type is not found when @p codec_cfg.id is @ref
* BT_HCI_CODING_FORMAT_LC3.
*
* @retval 0 if value is found and stored in the pointer provided
* @retval -EINVAL if arguments are invalid
* @retval -ENODATA if not found
* @retval -EBADMSG if found value has invalid size or value
*/
int bt_audio_codec_cfg_get_chan_allocation(const struct bt_audio_codec_cfg *codec_cfg,
enum bt_audio_location *chan_allocation,
bool fallback_to_default);
/**
* @brief Set the channel allocation of a codec configuration.
*
* @param codec_cfg The codec configuration to set data for.
* @param chan_allocation The channel allocation to set.
*
* @retval The data_len of @p codec_cfg on success
* @retval -EINVAL if arguments are invalid
* @retval -ENOMEM if the new value could not set or added due to memory
*/
int bt_audio_codec_cfg_set_chan_allocation(struct bt_audio_codec_cfg *codec_cfg,
enum bt_audio_location chan_allocation);
/**
* @brief Extract frame size in octets from BT codec config
*
* The overall SDU size will be octets_per_frame * blocks_per_sdu.
*
* The Bluetooth specifications are not clear about this value - it does not state that
* the codec shall use this SDU size only. A codec like LC3 supports variable bit-rate
* (per SDU) hence it might be allowed for an encoder to reduce the frame size below this
* value.
* Hence it is recommended to use the received SDU size and divide by
* blocks_per_sdu rather than relying on this octets_per_sdu value to be fixed.
*
* @param codec_cfg The codec configuration to extract data from.
*
* @retval Frame length in octets
* @retval -EINVAL if arguments are invalid
* @retval -ENODATA if not found
* @retval -EBADMSG if found value has invalid size or value
*/
int bt_audio_codec_cfg_get_octets_per_frame(const struct bt_audio_codec_cfg *codec_cfg);
/**
* @brief Set the octets per codec frame of a codec configuration.
*
* @param codec_cfg The codec configuration to set data for.
* @param octets_per_frame The octets per codec frame to set.
*
* @retval The data_len of @p codec_cfg on success
* @retval -EINVAL if arguments are invalid
* @retval -ENOMEM if the new value could not set or added due to memory
*/
int bt_audio_codec_cfg_set_octets_per_frame(struct bt_audio_codec_cfg *codec_cfg,
uint16_t octets_per_frame);
/**
* @brief Extract number of audio frame blocks in each SDU from BT codec config
*
* The overall SDU size will be octets_per_frame * frame_blocks_per_sdu * number-of-channels.
*
* If this value is not present a default value of 1 shall be used.
*
* A frame block is one or more frames that represents data for the same period of time but
* for different channels. If the stream have two audio channels and this value is two
* there will be four frames in the SDU.
*
* @param codec_cfg The codec configuration to extract data from.
* @param fallback_to_default If true this function will return the default value of 1
* if the type is not found when @p codec_cfg.id is @ref BT_HCI_CODING_FORMAT_LC3.
*
* @retval The count of codec frame blocks in each SDU.
* @retval -EINVAL if arguments are invalid
* @retval -ENODATA if not found
* @retval -EBADMSG if found value has invalid size or value
*/
int bt_audio_codec_cfg_get_frame_blocks_per_sdu(const struct bt_audio_codec_cfg *codec_cfg,
bool fallback_to_default);
/**
* @brief Set the frame blocks per SDU of a codec configuration.
*
* @param codec_cfg The codec configuration to set data for.
* @param frame_blocks The frame blocks per SDU to set.
*
* @retval The data_len of @p codec_cfg on success
* @retval -EINVAL if arguments are invalid
* @retval -ENOMEM if the new value could not set or added due to memory
*/
int bt_audio_codec_cfg_set_frame_blocks_per_sdu(struct bt_audio_codec_cfg *codec_cfg,
uint8_t frame_blocks);
/**
* @brief Lookup a specific codec configuration value
*
* @param[in] codec_cfg The codec data to search in.
* @param[in] type The type id to look for
* @param[out] data Pointer to the data-pointer to update when item is found
*
* @retval Length of found @p data (may be 0)
* @retval -EINVAL if arguments are invalid
* @retval -ENODATA if not found
*/
int bt_audio_codec_cfg_get_val(const struct bt_audio_codec_cfg *codec_cfg,
enum bt_audio_codec_cfg_type type, const uint8_t **data);
/**
* @brief Set or add a specific codec configuration value
*
* @param codec_cfg The codec data to set the value in.
* @param type The type id to set
* @param data Pointer to the data-pointer to set
* @param data_len Length of @p data
*
* @retval The data_len of @p codec_cfg on success
* @retval -EINVAL if arguments are invalid
* @retval -ENOMEM if the new value could not set or added due to memory
*/
int bt_audio_codec_cfg_set_val(struct bt_audio_codec_cfg *codec_cfg,
enum bt_audio_codec_cfg_type type, const uint8_t *data,
size_t data_len);
/**
* @brief Unset a specific codec configuration value
*
* The type and the value will be removed from the codec configuration.
*
* @param codec_cfg The codec data to set the value in.
* @param type The type id to unset.
*
* @retval The data_len of @p codec_cfg on success
* @retval -EINVAL if arguments are invalid
*/
int bt_audio_codec_cfg_unset_val(struct bt_audio_codec_cfg *codec_cfg,
enum bt_audio_codec_cfg_type type);
/**
* @brief Lookup a specific metadata value based on type
*
*
* @param[in] codec_cfg The codec data to search in.
* @param[in] type The type id to look for
* @param[out] data Pointer to the data-pointer to update when item is found
*
* @retval Length of found @p data (may be 0)
* @retval -EINVAL if arguments are invalid
* @retval -ENODATA if not found
*/
int bt_audio_codec_cfg_meta_get_val(const struct bt_audio_codec_cfg *codec_cfg, uint8_t type,
const uint8_t **data);
/**
* @brief Set or add a specific codec configuration metadata value.
*
* @param codec_cfg The codec configuration to set the value in.
* @param type The type id to set.
* @param data Pointer to the data-pointer to set.
* @param data_len Length of @p data.
*
* @retval The meta_len of @p codec_cfg on success
* @retval -EINVAL if arguments are invalid
* @retval -ENOMEM if the new value could not set or added due to memory
*/
int bt_audio_codec_cfg_meta_set_val(struct bt_audio_codec_cfg *codec_cfg,
enum bt_audio_metadata_type type, const uint8_t *data,
size_t data_len);
/**
* @brief Unset a specific codec configuration metadata value
*
* The type and the value will be removed from the codec configuration metadata.
*
* @param codec_cfg The codec data to set the value in.
* @param type The type id to unset.
*
* @retval The meta_len of @p codec_cfg on success
* @retval -EINVAL if arguments are invalid
*/
int bt_audio_codec_cfg_meta_unset_val(struct bt_audio_codec_cfg *codec_cfg,
enum bt_audio_metadata_type type);
/**
* @brief Extract preferred contexts
*
* See @ref BT_AUDIO_METADATA_TYPE_PREF_CONTEXT for more information about this value.
*
* @param codec_cfg The codec data to search in.
* @param fallback_to_default If true this function will provide the default value of
* @ref BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED if the type is not found when @p codec_cfg.id is
* @ref BT_HCI_CODING_FORMAT_LC3.
*
* @retval The preferred context type if positive or 0
* @retval -EINVAL if arguments are invalid
* @retval -ENODATA if not found
* @retval -EBADMSG if found value has invalid size
*/
int bt_audio_codec_cfg_meta_get_pref_context(const struct bt_audio_codec_cfg *codec_cfg,
bool fallback_to_default);
/**
* @brief Set the preferred context of a codec configuration metadata.
*
* @param codec_cfg The codec configuration to set data for.
* @param ctx The preferred context to set.
*
* @retval The data_len of @p codec_cfg on success
* @retval -EINVAL if arguments are invalid
* @retval -ENOMEM if the new value could not set or added due to memory
*/
int bt_audio_codec_cfg_meta_set_pref_context(struct bt_audio_codec_cfg *codec_cfg,
enum bt_audio_context ctx);
/**
* @brief Extract stream contexts
*
* See @ref BT_AUDIO_METADATA_TYPE_STREAM_CONTEXT for more information about this value.
*
* @param codec_cfg The codec data to search in.
*
* @retval The stream context type if positive or 0
* @retval -EINVAL if arguments are invalid
* @retval -ENODATA if not found
* @retval -EBADMSG if found value has invalid size
*/
int bt_audio_codec_cfg_meta_get_stream_context(const struct bt_audio_codec_cfg *codec_cfg);
/**
* @brief Set the stream context of a codec configuration metadata.
*
* @param codec_cfg The codec configuration to set data for.
* @param ctx The stream context to set.
*
* @retval The data_len of @p codec_cfg on success
* @retval -EINVAL if arguments are invalid
* @retval -ENOMEM if the new value could not set or added due to memory
*/
int bt_audio_codec_cfg_meta_set_stream_context(struct bt_audio_codec_cfg *codec_cfg,
enum bt_audio_context ctx);
/**
* @brief Extract program info
*
* See @ref BT_AUDIO_METADATA_TYPE_PROGRAM_INFO for more information about this value.
*
* @param[in] codec_cfg The codec data to search in.
* @param[out] program_info Pointer to the UTF-8 formatted program info.
*
* @retval The length of the @p program_info (may be 0)
* @retval -EINVAL if arguments are invalid
* @retval -ENODATA if not found
*/
int bt_audio_codec_cfg_meta_get_program_info(const struct bt_audio_codec_cfg *codec_cfg,
const uint8_t **program_info);
/**
* @brief Set the program info of a codec configuration metadata.
*
* @param codec_cfg The codec configuration to set data for.
* @param program_info The program info to set.
* @param program_info_len The length of @p program_info.
*
* @retval The data_len of @p codec_cfg on success
* @retval -EINVAL if arguments are invalid
* @retval -ENOMEM if the new value could not set or added due to memory
*/
int bt_audio_codec_cfg_meta_set_program_info(struct bt_audio_codec_cfg *codec_cfg,
const uint8_t *program_info, size_t program_info_len);
/**
* @brief Extract language
*
* See @ref BT_AUDIO_METADATA_TYPE_LANG for more information about this value.
*
* @param[in] codec_cfg The codec data to search in.
* @param[out] lang Pointer to the language bytes (of length BT_AUDIO_LANG_SIZE)
*
* @retval The language if positive or 0
* @retval -EINVAL if arguments are invalid
* @retval -ENODATA if not found
* @retval -EBADMSG if found value has invalid size
*/
int bt_audio_codec_cfg_meta_get_lang(const struct bt_audio_codec_cfg *codec_cfg,
const uint8_t **lang);
/**
* @brief Set the language of a codec configuration metadata.
*
* @param codec_cfg The codec configuration to set data for.
* @param lang The 24-bit language to set.
*
* @retval The data_len of @p codec_cfg on success
* @retval -EINVAL if arguments are invalid
* @retval -ENOMEM if the new value could not set or added due to memory
*/
int bt_audio_codec_cfg_meta_set_lang(struct bt_audio_codec_cfg *codec_cfg,
const uint8_t lang[BT_AUDIO_LANG_SIZE]);
/**
* @brief Extract CCID list
*
* See @ref BT_AUDIO_METADATA_TYPE_CCID_LIST for more information about this value.
*
* @param[in] codec_cfg The codec data to search in.
* @param[out] ccid_list Pointer to the array containing 8-bit CCIDs.
*
* @retval The length of the @p ccid_list (may be 0)
* @retval -EINVAL if arguments are invalid
* @retval -ENODATA if not found
*/
int bt_audio_codec_cfg_meta_get_ccid_list(const struct bt_audio_codec_cfg *codec_cfg,
const uint8_t **ccid_list);
/**
* @brief Set the CCID list of a codec configuration metadata.
*
* @param codec_cfg The codec configuration to set data for.
* @param ccid_list The program info to set.
* @param ccid_list_len The length of @p ccid_list.
*
* @retval The data_len of @p codec_cfg on success
* @retval -EINVAL if arguments are invalid
* @retval -ENOMEM if the new value could not set or added due to memory
*/
int bt_audio_codec_cfg_meta_set_ccid_list(struct bt_audio_codec_cfg *codec_cfg,
const uint8_t *ccid_list, size_t ccid_list_len);
/**
* @brief Extract parental rating
*
* See @ref BT_AUDIO_METADATA_TYPE_PARENTAL_RATING for more information about this value.
*
* @param codec_cfg The codec data to search in.
*
* @retval The parental rating if positive or 0
* @retval -EINVAL if arguments are invalid
* @retval -ENODATA if not found
* @retval -EBADMSG if found value has invalid size
*/
int bt_audio_codec_cfg_meta_get_parental_rating(const struct bt_audio_codec_cfg *codec_cfg);
/**
* @brief Set the parental rating of a codec configuration metadata.
*
* @param codec_cfg The codec configuration to set data for.
* @param parental_rating The parental rating to set.
*
* @retval The data_len of @p codec_cfg on success
* @retval -EINVAL if arguments are invalid
* @retval -ENOMEM if the new value could not set or added due to memory
*/
int bt_audio_codec_cfg_meta_set_parental_rating(struct bt_audio_codec_cfg *codec_cfg,
enum bt_audio_parental_rating parental_rating);
/**
* @brief Extract program info URI
*
* See @ref BT_AUDIO_METADATA_TYPE_PROGRAM_INFO_URI for more information about this value.
*
* @param[in] codec_cfg The codec data to search in.
* @param[out] program_info_uri Pointer to the UTF-8 formatted program info URI.
*
* @retval The length of the @p ccid_list (may be 0)
* @retval -EINVAL if arguments are invalid
* @retval -ENODATA if not found
*/
int bt_audio_codec_cfg_meta_get_program_info_uri(const struct bt_audio_codec_cfg *codec_cfg,
const uint8_t **program_info_uri);
/**
* @brief Set the program info URI of a codec configuration metadata.
*
* @param codec_cfg The codec configuration to set data for.
* @param program_info_uri The program info URI to set.
* @param program_info_uri_len The length of @p program_info_uri.
*
* @retval The data_len of @p codec_cfg on success
* @retval -EINVAL if arguments are invalid
* @retval -ENOMEM if the new value could not set or added due to memory
*/
int bt_audio_codec_cfg_meta_set_program_info_uri(struct bt_audio_codec_cfg *codec_cfg,
const uint8_t *program_info_uri,
size_t program_info_uri_len);
/**
* @brief Extract audio active state
*
* See @ref BT_AUDIO_METADATA_TYPE_AUDIO_STATE for more information about this value.
*
* @param codec_cfg The codec data to search in.
*
* @retval The preferred context type if positive or 0
* @retval -EINVAL if arguments are invalid
* @retval -ENODATA if not found
* @retval -EBADMSG if found value has invalid size
*/
int bt_audio_codec_cfg_meta_get_audio_active_state(const struct bt_audio_codec_cfg *codec_cfg);
/**
* @brief Set the audio active state of a codec configuration metadata.
*
* @param codec_cfg The codec configuration to set data for.
* @param state The audio active state to set.
*
* @retval The data_len of @p codec_cfg on success
* @retval -EINVAL if arguments are invalid
* @retval -ENOMEM if the new value could not set or added due to memory
*/
int bt_audio_codec_cfg_meta_set_audio_active_state(struct bt_audio_codec_cfg *codec_cfg,
enum bt_audio_active_state state);
/**
* @brief Extract broadcast audio immediate rendering flag
*
* See @ref BT_AUDIO_METADATA_TYPE_BROADCAST_IMMEDIATE for more information about this value.
*
* @param codec_cfg The codec data to search in.
*
* @retval 0 if the flag was found
* @retval -EINVAL if arguments are invalid
* @retval -ENODATA if the flag was not found
*/
int bt_audio_codec_cfg_meta_get_bcast_audio_immediate_rend_flag(
const struct bt_audio_codec_cfg *codec_cfg);
/**
* @brief Set the broadcast audio immediate rendering flag of a codec configuration metadata.
*
* @param codec_cfg The codec configuration to set data for.
*
* @retval The data_len of @p codec_cfg on success
* @retval -EINVAL if arguments are invalid
* @retval -ENOMEM if the new value could not set or added due to memory
*/
int bt_audio_codec_cfg_meta_set_bcast_audio_immediate_rend_flag(
struct bt_audio_codec_cfg *codec_cfg);
/**
* @brief Extract extended metadata
*
* See @ref BT_AUDIO_METADATA_TYPE_EXTENDED for more information about this value.
*
* @param[in] codec_cfg The codec data to search in.
* @param[out] extended_meta Pointer to the extended metadata.
*
* @retval The length of the @p ccid_list (may be 0)
* @retval -EINVAL if arguments are invalid
* @retval -ENODATA if not found
*/
int bt_audio_codec_cfg_meta_get_extended(const struct bt_audio_codec_cfg *codec_cfg,
const uint8_t **extended_meta);
/**
* @brief Set the extended metadata of a codec configuration metadata.
*
* @param codec_cfg The codec configuration to set data for.
* @param extended_meta The extended metadata to set.
* @param extended_meta_len The length of @p extended_meta.
*
* @retval The data_len of @p codec_cfg on success
* @retval -EINVAL if arguments are invalid
* @retval -ENOMEM if the new value could not set or added due to memory
*/
int bt_audio_codec_cfg_meta_set_extended(struct bt_audio_codec_cfg *codec_cfg,
const uint8_t *extended_meta, size_t extended_meta_len);
/**
* @brief Extract vendor specific metadata
*
* See @ref BT_AUDIO_METADATA_TYPE_VENDOR for more information about this value.
*
* @param[in] codec_cfg The codec data to search in.
* @param[out] vendor_meta Pointer to the vendor specific metadata.
*
* @retval The length of the @p ccid_list (may be 0)
* @retval -EINVAL if arguments are invalid
* @retval -ENODATA if not found
*/
int bt_audio_codec_cfg_meta_get_vendor(const struct bt_audio_codec_cfg *codec_cfg,
const uint8_t **vendor_meta);
/**
* @brief Set the vendor specific metadata of a codec configuration metadata.
*
* @param codec_cfg The codec configuration to set data for.
* @param vendor_meta The vendor specific metadata to set.
* @param vendor_meta_len The length of @p vendor_meta.
*
* @retval The data_len of @p codec_cfg on success
* @retval -EINVAL if arguments are invalid
* @retval -ENOMEM if the new value could not set or added due to memory
*/
int bt_audio_codec_cfg_meta_set_vendor(struct bt_audio_codec_cfg *codec_cfg,
const uint8_t *vendor_meta, size_t vendor_meta_len);
/** @} */ /* End of bt_audio_codec_cfg */
/**
* @brief Audio codec capabilities APIs
* @defgroup bt_audio_codec_cap Codec capability parsing APIs
*
* Functions to parse codec capability data when formatted as LTV wrapped into @ref
* bt_audio_codec_cap.
*
* @{
*/
/**
* @brief Lookup a specific value based on type
*
* @param[in] codec_cap The codec data to search in.
* @param[in] type The type id to look for
* @param[out] data Pointer to the data-pointer to update when item is found
*
* @retval Length of found @p data (may be 0)
* @retval -EINVAL if arguments are invalid
* @retval -ENODATA if not found
*/
int bt_audio_codec_cap_get_val(const struct bt_audio_codec_cap *codec_cap,
enum bt_audio_codec_cap_type type, const uint8_t **data);
/**
* @brief Set or add a specific codec capability value
*
* @param codec_cap The codec data to set the value in.
* @param type The type id to set
* @param data Pointer to the data-pointer to set
* @param data_len Length of @p data
*
* @retval The data_len of @p codec_cap on success
* @retval -EINVAL if arguments are invalid
* @retval -ENOMEM if the new value could not set or added due to memory
*/
int bt_audio_codec_cap_set_val(struct bt_audio_codec_cap *codec_cap,
enum bt_audio_codec_cap_type type, const uint8_t *data,
size_t data_len);
/**
* @brief Unset a specific codec capability value
*
* The type and the value will be removed from the codec capability.
*
* @param codec_cap The codec data to set the value in.
* @param type The type id to unset.
*
* @retval The data_len of @p codec_cap on success
* @retval -EINVAL if arguments are invalid
*/
int bt_audio_codec_cap_unset_val(struct bt_audio_codec_cap *codec_cap,
enum bt_audio_codec_cap_type type);
/**
* @brief Extract the frequency from a codec capability.
*
* @param codec_cap The codec capabilities to extract data from.
*
* @retval Bitfield of supported frequencies (@ref bt_audio_codec_cap_freq) if 0 or positive
* @retval -EINVAL if arguments are invalid
* @retval -ENODATA if not found
* @retval -EBADMSG if found value has invalid size or value
*/
int bt_audio_codec_cap_get_freq(const struct bt_audio_codec_cap *codec_cap);
/**
* @brief Set the supported frequencies of a codec capability.
*
* @param codec_cap The codec capabilities to set data for.
* @param freq The supported frequencies to set.
*
* @retval The data_len of @p codec_cap on success
* @retval -EINVAL if arguments are invalid
* @retval -ENOMEM if the new value could not set or added due to memory
*/
int bt_audio_codec_cap_set_freq(struct bt_audio_codec_cap *codec_cap,
enum bt_audio_codec_cap_freq freq);
/**
* @brief Extract the frequency from a codec capability.
*
* @param codec_cap The codec capabilities to extract data from.
*
* @retval Bitfield of supported frame durations if 0 or positive
* @retval -EINVAL if arguments are invalid
* @retval -ENODATA if not found
* @retval -EBADMSG if found value has invalid size or value
*/
int bt_audio_codec_cap_get_frame_dur(const struct bt_audio_codec_cap *codec_cap);
/**
* @brief Set the frame duration of a codec capability.
*
* @param codec_cap The codec capabilities to set data for.
* @param frame_dur The frame duration to set.
*
* @retval The data_len of @p codec_cap on success
* @retval -EINVAL if arguments are invalid
* @retval -ENOMEM if the new value could not set or added due to memory
*/
int bt_audio_codec_cap_set_frame_dur(struct bt_audio_codec_cap *codec_cap,
enum bt_audio_codec_cap_frame_dur frame_dur);
/**
* @brief Extract the frequency from a codec capability.
*
* @param codec_cap The codec capabilities to extract data from.
* @param fallback_to_default If true this function will provide the default value of 1
* if the type is not found when @p codec_cap.id is @ref BT_HCI_CODING_FORMAT_LC3.
*
* @retval Number of supported channel counts if 0 or positive
* @retval -EINVAL if arguments are invalid
* @retval -ENODATA if not found
* @retval -EBADMSG if found value has invalid size or value
*/
int bt_audio_codec_cap_get_supported_audio_chan_counts(const struct bt_audio_codec_cap *codec_cap,
bool fallback_to_default);
/**
* @brief Set the channel count of a codec capability.
*
* @param codec_cap The codec capabilities to set data for.
* @param chan_count The channel count frequency to set.
*
* @retval The data_len of @p codec_cap on success
* @retval -EINVAL if arguments are invalid
* @retval -ENOMEM if the new value could not set or added due to memory
*/
int bt_audio_codec_cap_set_supported_audio_chan_counts(
struct bt_audio_codec_cap *codec_cap, enum bt_audio_codec_cap_chan_count chan_count);
/**
* @brief Extract the supported octets per codec frame from a codec capability.
*
* @param[in] codec_cap The codec capabilities to extract data from.
* @param[out] codec_frame Struct to place the resulting values in
*
* @retval 0 on success
* @retval -EINVAL if arguments are invalid
* @retval -ENODATA if not found
* @retval -EBADMSG if found value has invalid size or value
*/
int bt_audio_codec_cap_get_octets_per_frame(
const struct bt_audio_codec_cap *codec_cap,
struct bt_audio_codec_octets_per_codec_frame *codec_frame);
/**
* @brief Set the octets per codec frame of a codec capability.
*
* @param codec_cap The codec capabilities to set data for.
* @param codec_frame The octets per codec frame to set.
*
* @retval The data_len of @p codec_cap on success
* @retval -EINVAL if arguments are invalid
* @retval -ENOMEM if the new value could not set or added due to memory
*/
int bt_audio_codec_cap_set_octets_per_frame(
struct bt_audio_codec_cap *codec_cap,
const struct bt_audio_codec_octets_per_codec_frame *codec_frame);
/**
* @brief Extract the maximum codec frames per SDU from a codec capability.
*
* @param codec_cap The codec capabilities to extract data from.
* @param fallback_to_default If true this function will provide the default value of 1
* if the type is not found when @p codec_cap.id is @ref BT_HCI_CODING_FORMAT_LC3.
*
* @retval Maximum number of codec frames per SDU supported
* @retval -EINVAL if arguments are invalid
* @retval -ENODATA if not found
* @retval -EBADMSG if found value has invalid size or value
*/
int bt_audio_codec_cap_get_max_codec_frames_per_sdu(const struct bt_audio_codec_cap *codec_cap,
bool fallback_to_default);
/**
* @brief Set the maximum codec frames per SDU of a codec capability.
*
* @param codec_cap The codec capabilities to set data for.
* @param codec_frames_per_sdu The maximum codec frames per SDU to set.
*
* @retval The data_len of @p codec_cap on success
* @retval -EINVAL if arguments are invalid
* @retval -ENOMEM if the new value could not set or added due to memory
*/
int bt_audio_codec_cap_set_max_codec_frames_per_sdu(struct bt_audio_codec_cap *codec_cap,
uint8_t codec_frames_per_sdu);
/**
* @brief Lookup a specific metadata value based on type
*
* @param[in] codec_cap The codec data to search in.
* @param[in] type The type id to look for
* @param[out] data Pointer to the data-pointer to update when item is found
*
* @retval Length of found @p data (may be 0)
* @retval -EINVAL if arguments are invalid
* @retval -ENODATA if not found
*/
int bt_audio_codec_cap_meta_get_val(const struct bt_audio_codec_cap *codec_cap, uint8_t type,
const uint8_t **data);
/**
* @brief Set or add a specific codec capability metadata value.
*
* @param codec_cap The codec capability to set the value in.
* @param type The type id to set.
* @param data Pointer to the data-pointer to set.
* @param data_len Length of @p data.
*
* @retval The meta_len of @p codec_cap on success
* @retval -EINVAL if arguments are invalid
* @retval -ENOMEM if the new value could not set or added due to memory
*/
int bt_audio_codec_cap_meta_set_val(struct bt_audio_codec_cap *codec_cap,
enum bt_audio_metadata_type type, const uint8_t *data,
size_t data_len);
/**
* @brief Unset a specific codec capability metadata value
*
* The type and the value will be removed from the codec capability metadata.
*
* @param codec_cap The codec data to set the value in.
* @param type The type id to unset.
*
* @retval The meta_len of @p codec_cap on success
* @retval -EINVAL if arguments are invalid
*/
int bt_audio_codec_cap_meta_unset_val(struct bt_audio_codec_cap *codec_cap,
enum bt_audio_metadata_type type);
/**
* @brief Extract preferred contexts
*
* See @ref BT_AUDIO_METADATA_TYPE_PREF_CONTEXT for more information about this value.
*
* @param codec_cap The codec data to search in.
*
* @retval The preferred context type if positive or 0
* @retval -EINVAL if arguments are invalid
* @retval -ENODATA if not found
* @retval -EBADMSG if found value has invalid size
*/
int bt_audio_codec_cap_meta_get_pref_context(const struct bt_audio_codec_cap *codec_cap);
/**
* @brief Set the preferred context of a codec capability metadata.
*
* @param codec_cap The codec capability to set data for.
* @param ctx The preferred context to set.
*
* @retval The data_len of @p codec_cap on success
* @retval -EINVAL if arguments are invalid
* @retval -ENOMEM if the new value could not set or added due to memory
*/
int bt_audio_codec_cap_meta_set_pref_context(struct bt_audio_codec_cap *codec_cap,
enum bt_audio_context ctx);
/**
* @brief Extract stream contexts
*
* See @ref BT_AUDIO_METADATA_TYPE_STREAM_CONTEXT for more information about this value.
*
* @param codec_cap The codec data to search in.
*
* @retval The stream context type if positive or 0
* @retval -EINVAL if arguments are invalid
* @retval -ENODATA if not found
* @retval -EBADMSG if found value has invalid size
*/
int bt_audio_codec_cap_meta_get_stream_context(const struct bt_audio_codec_cap *codec_cap);
/**
* @brief Set the stream context of a codec capability metadata.
*
* @param codec_cap The codec capability to set data for.
* @param ctx The stream context to set.
*
* @retval The data_len of @p codec_cap on success
* @retval -EINVAL if arguments are invalid
* @retval -ENOMEM if the new value could not set or added due to memory
*/
int bt_audio_codec_cap_meta_set_stream_context(struct bt_audio_codec_cap *codec_cap,
enum bt_audio_context ctx);
/**
* @brief Extract program info
*
* See @ref BT_AUDIO_METADATA_TYPE_PROGRAM_INFO for more information about this value.
*
* @param[in] codec_cap The codec data to search in.
* @param[out] program_info Pointer to the UTF-8 formatted program info.
*
* @retval The length of the @p program_info (may be 0)
* @retval -EINVAL if arguments are invalid
* @retval -ENODATA if not found
*/
int bt_audio_codec_cap_meta_get_program_info(const struct bt_audio_codec_cap *codec_cap,
const uint8_t **program_info);
/**
* @brief Set the program info of a codec capability metadata.
*
* @param codec_cap The codec capability to set data for.
* @param program_info The program info to set.
* @param program_info_len The length of @p program_info.
*
* @retval The data_len of @p codec_cap on success
* @retval -EINVAL if arguments are invalid
* @retval -ENOMEM if the new value could not set or added due to memory
*/
int bt_audio_codec_cap_meta_set_program_info(struct bt_audio_codec_cap *codec_cap,
const uint8_t *program_info, size_t program_info_len);
/**
* @brief Extract language
*
* See @ref BT_AUDIO_METADATA_TYPE_LANG for more information about this value.
*
* @param[in] codec_cap The codec data to search in.
* @param[out] lang Pointer to the language bytes (of length BT_AUDIO_LANG_SIZE)
*
* @retval 0 On success
* @retval -EINVAL if arguments are invalid
* @retval -ENODATA if not found
* @retval -EBADMSG if found value has invalid size
*/
int bt_audio_codec_cap_meta_get_lang(const struct bt_audio_codec_cap *codec_cap,
const uint8_t **lang);
/**
* @brief Set the language of a codec capability metadata.
*
* @param codec_cap The codec capability to set data for.
* @param lang The 24-bit language to set.
*
* @retval The data_len of @p codec_cap on success
* @retval -EINVAL if arguments are invalid
* @retval -ENOMEM if the new value could not set or added due to memory
*/
int bt_audio_codec_cap_meta_set_lang(struct bt_audio_codec_cap *codec_cap,
const uint8_t lang[BT_AUDIO_LANG_SIZE]);
/**
* @brief Extract CCID list
*
* See @ref BT_AUDIO_METADATA_TYPE_CCID_LIST for more information about this value.
*
* @param[in] codec_cap The codec data to search in.
* @param[out] ccid_list Pointer to the array containing 8-bit CCIDs.
*
* @retval The length of the @p ccid_list (may be 0)
* @retval -EINVAL if arguments are invalid
* @retval -ENODATA if not found
*/
int bt_audio_codec_cap_meta_get_ccid_list(const struct bt_audio_codec_cap *codec_cap,
const uint8_t **ccid_list);
/**
* @brief Set the CCID list of a codec capability metadata.
*
* @param codec_cap The codec capability to set data for.
* @param ccid_list The program info to set.
* @param ccid_list_len The length of @p ccid_list.
*
* @retval The data_len of @p codec_cap on success
* @retval -EINVAL if arguments are invalid
* @retval -ENOMEM if the new value could not set or added due to memory
*/
int bt_audio_codec_cap_meta_set_ccid_list(struct bt_audio_codec_cap *codec_cap,
const uint8_t *ccid_list, size_t ccid_list_len);
/**
* @brief Extract parental rating
*
* See @ref BT_AUDIO_METADATA_TYPE_PARENTAL_RATING for more information about this value.
*
* @param codec_cap The codec data to search in.
*
* @retval The parental rating if positive or 0
* @retval -EINVAL if arguments are invalid
* @retval -ENODATA if not found
* @retval -EBADMSG if found value has invalid size
*/
int bt_audio_codec_cap_meta_get_parental_rating(const struct bt_audio_codec_cap *codec_cap);
/**
* @brief Set the parental rating of a codec capability metadata.
*
* @param codec_cap The codec capability to set data for.
* @param parental_rating The parental rating to set.
*
* @retval The data_len of @p codec_cap on success
* @retval -EINVAL if arguments are invalid
* @retval -ENOMEM if the new value could not set or added due to memory
*/
int bt_audio_codec_cap_meta_set_parental_rating(struct bt_audio_codec_cap *codec_cap,
enum bt_audio_parental_rating parental_rating);
/**
* @brief Extract program info URI
*
* See @ref BT_AUDIO_METADATA_TYPE_PROGRAM_INFO_URI for more information about this value.
*
* @param[in] codec_cap The codec data to search in.
* @param[out] program_info_uri Pointer to the UTF-8 formatted program info URI.
*
* @retval The length of the @p ccid_list (may be 0)
* @retval -EINVAL if arguments are invalid
* @retval -ENODATA if not found
*/
int bt_audio_codec_cap_meta_get_program_info_uri(const struct bt_audio_codec_cap *codec_cap,
const uint8_t **program_info_uri);
/**
* @brief Set the program info URI of a codec capability metadata.
*
* @param codec_cap The codec capability to set data for.
* @param program_info_uri The program info URI to set.
* @param program_info_uri_len The length of @p program_info_uri.
*
* @retval The data_len of @p codec_cap on success
* @retval -EINVAL if arguments are invalid
* @retval -ENOMEM if the new value could not set or added due to memory
*/
int bt_audio_codec_cap_meta_set_program_info_uri(struct bt_audio_codec_cap *codec_cap,
const uint8_t *program_info_uri,
size_t program_info_uri_len);
/**
* @brief Extract audio active state
*
* See @ref BT_AUDIO_METADATA_TYPE_AUDIO_STATE for more information about this value.
*
* @param codec_cap The codec data to search in.
*
* @retval The preferred context type if positive or 0
* @retval -EINVAL if arguments are invalid
* @retval -ENODATA if not found
* @retval -EBADMSG if found value has invalid size
*/
int bt_audio_codec_cap_meta_get_audio_active_state(const struct bt_audio_codec_cap *codec_cap);
/**
* @brief Set the audio active state of a codec capability metadata.
*
* @param codec_cap The codec capability to set data for.
* @param state The audio active state to set.
*
* @retval The data_len of @p codec_cap on success
* @retval -EINVAL if arguments are invalid
* @retval -ENOMEM if the new value could not set or added due to memory
*/
int bt_audio_codec_cap_meta_set_audio_active_state(struct bt_audio_codec_cap *codec_cap,
enum bt_audio_active_state state);
/**
* @brief Extract broadcast audio immediate rendering flag
*
* See @ref BT_AUDIO_METADATA_TYPE_BROADCAST_IMMEDIATE for more information about this value.
*
* @param codec_cap The codec data to search in.
*
* @retval 0 if the flag was found
* @retval -EINVAL if arguments are invalid
* @retval -ENODATA if not the flag was not found
*/
int bt_audio_codec_cap_meta_get_bcast_audio_immediate_rend_flag(
const struct bt_audio_codec_cap *codec_cap);
/**
* @brief Set the broadcast audio immediate rendering flag of a codec capability metadata.
*
* @param codec_cap The codec capability to set data for.
*
* @retval The data_len of @p codec_cap on success
* @retval -EINVAL if arguments are invalid
* @retval -ENOMEM if the new value could not set or added due to memory
*/
int bt_audio_codec_cap_meta_set_bcast_audio_immediate_rend_flag(
struct bt_audio_codec_cap *codec_cap);
/**
* @brief Extract extended metadata
*
* See @ref BT_AUDIO_METADATA_TYPE_EXTENDED for more information about this value.
*
* @param[in] codec_cap The codec data to search in.
* @param[out] extended_meta Pointer to the extended metadata.
*
* @retval The length of the @p ccid_list (may be 0)
* @retval -EINVAL if arguments are invalid
* @retval -ENODATA if not found
*/
int bt_audio_codec_cap_meta_get_extended(const struct bt_audio_codec_cap *codec_cap,
const uint8_t **extended_meta);
/**
* @brief Set the extended metadata of a codec capability metadata.
*
* @param codec_cap The codec capability to set data for.
* @param extended_meta The extended metadata to set.
* @param extended_meta_len The length of @p extended_meta.
*
* @retval The data_len of @p codec_cap on success
* @retval -EINVAL if arguments are invalid
* @retval -ENOMEM if the new value could not set or added due to memory
*/
int bt_audio_codec_cap_meta_set_extended(struct bt_audio_codec_cap *codec_cap,
const uint8_t *extended_meta, size_t extended_meta_len);
/**
* @brief Extract vendor specific metadata
*
* See @ref BT_AUDIO_METADATA_TYPE_VENDOR for more information about this value.
*
* @param[in] codec_cap The codec data to search in.
* @param[out] vendor_meta Pointer to the vendor specific metadata.
*
* @retval The length of the @p ccid_list (may be 0)
* @retval -EINVAL if arguments are invalid
* @retval -ENODATA if not found
*/
int bt_audio_codec_cap_meta_get_vendor(const struct bt_audio_codec_cap *codec_cap,
const uint8_t **vendor_meta);
/**
* @brief Set the vendor specific metadata of a codec capability metadata.
*
* @param codec_cap The codec capability to set data for.
* @param vendor_meta The vendor specific metadata to set.
* @param vendor_meta_len The length of @p vendor_meta.
*
* @retval The data_len of @p codec_cap on success
* @retval -EINVAL if arguments are invalid
* @retval -ENOMEM if the new value could not set or added due to memory
*/
int bt_audio_codec_cap_meta_set_vendor(struct bt_audio_codec_cap *codec_cap,
const uint8_t *vendor_meta, size_t vendor_meta_len);
/** @} */ /* End of bt_audio_codec_cap */
#ifdef __cplusplus
}
#endif
/** @} */ /* end of bt_audio */
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/audio/audio.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 18,727 |
```objective-c
/**
* @file
* @brief Bluetooth Media Proxy APIs
*/
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_MEDIA_PROXY_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_MEDIA_PROXY_H_
/**
* @brief Media proxy module
*
* @defgroup bt_media_proxy Media Proxy
*
* @since 3.0
* @version 0.8.0
*
* @ingroup bluetooth
* @{
*
* The media proxy module is the connection point between media players
* and media controllers.
*
* A media player has (access to) media content and knows how to
* navigate and play this content. A media controller reads or gets
* information from a player and controls the player by setting player
* parameters and giving the player commands.
*
* The media proxy module allows media player implementations to make
* themselves available to media controllers. And it allows
* controllers to access, and get updates from, any player.
*
* The media proxy module allows both local and remote control of
* local player instances: A media controller may be a local
* application, or it may be a Media Control Service relaying requests
* from a remote Media Control Client. There may be either local or
* remote control, or both, or even multiple instances of each.
*/
#include <stdint.h>
#include <stdbool.h>
#include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/sys/util_macro.h>
/* TODO: Remove dependency on mcs.h */
#include "mcs.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Media player command
*/
struct mpl_cmd {
/** The opcode. See the MEDIA_PROXY_OP_* values */
uint8_t opcode;
/** Whether or not the @ref mpl_cmd.param is used */
bool use_param;
/** A 32-bit signed parameter. The parameter value depends on the @ref mpl_cmd.opcode */
int32_t param;
};
/**
* @brief Media command notification
*/
struct mpl_cmd_ntf {
/** The opcode that was sent */
uint8_t requested_opcode;
/** The result of the operation */
uint8_t result_code;
};
/**
* @brief Search control item
*/
struct mpl_sci {
uint8_t len; /**< Length of type and parameter */
uint8_t type; /**< MEDIA_PROXY_SEARCH_TYPE_<...> */
char param[SEARCH_PARAM_MAX]; /**< Search parameter */
};
/**
* @brief Search
*/
struct mpl_search {
/** The length of the @ref mpl_search.search value */
uint8_t len;
/** Concatenated search control items - (type, length, param) */
char search[SEARCH_LEN_MAX];
};
/**
* @name Playback speed parameters
*
* All values from -128 to 127 allowed, only some defined
* @{
*/
/** Minimum playback speed, resulting in 25 % speed */
#define MEDIA_PROXY_PLAYBACK_SPEED_MIN -128
/** Quarter playback speed, resulting in 25 % speed */
#define MEDIA_PROXY_PLAYBACK_SPEED_QUARTER -128
/** Half playback speed, resulting in 50 % speed */
#define MEDIA_PROXY_PLAYBACK_SPEED_HALF -64
/** Unity playback speed, resulting in 100 % speed */
#define MEDIA_PROXY_PLAYBACK_SPEED_UNITY 0
/** Double playback speed, resulting in 200 % speed */
#define MEDIA_PROXY_PLAYBACK_SPEED_DOUBLE 64
/** Max playback speed, resulting in 395.7 % speed (nearly 400 %) */
#define MEDIA_PROXY_PLAYBACK_SPEED_MAX 127
/** @} */
/**
* @name Seeking speed factors
*
* The allowed values for seeking speed are the range -64 to -4
* (endpoints included), the value 0, and the range 4 to 64
* (endpoints included).
* @{
*/
/** Maximum seeking speed - Can be negated */
#define MEDIA_PROXY_SEEKING_SPEED_FACTOR_MAX 64
/** Minimum seeking speed - Can be negated */
#define MEDIA_PROXY_SEEKING_SPEED_FACTOR_MIN 4
/** No seeking */
#define MEDIA_PROXY_SEEKING_SPEED_FACTOR_ZERO 0
/** @} */
/**
* @name Playing orders
* @{
*/
/** A single track is played once; there is no next track. */
#define MEDIA_PROXY_PLAYING_ORDER_SINGLE_ONCE 0x01
/** A single track is played repeatedly; the next track is the current track. */
#define MEDIA_PROXY_PLAYING_ORDER_SINGLE_REPEAT 0x02
/** The tracks within a group are played once in track order. */
#define MEDIA_PROXY_PLAYING_ORDER_INORDER_ONCE 0x03
/** The tracks within a group are played in track order repeatedly. */
#define MEDIA_PROXY_PLAYING_ORDER_INORDER_REPEAT 0x04
/** The tracks within a group are played once only from the oldest first. */
#define MEDIA_PROXY_PLAYING_ORDER_OLDEST_ONCE 0x05
/** The tracks within a group are played from the oldest first repeatedly. */
#define MEDIA_PROXY_PLAYING_ORDER_OLDEST_REPEAT 0x06
/** The tracks within a group are played once only from the newest first. */
#define MEDIA_PROXY_PLAYING_ORDER_NEWEST_ONCE 0x07
/** The tracks within a group are played from the newest first repeatedly. */
#define MEDIA_PROXY_PLAYING_ORDER_NEWEST_REPEAT 0x08
/** The tracks within a group are played in random order once. */
#define MEDIA_PROXY_PLAYING_ORDER_SHUFFLE_ONCE 0x09
/** The tracks within a group are played in random order repeatedly. */
#define MEDIA_PROXY_PLAYING_ORDER_SHUFFLE_REPEAT 0x0a
/** @} */
/**
* @name Playing orders supported
*
* A bitmap, in the same order as the playing orders above.
* Note that playing order 1 corresponds to bit 0, and so on.
* @{
*/
/** A single track is played once; there is no next track. */
#define MEDIA_PROXY_PLAYING_ORDERS_SUPPORTED_SINGLE_ONCE BIT(0)
/** A single track is played repeatedly; the next track is the current track. */
#define MEDIA_PROXY_PLAYING_ORDERS_SUPPORTED_SINGLE_REPEAT BIT(1)
/** The tracks within a group are played once in track order. */
#define MEDIA_PROXY_PLAYING_ORDERS_SUPPORTED_INORDER_ONCE BIT(2)
/** The tracks within a group are played in track order repeatedly. */
#define MEDIA_PROXY_PLAYING_ORDERS_SUPPORTED_INORDER_REPEAT BIT(3)
/** The tracks within a group are played once only from the oldest first. */
#define MEDIA_PROXY_PLAYING_ORDERS_SUPPORTED_OLDEST_ONCE BIT(4)
/** The tracks within a group are played from the oldest first repeatedly. */
#define MEDIA_PROXY_PLAYING_ORDERS_SUPPORTED_OLDEST_REPEAT BIT(5)
/** The tracks within a group are played once only from the newest first. */
#define MEDIA_PROXY_PLAYING_ORDERS_SUPPORTED_NEWEST_ONCE BIT(6)
/** The tracks within a group are played from the newest first repeatedly. */
#define MEDIA_PROXY_PLAYING_ORDERS_SUPPORTED_NEWEST_REPEAT BIT(7)
/** The tracks within a group are played in random order once. */
#define MEDIA_PROXY_PLAYING_ORDERS_SUPPORTED_SHUFFLE_ONCE BIT(8)
/** The tracks within a group are played in random order repeatedly. */
#define MEDIA_PROXY_PLAYING_ORDERS_SUPPORTED_SHUFFLE_REPEAT BIT(9)
/** @} */
/**
* @name Media player states
* @{
*/
/** The current track is invalid, and no track has been selected. */
#define MEDIA_PROXY_STATE_INACTIVE 0x00
/** The media player is playing the current track. */
#define MEDIA_PROXY_STATE_PLAYING 0x01
/** The current track is paused. The media player has a current track, but it is not being played */
#define MEDIA_PROXY_STATE_PAUSED 0x02
/** The current track is fast forwarding or fast rewinding. */
#define MEDIA_PROXY_STATE_SEEKING 0x03
/** Used internally as the last state value */
#define MEDIA_PROXY_STATE_LAST 0x04
/** @} */
/**
* @name Media player command opcodes
* @{
*/
/** Start playing the current track. */
#define MEDIA_PROXY_OP_PLAY 0x01
/** Pause playing the current track. */
#define MEDIA_PROXY_OP_PAUSE 0x02
/** Fast rewind the current track. */
#define MEDIA_PROXY_OP_FAST_REWIND 0x03
/** Fast forward the current track. */
#define MEDIA_PROXY_OP_FAST_FORWARD 0x04
/**
* Stop current activity and return to the paused state and set the current track position to the
* start of the current track.
*/
#define MEDIA_PROXY_OP_STOP 0x05
/** Set a new current track position relative to the current track position. */
#define MEDIA_PROXY_OP_MOVE_RELATIVE 0x10
/**
* Set the current track position to the starting position of the previous segment of the current
* track.
*/
#define MEDIA_PROXY_OP_PREV_SEGMENT 0x20
/**
* Set the current track position to the starting position of
* the next segment of the current track.
*/
#define MEDIA_PROXY_OP_NEXT_SEGMENT 0x21
/**
* Set the current track position to the starting position of
* the first segment of the current track.
*/
#define MEDIA_PROXY_OP_FIRST_SEGMENT 0x22
/**
* Set the current track position to the starting position of
* the last segment of the current track.
*/
#define MEDIA_PROXY_OP_LAST_SEGMENT 0x23
/**
* Set the current track position to the starting position of
* the nth segment of the current track.
*/
#define MEDIA_PROXY_OP_GOTO_SEGMENT 0x24
/** Set the current track to the previous track based on the playing order. */
#define MEDIA_PROXY_OP_PREV_TRACK 0x30
/** Set the current track to the next track based on the playing order. */
#define MEDIA_PROXY_OP_NEXT_TRACK 0x31
/** Set the current track to the first track based on the playing order. */
#define MEDIA_PROXY_OP_FIRST_TRACK 0x32
/** Set the current track to the last track based on the playing order. */
#define MEDIA_PROXY_OP_LAST_TRACK 0x33
/** Set the current track to the nth track based on the playing order. */
#define MEDIA_PROXY_OP_GOTO_TRACK 0x34
/** Set the current group to the previous group in the sequence of groups. */
#define MEDIA_PROXY_OP_PREV_GROUP 0x40
/** Set the current group to the next group in the sequence of groups. */
#define MEDIA_PROXY_OP_NEXT_GROUP 0x41
/** Set the current group to the first group in the sequence of groups. */
#define MEDIA_PROXY_OP_FIRST_GROUP 0x42
/** Set the current group to the last group in the sequence of groups. */
#define MEDIA_PROXY_OP_LAST_GROUP 0x43
/** Set the current group to the nth group in the sequence of groups. */
#define MEDIA_PROXY_OP_GOTO_GROUP 0x44
/** @} */
/**
* @brief Media player supported opcodes length
*/
#define MEDIA_PROXY_OPCODES_SUPPORTED_LEN 4
/**
* @brief Media player supported command opcodes
* @{
*/
/** Support the Play opcode */
#define MEDIA_PROXY_OP_SUP_PLAY BIT(0)
/** Support the Pause opcode */
#define MEDIA_PROXY_OP_SUP_PAUSE BIT(1)
/** Support the Fast Rewind opcode */
#define MEDIA_PROXY_OP_SUP_FAST_REWIND BIT(2)
/** Support the Fast Forward opcode */
#define MEDIA_PROXY_OP_SUP_FAST_FORWARD BIT(3)
/** Support the Stop opcode */
#define MEDIA_PROXY_OP_SUP_STOP BIT(4)
/** Support the Move Relative opcode */
#define MEDIA_PROXY_OP_SUP_MOVE_RELATIVE BIT(5)
/** Support the Previous Segment opcode */
#define MEDIA_PROXY_OP_SUP_PREV_SEGMENT BIT(6)
/** Support the Next Segment opcode */
#define MEDIA_PROXY_OP_SUP_NEXT_SEGMENT BIT(7)
/** Support the First Segment opcode */
#define MEDIA_PROXY_OP_SUP_FIRST_SEGMENT BIT(8)
/** Support the Last Segment opcode */
#define MEDIA_PROXY_OP_SUP_LAST_SEGMENT BIT(9)
/** Support the Goto Segment opcode */
#define MEDIA_PROXY_OP_SUP_GOTO_SEGMENT BIT(10)
/** Support the Previous Track opcode */
#define MEDIA_PROXY_OP_SUP_PREV_TRACK BIT(11)
/** Support the Next Track opcode */
#define MEDIA_PROXY_OP_SUP_NEXT_TRACK BIT(12)
/** Support the First Track opcode */
#define MEDIA_PROXY_OP_SUP_FIRST_TRACK BIT(13)
/** Support the Last Track opcode */
#define MEDIA_PROXY_OP_SUP_LAST_TRACK BIT(14)
/** Support the Goto Track opcode */
#define MEDIA_PROXY_OP_SUP_GOTO_TRACK BIT(15)
/** Support the Previous Group opcode */
#define MEDIA_PROXY_OP_SUP_PREV_GROUP BIT(16)
/** Support the Next Group opcode */
#define MEDIA_PROXY_OP_SUP_NEXT_GROUP BIT(17)
/** Support the First Group opcode */
#define MEDIA_PROXY_OP_SUP_FIRST_GROUP BIT(18)
/** Support the Last Group opcode */
#define MEDIA_PROXY_OP_SUP_LAST_GROUP BIT(19)
/** Support the Goto Group opcode */
#define MEDIA_PROXY_OP_SUP_GOTO_GROUP BIT(20)
/** @} */
/**
* @name Media player command result codes
* @{
*/
/** Action requested by the opcode write was completed successfully. */
#define MEDIA_PROXY_CMD_SUCCESS 0x01
/** An invalid or unsupported opcode was used for the Media Control Point write. */
#define MEDIA_PROXY_CMD_NOT_SUPPORTED 0x02
/**
* The Media Player State characteristic value is Inactive when the opcode is received or the
* result of the requested action of the opcode results in the Media Player State characteristic
* being set to Inactive.
*/
#define MEDIA_PROXY_CMD_PLAYER_INACTIVE 0x03
/**
* The requested action of any Media Control Point write cannot be completed successfully because of
* a condition within the player.
*/
#define MEDIA_PROXY_CMD_CANNOT_BE_COMPLETED 0x04
/** @} */
/**
* @name Search operation type values
* @{
*/
/** Search for Track Name */
#define MEDIA_PROXY_SEARCH_TYPE_TRACK_NAME 0x01
/** Search for Artist Name */
#define MEDIA_PROXY_SEARCH_TYPE_ARTIST_NAME 0x02
/** Search for Album Name */
#define MEDIA_PROXY_SEARCH_TYPE_ALBUM_NAME 0x03
/** Search for Group Name */
#define MEDIA_PROXY_SEARCH_TYPE_GROUP_NAME 0x04
/** Search for Earliest Year */
#define MEDIA_PROXY_SEARCH_TYPE_EARLIEST_YEAR 0x05
/** Search for Latest Year */
#define MEDIA_PROXY_SEARCH_TYPE_LATEST_YEAR 0x06
/** Search for Genre */
#define MEDIA_PROXY_SEARCH_TYPE_GENRE 0x07
/** Search for Tracks only */
#define MEDIA_PROXY_SEARCH_TYPE_ONLY_TRACKS 0x08
/** Search for Groups only */
#define MEDIA_PROXY_SEARCH_TYPE_ONLY_GROUPS 0x09
/** @} */
/**
* @name Search notification result codes
*
* @{
*/
/** Search request was accepted; search has started. */
#define MEDIA_PROXY_SEARCH_SUCCESS 0x01
/** Search request was invalid; no search started. */
#define MEDIA_PROXY_SEARCH_FAILURE 0x02
/** @} */
/**
* @name Group object object types
*
* @{
*/
/** Group object type is track */
#define MEDIA_PROXY_GROUP_OBJECT_TRACK_TYPE 0x00
/** Group object type is group */
#define MEDIA_PROXY_GROUP_OBJECT_GROUP_TYPE 0x01
/** @} */
/**
* @brief Opaque media player instance
*/
struct media_player;
/* PUBLIC API FOR CONTROLLERS */
/**
* @brief Callbacks to a controller, from the media proxy
*
* Given by a controller when registering
*/
struct media_proxy_ctrl_cbs {
/**
* @brief Media Player Instance callback
*
* Called when the local Media Player instance is registered or read (TODO).
* Also called if the local player instance is already registered when
* the controller is registered.
* Provides the controller with the pointer to the local player instance.
*
* @param player Media player instance pointer
* @param err Error value. 0 on success, or errno on negative value.
*/
void (*local_player_instance)(struct media_player *player, int err);
#ifdef CONFIG_MCTL_REMOTE_PLAYER_CONTROL
/**
* @brief Discover Player Instance callback
*
* Called when a remote player instance has been discovered.
* The instance has been discovered, and will be accessed, using Bluetooth,
* via media control client and a remote media control service.
*
* @param player Instance pointer to the remote player
* @param err Error value. 0 on success, GATT error on positive value
* or errno on negative value.
*/
void (*discover_player)(struct media_player *player, int err);
#endif /* CONFIG_MCTL_REMOTE_PLAYER_CONTROL */
/**
* @brief Media Player Name receive callback
*
* Called when the Media Player Name is read or changed
* See also media_proxy_ctrl_name_get()
*
* @param player Media player instance pointer
* @param err Error value. 0 on success, GATT error on positive value
* or errno on negative value.
* @param name The name of the media player
*/
void (*player_name_recv)(struct media_player *player, int err, const char *name);
/**
* @brief Media Player Icon Object ID receive callback
*
* Called when the Media Player Icon Object ID is read
* See also media_proxy_ctrl_get_icon_id()
*
* @param player Media player instance pointer
* @param err Error value. 0 on success, GATT error on positive value
* or errno on negative value.
* @param id The ID of the Icon object in the Object Transfer Service (48 bits)
*/
void (*icon_id_recv)(struct media_player *player, int err, uint64_t id);
/**
* @brief Media Player Icon URL receive callback
*
* Called when the Media Player Icon URL is read
* See also media_proxy_ctrl_get_icon_url()
*
* @param player Media player instance pointer
* @param err Error value. 0 on success, GATT error on positive value
* or errno on negative value.
* @param url The URL of the icon
*/
void (*icon_url_recv)(struct media_player *player, int err, const char *url);
/**
* @brief Track changed receive callback
*
* Called when the Current Track is changed
*
* @param player Media player instance pointer
* @param err Error value. 0 on success, GATT error on positive value
* or errno on negative value.
*/
void (*track_changed_recv)(struct media_player *player, int err);
/**
* @brief Track Title receive callback
*
* Called when the Track Title is read or changed
* See also media_proxy_ctrl_get_track_title()
*
* @param player Media player instance pointer
* @param err Error value. 0 on success, GATT error on positive value
* or errno on negative value.
* @param title The title of the current track
*/
void (*track_title_recv)(struct media_player *player, int err, const char *title);
/**
* @brief Track Duration receive callback
*
* Called when the Track Duration is read or changed
* See also media_proxy_ctrl_get_track_duration()
*
* @param player Media player instance pointer
* @param err Error value. 0 on success, GATT error on positive value
* or errno on negative value.
* @param duration The duration of the current track
*/
void (*track_duration_recv)(struct media_player *player, int err, int32_t duration);
/**
* @brief Track Position receive callback
*
* Called when the Track Position is read or changed
* See also media_proxy_ctrl_get_track_position() and
* media_proxy_ctrl_set_track_position()
*
* @param player Media player instance pointer
* @param err Error value. 0 on success, GATT error on positive value
* or errno on negative value.
* @param position The player's position in the track
*/
void (*track_position_recv)(struct media_player *player, int err, int32_t position);
/**
* @brief Track Position write callback
*
* Called when the Track Position is written
* See also media_proxy_ctrl_set_track_position().
*
* @param player Media player instance pointer
* @param err Error value. 0 on success, GATT error on positive value
* or errno on negative value.
* @param position The position given attempted to write
*/
void (*track_position_write)(struct media_player *player, int err, int32_t position);
/**
* @brief Playback Speed receive callback
*
* Called when the Playback Speed is read or changed
* See also media_proxy_ctrl_get_playback_speed() and
* media_proxy_ctrl_set_playback_speed()
*
* @param player Media player instance pointer
* @param err Error value. 0 on success, GATT error on positive value
* or errno on negative value.
* @param speed The playback speed parameter
*/
void (*playback_speed_recv)(struct media_player *player, int err, int8_t speed);
/**
* @brief Playback Speed write callback
*
* Called when the Playback Speed is written
* See also media_proxy_ctrl_set_playback_speed()
*
* @param player Media player instance pointer
* @param err Error value. 0 on success, GATT error on positive value
* or errno on negative value.
* @param speed The playback speed parameter attempted to write
*/
void (*playback_speed_write)(struct media_player *player, int err, int8_t speed);
/**
* @brief Seeking Speed receive callback
*
* Called when the Seeking Speed is read or changed
* See also media_proxy_ctrl_get_seeking_speed()
*
* @param player Media player instance pointer
* @param err Error value. 0 on success, GATT error on positive value
* or errno on negative value.
* @param speed The seeking speed factor
*/
void (*seeking_speed_recv)(struct media_player *player, int err, int8_t speed);
/**
* @brief Track Segments Object ID receive callback
*
* Called when the Track Segments Object ID is read
* See also media_proxy_ctrl_get_track_segments_id()
*
* @param player Media player instance pointer
* @param err Error value. 0 on success, GATT error on positive value
* or errno on negative value.
* @param id The ID of the track segments object in Object Transfer Service (48 bits)
*/
void (*track_segments_id_recv)(struct media_player *player, int err, uint64_t id);
/**
* @brief Current Track Object ID receive callback
*
* Called when the Current Track Object ID is read or changed
* See also media_proxy_ctrl_get_current_track_id() and
* media_proxy_ctrl_set_current_track_id()
*
* @param player Media player instance pointer
* @param err Error value. 0 on success, GATT error on positive value
* or errno on negative value.
* @param id The ID of the current track object in Object Transfer Service (48 bits)
*/
void (*current_track_id_recv)(struct media_player *player, int err, uint64_t id);
/**
* @brief Current Track Object ID write callback
*
* Called when the Current Track Object ID is written
* See also media_proxy_ctrl_set_current_track_id()
*
* @param player Media player instance pointer
* @param err Error value. 0 on success, GATT error on positive value
* or errno on negative value.
* @param id The ID (48 bits) attempted to write
*/
void (*current_track_id_write)(struct media_player *player, int err, uint64_t id);
/**
* @brief Next Track Object ID receive callback
*
* Called when the Next Track Object ID is read or changed
* See also media_proxy_ctrl_get_next_track_id() and
* media_proxy_ctrl_set_next_track_id()
*
* @param player Media player instance pointer
* @param err Error value. 0 on success, GATT error on positive value
* or errno on negative value.
* @param id The ID of the next track object in Object Transfer Service (48 bits)
*/
void (*next_track_id_recv)(struct media_player *player, int err, uint64_t id);
/**
* @brief Next Track Object ID write callback
*
* Called when the Next Track Object ID is written
* See also media_proxy_ctrl_set_next_track_id()
*
* @param player Media player instance pointer
* @param err Error value. 0 on success, GATT error on positive value
* or errno on negative value.
* @param id The ID (48 bits) attempted to write
*/
void (*next_track_id_write)(struct media_player *player, int err, uint64_t id);
/**
* @brief Parent Group Object ID receive callback
*
* Called when the Parent Group Object ID is read or changed
* See also media_proxy_ctrl_get_parent_group_id()
*
* @param player Media player instance pointer
* @param err Error value. 0 on success, GATT error on positive value
* or errno on negative value.
* @param id The ID of the parent group object in Object Transfer Service (48 bits)
*/
void (*parent_group_id_recv)(struct media_player *player, int err, uint64_t id);
/**
* @brief Current Group Object ID receive callback
*
* Called when the Current Group Object ID is read or changed
* See also media_proxy_ctrl_get_current_group_id() and
* media_proxy_ctrl_set_current_group_id()
*
* @param player Media player instance pointer
* @param err Error value. 0 on success, GATT error on positive value
* or errno on negative value.
* @param id The ID of the current group object in Object Transfer Service (48 bits)
*/
void (*current_group_id_recv)(struct media_player *player, int err, uint64_t id);
/**
* @brief Current Group Object ID write callback
*
* Called when the Current Group Object ID is written
* See also media_proxy_ctrl_set_current_group_id()
*
* @param player Media player instance pointer
* @param err Error value. 0 on success, GATT error on positive value
* or errno on negative value.
* @param id The ID (48 bits) attempted to write
*/
void (*current_group_id_write)(struct media_player *player, int err, uint64_t id);
/**
* @brief Playing Order receive callback
*
* Called when the Playing Order is read or changed
* See also media_proxy_ctrl_get_playing_order() and
* media_proxy_ctrl_set_playing_order()
*
* @param player Media player instance pointer
* @param err Error value. 0 on success, GATT error on positive value
* or errno on negative value.
* @param order The playing order
*/
void (*playing_order_recv)(struct media_player *player, int err, uint8_t order);
/**
* @brief Playing Order write callback
*
* Called when the Playing Order is written
* See also media_proxy_ctrl_set_playing_order()
*
* @param player Media player instance pointer
* @param err Error value. 0 on success, GATT error on positive value
* or errno on negative value.
* @param order The playing order attempted to write
*/
void (*playing_order_write)(struct media_player *player, int err, uint8_t order);
/**
* @brief Playing Orders Supported receive callback
*
* Called when the Playing Orders Supported is read
* See also media_proxy_ctrl_get_playing_orders_supported()
*
* @param player Media player instance pointer
* @param err Error value. 0 on success, GATT error on positive value
* or errno on negative value.
* @param orders The playing orders supported
*/
void (*playing_orders_supported_recv)(struct media_player *player, int err,
uint16_t orders);
/**
* @brief Media State receive callback
*
* Called when the Media State is read or changed
* See also media_proxy_ctrl_get_media_state() and
* media_proxy_ctrl_send_command()
*
* @param player Media player instance pointer
* @param err Error value. 0 on success, GATT error on positive value
* or errno on negative value.
* @param state The media player state
*/
void (*media_state_recv)(struct media_player *player, int err, uint8_t state);
/**
* @brief Command send callback
*
* Called when a command has been sent
* See also media_proxy_ctrl_send_command()
*
* @param player Media player instance pointer
* @param err Error value. 0 on success, GATT error on positive value
* or errno on negative value.
* @param cmd The command sent
*/
void (*command_send)(struct media_player *player, int err, const struct mpl_cmd *cmd);
/**
* @brief Command result receive callback
*
* Called when a command result has been received
* See also media_proxy_ctrl_send_command()
*
* @param player Media player instance pointer
* @param err Error value. 0 on success, GATT error on positive value
* or errno on negative value.
* @param result The result received
*/
void (*command_recv)(struct media_player *player, int err,
const struct mpl_cmd_ntf *result);
/**
* @brief Commands supported receive callback
*
* Called when the Commands Supported is read or changed
* See also media_proxy_ctrl_get_commands_supported()
*
* @param player Media player instance pointer
* @param err Error value. 0 on success, GATT error on positive value
* or errno on negative value.
* @param opcodes The supported command opcodes (bitmap)
*/
void (*commands_supported_recv)(struct media_player *player, int err, uint32_t opcodes);
/**
* @brief Search send callback
*
* Called when a search has been sent
* See also media_proxy_ctrl_send_search()
*
* @param player Media player instance pointer
* @param err Error value. 0 on success, GATT error on positive value
* or errno on negative value.
* @param search The search sent
*/
void (*search_send)(struct media_player *player, int err, const struct mpl_search *search);
/**
* @brief Search result code receive callback
*
* Called when a search result code has been received
* See also media_proxy_ctrl_send_search()
*
* The search result code tells whether the search was successful or not.
* For a successful search, the actual results of the search (i.e. what was found
* as a result of the search)can be accessed using the Search Results Object ID.
* The Search Results Object ID has a separate callback - search_results_id_recv().
*
* @param player Media player instance pointer
* @param err Error value. 0 on success, GATT error on positive value
* or errno on negative value.
* @param result_code Search result code
*/
void (*search_recv)(struct media_player *player, int err, uint8_t result_code);
/**
* @brief Search Results Object ID receive callback
* See also media_proxy_ctrl_get_search_results_id()
*
* Called when the Search Results Object ID is read or changed
*
* @param player Media player instance pointer
* @param err Error value. 0 on success, GATT error on positive value
* or errno on negative value.
* @param id The ID of the search results object in Object Transfer Service (48 bits)
*/
void (*search_results_id_recv)(struct media_player *player, int err, uint64_t id);
/**
* @brief Content Control ID receive callback
*
* Called when the Content Control ID is read
* See also media_proxy_ctrl_get_content_ctrl_id()
*
* @param player Media player instance pointer
* @param err Error value. 0 on success, GATT error on positive value
* or errno on negative value.
* @param ccid The content control ID
*/
void (*content_ctrl_id_recv)(struct media_player *player, int err, uint8_t ccid);
};
/**
* @brief Register a controller with the media_proxy
*
* @param ctrl_cbs Callbacks to the controller
*
* @return 0 if success, errno on failure
*/
int media_proxy_ctrl_register(struct media_proxy_ctrl_cbs *ctrl_cbs);
/**
* @brief Discover a remote media player
*
* Discover a remote media player instance.
* The remote player instance will be discovered, and accessed, using Bluetooth,
* via the media control client and a remote media control service.
* This call will start a GATT discovery of the Media Control Service on the peer,
* and setup handles and subscriptions.
*
* This shall be called once before any other actions can be executed for the
* remote player. The remote player instance will be returned in the
* discover_player() callback.
*
* @param conn The connection to do discovery for
*
* @return 0 if success, errno on failure
*/
int media_proxy_ctrl_discover_player(struct bt_conn *conn);
/**
* @brief Read Media Player Name
*
* @param player Media player instance pointer
*
* @return 0 if success, errno on failure.
*/
int media_proxy_ctrl_get_player_name(struct media_player *player);
/**
* @brief Read Icon Object ID
*
* Get an ID (48 bit) that can be used to retrieve the Icon
* Object from an Object Transfer Service
*
* See the Media Control Service spec v1.0 sections 3.2 and
* 4.1 for a description of the Icon Object.
*
* Requires Object Transfer Service
*
* @param player Media player instance pointer
*
* @return 0 if success, errno on failure.
*/
int media_proxy_ctrl_get_icon_id(struct media_player *player);
/**
* @brief Read Icon URL
*
* Get a URL to the media player's icon.
*
* @param player Media player instance pointer
*/
int media_proxy_ctrl_get_icon_url(struct media_player *player);
/**
* @brief Read Track Title
*
* @param player Media player instance pointer
*
* @return 0 if success, errno on failure.
*/
int media_proxy_ctrl_get_track_title(struct media_player *player);
/**
* @brief Read Track Duration
*
* The duration of a track is measured in hundredths of a
* second.
*
* @param player Media player instance pointer
*
* @return 0 if success, errno on failure.
*/
int media_proxy_ctrl_get_track_duration(struct media_player *player);
/**
* @brief Read Track Position
*
* The position of the player (the playing position) is
* measured in hundredths of a second from the beginning of
* the track
*
* @param player Media player instance pointer
*
* @return 0 if success, errno on failure.
*/
int media_proxy_ctrl_get_track_position(struct media_player *player);
/**
* @brief Set Track Position
*
* Set the playing position of the media player in the current
* track. The position is given in hundredths of a second,
* from the beginning of the track of the track for positive
* values, and (backwards) from the end of the track for
* negative values.
*
* @param player Media player instance pointer
* @param position The track position to set
*
* @return 0 if success, errno on failure.
*/
int media_proxy_ctrl_set_track_position(struct media_player *player, int32_t position);
/**
* @brief Get Playback Speed
*
* The playback speed parameter is related to the actual
* playback speed as follows:
* actual playback speed = 2^(speed_parameter/64)
*
* A speed parameter of 0 corresponds to unity speed playback
* (i.e. playback at "normal" speed). A speed parameter of
* -128 corresponds to playback at one fourth of normal speed,
* 127 corresponds to playback at almost four times the normal
* speed.
*
* @param player Media player instance pointer
*
* @return 0 if success, errno on failure.
*/
int media_proxy_ctrl_get_playback_speed(struct media_player *player);
/**
* @brief Set Playback Speed
*
* See the get_playback_speed() function for an explanation of
* the playback speed parameter.
*
* Note that the media player may not support all possible
* values of the playback speed parameter. If the value given
* is not supported, and is higher than the current value, the
* player should set the playback speed to the next higher
* supported value. (And correspondingly to the next lower
* supported value for given values lower than the current
* value.)
*
* @param player Media player instance pointer
* @param speed The playback speed parameter to set
*
* @return 0 if success, errno on failure.
*/
int media_proxy_ctrl_set_playback_speed(struct media_player *player, int8_t speed);
/**
* @brief Get Seeking Speed
*
* The seeking speed gives the speed with which the player is
* seeking. It is a factor, relative to real-time playback
* speed - a factor four means seeking happens at four times
* the real-time playback speed. Positive values are for
* forward seeking, negative values for backwards seeking.
*
* The seeking speed is not settable - a non-zero seeking speed
* is the result of "fast rewind" of "fast forward" commands.
*
* @param player Media player instance pointer
*
* @return 0 if success, errno on failure.
*/
int media_proxy_ctrl_get_seeking_speed(struct media_player *player);
/**
* @brief Read Current Track Segments Object ID
*
* Get an ID (48 bit) that can be used to retrieve the Current
* Track Segments Object from an Object Transfer Service
*
* See the Media Control Service spec v1.0 sections 3.10 and
* 4.2 for a description of the Track Segments Object.
*
* Requires Object Transfer Service
*
* @param player Media player instance pointer
*
* @return 0 if success, errno on failure.
*/
int media_proxy_ctrl_get_track_segments_id(struct media_player *player);
/**
* @brief Read Current Track Object ID
*
* Get an ID (48 bit) that can be used to retrieve the Current
* Track Object from an Object Transfer Service
*
* See the Media Control Service spec v1.0 sections 3.11 and
* 4.3 for a description of the Current Track Object.
*
* Requires Object Transfer Service
*
* @param player Media player instance pointer
*
* @return 0 if success, errno on failure.
*/
int media_proxy_ctrl_get_current_track_id(struct media_player *player);
/**
* @brief Set Current Track Object ID
*
* Change the player's current track to the track given by the ID.
* (Behaves similarly to the goto track command.)
*
* Requires Object Transfer Service
*
* @param player Media player instance pointer
* @param id The ID of a track object
*
* @return 0 if success, errno on failure.
*/
int media_proxy_ctrl_set_current_track_id(struct media_player *player, uint64_t id);
/**
* @brief Read Next Track Object ID
*
* Get an ID (48 bit) that can be used to retrieve the Next
* Track Object from an Object Transfer Service
*
* Requires Object Transfer Service
*
* @param player Media player instance pointer
*
* @return 0 if success, errno on failure.
*/
int media_proxy_ctrl_get_next_track_id(struct media_player *player);
/**
* @brief Set Next Track Object ID
*
* Change the player's next track to the track given by the ID.
*
* Requires Object Transfer Service
*
* @param player Media player instance pointer
* @param id The ID of a track object
*
* @return 0 if success, errno on failure.
*/
int media_proxy_ctrl_set_next_track_id(struct media_player *player, uint64_t id);
/**
* @brief Read Parent Group Object ID
*
* Get an ID (48 bit) that can be used to retrieve the Parent
* Track Object from an Object Transfer Service
*
* The parent group is the parent of the current group.
*
* See the Media Control Service spec v1.0 sections 3.14 and
* 4.4 for a description of the Current Track Object.
*
* Requires Object Transfer Service
*
* @param player Media player instance pointer
*
* @return 0 if success, errno on failure.
*/
int media_proxy_ctrl_get_parent_group_id(struct media_player *player);
/**
* @brief Read Current Group Object ID
*
* Get an ID (48 bit) that can be used to retrieve the Current
* Track Object from an Object Transfer Service
*
* See the Media Control Service spec v1.0 sections 3.14 and
* 4.4 for a description of the Current Group Object.
*
* Requires Object Transfer Service
*
* @param player Media player instance pointer
*
* @return 0 if success, errno on failure.
*/
int media_proxy_ctrl_get_current_group_id(struct media_player *player);
/**
* @brief Set Current Group Object ID
*
* Change the player's current group to the group given by the
* ID, and the current track to the first track in that group.
*
* Requires Object Transfer Service
*
* @param player Media player instance pointer
* @param id The ID of a group object
*
* @return 0 if success, errno on failure.
*/
int media_proxy_ctrl_set_current_group_id(struct media_player *player, uint64_t id);
/**
* @brief Read Playing Order
*
* @param player Media player instance pointer
*
* @return 0 if success, errno on failure.
*/
int media_proxy_ctrl_get_playing_order(struct media_player *player);
/**
* @brief Set Playing Order
*
* Set the media player's playing order
*
* @param player Media player instance pointer
* @param order The playing order to set
*
* @return 0 if success, errno on failure.
*/
int media_proxy_ctrl_set_playing_order(struct media_player *player, uint8_t order);
/**
* @brief Read Playing Orders Supported
*
* Read a bitmap containing the media player's supported
* playing orders.
*
* @param player Media player instance pointer
*
* @return 0 if success, errno on failure.
*/
int media_proxy_ctrl_get_playing_orders_supported(struct media_player *player);
/**
* @brief Read Media State
*
* Read the media player's state
*
* @param player Media player instance pointer
*
* @return 0 if success, errno on failure.
*/
int media_proxy_ctrl_get_media_state(struct media_player *player);
/**
* @brief Send Command
*
* Send a command to the media player.
* Commands may cause the media player to change its state
* May result in two callbacks - one for the actual sending of the command to the
* player, one for the result of the command from the player.
*
* @param player Media player instance pointer
* @param command The command to send
*
* @return 0 if success, errno on failure.
*/
int media_proxy_ctrl_send_command(struct media_player *player, const struct mpl_cmd *command);
/**
* @brief Read Commands Supported
*
* Read a bitmap containing the media player's supported
* command opcodes.
*
* @param player Media player instance pointer
*
* @return 0 if success, errno on failure.
*/
int media_proxy_ctrl_get_commands_supported(struct media_player *player);
/**
* @brief Set Search
*
* Write a search to the media player.
* If the search is successful, the search results will be available as a group object
* in the Object Transfer Service (OTS).
*
* May result in up to three callbacks
* - one for the actual sending of the search to the player
* - one for the result code for the search from the player
* - if the search is successful, one for the search results object ID in the OTs
*
* Requires Object Transfer Service
*
* @param player Media player instance pointer
* @param search The search to write
*
* @return 0 if success, errno on failure.
*/
int media_proxy_ctrl_send_search(struct media_player *player, const struct mpl_search *search);
/**
* @brief Read Search Results Object ID
*
* Get an ID (48 bit) that can be used to retrieve the Search
* Results Object from an Object Transfer Service
*
* The search results object is a group object.
* The search results object only exists if a successful
* search operation has been done.
*
* Requires Object Transfer Service
*
* @param player Media player instance pointer
*
* @return 0 if success, errno on failure.
*/
int media_proxy_ctrl_get_search_results_id(struct media_player *player);
/**
* @brief Read Content Control ID
*
* The content control ID identifies a content control service
* on a device, and links it to the corresponding audio
* stream.
*
* @param player Media player instance pointer
*
* @return 0 if success, errno on failure.
*/
uint8_t media_proxy_ctrl_get_content_ctrl_id(struct media_player *player);
/**
* @brief Available calls in a player, that the media proxy can call
*
* Given by a player when registering.
*/
struct media_proxy_pl_calls {
/**
* @brief Read Media Player Name
*
* @return The name of the media player
*/
const char *(*get_player_name)(void);
/**
* @brief Read Icon Object ID
*
* Get an ID (48 bit) that can be used to retrieve the Icon
* Object from an Object Transfer Service
*
* See the Media Control Service spec v1.0 sections 3.2 and
* 4.1 for a description of the Icon Object.
*
* @return The Icon Object ID
*/
uint64_t (*get_icon_id)(void);
/**
* @brief Read Icon URL
*
* Get a URL to the media player's icon.
*
* @return The URL of the Icon
*/
const char *(*get_icon_url)(void);
/**
* @brief Read Track Title
*
* @return The title of the current track
*/
const char *(*get_track_title)(void);
/**
* @brief Read Track Duration
*
* The duration of a track is measured in hundredths of a
* second.
*
* @return The duration of the current track
*/
int32_t (*get_track_duration)(void);
/**
* @brief Read Track Position
*
* The position of the player (the playing position) is
* measured in hundredths of a second from the beginning of
* the track
*
* @return The position of the player in the current track
*/
int32_t (*get_track_position)(void);
/**
* @brief Set Track Position
*
* Set the playing position of the media player in the current
* track. The position is given in hundredths of a second,
* from the beginning of the track of the track for positive
* values, and (backwards) from the end of the track for
* negative values.
*
* @param position The player position to set
*/
void (*set_track_position)(int32_t position);
/**
* @brief Get Playback Speed
*
* The playback speed parameter is related to the actual
* playback speed as follows:
* actual playback speed = 2^(speed_parameter/64)
*
* A speed parameter of 0 corresponds to unity speed playback
* (i.e. playback at "normal" speed). A speed parameter of
* -128 corresponds to playback at one fourth of normal speed,
* 127 corresponds to playback at almost four times the normal
* speed.
*
* @return The playback speed parameter
*/
int8_t (*get_playback_speed)(void);
/**
* @brief Set Playback Speed
*
* See the get_playback_speed() function for an explanation of
* the playback speed parameter.
*
* Note that the media player may not support all possible
* values of the playback speed parameter. If the value given
* is not supported, and is higher than the current value, the
* player should set the playback speed to the next higher
* supported value. (And correspondingly to the next lower
* supported value for given values lower than the current
* value.)
*
* @param speed The playback speed parameter to set
*/
void (*set_playback_speed)(int8_t speed);
/**
* @brief Get Seeking Speed
*
* The seeking speed gives the speed with which the player is
* seeking. It is a factor, relative to real-time playback
* speed - a factor four means seeking happens at four times
* the real-time playback speed. Positive values are for
* forward seeking, negative values for backwards seeking.
*
* The seeking speed is not settable - a non-zero seeking speed
* is the result of "fast rewind" of "fast forward" commands.
*
* @return The seeking speed factor
*/
int8_t (*get_seeking_speed)(void);
/**
* @brief Read Current Track Segments Object ID
*
* Get an ID (48 bit) that can be used to retrieve the Current
* Track Segments Object from an Object Transfer Service
*
* See the Media Control Service spec v1.0 sections 3.10 and
* 4.2 for a description of the Track Segments Object.
*
* @return Current The Track Segments Object ID
*/
uint64_t (*get_track_segments_id)(void);
/**
* @brief Read Current Track Object ID
*
* Get an ID (48 bit) that can be used to retrieve the Current
* Track Object from an Object Transfer Service
*
* See the Media Control Service spec v1.0 sections 3.11 and
* 4.3 for a description of the Current Track Object.
*
* @return The Current Track Object ID
*/
uint64_t (*get_current_track_id)(void);
/**
* @brief Set Current Track Object ID
*
* Change the player's current track to the track given by the ID.
* (Behaves similarly to the goto track command.)
*
* @param id The ID of a track object
*/
void (*set_current_track_id)(uint64_t id);
/**
* @brief Read Next Track Object ID
*
* Get an ID (48 bit) that can be used to retrieve the Next
* Track Object from an Object Transfer Service
*
* @return The Next Track Object ID
*/
uint64_t (*get_next_track_id)(void);
/**
* @brief Set Next Track Object ID
*
* Change the player's next track to the track given by the ID.
*
* @param id The ID of a track object
*/
void (*set_next_track_id)(uint64_t id);
/**
* @brief Read Parent Group Object ID
*
* Get an ID (48 bit) that can be used to retrieve the Parent
* Track Object from an Object Transfer Service
*
* The parent group is the parent of the current group.
*
* See the Media Control Service spec v1.0 sections 3.14 and
* 4.4 for a description of the Current Track Object.
*
* @return The Current Group Object ID
*/
uint64_t (*get_parent_group_id)(void);
/**
* @brief Read Current Group Object ID
*
* Get an ID (48 bit) that can be used to retrieve the Current
* Track Object from an Object Transfer Service
*
* See the Media Control Service spec v1.0 sections 3.14 and
* 4.4 for a description of the Current Group Object.
*
* @return The Current Group Object ID
*/
uint64_t (*get_current_group_id)(void);
/**
* @brief Set Current Group Object ID
*
* Change the player's current group to the group given by the
* ID, and the current track to the first track in that group.
*
* @param id The ID of a group object
*/
void (*set_current_group_id)(uint64_t id);
/**
* @brief Read Playing Order
*
* return The media player's current playing order
*/
uint8_t (*get_playing_order)(void);
/**
* @brief Set Playing Order
*
* Set the media player's playing order.
* See the MEDIA_PROXY_PLAYING_ORDER_* defines.
*
* @param order The playing order to set
*/
void (*set_playing_order)(uint8_t order);
/**
* @brief Read Playing Orders Supported
*
* Read a bitmap containing the media player's supported
* playing orders.
* See the MEDIA_PROXY_PLAYING_ORDERS_SUPPORTED_* defines.
*
* @return The media player's supported playing orders
*/
uint16_t (*get_playing_orders_supported)(void);
/**
* @brief Read Media State
*
* Read the media player's state
* See the MEDIA_PROXY_MEDIA_STATE_* defines.
*
* @return The media player's state
*/
uint8_t (*get_media_state)(void);
/**
* @brief Send Command
*
* Send a command to the media player.
* For command opcodes (play, pause, ...) - see the MEDIA_PROXY_OP_*
* defines.
*
* @param command The command to send
*/
void (*send_command)(const struct mpl_cmd *command);
/**
* @brief Read Commands Supported
*
* Read a bitmap containing the media player's supported
* command opcodes.
* See the MEDIA_PROXY_OP_SUP_* defines.
*
* @return The media player's supported command opcodes
*/
uint32_t (*get_commands_supported)(void);
/**
* @brief Set Search
*
* Write a search to the media player.
* (For the formatting of a search, see the Media Control
* Service spec and the mcs.h file.)
*
* @param search The search to write
*/
void (*send_search)(const struct mpl_search *search);
/**
* @brief Read Search Results Object ID
*
* Get an ID (48 bit) that can be used to retrieve the Search
* Results Object from an Object Transfer Service
*
* The search results object is a group object.
* The search results object only exists if a successful
* search operation has been done.
*
* @return The Search Results Object ID
*/
uint64_t (*get_search_results_id)(void);
/**
* @brief Read Content Control ID
*
* The content control ID identifies a content control service
* on a device, and links it to the corresponding audio
* stream.
*
* @return The content control ID for the media player
*/
uint8_t (*get_content_ctrl_id)(void);
};
/**
* @brief Register a player with the media proxy
*
* Register a player with the media proxy module, for use by media
* controllers.
*
* The media proxy may call any non-NULL function pointers in the
* supplied media_proxy_pl_calls structure.
*
* @param pl_calls Function pointers to the media player's calls
*
* @return 0 if success, errno on failure
*/
int media_proxy_pl_register(struct media_proxy_pl_calls *pl_calls);
/**
* @brief Initialize player
*
* TODO: Move to player header file
*/
int media_proxy_pl_init(void);
/**
* @brief Get the pointer of the Object Transfer Service used by the Media Control Service
*
* TODO: Find best location for this call, and move this one also
*/
struct bt_ots *bt_mcs_get_ots(void);
/**
* @brief Player name changed callback
*
* To be called when the player's name is changed.
*
* @param name The name of the player
*/
void media_proxy_pl_name_cb(const char *name);
/**
* @brief Player icon URL changed callback
*
* To be called when the player's icon URL is changed.
*
* @param url The URL of the player's icon
*/
void media_proxy_pl_icon_url_cb(const char *url);
/**
* @brief Track changed callback
*
* To be called when the player's current track is changed
*/
void media_proxy_pl_track_changed_cb(void);
/**
* @brief Track title callback
*
* To be called when the player's current track is changed
*
* @param title The title of the track
*/
void media_proxy_pl_track_title_cb(char *title);
/**
* @brief Track duration callback
*
* To be called when the current track's duration is changed (e.g. due
* to a track change)
*
* The track duration is given in hundredths of a second.
*
* @param duration The track duration
*/
void media_proxy_pl_track_duration_cb(int32_t duration);
/**
* @brief Track position callback
*
* To be called when the media player's position in the track is
* changed, or when the player is paused or similar.
*
* Exception: This callback should not be called when the position
* changes during regular playback, i.e. while the player is playing
* and playback happens at a constant speed.
*
* The track position is given in hundredths of a second from the
* start of the track.
*
* @param position The media player's position in the track
*/
void media_proxy_pl_track_position_cb(int32_t position);
/**
* @brief Playback speed callback
*
* To be called when the playback speed is changed.
*
* @param speed The playback speed parameter
*/
void media_proxy_pl_playback_speed_cb(int8_t speed);
/**
* @brief Seeking speed callback
*
* To be called when the seeking speed is changed.
*
* @param speed The seeking speed factor
*/
void media_proxy_pl_seeking_speed_cb(int8_t speed);
/**
* @brief Current track object ID callback
*
* To be called when the ID of the current track is changed (e.g. due
* to a track change).
*
* @param id The ID of the current track object in the OTS
*/
void media_proxy_pl_current_track_id_cb(uint64_t id);
/**
* @brief Next track object ID callback
*
* To be called when the ID of the current track is changes
*
* @param id The ID of the next track object in the OTS
*/
void media_proxy_pl_next_track_id_cb(uint64_t id);
/**
* @brief Parent group object ID callback
*
* To be called when the ID of the parent group is changed
*
* @param id The ID of the parent group object in the OTS
*/
void media_proxy_pl_parent_group_id_cb(uint64_t id);
/**
* @brief Current group object ID callback
*
* To be called when the ID of the current group is changed
*
* @param id The ID of the current group object in the OTS
*/
void media_proxy_pl_current_group_id_cb(uint64_t id);
/**
* @brief Playing order callback
*
* To be called when the playing order is changed
*
* @param order The playing order
*/
void media_proxy_pl_playing_order_cb(uint8_t order);
/**
* @brief Media state callback
*
* To be called when the media state is changed
*
* @param state The media player's state
*/
void media_proxy_pl_media_state_cb(uint8_t state);
/**
* @brief Command callback
*
* To be called when a command has been sent, to notify whether the
* command was successfully performed or not.
* See the MEDIA_PROXY_CMD_* result code defines.
*
* @param cmd_ntf The result of the command
*/
void media_proxy_pl_command_cb(const struct mpl_cmd_ntf *cmd_ntf);
/**
* @brief Commands supported callback
*
* To be called when the set of commands supported is changed
*
* @param opcodes The supported commands opcodes
*/
void media_proxy_pl_commands_supported_cb(uint32_t opcodes);
/**
* @brief Search callback
*
* To be called when a search has been set to notify whether the
* search was successfully performed or not.
* See the MEDIA_PROXY_SEARCH_* result code defines.
*
* The actual results of the search, if successful, can be found in
* the search results object.
*
* @param result_code The result (success or failure) of the search
*/
void media_proxy_pl_search_cb(uint8_t result_code);
/**
* @brief Search Results object ID callback
*
* To be called when the ID of the search results is changed
* (typically as the result of a new successful search).
*
* @param id The ID of the search results object in the OTS
*/
void media_proxy_pl_search_results_id_cb(uint64_t id);
#ifdef __cplusplus
}
#endif
/** @} */ /* End of group bt_media_proxy */
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_MEDIA_PROXY_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/audio/media_proxy.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 13,420 |
```objective-c
/**
* @file
* @brief Header for Bluetooth Gaming Audio Profile (GMAP).
*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_GMAP_
#define ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_GMAP_
/**
* @brief Bluetooth Gaming Audio Profile (GMAP)
*
* @defgroup bt_gmap Bluetooth Gaming Audio Profile
*
* @since 3.5
* @version 0.8.0
*
* @ingroup bluetooth
* @{
*/
#include <zephyr/bluetooth/conn.h>
#include <zephyr/sys/util_macro.h>
#ifdef __cplusplus
extern "C" {
#endif
/** Gaming Role bitfield */
enum bt_gmap_role {
/**
* @brief Gaming Role Unicast Game Gateway
*
* Requires @kconfig{CONFIG_BT_CAP_INITIATOR}, @kconfig{CONFIG_BT_BAP_UNICAST_CLIENT} and
* @kconfig{CONFIG_BT_VCP_VOL_CTLR} to be enabled.
*/
BT_GMAP_ROLE_UGG = BIT(0),
/**
* @brief Gaming Role Unicast Game Terminal
*
* Requires @kconfig{CONFIG_BT_CAP_ACCEPTOR} and @kconfig{CONFIG_BT_BAP_UNICAST_SERVER} to
* be enabled.
*/
BT_GMAP_ROLE_UGT = BIT(1),
/**
* @brief Gaming Role Broadcast Game Sender
*
* Requires @kconfig{CONFIG_BT_CAP_INITIATOR} and @kconfig{CONFIG_BT_BAP_BROADCAST_SOURCE}
* to be enabled.
*/
BT_GMAP_ROLE_BGS = BIT(2),
/**
* @brief Gaming Role Broadcast Game Receiver
*
* Requires @kconfig{CONFIG_BT_CAP_ACCEPTOR}, @kconfig{CONFIG_BT_BAP_BROADCAST_SINK} and
* @kconfig{CONFIG_BT_VCP_VOL_REND} to be enabled.
*/
BT_GMAP_ROLE_BGR = BIT(3),
};
/** Unicast Game Gateway Feature bitfield */
enum bt_gmap_ugg_feat {
/**
* @brief Support transmitting multiple LC3 codec frames per block in an SDU
*
* Requires @kconfig{CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SRC_COUNT} > 0
*/
BT_GMAP_UGG_FEAT_MULTIPLEX = BIT(0),
/**
* @brief 96 kbps source support
*
* Requires @kconfig{CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SRC_COUNT} > 0
*/
BT_GMAP_UGG_FEAT_96KBPS_SOURCE = BIT(1),
/**
* @brief Support for receiving at least two channels of audio, each in a separate CIS
*
* Requires @kconfig{CONFIG_BT_BAP_UNICAST_CLIENT_ASE_SNK_COUNT} > 1 and
* @kconfig{CONFIG_BT_BAP_UNICAST_CLIENT_GROUP_STREAM_COUNT} > 1
*/
BT_GMAP_UGG_FEAT_MULTISINK = BIT(2),
};
/** Unicast Game Terminal Feature bitfield */
enum bt_gmap_ugt_feat {
/**
* @brief Source support
*
* Requires @kconfig{CONFIG_BT_ASCS_ASE_SRC_COUNT} > 0
*/
BT_GMAP_UGT_FEAT_SOURCE = BIT(0),
/**
* @brief 80 kbps source support
*
* Requires BT_GMAP_UGT_FEAT_SOURCE to be set as well
*/
BT_GMAP_UGT_FEAT_80KBPS_SOURCE = BIT(1),
/**
* @brief Sink support
*
* Requires @kconfig{CONFIG_BT_ASCS_ASE_SNK_COUNT} > 0
*/
BT_GMAP_UGT_FEAT_SINK = BIT(2),
/**
* @brief 64 kbps sink support
*
* Requires BT_GMAP_UGT_FEAT_SINK to be set as well
*/
BT_GMAP_UGT_FEAT_64KBPS_SINK = BIT(3),
/**
* @brief Support for receiving multiple LC3 codec frames per block in an SDU
*
* Requires BT_GMAP_UGT_FEAT_SINK to be set as well
*/
BT_GMAP_UGT_FEAT_MULTIPLEX = BIT(4),
/**
* @brief Support for receiving at least two audio channels, each in a separate CIS
*
* Requires @kconfig{CONFIG_BT_ASCS_ASE_SNK_COUNT} > 1 and
* @kconfig{CONFIG_BT_ASCS_MAX_ACTIVE_ASES} > 1, and BT_GMAP_UGT_FEAT_SINK to be set as well
*/
BT_GMAP_UGT_FEAT_MULTISINK = BIT(5),
/**
* @brief Support for sending at least two audio channels, each in a separate CIS
*
* Requires @kconfig{CONFIG_BT_ASCS_ASE_SRC_COUNT} > 1 and
* @kconfig{CONFIG_BT_ASCS_MAX_ACTIVE_ASES} > 1, and BT_GMAP_UGT_FEAT_SOURCE to be set
* as well
*/
BT_GMAP_UGT_FEAT_MULTISOURCE = BIT(6),
};
/** Broadcast Game Sender Feature bitfield */
enum bt_gmap_bgs_feat {
/** 96 kbps support */
BT_GMAP_BGS_FEAT_96KBPS = BIT(0),
};
/** Broadcast Game Receiver Feature bitfield */
enum bt_gmap_bgr_feat {
/**
* @brief Support for receiving at least two audio channels, each in a separate BIS
*
* Requires @kconfig{CONFIG_BT_BAP_BROADCAST_SNK_STREAM_COUNT} > 1
*/
BT_GMAP_BGR_FEAT_MULTISINK = BIT(0),
/** @brief Support for receiving multiple LC3 codec frames per block in an SDU */
BT_GMAP_BGR_FEAT_MULTIPLEX = BIT(1),
};
/** Broadcast Game Receiver Feature bitfield */
struct bt_gmap_feat {
/** Unicast Game Gateway features */
enum bt_gmap_ugg_feat ugg_feat;
/** Unicast Game Terminal features */
enum bt_gmap_ugt_feat ugt_feat;
/** Remote Broadcast Game Sender features */
enum bt_gmap_bgs_feat bgs_feat;
/** Remote Broadcast Game Receiver features */
enum bt_gmap_bgr_feat bgr_feat;
};
/** @brief Hearing Access Service Client callback structure. */
struct bt_gmap_cb {
/**
* @brief Callback function for bt_has_discover.
*
* This callback is called when discovery procedure is complete.
*
* @param conn Bluetooth connection object.
* @param err 0 on success, ATT error or negative errno otherwise.
* @param role Role of remote device. 0 on failure.
* @param features Remote features.
*/
void (*discover)(struct bt_conn *conn, int err, enum bt_gmap_role role,
struct bt_gmap_feat features);
};
/**
* @brief Registers the callbacks used by the Gaming Audio Profile.
*
* @param cb The callback structure.
*
* @retval -EINVAL if @p cb is NULL
* @retval -EALREADY if callbacks have already be registered
* @retval 0 on success
*/
int bt_gmap_cb_register(const struct bt_gmap_cb *cb);
/**
* @brief Discover Gaming Service on a remote device.
*
* Procedure to find a Gaming Service on a server identified by @p conn.
* The @ref bt_gmap_cb.discover callback is called when the discovery procedure completes of fails.
* On discovery success the callback contains information about the remote device.
*
* @param conn Bluetooth connection object.
*
* @retval -EINVAL if @p conn is NULL
* @retval -EBUSY if discovery is already in progress for @p conn
* @retval -ENOEXEC if discovery failed to initiate
* @retval 0 on success
*/
int bt_gmap_discover(struct bt_conn *conn);
/**
* @brief Adds GMAS instance to database and sets the received Gaming Audio Profile role(s).
*
* @param role Gaming Audio Profile role(s) of the device (one or multiple).
* @param features Features of the roles. If a role is not in the @p role parameter, then the
* feature value for that role is simply ignored.
*
* @retval -EINVAL on invalid arguments
* @retval -ENOEXEC on service register failure
* @retval 0 on success
*/
int bt_gmap_register(enum bt_gmap_role role, struct bt_gmap_feat features);
/**
* @brief Set one or multiple Gaming Audio Profile roles and features dynamically.
*
* Previously registered value will be overwritten. If there is a role change, this will trigger
* a Gaming Audio Service (GMAS) service change. If there is only a feature change, no service
* change will happen.
*
* @param role Gaming Audio Profile role(s).
* @param features Features of the roles. If a role is not in the @p role parameter, then the
* feature value for that role is simply ignored.
*
* @retval -ENOEXEC if the service has not yet been registered
* @retval -EINVAL on invalid arguments
* @retval -EALREADY if the @p role and @p features are the same as existing ones
* @retval -ENOENT on service unregister failure
* @retval -ECANCELED on service re-register failure
* @retval 0 on success
*/
int bt_gmap_set_role(enum bt_gmap_role role, struct bt_gmap_feat features);
#ifdef __cplusplus
}
#endif
/** @} */ /* end of bt_gmap */
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_GMAP_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/audio/gmap.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 2,092 |
```objective-c
/**
* @file
* @brief Header for Bluetooth BAP.
*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_BAP_
#define ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_BAP_
/**
* @brief Bluetooth Basic Audio Profile (BAP)
* @defgroup bt_bap Bluetooth Basic Audio Profile
*
* @since 3.0
* @version 0.8.0
*
* @ingroup bluetooth
* @{
*
* The Basic Audio Profile (BAP) allows for both unicast and broadcast Audio Stream control.
*/
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <zephyr/bluetooth/audio/audio.h>
#include <zephyr/bluetooth/addr.h>
#include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/conn.h>
#include <zephyr/bluetooth/iso.h>
#include <zephyr/net/buf.h>
#include <zephyr/sys/slist.h>
#ifdef __cplusplus
extern "C" {
#endif
/** Periodic advertising state reported by the Scan Delegator */
enum bt_bap_pa_state {
/** The periodic advertising has not been synchronized */
BT_BAP_PA_STATE_NOT_SYNCED = 0x00,
/** Waiting for SyncInfo from Broadcast Assistant */
BT_BAP_PA_STATE_INFO_REQ = 0x01,
/** Synchronized to periodic advertising */
BT_BAP_PA_STATE_SYNCED = 0x02,
/** Failed to synchronized to periodic advertising */
BT_BAP_PA_STATE_FAILED = 0x03,
/** No periodic advertising sync transfer receiver from Broadcast Assistant */
BT_BAP_PA_STATE_NO_PAST = 0x04,
};
/** Broadcast Isochronous Group encryption state reported by the Scan Delegator */
enum bt_bap_big_enc_state {
/** The Broadcast Isochronous Group not encrypted */
BT_BAP_BIG_ENC_STATE_NO_ENC = 0x00,
/** The Broadcast Isochronous Group broadcast code requested */
BT_BAP_BIG_ENC_STATE_BCODE_REQ = 0x01,
/** The Broadcast Isochronous Group decrypted */
BT_BAP_BIG_ENC_STATE_DEC = 0x02,
/** The Broadcast Isochronous Group bad broadcast code */
BT_BAP_BIG_ENC_STATE_BAD_CODE = 0x03,
};
/** Broadcast Audio Scan Service (BASS) specific ATT error codes */
enum bt_bap_bass_att_err {
/** Opcode not supported */
BT_BAP_BASS_ERR_OPCODE_NOT_SUPPORTED = 0x80,
/** Invalid source ID supplied */
BT_BAP_BASS_ERR_INVALID_SRC_ID = 0x81,
};
/** Value indicating that the periodic advertising interval is unknown */
#define BT_BAP_PA_INTERVAL_UNKNOWN 0xFFFF
/**
* @brief Broadcast Assistant no BIS sync preference
*
* Value indicating that the Broadcast Assistant has no preference to which BIS
* the Scan Delegator syncs to
*/
#define BT_BAP_BIS_SYNC_NO_PREF 0xFFFFFFFF
/** Endpoint states */
enum bt_bap_ep_state {
/** Audio Stream Endpoint Idle state */
BT_BAP_EP_STATE_IDLE = 0x00,
/** Audio Stream Endpoint Codec Configured state */
BT_BAP_EP_STATE_CODEC_CONFIGURED = 0x01,
/** Audio Stream Endpoint QoS Configured state */
BT_BAP_EP_STATE_QOS_CONFIGURED = 0x02,
/** Audio Stream Endpoint Enabling state */
BT_BAP_EP_STATE_ENABLING = 0x03,
/** Audio Stream Endpoint Streaming state */
BT_BAP_EP_STATE_STREAMING = 0x04,
/** Audio Stream Endpoint Disabling state */
BT_BAP_EP_STATE_DISABLING = 0x05,
/** Audio Stream Endpoint Streaming state */
BT_BAP_EP_STATE_RELEASING = 0x06,
};
/**
* @brief Response Status Code
*
* These are sent by the server to the client when a stream operation is
* requested.
*/
enum bt_bap_ascs_rsp_code {
/** Server completed operation successfully */
BT_BAP_ASCS_RSP_CODE_SUCCESS = 0x00,
/** Server did not support operation by client */
BT_BAP_ASCS_RSP_CODE_NOT_SUPPORTED = 0x01,
/** Server rejected due to invalid operation length */
BT_BAP_ASCS_RSP_CODE_INVALID_LENGTH = 0x02,
/** Invalid ASE ID */
BT_BAP_ASCS_RSP_CODE_INVALID_ASE = 0x03,
/** Invalid ASE state */
BT_BAP_ASCS_RSP_CODE_INVALID_ASE_STATE = 0x04,
/** Invalid operation for direction */
BT_BAP_ASCS_RSP_CODE_INVALID_DIR = 0x05,
/** Capabilities not supported by server */
BT_BAP_ASCS_RSP_CODE_CAP_UNSUPPORTED = 0x06,
/** Configuration parameters not supported by server */
BT_BAP_ASCS_RSP_CODE_CONF_UNSUPPORTED = 0x07,
/** Configuration parameters rejected by server */
BT_BAP_ASCS_RSP_CODE_CONF_REJECTED = 0x08,
/** Invalid Configuration parameters */
BT_BAP_ASCS_RSP_CODE_CONF_INVALID = 0x09,
/** Unsupported metadata */
BT_BAP_ASCS_RSP_CODE_METADATA_UNSUPPORTED = 0x0a,
/** Metadata rejected by server */
BT_BAP_ASCS_RSP_CODE_METADATA_REJECTED = 0x0b,
/** Invalid metadata */
BT_BAP_ASCS_RSP_CODE_METADATA_INVALID = 0x0c,
/** Server has insufficient resources */
BT_BAP_ASCS_RSP_CODE_NO_MEM = 0x0d,
/** Unspecified error */
BT_BAP_ASCS_RSP_CODE_UNSPECIFIED = 0x0e,
};
/**
* @brief Response Reasons
*
* These are used if the @ref bt_bap_ascs_rsp_code value is
* @ref BT_BAP_ASCS_RSP_CODE_CONF_UNSUPPORTED, @ref BT_BAP_ASCS_RSP_CODE_CONF_REJECTED or
* @ref BT_BAP_ASCS_RSP_CODE_CONF_INVALID.
*/
enum bt_bap_ascs_reason {
/** No reason */
BT_BAP_ASCS_REASON_NONE = 0x00,
/** Codec ID */
BT_BAP_ASCS_REASON_CODEC = 0x01,
/** Codec configuration */
BT_BAP_ASCS_REASON_CODEC_DATA = 0x02,
/** SDU interval */
BT_BAP_ASCS_REASON_INTERVAL = 0x03,
/** Framing */
BT_BAP_ASCS_REASON_FRAMING = 0x04,
/** PHY */
BT_BAP_ASCS_REASON_PHY = 0x05,
/** Maximum SDU size*/
BT_BAP_ASCS_REASON_SDU = 0x06,
/** RTN */
BT_BAP_ASCS_REASON_RTN = 0x07,
/** Max transport latency */
BT_BAP_ASCS_REASON_LATENCY = 0x08,
/** Presendation delay */
BT_BAP_ASCS_REASON_PD = 0x09,
/** Invalid CIS mapping */
BT_BAP_ASCS_REASON_CIS = 0x0a,
};
/** @brief Structure storing values of fields of ASE Control Point notification. */
struct bt_bap_ascs_rsp {
/**
* @brief Value of the Response Code field.
*
* The following response codes are accepted:
* - @ref BT_BAP_ASCS_RSP_CODE_SUCCESS
* - @ref BT_BAP_ASCS_RSP_CODE_CAP_UNSUPPORTED
* - @ref BT_BAP_ASCS_RSP_CODE_CONF_UNSUPPORTED
* - @ref BT_BAP_ASCS_RSP_CODE_CONF_REJECTED
* - @ref BT_BAP_ASCS_RSP_CODE_METADATA_UNSUPPORTED
* - @ref BT_BAP_ASCS_RSP_CODE_METADATA_REJECTED
* - @ref BT_BAP_ASCS_RSP_CODE_NO_MEM
* - @ref BT_BAP_ASCS_RSP_CODE_UNSPECIFIED
*/
enum bt_bap_ascs_rsp_code code;
/**
* @brief Value of the Reason field.
*
* The meaning of this value depend on the Response Code field.
*/
union {
/**
* @brief Response reason
*
* If the Response Code is one of the following:
* - @ref BT_BAP_ASCS_RSP_CODE_CONF_UNSUPPORTED
* - @ref BT_BAP_ASCS_RSP_CODE_CONF_REJECTED
* all values from @ref bt_bap_ascs_reason can be used.
*
* If the Response Code is one of the following:
* - @ref BT_BAP_ASCS_RSP_CODE_SUCCESS
* - @ref BT_BAP_ASCS_RSP_CODE_CAP_UNSUPPORTED
* - @ref BT_BAP_ASCS_RSP_CODE_NO_MEM
* - @ref BT_BAP_ASCS_RSP_CODE_UNSPECIFIED
* only value @ref BT_BAP_ASCS_REASON_NONE shall be used.
*/
enum bt_bap_ascs_reason reason;
/**
* @brief Response metadata type
*
* If the Response Code is one of the following:
* - @ref BT_BAP_ASCS_RSP_CODE_METADATA_UNSUPPORTED
* - @ref BT_BAP_ASCS_RSP_CODE_METADATA_REJECTED
* the value of the Metadata Type shall be used.
*/
enum bt_audio_metadata_type metadata_type;
};
};
/**
* @brief Macro used to initialise the object storing values of ASE Control Point notification.
*
* @param c Response Code field
* @param r Reason field - @ref bt_bap_ascs_reason or @ref bt_audio_metadata_type (see notes in
* @ref bt_bap_ascs_rsp).
*/
#define BT_BAP_ASCS_RSP(c, r) (struct bt_bap_ascs_rsp) { .code = c, .reason = r }
/** @brief Abstract Audio Broadcast Source structure. */
struct bt_bap_broadcast_source;
/** @brief Abstract Audio Broadcast Sink structure. */
struct bt_bap_broadcast_sink;
/** @brief Abstract Audio Unicast Group structure. */
struct bt_bap_unicast_group;
/** @brief Abstract Audio Endpoint structure. */
struct bt_bap_ep;
/** Struct to hold subgroup specific information for the receive state */
struct bt_bap_bass_subgroup {
/** BIS synced bitfield */
uint32_t bis_sync;
/** Length of the metadata */
uint8_t metadata_len;
#if defined(CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_SIZE) || defined(__DOXYGEN__)
/** The metadata */
uint8_t metadata[CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_SIZE];
#endif /* CONFIG_BT_AUDIO_CODEC_CFG_MAX_METADATA_SIZE */
};
/** Represents the Broadcast Audio Scan Service receive state */
struct bt_bap_scan_delegator_recv_state {
/** The source ID */
uint8_t src_id;
/** The Bluetooth address */
bt_addr_le_t addr;
/** The advertising set ID*/
uint8_t adv_sid;
/** The periodic adverting sync state */
enum bt_bap_pa_state pa_sync_state;
/** The broadcast isochronous group encryption state */
enum bt_bap_big_enc_state encrypt_state;
/** The 24-bit broadcast ID */
uint32_t broadcast_id;
/**
* @brief The bad broadcast code
*
* Only valid if encrypt_state is @ref BT_BAP_BIG_ENC_STATE_BCODE_REQ
*/
uint8_t bad_code[BT_AUDIO_BROADCAST_CODE_SIZE];
/** Number of subgroups */
uint8_t num_subgroups;
/** Subgroup specific information */
struct bt_bap_bass_subgroup subgroups[CONFIG_BT_BAP_BASS_MAX_SUBGROUPS];
};
/**
* @brief Struct to hold the Basic Audio Profile Scan Delegator callbacks
*
* These can be registered for usage with bt_bap_scan_delegator_register_cb().
*/
struct bt_bap_scan_delegator_cb {
/**
* @brief Receive state updated
*
* @param conn Pointer to the connection to a remote device if
* the change was caused by it, otherwise NULL.
* @param recv_state Pointer to the receive state that was updated.
*
* @return 0 in case of success or negative value in case of error.
*/
void (*recv_state_updated)(struct bt_conn *conn,
const struct bt_bap_scan_delegator_recv_state *recv_state);
/**
* @brief Periodic advertising sync request
*
* Request from peer device to synchronize with the periodic advertiser
* denoted by the @p recv_state. To notify the Broadcast Assistant about
* any pending sync
*
* @param conn Pointer to the connection requesting the
* periodic advertising sync.
* @param recv_state Pointer to the receive state that is being
* requested for periodic advertising sync.
* @param past_avail True if periodic advertising sync transfer is available.
* @param pa_interval The periodic advertising interval.
*
* @return 0 in case of accept, or other value to reject.
*/
int (*pa_sync_req)(struct bt_conn *conn,
const struct bt_bap_scan_delegator_recv_state *recv_state,
bool past_avail, uint16_t pa_interval);
/**
* @brief Periodic advertising sync termination request
*
* Request from peer device to terminate the periodic advertiser sync
* denoted by the @p recv_state.
*
* @param conn Pointer to the connection requesting the periodic
* advertising sync termination.
* @param recv_state Pointer to the receive state that is being
* requested for periodic advertising sync.
*
* @return 0 in case of success or negative value in case of error.
*/
int (*pa_sync_term_req)(struct bt_conn *conn,
const struct bt_bap_scan_delegator_recv_state *recv_state);
/**
* @brief Broadcast code received
*
* Broadcast code received from a broadcast assistant
*
* @param conn Pointer to the connection providing the
* broadcast code.
* @param recv_state Pointer to the receive state the broadcast code
* is being provided for.
* @param broadcast_code The 16-octet broadcast code
*/
void (*broadcast_code)(struct bt_conn *conn,
const struct bt_bap_scan_delegator_recv_state *recv_state,
const uint8_t broadcast_code[BT_AUDIO_BROADCAST_CODE_SIZE]);
/**
* @brief Broadcast Isochronous Stream synchronize request
*
* Request from Broadcast Assistant device to modify the Broadcast
* Isochronous Stream states. The request shall be fulfilled with
* accordance to the @p bis_sync_req within reasonable time. The
* Broadcast Assistant may also request fewer, or none, indexes to
* be synchronized.
*
* @param[in] conn Pointer to the connection of the
* Broadcast Assistant requesting the sync.
* @param[in] recv_state Pointer to the receive state that is being
* requested for the sync.
* @param[in] bis_sync_req Array of bitfields of which BIS indexes
* that is requested to sync for each subgroup
* by the Broadcast Assistant. A value of 0
* indicates a request to terminate the BIG
* sync.
*
* @return 0 in case of accept, or other value to reject.
*/
int (*bis_sync_req)(struct bt_conn *conn,
const struct bt_bap_scan_delegator_recv_state *recv_state,
const uint32_t bis_sync_req[CONFIG_BT_BAP_BASS_MAX_SUBGROUPS]);
};
/** Structure holding information of audio stream endpoint */
struct bt_bap_ep_info {
/** The ID of the endpoint */
uint8_t id;
/** The state of the endpoint */
enum bt_bap_ep_state state;
/** Capabilities type */
enum bt_audio_dir dir;
/** The isochronous channel associated with the endpoint. */
struct bt_iso_chan *iso_chan;
/** @brief True if the stream associated with the endpoint is able to send data */
bool can_send;
/** @brief True if the stream associated with the endpoint is able to receive data */
bool can_recv;
/** Pointer to paired endpoint if the endpoint is part of a bidirectional CIS,
* otherwise NULL
*/
struct bt_bap_ep *paired_ep;
/** Pointer to the preferred QoS settings associated with the endpoint */
const struct bt_audio_codec_qos_pref *qos_pref;
};
/**
* @brief Return structure holding information of audio stream endpoint
*
* @param ep The audio stream endpoint object.
* @param info The structure object to be filled with the info.
*
* @retval 0 in case of success
* @retval -EINVAL if @p ep or @p info are NULL
*/
int bt_bap_ep_get_info(const struct bt_bap_ep *ep, struct bt_bap_ep_info *info);
/**
* @brief Basic Audio Profile stream structure.
*
* Streams represents a stream configuration of a Remote Endpoint and a Local Capability.
*
* @note Streams are unidirectional but can be paired with other streams to use a bidirectional
* connected isochronous stream.
*/
struct bt_bap_stream {
/** Connection reference */
struct bt_conn *conn;
/** Endpoint reference */
struct bt_bap_ep *ep;
/** Codec Configuration */
struct bt_audio_codec_cfg *codec_cfg;
/** QoS Configuration */
struct bt_audio_codec_qos *qos;
/** Audio stream operations */
struct bt_bap_stream_ops *ops;
#if defined(CONFIG_BT_BAP_UNICAST_CLIENT) || defined(__DOXYGEN__)
/**
* @internal Audio ISO reference
*
* This is only used for Unicast Client streams, and is handled internally.
*/
struct bt_bap_iso *bap_iso;
#endif /* CONFIG_BT_BAP_UNICAST_CLIENT */
/** @internal Unicast or Broadcast group - Used internally */
void *group;
/** Stream user data */
void *user_data;
#if defined(CONFIG_BT_BAP_DEBUG_STREAM_SEQ_NUM) || defined(__DOXYGEN__)
/** @internal Previously sent sequence number */
uint16_t _prev_seq_num;
#endif /* CONFIG_BT_BAP_DEBUG_STREAM_SEQ_NUM */
/** @internal Internally used list node */
sys_snode_t _node;
};
/** @brief Stream operation. */
struct bt_bap_stream_ops {
#if defined(CONFIG_BT_BAP_UNICAST) || defined(__DOXYGEN__)
/**
* @brief Stream configured callback
*
* Configured callback is called whenever an Audio Stream has been configured.
*
* @param stream Stream object that has been configured.
* @param pref Remote QoS preferences.
*/
void (*configured)(struct bt_bap_stream *stream,
const struct bt_audio_codec_qos_pref *pref);
/**
* @brief Stream QoS set callback
*
* QoS set callback is called whenever an Audio Stream Quality of Service has been set or
* updated.
*
* @param stream Stream object that had its QoS updated.
*/
void (*qos_set)(struct bt_bap_stream *stream);
/**
* @brief Stream enabled callback
*
* Enabled callback is called whenever an Audio Stream has been enabled.
*
* @param stream Stream object that has been enabled.
*/
void (*enabled)(struct bt_bap_stream *stream);
/**
* @brief Stream metadata updated callback
*
* Metadata Updated callback is called whenever an Audio Stream's metadata has been
* updated.
*
* @param stream Stream object that had its metadata updated.
*/
void (*metadata_updated)(struct bt_bap_stream *stream);
/**
* @brief Stream disabled callback
*
* Disabled callback is called whenever an Audio Stream has been disabled.
*
* @param stream Stream object that has been disabled.
*/
void (*disabled)(struct bt_bap_stream *stream);
/**
* @brief Stream released callback
*
* Released callback is called whenever a Audio Stream has been released and can be
* deallocated.
*
* @param stream Stream object that has been released.
*/
void (*released)(struct bt_bap_stream *stream);
#endif /* CONFIG_BT_BAP_UNICAST */
/**
* @brief Stream started callback
*
* Started callback is called whenever an Audio Stream has been started
* and will be usable for streaming.
*
* @param stream Stream object that has been started.
*/
void (*started)(struct bt_bap_stream *stream);
/**
* @brief Stream stopped callback
*
* Stopped callback is called whenever an Audio Stream has been stopped.
*
* @param stream Stream object that has been stopped.
* @param reason BT_HCI_ERR_* reason for the disconnection.
*/
void (*stopped)(struct bt_bap_stream *stream, uint8_t reason);
#if defined(CONFIG_BT_AUDIO_RX) || defined(__DOXYGEN__)
/**
* @brief Stream audio HCI receive callback.
*
* This callback is only used if the ISO data path is HCI.
*
* @param stream Stream object.
* @param info Pointer to the metadata for the buffer. The lifetime of the pointer is
* linked to the lifetime of the net_buf. Metadata such as sequence number and
* timestamp can be provided by the bluetooth controller.
* @param buf Buffer containing incoming audio data.
*/
void (*recv)(struct bt_bap_stream *stream, const struct bt_iso_recv_info *info,
struct net_buf *buf);
#endif /* CONFIG_BT_AUDIO_RX */
#if defined(CONFIG_BT_AUDIO_TX) || defined(__DOXYGEN__)
/**
* @brief Stream audio HCI sent callback
*
* This callback will be called once the controller marks the SDU
* as completed. When the controller does so is implementation
* dependent. It could be after the SDU is enqueued for transmission,
* or after it is sent on air or flushed.
*
* This callback is only used if the ISO data path is HCI.
*
* @param stream Stream object.
*/
void (*sent)(struct bt_bap_stream *stream);
#endif /* CONFIG_BT_AUDIO_TX */
/**
* @brief Isochronous channel connected callback
*
* If this callback is provided it will be called whenever the isochronous channel for the
* stream has been connected. This does not mean that the stream is ready to be used, which
* is indicated by the @ref bt_bap_stream_ops.started callback.
*
* If the stream shares an isochronous channel with another stream, then this callback may
* still be called, without the stream going into the started state.
*
* @param stream Stream object.
*/
void (*connected)(struct bt_bap_stream *stream);
/**
* @brief Isochronous channel disconnected callback
*
* If this callback is provided it will be called whenever the isochronous channel is
* disconnected, including when a connection gets rejected.
*
* If the stream shares an isochronous channel with another stream, then this callback may
* not be called, even if the stream is leaving the streaming state.
*
* @param stream Stream object.
* @param reason BT_HCI_ERR_* reason for the disconnection.
*/
void (*disconnected)(struct bt_bap_stream *stream, uint8_t reason);
};
/**
* @brief Register Audio callbacks for a stream.
*
* Register Audio callbacks for a stream.
*
* @param stream Stream object.
* @param ops Stream operations structure.
*/
void bt_bap_stream_cb_register(struct bt_bap_stream *stream, struct bt_bap_stream_ops *ops);
/**
* @brief Configure Audio Stream
*
* This procedure is used by a client to configure a new stream using the
* remote endpoint, local capability and codec configuration.
*
* @param conn Connection object
* @param stream Stream object being configured
* @param ep Remote Audio Endpoint being configured
* @param codec_cfg Codec configuration
*
* @return Allocated Audio Stream object or NULL in case of error.
*/
int bt_bap_stream_config(struct bt_conn *conn, struct bt_bap_stream *stream, struct bt_bap_ep *ep,
struct bt_audio_codec_cfg *codec_cfg);
/**
* @brief Reconfigure Audio Stream
*
* This procedure is used by a unicast client or unicast server to reconfigure
* a stream to use a different local codec configuration.
*
* This can only be done for unicast streams.
*
* @param stream Stream object being reconfigured
* @param codec_cfg Codec configuration
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_bap_stream_reconfig(struct bt_bap_stream *stream, struct bt_audio_codec_cfg *codec_cfg);
/**
* @brief Configure Audio Stream QoS
*
* This procedure is used by a client to configure the Quality of Service of streams in a unicast
* group. All streams in the group for the specified @p conn will have the Quality of Service
* configured. This shall only be used to configure unicast streams.
*
* @param conn Connection object
* @param group Unicast group object
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_bap_stream_qos(struct bt_conn *conn, struct bt_bap_unicast_group *group);
/**
* @brief Enable Audio Stream
*
* This procedure is used by a client to enable a stream.
*
* This shall only be called for unicast streams, as broadcast streams will always be enabled once
* created.
*
* @param stream Stream object
* @param meta Metadata
* @param meta_len Metadata length
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_bap_stream_enable(struct bt_bap_stream *stream, const uint8_t meta[], size_t meta_len);
/**
* @brief Change Audio Stream Metadata
*
* This procedure is used by a unicast client or unicast server to change the metadata of a stream.
*
* @param stream Stream object
* @param meta Metadata
* @param meta_len Metadata length
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_bap_stream_metadata(struct bt_bap_stream *stream, const uint8_t meta[], size_t meta_len);
/**
* @brief Disable Audio Stream
*
* This procedure is used by a unicast client or unicast server to disable a stream.
*
* This shall only be called for unicast streams, as broadcast streams will
* always be enabled once created.
*
* @param stream Stream object
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_bap_stream_disable(struct bt_bap_stream *stream);
/**
* @brief Connect unicast audio stream
*
* This procedure is used by a unicast client to connect the connected isochronous stream (CIS)
* associated with the audio stream. If two audio streams share a CIS, then this only needs to be
* done once for those streams. This can only be done for streams in the QoS configured or enabled
* states.
*
* The bt_bap_stream_ops.connected() callback will be called on the streams once this has finished.
*
* This shall only be called for unicast streams, and only as the unicast client
* (@kconfig{CONFIG_BT_BAP_UNICAST_CLIENT}).
*
* @param stream Stream object
*
* @retval 0 in case of success
* @retval -EINVAL if the stream, endpoint, ISO channel or connection is NULL
* @retval -EBADMSG if the stream or ISO channel is in an invalid state for connection
* @retval -EOPNOTSUPP if the role of the stream is not @ref BT_HCI_ROLE_CENTRAL
* @retval -EALREADY if the ISO channel is already connecting or connected
* @retval -EBUSY if another ISO channel is connecting
* @retval -ENOEXEC if otherwise rejected by the ISO layer
*/
int bt_bap_stream_connect(struct bt_bap_stream *stream);
/**
* @brief Start Audio Stream
*
* This procedure is used by a unicast client or unicast server to make a stream start streaming.
*
* For the unicast client, this will send the receiver start ready command to the unicast server for
* @ref BT_AUDIO_DIR_SOURCE ASEs. The CIS is required to be connected first by
* bt_bap_stream_connect() before the command can be sent.
*
* For the unicast server, this will execute the receiver start ready command on the unicast server
* for @ref BT_AUDIO_DIR_SINK ASEs. If the CIS is not connected yet, the stream will go into the
* streaming state as soon as the CIS is connected.
*
* This shall only be called for unicast streams.
*
* Broadcast sinks will always be started once synchronized, and broadcast
* source streams shall be started with bt_bap_broadcast_source_start().
*
* @param stream Stream object
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_bap_stream_start(struct bt_bap_stream *stream);
/**
* @brief Stop Audio Stream
*
* This procedure is used by a client to make a stream stop streaming.
*
* This shall only be called for unicast streams.
* Broadcast sinks cannot be stopped.
* Broadcast sources shall be stopped with bt_bap_broadcast_source_stop().
*
* @param stream Stream object
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_bap_stream_stop(struct bt_bap_stream *stream);
/**
* @brief Release Audio Stream
*
* This procedure is used by a unicast client or unicast server to release a unicast stream.
*
* Broadcast sink streams cannot be released, but can be deleted by bt_bap_broadcast_sink_delete().
* Broadcast source streams cannot be released, but can be deleted by
* bt_bap_broadcast_source_delete().
*
* @param stream Stream object
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_bap_stream_release(struct bt_bap_stream *stream);
/**
* @brief Send data to Audio stream without timestamp
*
* Send data from buffer to the stream.
*
* @note Support for sending must be supported, determined by @kconfig{CONFIG_BT_AUDIO_TX}.
*
* @param stream Stream object.
* @param buf Buffer containing data to be sent.
* @param seq_num Packet Sequence number. This value shall be incremented for each call to this
* function and at least once per SDU interval for a specific channel.
*
* @return Bytes sent in case of success or negative value in case of error.
*/
int bt_bap_stream_send(struct bt_bap_stream *stream, struct net_buf *buf, uint16_t seq_num);
/**
* @brief Send data to Audio stream with timestamp
*
* Send data from buffer to the stream.
*
* @note Support for sending must be supported, determined by @kconfig{CONFIG_BT_AUDIO_TX}.
*
* @param stream Stream object.
* @param buf Buffer containing data to be sent.
* @param seq_num Packet Sequence number. This value shall be incremented for each call to this
* function and at least once per SDU interval for a specific channel.
* @param ts Timestamp of the SDU in microseconds (us). This value can be used to transmit
* multiple SDUs in the same SDU interval in a CIG or BIG.
*
* @return Bytes sent in case of success or negative value in case of error.
*/
int bt_bap_stream_send_ts(struct bt_bap_stream *stream, struct net_buf *buf, uint16_t seq_num,
uint32_t ts);
/**
* @brief Get ISO transmission timing info for a Basic Audio Profile stream
*
* Reads timing information for transmitted ISO packet on an ISO channel.
* The HCI_LE_Read_ISO_TX_Sync HCI command is used to retrieve this information from the controller.
*
* @note An SDU must have already been successfully transmitted on the ISO channel
* for this function to return successfully.
* Support for sending must be supported, determined by @kconfig{CONFIG_BT_AUDIO_TX}.
*
* @param[in] stream Stream object.
* @param[out] info Transmit info object.
*
* @retval 0 on success
* @retval -EINVAL if the stream is invalid, if the stream is not configured for sending or if it is
* not connected with a isochronous stream
* @retval Any return value from bt_iso_chan_get_tx_sync()
*/
int bt_bap_stream_get_tx_sync(struct bt_bap_stream *stream, struct bt_iso_tx_info *info);
/**
* @defgroup bt_bap_unicast_server BAP Unicast Server APIs
* @ingroup bt_bap
* @{
*/
/** Unicast Server callback structure */
struct bt_bap_unicast_server_cb {
/**
* @brief Endpoint config request callback
*
* Config callback is called whenever an endpoint is requested to be
* configured
*
* @param[in] conn Connection object.
* @param[in] ep Local Audio Endpoint being configured.
* @param[in] dir Direction of the endpoint.
* @param[in] codec_cfg Codec configuration.
* @param[out] stream Pointer to stream that will be configured for the endpoint.
* @param[out] pref Pointer to a QoS preference object that shall be populated with
* values. Invalid values will reject the codec configuration request.
* @param[out] rsp Object for the ASE operation response. Only used if the return
* value is non-zero.
*
* @return 0 in case of success or negative value in case of error.
*/
int (*config)(struct bt_conn *conn, const struct bt_bap_ep *ep, enum bt_audio_dir dir,
const struct bt_audio_codec_cfg *codec_cfg, struct bt_bap_stream **stream,
struct bt_audio_codec_qos_pref *const pref, struct bt_bap_ascs_rsp *rsp);
/**
* @brief Stream reconfig request callback
*
* Reconfig callback is called whenever an Audio Stream needs to be
* reconfigured with different codec configuration.
*
* @param[in] stream Stream object being reconfigured.
* @param[in] dir Direction of the endpoint.
* @param[in] codec_cfg Codec configuration.
* @param[out] pref Pointer to a QoS preference object that shall be populated with
* values. Invalid values will reject the codec configuration request.
* @param[out] rsp Object for the ASE operation response. Only used if the return
* value is non-zero.
*
* @return 0 in case of success or negative value in case of error.
*/
int (*reconfig)(struct bt_bap_stream *stream, enum bt_audio_dir dir,
const struct bt_audio_codec_cfg *codec_cfg,
struct bt_audio_codec_qos_pref *const pref, struct bt_bap_ascs_rsp *rsp);
/**
* @brief Stream QoS request callback
*
* QoS callback is called whenever an Audio Stream Quality of
* Service needs to be configured.
*
* @param[in] stream Stream object being reconfigured.
* @param[in] qos Quality of Service configuration.
* @param[out] rsp Object for the ASE operation response. Only used if the return
* value is non-zero.
*
* @return 0 in case of success or negative value in case of error.
*/
int (*qos)(struct bt_bap_stream *stream, const struct bt_audio_codec_qos *qos,
struct bt_bap_ascs_rsp *rsp);
/**
* @brief Stream Enable request callback
*
* Enable callback is called whenever an Audio Stream is requested to be enabled to stream.
*
* @param[in] stream Stream object being enabled.
* @param[in] meta Metadata entries.
* @param[in] meta_len Length of metadata.
* @param[out] rsp Object for the ASE operation response. Only used if the return
* value is non-zero.
*
* @return 0 in case of success or negative value in case of error.
*/
int (*enable)(struct bt_bap_stream *stream, const uint8_t meta[], size_t meta_len,
struct bt_bap_ascs_rsp *rsp);
/**
* @brief Stream Start request callback
*
* Start callback is called whenever an Audio Stream is requested to start streaming.
*
* @param[in] stream Stream object.
* @param[out] rsp Object for the ASE operation response. Only used if the return
* value is non-zero.
*
* @return 0 in case of success or negative value in case of error.
*/
int (*start)(struct bt_bap_stream *stream, struct bt_bap_ascs_rsp *rsp);
/**
* @brief Stream Metadata update request callback
*
* Metadata callback is called whenever an Audio Stream is requested to update its metadata.
*
* @param[in] stream Stream object.
* @param[in] meta Metadata entries.
* @param[in] meta_len Length of metadata.
* @param[out] rsp Object for the ASE operation response. Only used if the return
* value is non-zero.
*
* @return 0 in case of success or negative value in case of error.
*/
int (*metadata)(struct bt_bap_stream *stream, const uint8_t meta[], size_t meta_len,
struct bt_bap_ascs_rsp *rsp);
/**
* @brief Stream Disable request callback
*
* Disable callback is called whenever an Audio Stream is requested to disable the stream.
*
* @param[in] stream Stream object being disabled.
* @param[out] rsp Object for the ASE operation response. Only used if the return
* value is non-zero.
*
* @return 0 in case of success or negative value in case of error.
*/
int (*disable)(struct bt_bap_stream *stream, struct bt_bap_ascs_rsp *rsp);
/**
* @brief Stream Stop callback
*
* Stop callback is called whenever an Audio Stream is requested to stop streaming.
*
* @param[in] stream Stream object.
* @param[out] rsp Object for the ASE operation response. Only used if the return
* value is non-zero.
*
* @return 0 in case of success or negative value in case of error.
*/
int (*stop)(struct bt_bap_stream *stream, struct bt_bap_ascs_rsp *rsp);
/**
* @brief Stream release callback
*
* Release callback is called whenever a new Audio Stream needs to be released and thus
* deallocated.
*
* @param[in] stream Stream object.
* @param[out] rsp Object for the ASE operation response. Only used if the return
* value is non-zero.
*
* @return 0 in case of success or negative value in case of error.
*/
int (*release)(struct bt_bap_stream *stream, struct bt_bap_ascs_rsp *rsp);
};
/**
* @brief Register unicast server callbacks.
*
* Only one callback structure can be registered, and attempting to
* registering more than one will result in an error.
*
* @param cb Unicast server callback structure.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_bap_unicast_server_register_cb(const struct bt_bap_unicast_server_cb *cb);
/**
* @brief Unregister unicast server callbacks.
*
* May only unregister a callback structure that has previously been
* registered by bt_bap_unicast_server_register_cb().
*
* @param cb Unicast server callback structure.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_bap_unicast_server_unregister_cb(const struct bt_bap_unicast_server_cb *cb);
/**
* @typedef bt_bap_ep_func_t
* @brief The callback function called for each endpoint.
*
* @param ep The structure object with endpoint info.
* @param user_data Data to pass to the function.
*/
typedef void (*bt_bap_ep_func_t)(struct bt_bap_ep *ep, void *user_data);
/**
* @brief Iterate through all endpoints of the given connection.
*
* @param conn Connection object
* @param func Function to call for each endpoint.
* @param user_data Data to pass to the callback function.
*/
void bt_bap_unicast_server_foreach_ep(struct bt_conn *conn, bt_bap_ep_func_t func, void *user_data);
/**
* @brief Initialize and configure a new ASE.
*
* @param conn Connection object
* @param stream Configured stream object to be attached to the ASE
* @param codec_cfg Codec configuration
* @param qos_pref Audio Stream Quality of Service Preference
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_bap_unicast_server_config_ase(struct bt_conn *conn, struct bt_bap_stream *stream,
struct bt_audio_codec_cfg *codec_cfg,
const struct bt_audio_codec_qos_pref *qos_pref);
/** @} */ /* End of group bt_bap_unicast_server */
/**
* @defgroup bt_bap_unicast_client BAP Unicast Client APIs
* @ingroup bt_bap
* @{
*/
/** Parameter struct for each stream in the unicast group */
struct bt_bap_unicast_group_stream_param {
/** Pointer to a stream object. */
struct bt_bap_stream *stream;
/** The QoS settings for the stream object. */
struct bt_audio_codec_qos *qos;
};
/**
* @brief Parameter struct for the unicast group functions
*
* Parameter struct for the bt_bap_unicast_group_create() and
* bt_bap_unicast_group_add_streams() functions.
*/
struct bt_bap_unicast_group_stream_pair_param {
/** Pointer to a receiving stream parameters. */
struct bt_bap_unicast_group_stream_param *rx_param;
/** Pointer to a transmitting stream parameters. */
struct bt_bap_unicast_group_stream_param *tx_param;
};
/** Parameters for the creating unicast groups with bt_bap_unicast_group_create() */
struct bt_bap_unicast_group_param {
/** The number of parameters in @p params */
size_t params_count;
/** Array of stream parameters */
struct bt_bap_unicast_group_stream_pair_param *params;
/**
* @brief Unicast Group packing mode.
*
* @ref BT_ISO_PACKING_SEQUENTIAL or @ref BT_ISO_PACKING_INTERLEAVED.
*
* @note This is a recommendation to the controller, which the controller may ignore.
*/
uint8_t packing;
#if defined(CONFIG_BT_ISO_TEST_PARAMS) || defined(__DOXYGEN__)
/**
* @brief Central to Peripheral flush timeout
*
* The flush timeout in multiples of ISO_Interval for each payload sent
* from the Central to Peripheral.
*
* Value range from @ref BT_ISO_FT_MIN to @ref BT_ISO_FT_MAX
*/
uint8_t c_to_p_ft;
/**
* @brief Peripheral to Central flush timeout
*
* The flush timeout in multiples of ISO_Interval for each payload sent
* from the Peripheral to Central.
*
* Value range from @ref BT_ISO_FT_MIN to @ref BT_ISO_FT_MAX.
*/
uint8_t p_to_c_ft;
/**
* @brief ISO interval
*
* Time between consecutive CIS anchor points.
*
* Value range from @ref BT_ISO_ISO_INTERVAL_MIN to @ref BT_ISO_ISO_INTERVAL_MAX.
*/
uint16_t iso_interval;
#endif /* CONFIG_BT_ISO_TEST_PARAMS */
};
/**
* @brief Create audio unicast group.
*
* Create a new audio unicast group with one or more audio streams as a unicast client.
* All streams shall share the same framing.
* All streams in the same direction shall share the same interval and latency (see
* @ref bt_audio_codec_qos).
*
* @param[in] param The unicast group create parameters.
* @param[out] unicast_group Pointer to the unicast group created.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_bap_unicast_group_create(struct bt_bap_unicast_group_param *param,
struct bt_bap_unicast_group **unicast_group);
/**
* @brief Add streams to a unicast group as a unicast client
*
* This function can be used to add additional streams to a bt_bap_unicast_group.
*
* This can be called at any time before any of the streams in the group has been started
* (see bt_bap_stream_ops.started()).
* This can also be called after the streams have been stopped (see bt_bap_stream_ops.stopped()).
*
* Once a stream has been added to a unicast group, it cannot be removed. To remove a stream from a
* group, the group must be deleted with bt_bap_unicast_group_delete(), but this will require all
* streams in the group to be released first.
*
* @param unicast_group Pointer to the unicast group
* @param params Array of stream parameters with streams being added to the group.
* @param num_param Number of parameters in @p params.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_bap_unicast_group_add_streams(struct bt_bap_unicast_group *unicast_group,
struct bt_bap_unicast_group_stream_pair_param params[],
size_t num_param);
/**
* @brief Delete audio unicast group.
*
* Delete a audio unicast group as a client. All streams in the group shall
* be in the idle or configured state.
*
* @param unicast_group Pointer to the unicast group to delete
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_bap_unicast_group_delete(struct bt_bap_unicast_group *unicast_group);
/** Unicast Client callback structure */
struct bt_bap_unicast_client_cb {
/**
* @brief Remote Unicast Server Audio Locations
*
* This callback is called whenever the audio locations is read from
* the server or otherwise notified to the client.
*
* @param conn Connection to the remote unicast server.
* @param dir Direction of the location.
* @param loc The location bitfield value.
*
* @return 0 in case of success or negative value in case of error.
*/
void (*location)(struct bt_conn *conn, enum bt_audio_dir dir, enum bt_audio_location loc);
/**
* @brief Remote Unicast Server Available Contexts
*
* This callback is called whenever the available contexts are read
* from the server or otherwise notified to the client.
*
* @param conn Connection to the remote unicast server.
* @param snk_ctx The sink context bitfield value.
* @param src_ctx The source context bitfield value.
*
* @return 0 in case of success or negative value in case of error.
*/
void (*available_contexts)(struct bt_conn *conn, enum bt_audio_context snk_ctx,
enum bt_audio_context src_ctx);
/**
* @brief Callback function for bt_bap_stream_config() and bt_bap_stream_reconfig().
*
* Called when the codec configure operation is completed on the server.
*
* @param stream Stream the operation was performed on.
* @param rsp_code Response code.
* @param reason Reason code.
*/
void (*config)(struct bt_bap_stream *stream, enum bt_bap_ascs_rsp_code rsp_code,
enum bt_bap_ascs_reason reason);
/**
* @brief Callback function for bt_bap_stream_qos().
*
* Called when the QoS configure operation is completed on the server.
* This will be called for each stream in the group that was being QoS
* configured.
*
* @param stream Stream the operation was performed on. May be NULL if there is no stream
* associated with the ASE ID sent by the server.
* @param rsp_code Response code.
* @param reason Reason code.
*/
void (*qos)(struct bt_bap_stream *stream, enum bt_bap_ascs_rsp_code rsp_code,
enum bt_bap_ascs_reason reason);
/**
* @brief Callback function for bt_bap_stream_enable().
*
* Called when the enable operation is completed on the server.
*
* @param stream Stream the operation was performed on. May be NULL if there is no stream
* associated with the ASE ID sent by the server.
* @param rsp_code Response code.
* @param reason Reason code.
*/
void (*enable)(struct bt_bap_stream *stream, enum bt_bap_ascs_rsp_code rsp_code,
enum bt_bap_ascs_reason reason);
/**
* @brief Callback function for bt_bap_stream_start().
*
* Called when the start operation is completed on the server. This will
* only be called if the stream supplied to bt_bap_stream_start() is
* for a @ref BT_AUDIO_DIR_SOURCE endpoint.
*
* @param stream Stream the operation was performed on. May be NULL if there is no stream
* associated with the ASE ID sent by the server.
* @param rsp_code Response code.
* @param reason Reason code.
*/
void (*start)(struct bt_bap_stream *stream, enum bt_bap_ascs_rsp_code rsp_code,
enum bt_bap_ascs_reason reason);
/**
* @brief Callback function for bt_bap_stream_stop().
*
* Called when the stop operation is completed on the server. This will
* only be called if the stream supplied to bt_bap_stream_stop() is
* for a @ref BT_AUDIO_DIR_SOURCE endpoint.
*
* @param stream Stream the operation was performed on. May be NULL if there is no stream
* associated with the ASE ID sent by the server.
* @param rsp_code Response code.
* @param reason Reason code.
*/
void (*stop)(struct bt_bap_stream *stream, enum bt_bap_ascs_rsp_code rsp_code,
enum bt_bap_ascs_reason reason);
/**
* @brief Callback function for bt_bap_stream_disable().
*
* Called when the disable operation is completed on the server.
*
* @param stream Stream the operation was performed on. May be NULL if there is no stream
* associated with the ASE ID sent by the server.
* @param rsp_code Response code.
* @param reason Reason code.
*/
void (*disable)(struct bt_bap_stream *stream, enum bt_bap_ascs_rsp_code rsp_code,
enum bt_bap_ascs_reason reason);
/**
* @brief Callback function for bt_bap_stream_metadata().
*
* Called when the metadata operation is completed on the server.
*
* @param stream Stream the operation was performed on. May be NULL if there is no stream
* associated with the ASE ID sent by the server.
* @param rsp_code Response code.
* @param reason Reason code.
*/
void (*metadata)(struct bt_bap_stream *stream, enum bt_bap_ascs_rsp_code rsp_code,
enum bt_bap_ascs_reason reason);
/**
* @brief Callback function for bt_bap_stream_release().
*
* Called when the release operation is completed on the server.
*
* @param stream Stream the operation was performed on. May be NULL if there is no stream
* associated with the ASE ID sent by the server.
* @param rsp_code Response code.
* @param reason Reason code.
*/
void (*release)(struct bt_bap_stream *stream, enum bt_bap_ascs_rsp_code rsp_code,
enum bt_bap_ascs_reason reason);
/**
* @brief Remote Published Audio Capability (PAC) record discovered
*
* Called when a PAC record has been discovered as part of the discovery procedure.
*
* The @p codec is only valid while in the callback, so the values must be stored by the
* receiver if future use is wanted.
*
* @param conn Connection to the remote unicast server.
* @param dir The type of remote endpoints and capabilities discovered.
* @param codec_cap Remote capabilities.
*
* If discovery procedure has complete both @p codec and @p ep are set to NULL.
*/
void (*pac_record)(struct bt_conn *conn, enum bt_audio_dir dir,
const struct bt_audio_codec_cap *codec_cap);
/**
* @brief Remote Audio Stream Endpoint (ASE) discovered
*
* Called when an ASE has been discovered as part of the discovery procedure.
*
* @param conn Connection to the remote unicast server.
* @param dir The type of remote endpoints and capabilities discovered.
* @param ep Remote endpoint.
*
* If discovery procedure has complete both @p codec and @p ep are set to NULL.
*/
void (*endpoint)(struct bt_conn *conn, enum bt_audio_dir dir, struct bt_bap_ep *ep);
/**
* @brief BAP discovery callback function.
*
* If discovery procedure has completed @p ep is set to NULL and @p err is 0.
*
* @param conn Connection to the remote unicast server.
* @param err Error value. 0 on success, GATT error on positive value or errno on
* negative value.
* @param dir The type of remote endpoints and capabilities discovered.
*
* If discovery procedure has complete both @p codec and @p ep are set to NULL.
*/
void (*discover)(struct bt_conn *conn, int err, enum bt_audio_dir dir);
};
/**
* @brief Register unicast client callbacks.
*
* Only one callback structure can be registered, and attempting to
* registering more than one will result in an error.
*
* @param cb Unicast client callback structure.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_bap_unicast_client_register_cb(const struct bt_bap_unicast_client_cb *cb);
/**
* @brief Discover remote capabilities and endpoints
*
* This procedure is used by a client to discover remote capabilities and
* endpoints and notifies via params callback.
*
* @param conn Connection object
* @param dir The type of remote endpoints and capabilities to discover.
*/
int bt_bap_unicast_client_discover(struct bt_conn *conn, enum bt_audio_dir dir);
/** @} */ /* End of group bt_bap_unicast_client */
/**
* @brief BAP Broadcast APIs
* @defgroup bt_bap_broadcast BAP Broadcast APIs
* @ingroup bt_bap
* @{
*/
/** @brief Abstract Broadcast Audio Source Endpoint (BASE) subgroup structure. */
struct bt_bap_base_subgroup;
/** @brief Abstract Broadcast Audio Source Endpoint (BASE) structure. */
struct bt_bap_base;
/** Codec ID structure for a Broadcast Audio Source Endpoint (BASE) */
struct bt_bap_base_codec_id {
/** Codec ID */
uint8_t id;
/** Codec Company ID */
uint16_t cid;
/** Codec Company Vendor ID */
uint16_t vid;
};
/** BIS structure for each BIS in a Broadcast Audio Source Endpoint (BASE) subgroup */
struct bt_bap_base_subgroup_bis {
/** Unique index of the BIS */
uint8_t index;
/** Codec Specific Data length. */
uint8_t data_len;
/** Codec Specific Data */
uint8_t *data;
};
/**
* @brief Generate a pointer to a BASE from periodic advertising data
*
* @param ad The periodic advertising data
*
* @retval NULL if the data does not contain a BASE
* @retval Pointer to a bt_bap_base structure
*/
const struct bt_bap_base *bt_bap_base_get_base_from_ad(const struct bt_data *ad);
/**
* @brief Get the size of a BASE
*
* @param base The BASE pointer
*
* @retval -EINVAL if arguments are invalid
* @retval The size of the BASE
*/
int bt_bap_base_get_size(const struct bt_bap_base *base);
/**
* @brief Get the presentation delay value of a BASE
*
* @param base The BASE pointer
*
* @retval -EINVAL if arguments are invalid
* @retval The 24-bit presentation delay value
*/
int bt_bap_base_get_pres_delay(const struct bt_bap_base *base);
/**
* @brief Get the subgroup count of a BASE
*
* @param base The BASE pointer
*
* @retval -EINVAL if arguments are invalid
* @retval The 8-bit subgroup count value
*/
int bt_bap_base_get_subgroup_count(const struct bt_bap_base *base);
/**
* @brief Get all BIS indexes of a BASE
*
* @param[in] base The BASE pointer
* @param[out] bis_indexes 32-bit BIS index bitfield that will be populated
*
* @retval -EINVAL if arguments are invalid
* @retval 0 on success
*/
int bt_bap_base_get_bis_indexes(const struct bt_bap_base *base, uint32_t *bis_indexes);
/**
* @brief Iterate on all subgroups in the BASE
*
* @param base The BASE pointer
* @param func Callback function. Return true to continue iterating, or false to stop.
* @param user_data Userdata supplied to @p func
*
* @retval -EINVAL if arguments are invalid
* @retval -ECANCELED if iterating over the subgroups stopped prematurely by @p func
* @retval 0 if all subgroups were iterated
*/
int bt_bap_base_foreach_subgroup(const struct bt_bap_base *base,
bool (*func)(const struct bt_bap_base_subgroup *subgroup,
void *user_data),
void *user_data);
/**
* @brief Get the codec ID of a subgroup
*
* @param[in] subgroup The subgroup pointer
* @param[out] codec_id Pointer to the struct where the results are placed
*
* @retval -EINVAL if arguments are invalid
* @retval 0 on success
*/
int bt_bap_base_get_subgroup_codec_id(const struct bt_bap_base_subgroup *subgroup,
struct bt_bap_base_codec_id *codec_id);
/**
* @brief Get the codec configuration data of a subgroup
*
* @param[in] subgroup The subgroup pointer
* @param[out] data Pointer that will point to the resulting codec configuration data
*
* @retval -EINVAL if arguments are invalid
* @retval 0 on success
*/
int bt_bap_base_get_subgroup_codec_data(const struct bt_bap_base_subgroup *subgroup,
uint8_t **data);
/**
* @brief Get the codec metadata of a subgroup
*
* @param[in] subgroup The subgroup pointer
* @param[out] meta Pointer that will point to the resulting codec metadata
*
* @retval -EINVAL if arguments are invalid
* @retval 0 on success
*/
int bt_bap_base_get_subgroup_codec_meta(const struct bt_bap_base_subgroup *subgroup,
uint8_t **meta);
/**
* @brief Store subgroup codec data in a @ref bt_audio_codec_cfg
*
* @param[in] subgroup The subgroup pointer
* @param[out] codec_cfg Pointer to the struct where the results are placed
*
* @retval -EINVAL if arguments are invalid
* @retval -ENOMEM if the @p codec_cfg cannot store the @p subgroup codec data
* @retval 0 on success
*/
int bt_bap_base_subgroup_codec_to_codec_cfg(const struct bt_bap_base_subgroup *subgroup,
struct bt_audio_codec_cfg *codec_cfg);
/**
* @brief Get the BIS count of a subgroup
*
* @param subgroup The subgroup pointer
*
* @retval -EINVAL if arguments are invalid
* @retval The 8-bit BIS count value
*/
int bt_bap_base_get_subgroup_bis_count(const struct bt_bap_base_subgroup *subgroup);
/**
* @brief Get all BIS indexes of a subgroup
*
* @param[in] subgroup The subgroup pointer
* @param[out] bis_indexes 32-bit BIS index bitfield that will be populated
*
* @retval -EINVAL if arguments are invalid
* @retval 0 on success
*/
int bt_bap_base_subgroup_get_bis_indexes(const struct bt_bap_base_subgroup *subgroup,
uint32_t *bis_indexes);
/**
* @brief Iterate on all BIS in the subgroup
*
* @param subgroup The subgroup pointer
* @param func Callback function. Return true to continue iterating, or false to stop.
* @param user_data Userdata supplied to @p func
*
* @retval -EINVAL if arguments are invalid
* @retval -ECANCELED if iterating over the subgroups stopped prematurely by @p func
* @retval 0 if all BIS were iterated
*/
int bt_bap_base_subgroup_foreach_bis(const struct bt_bap_base_subgroup *subgroup,
bool (*func)(const struct bt_bap_base_subgroup_bis *bis,
void *user_data),
void *user_data);
/**
* @brief Store BIS codec configuration data in a @ref bt_audio_codec_cfg
*
* This only sets the @ref bt_audio_codec_cfg data and @ref bt_audio_codec_cfg data_len, but is
* useful to use the BIS codec configuration data with the bt_audio_codec_cfg_* functions.
*
* @param[in] bis The BIS pointer
* @param[out] codec_cfg Pointer to the struct where the results are placed
*
* @retval -EINVAL if arguments are invalid
* @retval -ENOMEM if the @p codec_cfg cannot store the @p subgroup codec data
* @retval 0 on success
*/
int bt_bap_base_subgroup_bis_codec_to_codec_cfg(const struct bt_bap_base_subgroup_bis *bis,
struct bt_audio_codec_cfg *codec_cfg);
/** @} */ /* End of group bt_bap_broadcast */
/**
* @brief BAP Broadcast Source APIs
* @defgroup bt_bap_broadcast_source BAP Broadcast Source APIs
* @ingroup bt_bap_broadcast
* @{
*/
/** Broadcast Source stream parameters */
struct bt_bap_broadcast_source_stream_param {
/** Audio stream */
struct bt_bap_stream *stream;
#if CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_SIZE > 0 || defined(__DOXYGEN__)
/**
* @brief The number of elements in the @p data array.
*
* The BIS specific data may be omitted and this set to 0.
*/
size_t data_len;
/** BIS Codec Specific Configuration */
uint8_t *data;
#endif /* CONFIG_BT_AUDIO_CODEC_CFG_MAX_DATA_SIZE > 0 */
};
/** Broadcast Source subgroup parameters*/
struct bt_bap_broadcast_source_subgroup_param {
/** The number of parameters in @p stream_params */
size_t params_count;
/** Array of stream parameters */
struct bt_bap_broadcast_source_stream_param *params;
/** Subgroup Codec configuration. */
struct bt_audio_codec_cfg *codec_cfg;
};
/** Broadcast Source create parameters */
struct bt_bap_broadcast_source_param {
/** The number of parameters in @p subgroup_params */
size_t params_count;
/** Array of stream parameters */
struct bt_bap_broadcast_source_subgroup_param *params;
/** Quality of Service configuration. */
struct bt_audio_codec_qos *qos;
/**
* @brief Broadcast Source packing mode.
*
* @ref BT_ISO_PACKING_SEQUENTIAL or @ref BT_ISO_PACKING_INTERLEAVED.
*
* @note This is a recommendation to the controller, which the controller may ignore.
*/
uint8_t packing;
/** Whether or not to encrypt the streams. */
bool encryption;
/**
* @brief Broadcast code
*
* If the value is a string or a the value is less than 16 octets,
* the remaining octets shall be 0.
*
* Example:
* The string "Broadcast Code" shall be
* [42 72 6F 61 64 63 61 73 74 20 43 6F 64 65 00 00]
*/
uint8_t broadcast_code[BT_AUDIO_BROADCAST_CODE_SIZE];
#if defined(CONFIG_BT_ISO_TEST_PARAMS) || defined(__DOXYGEN__)
/**
* @brief Immediate Repetition Count
*
* The number of times the scheduled payloads are transmitted in a given event.
*
* Value range from @ref BT_ISO_IRC_MIN to @ref BT_ISO_IRC_MAX.
*/
uint8_t irc;
/**
* @brief Pre-transmission offset
*
* Offset used for pre-transmissions.
*
* Value range from @ref BT_ISO_PTO_MIN to @ref BT_ISO_PTO_MAX.
*/
uint8_t pto;
/**
* @brief ISO interval
*
* Time between consecutive BIS anchor points.
*
* Value range from @ref BT_ISO_ISO_INTERVAL_MIN to @ref BT_ISO_ISO_INTERVAL_MAX.
*/
uint16_t iso_interval;
#endif /* CONFIG_BT_ISO_TEST_PARAMS */
};
/**
* @brief Create audio broadcast source.
*
* Create a new audio broadcast source with one or more audio streams.
*
* The broadcast source will be visible for scanners once this has been called,
* and the device will advertise audio announcements.
*
* No audio data can be sent until bt_bap_broadcast_source_start() has been called and no audio
* information (BIGInfo) will be visible to scanners (see @ref bt_le_per_adv_sync_cb).
*
* @param[in] param Pointer to parameters used to create the broadcast source.
* @param[out] source Pointer to the broadcast source created
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_bap_broadcast_source_create(struct bt_bap_broadcast_source_param *param,
struct bt_bap_broadcast_source **source);
/**
* @brief Reconfigure audio broadcast source.
*
* Reconfigure an audio broadcast source with a new codec and codec quality of
* service parameters. This can only be done when the source is stopped.
*
* Since this may modify the Broadcast Audio Source Endpoint (BASE),
* bt_bap_broadcast_source_get_base() should be called after this to get the new BASE information.
*
* If the @p param.params_count is smaller than the number of subgroups that have been created in
* the Broadcast Source, only the first @p param.params_count subgroups are updated. If a stream
* exist in a subgroup not part of @p param, then that stream is left as is (i.e. it is not removed;
* the only way to remove a stream from a Broadcast Source is to recreate the Broadcast Source).
*
* @param source Pointer to the broadcast source
* @param param Pointer to parameters used to reconfigure the broadcast source.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_bap_broadcast_source_reconfig(struct bt_bap_broadcast_source *source,
struct bt_bap_broadcast_source_param *param);
/**
* @brief Modify the metadata of an audio broadcast source.
*
* Modify the metadata an audio broadcast source. This can only be done when the source is started.
* To update the metadata in the stopped state, use bt_bap_broadcast_source_reconfig().
*
* @param source Pointer to the broadcast source.
* @param meta Metadata.
* @param meta_len Length of metadata.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_bap_broadcast_source_update_metadata(struct bt_bap_broadcast_source *source,
const uint8_t meta[], size_t meta_len);
/**
* @brief Start audio broadcast source.
*
* Start an audio broadcast source with one or more audio streams.
* The broadcast source will start advertising BIGInfo, and audio data can be streamed.
*
* @param source Pointer to the broadcast source
* @param adv Pointer to an extended advertising set with periodic advertising configured.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_bap_broadcast_source_start(struct bt_bap_broadcast_source *source,
struct bt_le_ext_adv *adv);
/**
* @brief Stop audio broadcast source.
*
* Stop an audio broadcast source.
* The broadcast source will stop advertising BIGInfo, and audio data can no longer be streamed.
*
* @param source Pointer to the broadcast source
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_bap_broadcast_source_stop(struct bt_bap_broadcast_source *source);
/**
* @brief Delete audio broadcast source.
*
* Delete an audio broadcast source.
* The broadcast source will stop advertising entirely, and the source can no longer be used.
*
* @param source Pointer to the broadcast source
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_bap_broadcast_source_delete(struct bt_bap_broadcast_source *source);
/**
* @brief Get the broadcast ID of a broadcast source
*
* This will return the 3-octet broadcast ID that should be advertised in the
* extended advertising data with @ref BT_UUID_BROADCAST_AUDIO_VAL as @ref BT_DATA_SVC_DATA16.
*
* See table 3.14 in the Basic Audio Profile v1.0.1 for the structure.
*
* @param[in] source Pointer to the broadcast source.
* @param[out] broadcast_id Pointer to the 3-octet broadcast ID.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_bap_broadcast_source_get_id(struct bt_bap_broadcast_source *source,
uint32_t *const broadcast_id);
/**
* @brief Get the Broadcast Audio Stream Endpoint of a broadcast source
*
* This will encode the BASE of a broadcast source into a buffer, that can be used for
* advertisement. The encoded BASE will thus be encoded as little-endian. The BASE shall be put into
* the periodic advertising data (see bt_le_per_adv_set_data()).
*
* See table 3.15 in the Basic Audio Profile v1.0.1 for the structure.
*
* @param source Pointer to the broadcast source.
* @param base_buf Pointer to a buffer where the BASE will be inserted.
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_bap_broadcast_source_get_base(struct bt_bap_broadcast_source *source,
struct net_buf_simple *base_buf);
/** @} */ /* End of bt_bap_broadcast_source */
/**
* @brief BAP Broadcast Sink APIs
* @defgroup bt_bap_broadcast_sink BAP Broadcast Sink APIs
* @ingroup bt_bap_broadcast
* @{
*/
/** Broadcast Audio Sink callback structure */
struct bt_bap_broadcast_sink_cb {
/**
* @brief Broadcast Audio Source Endpoint (BASE) received
*
* Callback for when we receive a BASE from a broadcaster after
* syncing to the broadcaster's periodic advertising.
*
* @param sink Pointer to the sink structure.
* @param base Broadcast Audio Source Endpoint (BASE).
* @param base_size Size of the @p base
*/
void (*base_recv)(struct bt_bap_broadcast_sink *sink, const struct bt_bap_base *base,
size_t base_size);
/**
* @brief Broadcast sink is syncable
*
* Called whenever a broadcast sink is not synchronized to audio, but the audio is
* synchronizable. This is inferred when a BIGInfo report is received.
*
* Once this callback has been called, it is possible to call
* bt_bap_broadcast_sink_sync() to synchronize to the audio stream(s).
*
* @param sink Pointer to the sink structure.
* @param biginfo The BIGInfo report.
*/
void (*syncable)(struct bt_bap_broadcast_sink *sink, const struct bt_iso_biginfo *biginfo);
/** @internal Internally used list node */
sys_snode_t _node;
};
/**
* @brief Register Broadcast sink callbacks
*
* It is possible to register multiple struct of callbacks, but a single struct can only be
* registered once.
* Registering the same callback multiple times is undefined behavior and may break the stack.
*
* @param cb Broadcast sink callback structure.
*
* @retval 0 in case of success
* @retval -EINVAL if @p cb is NULL
*/
int bt_bap_broadcast_sink_register_cb(struct bt_bap_broadcast_sink_cb *cb);
/**
* @brief Create a Broadcast Sink from a periodic advertising sync
*
* This should only be done after verifying that the periodic advertising sync
* is from a Broadcast Source.
*
* The created Broadcast Sink will need to be supplied to
* bt_bap_broadcast_sink_sync() in order to synchronize to the broadcast audio.
*
* bt_bap_broadcast_sink_cb.pa_synced() will be called with the Broadcast
* Sink object created if this is successful.
*
* @param pa_sync Pointer to the periodic advertising sync object.
* @param broadcast_id 24-bit broadcast ID.
* @param[out] sink Pointer to the Broadcast Sink created.
*
* @return 0 in case of success or errno value in case of error.
*/
int bt_bap_broadcast_sink_create(struct bt_le_per_adv_sync *pa_sync, uint32_t broadcast_id,
struct bt_bap_broadcast_sink **sink);
/**
* @brief Sync to a broadcaster's audio
*
* @param sink Pointer to the sink object from the base_recv callback.
* @param indexes_bitfield Bitfield of the BIS index to sync to. To sync to e.g. BIS index 1 and
* 2, this should have the value of BIT(1) | BIT(2).
* @param streams Stream object pointers to be used for the receiver. If multiple BIS
* indexes shall be synchronized, multiple streams shall be provided.
* @param broadcast_code The 16-octet broadcast code. Shall be supplied if the broadcast is
* encrypted (see @ref bt_bap_broadcast_sink_cb.syncable).
* If the value is a string or a the value is less
* than 16 octets, the remaining octets shall be 0.
*
* Example:
* The string "Broadcast Code" shall be
* [42 72 6F 61 64 63 61 73 74 20 43 6F 64 65 00 00]
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_bap_broadcast_sink_sync(struct bt_bap_broadcast_sink *sink, uint32_t indexes_bitfield,
struct bt_bap_stream *streams[], const uint8_t broadcast_code[16]);
/**
* @brief Stop audio broadcast sink.
*
* Stop an audio broadcast sink.
* The broadcast sink will stop receiving BIGInfo, and audio data can no longer be streamed.
*
* @param sink Pointer to the broadcast sink
*
* @return Zero on success or (negative) error code otherwise.
*/
int bt_bap_broadcast_sink_stop(struct bt_bap_broadcast_sink *sink);
/**
* @brief Release a broadcast sink
*
* Once a broadcast sink has been allocated after the pa_synced callback, it can be deleted using
* this function. If the sink has synchronized to any broadcast audio streams, these must first be
* stopped using bt_bap_stream_stop.
*
* @param sink Pointer to the sink object to delete.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_bap_broadcast_sink_delete(struct bt_bap_broadcast_sink *sink);
/** @} */ /* End of group bt_bap_broadcast_sink */
/**
* @brief Register the callbacks for the Basic Audio Profile Scan Delegator
*
* Only one set of callbacks can be registered at any one time, and calling this function multiple
* times will override any previously registered callbacks.
*
* @param cb Pointer to the callback struct
*/
void bt_bap_scan_delegator_register_cb(struct bt_bap_scan_delegator_cb *cb);
/**
* @brief Set the periodic advertising sync state to syncing
*
* Set the periodic advertising sync state for a receive state to syncing,
* notifying Broadcast Assistants.
*
* @param src_id The source id used to identify the receive state.
* @param pa_state The Periodic Advertising sync state to set.
* BT_BAP_PA_STATE_NOT_SYNCED and BT_BAP_PA_STATE_SYNCED is
* not necessary to provide, as they are handled internally.
*
* @return int Error value. 0 on success, errno on fail.
*/
int bt_bap_scan_delegator_set_pa_state(uint8_t src_id,
enum bt_bap_pa_state pa_state);
/**
* @brief Set the sync state of a receive state in the server
*
* @param src_id The source id used to identify the receive state.
* @param bis_synced Array of bitfields to set the BIS sync state for each
* subgroup.
* @return int Error value. 0 on success, ERRNO on fail.
*/
int bt_bap_scan_delegator_set_bis_sync_state(
uint8_t src_id,
uint32_t bis_synced[CONFIG_BT_BAP_BASS_MAX_SUBGROUPS]);
/** Parameters for bt_bap_scan_delegator_add_src() */
struct bt_bap_scan_delegator_add_src_param {
/** Periodic Advertiser Address */
bt_addr_le_t addr;
/** Advertiser SID */
uint8_t sid;
/** The broadcast isochronous group encryption state */
enum bt_bap_big_enc_state encrypt_state;
/** The 24-bit broadcast ID */
uint32_t broadcast_id;
/** Number of subgroups */
uint8_t num_subgroups;
/** Subgroup specific information */
struct bt_bap_bass_subgroup subgroups[CONFIG_BT_BAP_BASS_MAX_SUBGROUPS];
};
/**
* @brief Add a receive state source locally
*
* This will notify any connected clients about the new source. This allows them
* to modify and even remove it.
*
* If @kconfig{CONFIG_BT_BAP_BROADCAST_SINK} is enabled, any Broadcast Sink
* sources are autonomously added.
*
* @param param The parameters for adding the new source
*
* @return int errno on failure, or source ID on success.
*/
int bt_bap_scan_delegator_add_src(const struct bt_bap_scan_delegator_add_src_param *param);
/** Parameters for bt_bap_scan_delegator_mod_src() */
struct bt_bap_scan_delegator_mod_src_param {
/** The periodic adverting sync */
uint8_t src_id;
/** The broadcast isochronous group encryption state */
enum bt_bap_big_enc_state encrypt_state;
/** The 24-bit broadcast ID */
uint32_t broadcast_id;
/** Number of subgroups */
uint8_t num_subgroups;
/**
* @brief Subgroup specific information
*
* If a subgroup's metadata_len is set to 0, the existing metadata
* for the subgroup will remain unchanged
*/
struct bt_bap_bass_subgroup subgroups[CONFIG_BT_BAP_BASS_MAX_SUBGROUPS];
};
/**
* @brief Add a receive state source locally
*
* This will notify any connected clients about the new source. This allows them
* to modify and even remove it.
*
* If @kconfig{CONFIG_BT_BAP_BROADCAST_SINK} is enabled, any Broadcast Sink
* sources are autonomously modified.
*
* @param param The parameters for adding the new source
*
* @return int errno on failure, or source ID on success.
*/
int bt_bap_scan_delegator_mod_src(const struct bt_bap_scan_delegator_mod_src_param *param);
/**
* @brief Remove a receive state source
*
* This will remove the receive state. If the receive state periodic advertising
* is synced, bt_bap_scan_delegator_cb.pa_sync_term_req() will be called.
*
* If @kconfig{CONFIG_BT_BAP_BROADCAST_SINK} is enabled, any Broadcast Sink
* sources are autonomously removed.
*
* @param src_id The source ID to remove
*
* @return int Error value. 0 on success, errno on fail.
*/
int bt_bap_scan_delegator_rem_src(uint8_t src_id);
/** Callback function for Scan Delegator receive state search functions
*
* @param recv_state The receive state.
* @param user_data User data.
*
* @retval true to stop iterating. If this is used in the context of
* bt_bap_scan_delegator_find_state(), the recv_state will be returned by
* bt_bap_scan_delegator_find_state()
* @retval false to continue iterating
*/
typedef bool (*bt_bap_scan_delegator_state_func_t)(
const struct bt_bap_scan_delegator_recv_state *recv_state, void *user_data);
/**
* @brief Iterate through all existing receive states
*
* @param func The callback function
* @param user_data User specified data that sent to the callback function
*/
void bt_bap_scan_delegator_foreach_state(bt_bap_scan_delegator_state_func_t func,
void *user_data);
/**
* @brief Find and return a receive state based on a compare function
*
* @param func The compare callback function
* @param user_data User specified data that sent to the callback function
*
* @return The first receive state where the @p func returned true, or NULL
*/
const struct bt_bap_scan_delegator_recv_state *bt_bap_scan_delegator_find_state(
bt_bap_scan_delegator_state_func_t func, void *user_data);
/******************************** CLIENT API ********************************/
/**
* @brief Callback function for writes.
*
* @param conn The connection to the peer device.
* @param err Error value. 0 on success, GATT error on fail.
*/
typedef void (*bt_bap_broadcast_assistant_write_cb)(struct bt_conn *conn,
int err);
/**
* @brief Struct to hold the Basic Audio Profile Broadcast Assistant callbacks
*
* These can be registered for usage with bt_bap_broadcast_assistant_register_cb().
*/
struct bt_bap_broadcast_assistant_cb {
/**
* @brief Callback function for bt_bap_broadcast_assistant_discover.
*
* @param conn The connection that was used to discover
* Broadcast Audio Scan Service.
* @param err Error value. 0 on success,
* GATT error or ERRNO on fail.
* @param recv_state_count Number of receive states on the server.
*/
void (*discover)(struct bt_conn *conn, int err,
uint8_t recv_state_count);
/**
* @brief Callback function for Broadcast Audio Scan Service client scan results
*
* Called when the scanner finds an advertiser that advertises the
* BT_UUID_BROADCAST_AUDIO UUID.
*
* @param info Advertiser information.
* @param broadcast_id 24-bit broadcast ID.
*/
void (*scan)(const struct bt_le_scan_recv_info *info,
uint32_t broadcast_id);
/**
* @brief Callback function for when a receive state is read or updated
*
* Called whenever a receive state is read or updated.
*
* @param conn The connection to the Broadcast Audio Scan Service server.
* @param err Error value. 0 on success, GATT error on fail.
* @param state The receive state or NULL if the receive state is empty.
*/
void (*recv_state)(struct bt_conn *conn, int err,
const struct bt_bap_scan_delegator_recv_state *state);
/**
* @brief Callback function for when a receive state is removed.
*
* @param conn The connection to the Broadcast Audio Scan Service server.
* @param src_id The receive state.
*/
void (*recv_state_removed)(struct bt_conn *conn, uint8_t src_id);
/**
* @brief Callback function for bt_bap_broadcast_assistant_scan_start().
*
* @param conn The connection to the peer device.
* @param err Error value. 0 on success, GATT error on fail.
*/
void (*scan_start)(struct bt_conn *conn, int err);
/**
* @brief Callback function for bt_bap_broadcast_assistant_scan_stop().
*
* @param conn The connection to the peer device.
* @param err Error value. 0 on success, GATT error on fail.
*/
void (*scan_stop)(struct bt_conn *conn, int err);
/**
* @brief Callback function for bt_bap_broadcast_assistant_add_src().
*
* @param conn The connection to the peer device.
* @param err Error value. 0 on success, GATT error on fail.
*/
void (*add_src)(struct bt_conn *conn, int err);
/**
* @brief Callback function for bt_bap_broadcast_assistant_mod_src().
*
* @param conn The connection to the peer device.
* @param err Error value. 0 on success, GATT error on fail.
*/
void (*mod_src)(struct bt_conn *conn, int err);
/**
* @brief Callback function for bt_bap_broadcast_assistant_broadcast_code().
*
* @param conn The connection to the peer device.
* @param err Error value. 0 on success, GATT error on fail.
*/
void (*broadcast_code)(struct bt_conn *conn, int err);
/**
* @brief Callback function for bt_bap_broadcast_assistant_rem_src().
*
* @param conn The connection to the peer device.
* @param err Error value. 0 on success, GATT error on fail.
*/
void (*rem_src)(struct bt_conn *conn, int err);
/** @internal Internally used list node */
sys_snode_t _node;
};
/**
* @brief Discover Broadcast Audio Scan Service on the server.
*
* Warning: Only one connection can be active at any time; discovering for a
* new connection, will delete all previous data.
*
* @param conn The connection
* @return int Error value. 0 on success, GATT error or ERRNO on fail.
*/
int bt_bap_broadcast_assistant_discover(struct bt_conn *conn);
/**
* @brief Scan start for BISes for a remote server.
*
* This will let the Broadcast Audio Scan Service server know that this device
* is actively scanning for broadcast sources.
* The function can optionally also start scanning, if the caller does not want
* to start scanning itself.
*
* Scan results, if @p start_scan is true, is sent to the
* bt_bap_broadcast_assistant_scan_cb callback.
*
* @param conn Connection to the Broadcast Audio Scan Service server.
* Used to let the server know that we are scanning.
* @param start_scan Start scanning if true. If false, the application should
* enable scan itself.
* @return int Error value. 0 on success, GATT error or ERRNO on fail.
*/
int bt_bap_broadcast_assistant_scan_start(struct bt_conn *conn,
bool start_scan);
/**
* @brief Stop remote scanning for BISes for a server.
*
* @param conn Connection to the server.
* @return int Error value. 0 on success, GATT error or ERRNO on fail.
*/
int bt_bap_broadcast_assistant_scan_stop(struct bt_conn *conn);
/**
* @brief Registers the callbacks used by Broadcast Audio Scan Service client.
*
* @param cb The callback structure.
*
* @retval 0 on success
* @retval -EINVAL if @p cb is NULL
* @retval -EALREADY if @p cb was already registered
*/
int bt_bap_broadcast_assistant_register_cb(struct bt_bap_broadcast_assistant_cb *cb);
/**
* @brief Unregisters the callbacks used by the Broadcast Audio Scan Service client.
*
* @param cb The callback structure.
*
* @retval 0 on success
* @retval -EINVAL if @p cb is NULL
* @retval -EALREADY if @p cb was not registered
*/
int bt_bap_broadcast_assistant_unregister_cb(struct bt_bap_broadcast_assistant_cb *cb);
/** Parameters for adding a source to a Broadcast Audio Scan Service server */
struct bt_bap_broadcast_assistant_add_src_param {
/** Address of the advertiser. */
bt_addr_le_t addr;
/** SID of the advertising set. */
uint8_t adv_sid;
/** Whether to sync to periodic advertisements. */
bool pa_sync;
/** 24-bit broadcast ID */
uint32_t broadcast_id;
/**
* @brief Periodic advertising interval in milliseconds.
*
* BT_BAP_PA_INTERVAL_UNKNOWN if unknown.
*/
uint16_t pa_interval;
/** Number of subgroups */
uint8_t num_subgroups;
/** Pointer to array of subgroups */
struct bt_bap_bass_subgroup *subgroups;
};
/**
* @brief Add a source on the server.
*
* @param conn Connection to the server.
* @param param Parameter struct.
*
* @return Error value. 0 on success, GATT error or ERRNO on fail.
*/
int bt_bap_broadcast_assistant_add_src(
struct bt_conn *conn, const struct bt_bap_broadcast_assistant_add_src_param *param);
/** Parameters for modifying a source */
struct bt_bap_broadcast_assistant_mod_src_param {
/** Source ID of the receive state. */
uint8_t src_id;
/** Whether to sync to periodic advertisements. */
bool pa_sync;
/**
* @brief Periodic advertising interval.
*
* BT_BAP_PA_INTERVAL_UNKNOWN if unknown.
*/
uint16_t pa_interval;
/** Number of subgroups */
uint8_t num_subgroups;
/** Pointer to array of subgroups */
struct bt_bap_bass_subgroup *subgroups;
};
/**
* @brief Modify a source on the server.
*
* @param conn Connection to the server.
* @param param Parameter struct.
*
* @return Error value. 0 on success, GATT error or ERRNO on fail.
*/
int bt_bap_broadcast_assistant_mod_src(
struct bt_conn *conn, const struct bt_bap_broadcast_assistant_mod_src_param *param);
/**
* @brief Set a broadcast code to the specified receive state.
*
* @param conn Connection to the server.
* @param src_id Source ID of the receive state.
* @param broadcast_code The broadcast code.
*
* @return Error value. 0 on success, GATT error or ERRNO on fail.
*/
int bt_bap_broadcast_assistant_set_broadcast_code(
struct bt_conn *conn, uint8_t src_id,
const uint8_t broadcast_code[BT_AUDIO_BROADCAST_CODE_SIZE]);
/**
* @brief Remove a source from the server.
*
* @param conn Connection to the server.
* @param src_id Source ID of the receive state.
*
* @return Error value. 0 on success, GATT error or ERRNO on fail.
*/
int bt_bap_broadcast_assistant_rem_src(struct bt_conn *conn, uint8_t src_id);
/**
* @brief Read the specified receive state from the server.
*
* @param conn Connection to the server.
* @param idx The index of the receive start (0 up to the value from
* bt_bap_broadcast_assistant_discover_cb)
*
* @return Error value. 0 on success, GATT error or ERRNO on fail.
*/
int bt_bap_broadcast_assistant_read_recv_state(struct bt_conn *conn, uint8_t idx);
/** @} */ /* end of bt_bap */
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_BAP_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/audio/bap.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 19,838 |
```objective-c
/**
* @file
* @brief Bluetooth Volume Control Profile (VCP) APIs.
*/
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_VCP_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_VCP_H_
/**
* @brief Volume Control Profile (VCP)
*
* @defgroup bt_gatt_vcp Volume Control Profile (VCP)
*
* @since 2.7
* @version 0.8.0
*
* @ingroup bluetooth
* @{
*
* The Volume Control Profile (VCP) provides procedures to control the volume level and mute state
* on audio devices.
*/
#include <stdint.h>
#include <zephyr/bluetooth/audio/aics.h>
#include <zephyr/bluetooth/audio/vocs.h>
#include <zephyr/bluetooth/conn.h>
#include <zephyr/sys/slist.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* Defines the maximum number of Volume Offset Control service instances for the
* Volume Control Profile Volume Renderer
*/
#if defined(CONFIG_BT_VCP_VOL_REND)
#define BT_VCP_VOL_REND_VOCS_CNT CONFIG_BT_VCP_VOL_REND_VOCS_INSTANCE_COUNT
#else
#define BT_VCP_VOL_REND_VOCS_CNT 0
#endif /* CONFIG_BT_VCP_VOL_REND */
/**
* Defines the maximum number of Audio Input Control service instances for the
* Volume Control Profile Volume Renderer
*/
#if defined(CONFIG_BT_VCP_VOL_REND)
#define BT_VCP_VOL_REND_AICS_CNT CONFIG_BT_VCP_VOL_REND_AICS_INSTANCE_COUNT
#else
#define BT_VCP_VOL_REND_AICS_CNT 0
#endif /* CONFIG_BT_VCP_VOL_REND */
/**
* @name Volume Control Service Error codes
* @{
*/
/**
* The Change_Counter operand value does not match the Change_Counter field value of the Volume
* State characteristic.
*/
#define BT_VCP_ERR_INVALID_COUNTER 0x80
/** An invalid opcode has been used in a control point procedure. */
#define BT_VCP_ERR_OP_NOT_SUPPORTED 0x81
/** @} */
/**
* @name Volume Control Service Mute Values
* @{
*/
/** The volume state is unmuted */
#define BT_VCP_STATE_UNMUTED 0x00
/** The volume state is muted */
#define BT_VCP_STATE_MUTED 0x01
/** @} */
/** @brief Opaque Volume Control Service instance. */
struct bt_vcp_vol_ctlr;
/** Register structure for Volume Control Service */
struct bt_vcp_vol_rend_register_param {
/** Initial step size (1-255) */
uint8_t step;
/** Initial mute state (0-1) */
uint8_t mute;
/** Initial volume level (0-255) */
uint8_t volume;
/** Register parameters for Volume Offset Control Services */
struct bt_vocs_register_param vocs_param[BT_VCP_VOL_REND_VOCS_CNT];
/** Register parameters for Audio Input Control Services */
struct bt_aics_register_param aics_param[BT_VCP_VOL_REND_AICS_CNT];
/** Volume Control Service callback structure. */
struct bt_vcp_vol_rend_cb *cb;
};
/**
* @brief Volume Control Service included services
*
* Used for to represent the Volume Control Service included service instances,
* for either a client or a server. The instance pointers either represent
* local server instances, or remote service instances.
*/
struct bt_vcp_included {
/** Number of Volume Offset Control Service instances */
uint8_t vocs_cnt;
/** Array of pointers to Volume Offset Control Service instances */
struct bt_vocs **vocs;
/** Number of Audio Input Control Service instances */
uint8_t aics_cnt;
/** Array of pointers to Audio Input Control Service instances */
struct bt_aics **aics;
};
/**
* @brief Get Volume Control Service included services.
*
* Returns a pointer to a struct that contains information about the
* Volume Control Service included service instances, such as pointers to the
* Volume Offset Control Service (Volume Offset Control Service) or
* Audio Input Control Service (AICS) instances.
*
* @param[out] included Pointer to store the result in.
*
* @return 0 if success, errno on failure.
*/
int bt_vcp_vol_rend_included_get(struct bt_vcp_included *included);
/**
* @brief Register the Volume Control Service.
*
* This will register and enable the service and make it discoverable by
* clients.
*
* @param param Volume Control Service register parameters.
*
* @return 0 if success, errno on failure.
*/
int bt_vcp_vol_rend_register(struct bt_vcp_vol_rend_register_param *param);
/**
* @brief Struct to hold the Volume Renderer callbacks
*
* These can be registered for usage with bt_vcp_vol_rend_register().
*/
struct bt_vcp_vol_rend_cb {
/**
* @brief Callback function for Volume Control Service volume state.
*
* Called when the value is locally read with
* bt_vcp_vol_rend_get_state(), or if the state is changed by either
* the Volume Renderer or a remote Volume Controller.
*
* @param conn Pointer to the connection to a remote device if
* the change was caused by it, otherwise NULL.
* @param err Error value. 0 on success, GATT error on positive value
* or errno on negative value.
* @param volume The volume of the Volume Control Service server.
* @param mute The mute setting of the Volume Control Service server.
*/
void (*state)(struct bt_conn *conn, int err, uint8_t volume, uint8_t mute);
/**
* @brief Callback function for Volume Control Service flags.
*
* Called when the value is locally read as the server.
* Called when the value is remotely read as the client.
* Called if the value is changed by either the server or client.
*
* @param conn Pointer to the connection to a remote device if
* the change was caused by it, otherwise NULL.
* @param err Error value. 0 on success, GATT error on positive value
* or errno on negative value.
* @param flags The flags of the Volume Control Service server.
*/
void (*flags)(struct bt_conn *conn, int err, uint8_t flags);
};
/**
* @brief Set the Volume Control Service volume step size.
*
* Set the value that the volume changes, when changed relatively with e.g.
* @ref bt_vcp_vol_rend_vol_down or @ref bt_vcp_vol_rend_vol_up.
*
* This can only be done as the server.
*
* @param volume_step The volume step size (1-255).
*
* @return 0 if success, errno on failure.
*/
int bt_vcp_vol_rend_set_step(uint8_t volume_step);
/**
* @brief Get the Volume Control Service volume state.
*
* @return 0 if success, errno on failure.
*/
int bt_vcp_vol_rend_get_state(void);
/**
* @brief Get the Volume Control Service flags.
*
* @return 0 if success, errno on failure.
*/
int bt_vcp_vol_rend_get_flags(void);
/**
* @brief Turn the volume down by one step on the server.
*
* @return 0 if success, errno on failure.
*/
int bt_vcp_vol_rend_vol_down(void);
/**
* @brief Turn the volume up by one step on the server.
*
* @return 0 if success, errno on failure.
*/
int bt_vcp_vol_rend_vol_up(void);
/**
* @brief Turn the volume down and unmute the server.
*
* @return 0 if success, errno on failure.
*/
int bt_vcp_vol_rend_unmute_vol_down(void);
/**
* @brief Turn the volume up and unmute the server.
*
* @return 0 if success, errno on failure.
*/
int bt_vcp_vol_rend_unmute_vol_up(void);
/**
* @brief Set the volume on the server
*
* @param volume The absolute volume to set.
*
* @return 0 if success, errno on failure.
*/
int bt_vcp_vol_rend_set_vol(uint8_t volume);
/**
* @brief Unmute the server.
*
* @return 0 if success, errno on failure.
*/
int bt_vcp_vol_rend_unmute(void);
/**
* @brief Mute the server.
*
* @return 0 if success, errno on failure.
*/
int bt_vcp_vol_rend_mute(void);
/**
* @brief Struct to hold the Volume Controller callbacks
*
* These can be registered for usage with bt_vcp_vol_ctlr_cb_register().
*/
struct bt_vcp_vol_ctlr_cb {
/**
* @brief Callback function for Volume Control Profile volume state.
*
* Called when the value is remotely read as the Volume Controller.
* Called if the value is changed by either the Volume Renderer or
* Volume Controller, and notified to the to Volume Controller.
*
* @param vol_ctlr Volume Controller instance pointer.
* @param err Error value. 0 on success, GATT error on positive
* value or errno on negative value.
* @param volume The volume of the Volume Renderer.
* @param mute The mute setting of the Volume Renderer.
*/
void (*state)(struct bt_vcp_vol_ctlr *vol_ctlr, int err, uint8_t volume,
uint8_t mute);
/**
* @brief Callback function for Volume Control Profile volume flags.
*
* Called when the value is remotely read as the Volume Controller.
* Called if the value is changed by the Volume Renderer.
*
* A non-zero value indicates the volume has been changed on the
* Volume Renderer since it was booted.
*
* @param vol_ctlr Volume Controller instance pointer.
* @param err Error value. 0 on success, GATT error on positive
* value or errno on negative value.
* @param flags The flags of the Volume Renderer.
*/
void (*flags)(struct bt_vcp_vol_ctlr *vol_ctlr, int err, uint8_t flags);
/**
* @brief Callback function for bt_vcp_vol_ctlr_discover().
*
* This callback is called once the discovery procedure is completed.
*
* @param vol_ctlr Volume Controller instance pointer.
* @param err Error value. 0 on success, GATT error on positive
* value or errno on negative value.
* @param vocs_count Number of Volume Offset Control Service instances
* on the remote Volume Renderer.
* @param aics_count Number of Audio Input Control Service instances
* the remote Volume Renderer.
*/
void (*discover)(struct bt_vcp_vol_ctlr *vol_ctlr, int err, uint8_t vocs_count,
uint8_t aics_count);
/**
* @brief Callback function for bt_vcp_vol_ctlr_vol_down().
*
* Called when the volume down procedure is completed.
*
* @param vol_ctlr Volume Controller instance pointer.
* @param err Error value. 0 on success, GATT error on positive
* value or errno on negative value.
*/
void (*vol_down)(struct bt_vcp_vol_ctlr *vol_ctlr, int err);
/**
* @brief Callback function for bt_vcp_vol_ctlr_vol_up().
*
* Called when the volume up procedure is completed.
*
* @param vol_ctlr Volume Controller instance pointer.
* @param err Error value. 0 on success, GATT error on positive
* value or errno on negative value.
*/
void (*vol_up)(struct bt_vcp_vol_ctlr *vol_ctlr, int err);
/**
* @brief Callback function for bt_vcp_vol_ctlr_mute().
*
* Called when the mute procedure is completed.
*
* @param vol_ctlr Volume Controller instance pointer.
* @param err Error value. 0 on success, GATT error on positive
* value or errno on negative value.
*/
void (*mute)(struct bt_vcp_vol_ctlr *vol_ctlr, int err);
/**
* @brief Callback function for bt_vcp_vol_ctlr_unmute().
*
* Called when the unmute procedure is completed.
*
* @param vol_ctlr Volume Controller instance pointer.
* @param err Error value. 0 on success, GATT error on positive
* value or errno on negative value.
*/
void (*unmute)(struct bt_vcp_vol_ctlr *vol_ctlr, int err);
/**
* @brief Callback function for bt_vcp_vol_ctlr_vol_down_unmute().
*
* Called when the volume down and unmute procedure is completed.
*
* @param vol_ctlr Volume Controller instance pointer.
* @param err Error value. 0 on success, GATT error on positive
* value or errno on negative value.
*/
void (*vol_down_unmute)(struct bt_vcp_vol_ctlr *vol_ctlr, int err);
/**
* @brief Callback function for bt_vcp_vol_ctlr_vol_up_unmute().
*
* Called when the volume up and unmute procedure is completed.
*
* @param vol_ctlr Volume Controller instance pointer.
* @param err Error value. 0 on success, GATT error on positive
* value or errno on negative value.
*/
void (*vol_up_unmute)(struct bt_vcp_vol_ctlr *vol_ctlr, int err);
/**
* @brief Callback function for bt_vcp_vol_ctlr_vol_set().
*
* Called when the set absolute volume procedure is completed.
*
* @param vol_ctlr Volume Controller instance pointer.
* @param err Error value. 0 on success, GATT error on positive
* value or errno on negative value.
*/
void (*vol_set)(struct bt_vcp_vol_ctlr *vol_ctlr, int err);
/** Volume Offset Control Service callbacks */
struct bt_vocs_cb vocs_cb;
/** Audio Input Control Service callbacks */
struct bt_aics_cb aics_cb;
/** @internal Internally used field for list handling */
sys_snode_t _node;
};
/**
* @brief Registers the callbacks used by the Volume Controller.
*
* @param cb The callback structure.
*
* @retval 0 on success
* @retval -EINVAL if @p cb is NULL
* @retval -EALREADY if @p cb was already registered
*/
int bt_vcp_vol_ctlr_cb_register(struct bt_vcp_vol_ctlr_cb *cb);
/**
* @brief Unregisters the callbacks used by the Volume Controller.
*
* @param cb The callback structure.
*
* @retval 0 on success
* @retval -EINVAL if @p cb is NULL
* @retval -EALREADY if @p cb was not registered
*/
int bt_vcp_vol_ctlr_cb_unregister(struct bt_vcp_vol_ctlr_cb *cb);
/**
* @brief Discover Volume Control Service and included services.
*
* This will start a GATT discovery and setup handles and subscriptions.
* This shall be called once before any other actions can be
* executed for the peer device, and the
* @ref bt_vcp_vol_ctlr_cb.discover callback will notify when it is possible to
* start remote operations.
*
* This shall only be done as the client,
*
* @param conn The connection to discover Volume Control Service for.
* @param[out] vol_ctlr Valid remote instance object on success.
*
* @return 0 if success, errno on failure.
*/
int bt_vcp_vol_ctlr_discover(struct bt_conn *conn,
struct bt_vcp_vol_ctlr **vol_ctlr);
/**
* @brief Get the volume controller from a connection pointer
*
* Get the Volume Control Profile Volume Controller pointer from a connection pointer.
* Only volume controllers that have been initiated via bt_vcp_vol_ctlr_discover() can be
* retrieved.
*
* @param conn Connection pointer.
*
* @retval Pointer to a Volume Control Profile Volume Controller instance
* @retval NULL if @p conn is NULL or if the connection has not done discovery yet
*/
struct bt_vcp_vol_ctlr *bt_vcp_vol_ctlr_get_by_conn(const struct bt_conn *conn);
/**
* @brief Get the connection pointer of a client instance
*
* Get the Bluetooth connection pointer of a Volume Control Service
* client instance.
*
* @param vol_ctlr Volume Controller instance pointer.
* @param[out] conn Connection pointer.
*
* @return 0 if success, errno on failure.
*/
int bt_vcp_vol_ctlr_conn_get(const struct bt_vcp_vol_ctlr *vol_ctlr,
struct bt_conn **conn);
/**
* @brief Get Volume Control Service included services.
*
* Returns a pointer to a struct that contains information about the
* Volume Control Service included service instances, such as pointers to the
* Volume Offset Control Service (Volume Offset Control Service) or
* Audio Input Control Service (AICS) instances.
*
* Requires that @kconfig{CONFIG_BT_VCP_VOL_CTLR_VOCS} or @kconfig{CONFIG_BT_VCP_VOL_CTLR_AICS} is
* enabled.
*
* @param vol_ctlr Volume Controller instance pointer.
* @param[out] included Pointer to store the result in.
*
* @return 0 if success, errno on failure.
*/
int bt_vcp_vol_ctlr_included_get(struct bt_vcp_vol_ctlr *vol_ctlr,
struct bt_vcp_included *included);
/**
* @brief Read the volume state of a remote Volume Renderer.
*
* @param vol_ctlr Volume Controller instance pointer.
*
* @return 0 if success, errno on failure.
*/
int bt_vcp_vol_ctlr_read_state(struct bt_vcp_vol_ctlr *vol_ctlr);
/**
* @brief Read the volume flags of a remote Volume Renderer.
*
* @param vol_ctlr Volume Controller instance pointer.
*
* @return 0 if success, errno on failure.
*/
int bt_vcp_vol_ctlr_read_flags(struct bt_vcp_vol_ctlr *vol_ctlr);
/**
* @brief Turn the volume down one step on a remote Volume Renderer
*
* @param vol_ctlr Volume Controller instance pointer.
*
* @return 0 if success, errno on failure.
*/
int bt_vcp_vol_ctlr_vol_down(struct bt_vcp_vol_ctlr *vol_ctlr);
/**
* @brief Turn the volume up one step on a remote Volume Renderer
*
* @param vol_ctlr Volume Controller instance pointer.
*
* @return 0 if success, errno on failure.
*/
int bt_vcp_vol_ctlr_vol_up(struct bt_vcp_vol_ctlr *vol_ctlr);
/**
* @brief Turn the volume down one step and unmute on a remote Volume Renderer
*
* @param vol_ctlr Volume Controller instance pointer.
*
* @return 0 if success, errno on failure.
*/
int bt_vcp_vol_ctlr_unmute_vol_down(struct bt_vcp_vol_ctlr *vol_ctlr);
/**
* @brief Turn the volume up one step and unmute on a remote Volume Renderer
*
* @param vol_ctlr Volume Controller instance pointer.
*
* @return 0 if success, errno on failure.
*/
int bt_vcp_vol_ctlr_unmute_vol_up(struct bt_vcp_vol_ctlr *vol_ctlr);
/**
* @brief Set the absolute volume on a remote Volume Renderer
*
* @param vol_ctlr Volume Controller instance pointer.
* @param volume The absolute volume to set.
*
* @return 0 if success, errno on failure.
*/
int bt_vcp_vol_ctlr_set_vol(struct bt_vcp_vol_ctlr *vol_ctlr, uint8_t volume);
/**
* @brief Unmute a remote Volume Renderer.
*
* @param vol_ctlr Volume Controller instance pointer.
*
* @return 0 if success, errno on failure.
*/
int bt_vcp_vol_ctlr_unmute(struct bt_vcp_vol_ctlr *vol_ctlr);
/**
* @brief Mute a remote Volume Renderer.
*
* @param vol_ctlr Volume Controller instance pointer.
*
* @return 0 if success, errno on failure.
*/
int bt_vcp_vol_ctlr_mute(struct bt_vcp_vol_ctlr *vol_ctlr);
#ifdef __cplusplus
}
#endif
/**
* @}
*/
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_SERVICES_VCP_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/audio/vcp.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 4,419 |
```objective-c
/**
* @file
* @brief Bluetooth Media Control Service (MCS) APIs.
*/
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_MCS_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_MCS_H_
/**
* @brief Media Control Service (MCS)
*
* @defgroup bt_mcs Media Control Service (MCS)
*
* @since 3.0
* @version 0.8.0
*
* @ingroup bluetooth
* @{
*
* Definitions and types related to the Media Control Service and Media Control
* Profile specifications.
*/
#include <zephyr/sys/util.h>
#include <zephyr/sys/util_macro.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* A characteristic value has changed while a Read Long Value Characteristic sub-procedure is in
* progress.
*/
#define BT_MCS_ERR_LONG_VAL_CHANGED 0x80
/**
* @name Playback speeds
*
* The playback speed (s) is calculated by the value of 2 to the power of p divided by 64.
* All values from -128 to 127 allowed, only some examples defined.
* @{
*/
/** Minimum playback speed, resulting in 25 % speed */
#define BT_MCS_PLAYBACK_SPEED_MIN -128
/** Quarter playback speed, resulting in 25 % speed */
#define BT_MCS_PLAYBACK_SPEED_QUARTER -128
/** Half playback speed, resulting in 50 % speed */
#define BT_MCS_PLAYBACK_SPEED_HALF -64
/** Unity playback speed, resulting in 100 % speed */
#define BT_MCS_PLAYBACK_SPEED_UNITY 0
/** Double playback speed, resulting in 200 % speed */
#define BT_MCS_PLAYBACK_SPEED_DOUBLE 64
/** Max playback speed, resulting in 395.7 % speed (nearly 400 %) */
#define BT_MCS_PLAYBACK_SPEED_MAX 127
/** @} */
/**
* @name Seeking speed
*
* The allowed values for seeking speed are the range -64 to -4
* (endpoints included), the value 0, and the range 4 to 64
* (endpoints included).
* @{
*/
/** Maximum seeking speed - Can be negated */
#define BT_MCS_SEEKING_SPEED_FACTOR_MAX 64
/** Minimum seeking speed - Can be negated */
#define BT_MCS_SEEKING_SPEED_FACTOR_MIN 4
/** No seeking */
#define BT_MCS_SEEKING_SPEED_FACTOR_ZERO 0
/** @} */
/**
* @name Playing orders
* @{
*/
/** A single track is played once; there is no next track. */
#define BT_MCS_PLAYING_ORDER_SINGLE_ONCE 0X01
/** A single track is played repeatedly; the next track is the current track. */
#define BT_MCS_PLAYING_ORDER_SINGLE_REPEAT 0x02
/** The tracks within a group are played once in track order. */
#define BT_MCS_PLAYING_ORDER_INORDER_ONCE 0x03
/** The tracks within a group are played in track order repeatedly. */
#define BT_MCS_PLAYING_ORDER_INORDER_REPEAT 0x04
/** The tracks within a group are played once only from the oldest first. */
#define BT_MCS_PLAYING_ORDER_OLDEST_ONCE 0x05
/** The tracks within a group are played from the oldest first repeatedly. */
#define BT_MCS_PLAYING_ORDER_OLDEST_REPEAT 0x06
/** The tracks within a group are played once only from the newest first. */
#define BT_MCS_PLAYING_ORDER_NEWEST_ONCE 0x07
/** The tracks within a group are played from the newest first repeatedly. */
#define BT_MCS_PLAYING_ORDER_NEWEST_REPEAT 0x08
/** The tracks within a group are played in random order once. */
#define BT_MCS_PLAYING_ORDER_SHUFFLE_ONCE 0x09
/** The tracks within a group are played in random order repeatedly. */
#define BT_MCS_PLAYING_ORDER_SHUFFLE_REPEAT 0x0a
/** @} */
/** @name Playing orders supported
*
* A bitmap, in the same order as the playing orders above.
* Note that playing order 1 corresponds to bit 0, and so on.
* @{
*/
/** A single track is played once; there is no next track. */
#define BT_MCS_PLAYING_ORDERS_SUPPORTED_SINGLE_ONCE BIT(0)
/** A single track is played repeatedly; the next track is the current track. */
#define BT_MCS_PLAYING_ORDERS_SUPPORTED_SINGLE_REPEAT BIT(1)
/** The tracks within a group are played once in track order. */
#define BT_MCS_PLAYING_ORDERS_SUPPORTED_INORDER_ONCE BIT(2)
/** The tracks within a group are played in track order repeatedly. */
#define BT_MCS_PLAYING_ORDERS_SUPPORTED_INORDER_REPEAT BIT(3)
/** The tracks within a group are played once only from the oldest first. */
#define BT_MCS_PLAYING_ORDERS_SUPPORTED_OLDEST_ONCE BIT(4)
/** The tracks within a group are played from the oldest first repeatedly. */
#define BT_MCS_PLAYING_ORDERS_SUPPORTED_OLDEST_REPEAT BIT(5)
/** The tracks within a group are played once only from the newest first. */
#define BT_MCS_PLAYING_ORDERS_SUPPORTED_NEWEST_ONCE BIT(6)
/** The tracks within a group are played from the newest first repeatedly. */
#define BT_MCS_PLAYING_ORDERS_SUPPORTED_NEWEST_REPEAT BIT(7)
/** The tracks within a group are played in random order once. */
#define BT_MCS_PLAYING_ORDERS_SUPPORTED_SHUFFLE_ONCE BIT(8)
/** The tracks within a group are played in random order repeatedly. */
#define BT_MCS_PLAYING_ORDERS_SUPPORTED_SHUFFLE_REPEAT BIT(9)
/** @} */
/**
* @name Media states
* @{
*/
/** The current track is invalid, and no track has been selected. */
#define BT_MCS_MEDIA_STATE_INACTIVE 0x00
/** The media player is playing the current track. */
#define BT_MCS_MEDIA_STATE_PLAYING 0x01
/** The current track is paused. The media player has a current track, but it is not being played */
#define BT_MCS_MEDIA_STATE_PAUSED 0x02
/** The current track is fast forwarding or fast rewinding. */
#define BT_MCS_MEDIA_STATE_SEEKING 0x03
/** @} */
/**
* @name Media control point opcodes
* @{
*/
/** Start playing the current track. */
#define BT_MCS_OPC_PLAY 0x01
/** Pause playing the current track. */
#define BT_MCS_OPC_PAUSE 0x02
/** Fast rewind the current track. */
#define BT_MCS_OPC_FAST_REWIND 0x03
/** Fast forward the current track. */
#define BT_MCS_OPC_FAST_FORWARD 0x04
/**
* Stop current activity and return to the paused state and set the current track position to the
* start of the current track.
*/
#define BT_MCS_OPC_STOP 0x05
/** Set a new current track position relative to the current track position. */
#define BT_MCS_OPC_MOVE_RELATIVE 0x10
/**
* Set the current track position to the starting position of the previous segment of the current
* track.
*/
#define BT_MCS_OPC_PREV_SEGMENT 0x20
/**
* Set the current track position to the starting position of
* the next segment of the current track.
*/
#define BT_MCS_OPC_NEXT_SEGMENT 0x21
/**
* Set the current track position to the starting position of
* the first segment of the current track.
*/
#define BT_MCS_OPC_FIRST_SEGMENT 0x22
/**
* Set the current track position to the starting position of
* the last segment of the current track.
*/
#define BT_MCS_OPC_LAST_SEGMENT 0x23
/**
* Set the current track position to the starting position of
* the nth segment of the current track.
*/
#define BT_MCS_OPC_GOTO_SEGMENT 0x24
/** Set the current track to the previous track based on the playing order. */
#define BT_MCS_OPC_PREV_TRACK 0x30
/** Set the current track to the next track based on the playing order. */
#define BT_MCS_OPC_NEXT_TRACK 0x31
/** Set the current track to the first track based on the playing order. */
#define BT_MCS_OPC_FIRST_TRACK 0x32
/** Set the current track to the last track based on the playing order. */
#define BT_MCS_OPC_LAST_TRACK 0x33
/** Set the current track to the nth track based on the playing order. */
#define BT_MCS_OPC_GOTO_TRACK 0x34
/** Set the current group to the previous group in the sequence of groups. */
#define BT_MCS_OPC_PREV_GROUP 0x40
/** Set the current group to the next group in the sequence of groups. */
#define BT_MCS_OPC_NEXT_GROUP 0x41
/** Set the current group to the first group in the sequence of groups. */
#define BT_MCS_OPC_FIRST_GROUP 0x42
/** Set the current group to the last group in the sequence of groups. */
#define BT_MCS_OPC_LAST_GROUP 0x43
/** Set the current group to the nth group in the sequence of groups. */
#define BT_MCS_OPC_GOTO_GROUP 0x44
/** @} */
/** Media control point supported opcodes length */
#define BT_MCS_OPCODES_SUPPORTED_LEN 4
/**
* @name Media control point supported opcodes values
* @{
*/
/** Support the Play opcode */
#define BT_MCS_OPC_SUP_PLAY BIT(0)
/** Support the Pause opcode */
#define BT_MCS_OPC_SUP_PAUSE BIT(1)
/** Support the Fast Rewind opcode */
#define BT_MCS_OPC_SUP_FAST_REWIND BIT(2)
/** Support the Fast Forward opcode */
#define BT_MCS_OPC_SUP_FAST_FORWARD BIT(3)
/** Support the Stop opcode */
#define BT_MCS_OPC_SUP_STOP BIT(4)
/** Support the Move Relative opcode */
#define BT_MCS_OPC_SUP_MOVE_RELATIVE BIT(5)
/** Support the Previous Segment opcode */
#define BT_MCS_OPC_SUP_PREV_SEGMENT BIT(6)
/** Support the Next Segment opcode */
#define BT_MCS_OPC_SUP_NEXT_SEGMENT BIT(7)
/** Support the First Segment opcode */
#define BT_MCS_OPC_SUP_FIRST_SEGMENT BIT(8)
/** Support the Last Segment opcode */
#define BT_MCS_OPC_SUP_LAST_SEGMENT BIT(9)
/** Support the Goto Segment opcode */
#define BT_MCS_OPC_SUP_GOTO_SEGMENT BIT(10)
/** Support the Previous Track opcode */
#define BT_MCS_OPC_SUP_PREV_TRACK BIT(11)
/** Support the Next Track opcode */
#define BT_MCS_OPC_SUP_NEXT_TRACK BIT(12)
/** Support the First Track opcode */
#define BT_MCS_OPC_SUP_FIRST_TRACK BIT(13)
/** Support the Last Track opcode */
#define BT_MCS_OPC_SUP_LAST_TRACK BIT(14)
/** Support the Goto Track opcode */
#define BT_MCS_OPC_SUP_GOTO_TRACK BIT(15)
/** Support the Previous Group opcode */
#define BT_MCS_OPC_SUP_PREV_GROUP BIT(16)
/** Support the Next Group opcode */
#define BT_MCS_OPC_SUP_NEXT_GROUP BIT(17)
/** Support the First Group opcode */
#define BT_MCS_OPC_SUP_FIRST_GROUP BIT(18)
/** Support the Last Group opcode */
#define BT_MCS_OPC_SUP_LAST_GROUP BIT(19)
/** Support the Goto Group opcode */
#define BT_MCS_OPC_SUP_GOTO_GROUP BIT(20)
/** @} */
/**
* @name Media control point notification result codes
* @{
*/
/** Action requested by the opcode write was completed successfully. */
#define BT_MCS_OPC_NTF_SUCCESS 0x01
/** An invalid or unsupported opcode was used for the Media Control Point write. */
#define BT_MCS_OPC_NTF_NOT_SUPPORTED 0x02
/**
* The Media Player State characteristic value is Inactive when the opcode is received or the
* result of the requested action of the opcode results in the Media Player State characteristic
* being set to Inactive.
*/
#define BT_MCS_OPC_NTF_PLAYER_INACTIVE 0x03
/**
* The requested action of any Media Control Point write cannot be completed successfully because of
* a condition within the player.
*/
#define BT_MCS_OPC_NTF_CANNOT_BE_COMPLETED 0x04
/** @} */
/**
* @name Search control point type values
*
* Reference: Media Control Service spec v1.0 section 3.20.2
* @{
*/
/** Search for Track Name */
#define BT_MCS_SEARCH_TYPE_TRACK_NAME 0x01
/** Search for Artist Name */
#define BT_MCS_SEARCH_TYPE_ARTIST_NAME 0x02
/** Search for Album Name */
#define BT_MCS_SEARCH_TYPE_ALBUM_NAME 0x03
/** Search for Group Name */
#define BT_MCS_SEARCH_TYPE_GROUP_NAME 0x04
/** Search for Earliest Year */
#define BT_MCS_SEARCH_TYPE_EARLIEST_YEAR 0x05
/** Search for Latest Year */
#define BT_MCS_SEARCH_TYPE_LATEST_YEAR 0x06
/** Search for Genre */
#define BT_MCS_SEARCH_TYPE_GENRE 0x07
/** Search for Tracks only */
#define BT_MCS_SEARCH_TYPE_ONLY_TRACKS 0x08
/** Search for Groups only */
#define BT_MCS_SEARCH_TYPE_ONLY_GROUPS 0x09
/** @} */
/**
* @brief Search control point minimum length
*
* At least one search control item (SCI), consisting of the length octet and the type octet.
* (The * parameter field may be empty.)
*/
#define SEARCH_LEN_MIN 2
/** Search control point maximum length */
#define SEARCH_LEN_MAX 64
/**
* @brief Search control point item (SCI) minimum length
*
* An SCI length can be as little as one byte, for an SCI that has only the type field.
* (The SCI len is the length of type + param.)
*/
#define SEARCH_SCI_LEN_MIN 1 /* An SCI length can be as little as one byte,
* for an SCI that has only the type field.
* (The SCI len is the length of type + param.)
*/
/** Search parameters maximum length */
#define SEARCH_PARAM_MAX 62
/**
* @name Search notification result codes
*
* Reference: Media Control Service spec v1.0 section 3.20.2
* @{
*/
/** Search request was accepted; search has started. */
#define BT_MCS_SCP_NTF_SUCCESS 0x01
/** Search request was invalid; no search started. */
#define BT_MCS_SCP_NTF_FAILURE 0x02
/** @} */
/**
* @name Group object object types
*
* Reference: Media Control Service spec v1.0 section 4.4.1
* @{
*/
/** Group object type is track */
#define BT_MCS_GROUP_OBJECT_TRACK_TYPE 0x00
/** Group object type is group */
#define BT_MCS_GROUP_OBJECT_GROUP_TYPE 0x01
/** @} */
#ifdef __cplusplus
}
#endif
/**
* @}
*/
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_MCS_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/audio/mcs.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 3,266 |
```objective-c
/**
* @file
* @brief Bluetooth Published Audio Capabilities Service (PACS) APIs
*/
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_PACS_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_PACS_H_
/**
* @brief Published Audio Capabilities Service (PACS)
*
* @defgroup bt_gatt_csip Coordinated Set Identification Profile (CSIP)
*
* @since 3.0
* @version 0.8.0
*
* @ingroup bluetooth
* @{
*
* The Published Audio Capabilities Service (PACS) is used to expose capabilities to remote devices.
*/
#include <stdbool.h>
#include <zephyr/bluetooth/audio/audio.h>
#include <zephyr/bluetooth/conn.h>
#include <zephyr/sys/slist.h>
#ifdef __cplusplus
extern "C" {
#endif
/** @brief Published Audio Capability structure. */
struct bt_pacs_cap {
/** Codec capability reference */
const struct bt_audio_codec_cap *codec_cap;
/** @internal Internally used list node */
sys_snode_t _node;
};
/**
* @typedef bt_pacs_cap_foreach_func_t
* @brief Published Audio Capability iterator callback.
*
* @param cap Capability found.
* @param user_data Data given.
*
* @return true to continue to the next capability
* @return false to stop the iteration
*/
typedef bool (*bt_pacs_cap_foreach_func_t)(const struct bt_pacs_cap *cap,
void *user_data);
/**
* @brief Published Audio Capability iterator.
*
* Iterate capabilities with endpoint direction specified.
*
* @param dir Direction of the endpoint to look capability for.
* @param func Callback function.
* @param user_data Data to pass to the callback.
*/
void bt_pacs_cap_foreach(enum bt_audio_dir dir,
bt_pacs_cap_foreach_func_t func,
void *user_data);
/**
* @brief Register Published Audio Capability.
*
* Register Audio Local Capability.
*
* @param dir Direction of the endpoint to register capability for.
* @param cap Capability structure.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_pacs_cap_register(enum bt_audio_dir dir, struct bt_pacs_cap *cap);
/**
* @brief Unregister Published Audio Capability.
*
* Unregister Audio Local Capability.
*
* @param dir Direction of the endpoint to unregister capability for.
* @param cap Capability structure.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_pacs_cap_unregister(enum bt_audio_dir dir, struct bt_pacs_cap *cap);
/**
* @brief Set the location for an endpoint type
*
* @param dir Direction of the endpoints to change location for.
* @param location The location to be set.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_pacs_set_location(enum bt_audio_dir dir,
enum bt_audio_location location);
/**
* @brief Set the available contexts for an endpoint type
*
* @param dir Direction of the endpoints to change available contexts for.
* @param contexts The contexts to be set.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_pacs_set_available_contexts(enum bt_audio_dir dir,
enum bt_audio_context contexts);
/**
* @brief Get the available contexts for an endpoint type
*
* @param dir Direction of the endpoints to get contexts for.
*
* @return Bitmask of available contexts.
*/
enum bt_audio_context bt_pacs_get_available_contexts(enum bt_audio_dir dir);
/**
* @brief Set the available contexts for a given connection
*
* This function sets the available contexts value for a given @p conn connection object.
* If the @p contexts parameter is NULL the available contexts value is reset to default.
* The default value of the available contexts is set using @ref bt_pacs_set_available_contexts
* function.
* The Available Context Value is reset to default on ACL disconnection.
*
* @param conn Connection object.
* @param dir Direction of the endpoints to change available contexts for.
* @param contexts The contexts to be set or NULL to reset to default.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_pacs_conn_set_available_contexts_for_conn(struct bt_conn *conn, enum bt_audio_dir dir,
enum bt_audio_context *contexts);
/**
* @brief Get the available contexts for a given connection
*
* This server function returns the available contexts value for a given @p conn connection object.
* The value returned is the one set with @ref bt_pacs_conn_set_available_contexts_for_conn function
* or the default value set with @ref bt_pacs_set_available_contexts function.
*
* @param conn Connection object.
* @param dir Direction of the endpoints to get contexts for.
*
* @return Bitmask of available contexts.
* @retval BT_AUDIO_CONTEXT_TYPE_PROHIBITED if @p conn or @p dir are invalid
*/
enum bt_audio_context bt_pacs_get_available_contexts_for_conn(struct bt_conn *conn,
enum bt_audio_dir dir);
/**
* @brief Set the supported contexts for an endpoint type
*
* @param dir Direction of the endpoints to change available contexts for.
* @param contexts The contexts to be set.
*
* @return 0 in case of success or negative value in case of error.
*/
int bt_pacs_set_supported_contexts(enum bt_audio_dir dir,
enum bt_audio_context contexts);
#ifdef __cplusplus
}
#endif
/** @} */
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_PACS_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/audio/pacs.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 1,203 |
```objective-c
/**
* @file
* @brief Public Broadcast Profile (PBP) APIs.
*/
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_PBP_
#define ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_PBP_
/**
* @brief Public Broadcast Profile (PBP)
*
* @defgroup bt_pbp Public Broadcast Profile (PBP)
*
* @since 3.5
* @version 0.8.0
*
* @ingroup bluetooth
* @{
*
* The Public Broadcast Profile (PBP) is used for public broadcasts by providing additional
* information in the advertising data.
*/
#include <zephyr/bluetooth/audio/audio.h>
#include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/uuid.h>
#include <zephyr/net/buf.h>
#include <zephyr/sys/util.h>
#include <zephyr/sys/util_macro.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Minimum size of the Public Broadcast Announcement
*
* It contains the Public Broadcast Announcement UUID (2), the Public Broadcast Announcement
* features (1) and the metadata length (1)
*/
#define BT_PBP_MIN_PBA_SIZE (BT_UUID_SIZE_16 + 1 + 1)
/** Public Broadcast Announcement features */
enum bt_pbp_announcement_feature {
/** Broadcast Streams encryption status */
BT_PBP_ANNOUNCEMENT_FEATURE_ENCRYPTION = BIT(0),
/** Standard Quality Public Broadcast Audio configuration */
BT_PBP_ANNOUNCEMENT_FEATURE_STANDARD_QUALITY = BIT(1),
/** High Quality Public Broadcast Audio configuration */
BT_PBP_ANNOUNCEMENT_FEATURE_HIGH_QUALITY = BIT(2),
};
/**
* @brief Creates a Public Broadcast Announcement based on the information received
* in the features parameter.
*
* @param meta Metadata to be included in the advertising data
* @param meta_len Size of the metadata fields to be included in the advertising data
* @param features Public Broadcast Announcement features
* @param pba_data_buf Pointer to store the PBA advertising data. Buffer size needs to be
* meta_len + @ref BT_PBP_MIN_PBA_SIZE.
*
* @return 0 on success or an appropriate error code.
*/
int bt_pbp_get_announcement(const uint8_t meta[], size_t meta_len,
enum bt_pbp_announcement_feature features,
struct net_buf_simple *pba_data_buf);
/**
* @brief Parses the received advertising data corresponding to a Public Broadcast
* Announcement. Returns the advertised Public Broadcast Announcement features and metadata.
*
* @param[in] data Advertising data to be checked
* @param[out] features Pointer to public broadcast source features to store the parsed features in
* @param[out] meta Pointer to the metadata present in the advertising data
*
* @return parsed metadata length on success.
* @retval -EINVAL if @p data, @p features or @p meta are NULL.
* @retval -ENOENT if @p data is not of type @ref BT_DATA_SVC_DATA16 or if the UUID in the service
* data is not @ref BT_UUID_PBA.
* @retval -EMSGSIZE if @p data is not large enough to contain a PBP announcement.
* @retval -EBADMSG if the @p data contains invalid data.
*/
int bt_pbp_parse_announcement(struct bt_data *data, enum bt_pbp_announcement_feature *features,
uint8_t **meta);
#ifdef __cplusplus
}
#endif
/**
* @}
*/
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_PBP_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/audio/pbp.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 761 |
```objective-c
/**
* @file
* @brief Header for Bluetooth BAP LC3 presets.
*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_BAP_LC3_PRESET_
#define ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_BAP_LC3_PRESET_
/**
* @brief Basic Audio Profile (BAP) LC3 Presets
*
* @defgroup bt_bap_lc3_preset Basic Audio Profile (BAP) LC3 Presets
*
* @since 3.0
* @version 0.8.0
*
* @ingroup bluetooth
* @{
*
* These APIs provide preset for codec configuration and codec QoS based on values supplied by the
* codec configuration tables in the BAP specification.
*
*/
#include <zephyr/bluetooth/audio/audio.h>
#include <zephyr/bluetooth/audio/lc3.h>
#ifdef __cplusplus
extern "C" {
#endif
/** Struct to hold a BAP defined LC3 preset */
struct bt_bap_lc3_preset {
/** The LC3 Codec */
struct bt_audio_codec_cfg codec_cfg;
/** The BAP spec defined QoS values */
struct bt_audio_codec_qos qos;
};
/** Helper to declare an LC3 preset structure */
#define BT_BAP_LC3_PRESET(_codec, _qos) \
{ \
.codec_cfg = _codec, .qos = _qos, \
}
/* LC3 Unicast presets defined by table 5.2 in the BAP v1.0 specification */
/**
* @brief Helper to declare LC3 Unicast 8_1_1 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_UNICAST_PRESET_8_1_1(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_8KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_7_5, _loc, 26u, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(7500u, 26u, 2u, 8u, 40000u))
/**
* @brief Helper to declare LC3 Unicast 8_2_1 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_UNICAST_PRESET_8_2_1(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_8KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_10, _loc, 30U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(10000u, 30u, 2u, 10u, 40000u))
/**
* @brief Helper to declare LC3 Unicast 16_1_1 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_UNICAST_PRESET_16_1_1(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_16KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_7_5, _loc, 30U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(7500u, 30u, 2u, 8u, 40000u))
/**
* @brief Helper to declare LC3 Unicast 16_2_1 codec configuration
*
* Mandatory to support as both unicast client and server
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_UNICAST_PRESET_16_2_1(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_16KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_10, _loc, 40U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(10000u, 40u, 2u, 10u, 40000u))
/**
* @brief Helper to declare LC3 Unicast 24_1_1 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_UNICAST_PRESET_24_1_1(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_24KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_7_5, _loc, 45U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(7500u, 45u, 2u, 8u, 40000u))
/**
* @brief Helper to declare LC3 Unicast 24_2_1 codec configuration
*
* Mandatory to support as unicast server
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_UNICAST_PRESET_24_2_1(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_24KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_10, _loc, 60U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(10000u, 60u, 2u, 10u, 40000u))
/**
* @brief Helper to declare LC3 Unicast 32_1_1 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_UNICAST_PRESET_32_1_1(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_32KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_7_5, _loc, 60U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(7500u, 60u, 2u, 8u, 40000u))
/**
* @brief Helper to declare LC3 Unicast 32_2_1 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_UNICAST_PRESET_32_2_1(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_32KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_10, _loc, 80U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(10000u, 80u, 2u, 10u, 40000u))
/**
* @brief Helper to declare LC3 Unicast 441_1_1 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_UNICAST_PRESET_441_1_1(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_44KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_7_5, _loc, 97U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_FRAMED(8163u, 97u, 5u, 24u, 40000u))
/**
* @brief Helper to declare LC3 Unicast 441_2_1 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_UNICAST_PRESET_441_2_1(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_44KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_10, _loc, 130U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_FRAMED(10884u, 130u, 5u, 31u, 40000u))
/**
* @brief Helper to declare LC3 Unicast 48_1_1 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_UNICAST_PRESET_48_1_1(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_48KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_7_5, _loc, 75U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(7500u, 75u, 5u, 15u, 40000u))
/**
* @brief Helper to declare LC3 Unicast 48_2_1 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_UNICAST_PRESET_48_2_1(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_48KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_10, _loc, 100U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(10000u, 100u, 5u, 20u, 40000u))
/**
* @brief Helper to declare LC3 Unicast 48_3_1 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_UNICAST_PRESET_48_3_1(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_48KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_7_5, _loc, 90U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(7500u, 90u, 5u, 15u, 40000u))
/**
* @brief Helper to declare LC3 Unicast 48_4_1 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_UNICAST_PRESET_48_4_1(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_48KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_10, _loc, 120u, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(10000u, 120u, 5u, 20u, 40000u))
/**
* @brief Helper to declare LC3 Unicast 8_5_1 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_UNICAST_PRESET_48_5_1(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_48KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_7_5, _loc, 117u, \
1, _stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(7500u, 117u, 5u, 15u, 40000u))
/**
* @brief Helper to declare LC3 Unicast 48_6_1 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_UNICAST_PRESET_48_6_1(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_48KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_10, _loc, 155u, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(10000u, 155u, 5u, 20u, 40000u))
/**
* @brief Helper to declare LC3 Unicast 8_1_2 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
/* Following presets are for unicast high reliability audio data */
#define BT_BAP_LC3_UNICAST_PRESET_8_1_2(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_8KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_7_5, _loc, 26u, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(7500u, 26u, 13u, 75u, 40000u))
/**
* @brief Helper to declare LC3 Unicast 8_2_2 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_UNICAST_PRESET_8_2_2(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_8KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_10, _loc, 30U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(10000u, 30u, 13u, 95u, 40000u))
/**
* @brief Helper to declare LC3 Unicast 16_1_2 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_UNICAST_PRESET_16_1_2(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_16KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_7_5, _loc, 30U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(7500u, 30u, 13u, 75u, 40000u))
/**
* @brief Helper to declare LC3 Unicast 16_2_2 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_UNICAST_PRESET_16_2_2(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_16KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_10, _loc, 40U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(10000u, 40u, 13u, 95u, 40000u))
/**
* @brief Helper to declare LC3 Unicast 24_1_2 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_UNICAST_PRESET_24_1_2(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_24KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_7_5, _loc, 45U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(7500u, 45u, 13u, 75u, 40000u))
/**
* @brief Helper to declare LC3 Unicast 24_2_2 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_UNICAST_PRESET_24_2_2(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_24KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_10, _loc, 60U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(10000u, 60u, 13u, 95u, 40000u))
/**
* @brief Helper to declare LC3 Unicast 32_1_2 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_UNICAST_PRESET_32_1_2(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_32KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_7_5, _loc, 60U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(7500u, 60u, 13u, 75u, 40000u))
/**
* @brief Helper to declare LC3 Unicast 32_2_2 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_UNICAST_PRESET_32_2_2(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_32KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_10, _loc, 80U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(10000u, 80u, 13u, 95u, 40000u))
/**
* @brief Helper to declare LC3 Unicast 441_1_2 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_UNICAST_PRESET_441_1_2(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_44KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_7_5, _loc, 97U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_FRAMED(8163u, 97u, 13u, 80u, 40000u))
/**
* @brief Helper to declare LC3 Unicast 441_2_2 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_UNICAST_PRESET_441_2_2(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_44KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_10, _loc, 130U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_FRAMED(10884u, 130u, 13u, 85u, 40000u))
/**
* @brief Helper to declare LC3 Unicast 48_1_2 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_UNICAST_PRESET_48_1_2(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_48KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_7_5, _loc, 75U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(7500u, 75u, 13u, 75u, 40000u))
/**
* @brief Helper to declare LC3 Unicast 48_2_2 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_UNICAST_PRESET_48_2_2(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_48KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_10, _loc, 100U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(10000u, 100u, 13u, 95u, 40000u))
/**
* @brief Helper to declare LC3 Unicast 48_3_2 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_UNICAST_PRESET_48_3_2(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_48KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_7_5, _loc, 90U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(7500u, 90u, 13u, 75u, 40000u))
/**
* @brief Helper to declare LC3 Unicast 48_4_2 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_UNICAST_PRESET_48_4_2(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_48KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_10, _loc, 120u, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(10000u, 120u, 13u, 100u, 40000u))
/**
* @brief Helper to declare LC3 Unicast 48_5_2 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_UNICAST_PRESET_48_5_2(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_48KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_7_5, _loc, 117u, \
1, _stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(7500u, 117u, 13u, 75u, 40000u))
/**
* @brief Helper to declare LC3 Unicast 48_6_2 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_UNICAST_PRESET_48_6_2(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_48KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_10, _loc, 155u, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(10000u, 155u, 13u, 100u, 40000u))
/**
* @brief Helper to declare LC3 Broadcast 8_1_1 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
/* LC3 Broadcast presets defined by table 6.4 in the BAP v1.0 specification */
#define BT_BAP_LC3_BROADCAST_PRESET_8_1_1(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_8KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_7_5, _loc, 26u, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(7500u, 26u, 2u, 8u, 40000u))
/**
* @brief Helper to declare LC3 Broadcast 8_2_1 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_BROADCAST_PRESET_8_2_1(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_8KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_10, _loc, 30U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(10000u, 30u, 2u, 10u, 40000u))
/**
* @brief Helper to declare LC3 Broadcast 16_1_1 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_BROADCAST_PRESET_16_1_1(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_16KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_7_5, _loc, 30U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(7500u, 30u, 2u, 8u, 40000u))
/**
* @brief Helper to declare LC3 Broadcast 16_2_1 codec configuration
*
* Mandatory to support as both broadcast source and sink
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_BROADCAST_PRESET_16_2_1(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_16KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_10, _loc, 40U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(10000u, 40u, 2u, 10u, 40000u))
/**
* @brief Helper to declare LC3 Broadcast 24_1_1 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_BROADCAST_PRESET_24_1_1(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_24KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_7_5, _loc, 45U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(7500u, 45u, 2u, 8u, 40000u))
/**
* @brief Helper to declare LC3 Broadcast 24_2_1 codec configuration
*
* Mandatory to support as broadcast sink
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_BROADCAST_PRESET_24_2_1(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_24KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_10, _loc, 60U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(10000u, 60u, 2u, 10u, 40000u))
/**
* @brief Helper to declare LC3 Broadcast 32_1_1 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_BROADCAST_PRESET_32_1_1(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_32KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_7_5, _loc, 60U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(7500u, 60u, 2u, 8u, 40000u))
/**
* @brief Helper to declare LC3 Broadcast 32_2_1 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_BROADCAST_PRESET_32_2_1(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_32KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_10, _loc, 80U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(10000u, 80u, 2u, 10u, 40000u))
/**
* @brief Helper to declare LC3 Broadcast 441_1_1 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_BROADCAST_PRESET_441_1_1(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_44KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_7_5, _loc, 97U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_FRAMED(8163u, 97u, 4u, 24u, 40000u))
/**
* @brief Helper to declare LC3 Broadcast 441_2_1 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_BROADCAST_PRESET_441_2_1(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_44KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_10, _loc, 130U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_FRAMED(10884u, 130u, 4u, 31u, 40000u))
/**
* @brief Helper to declare LC3 Broadcast 48_1_1 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_BROADCAST_PRESET_48_1_1(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_48KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_7_5, _loc, 75U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(7500u, 75u, 4u, 15u, 40000u))
/**
* @brief Helper to declare LC3 Broadcast 48_2_1 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_BROADCAST_PRESET_48_2_1(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_48KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_10, _loc, 100U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(10000u, 100u, 4u, 20u, 40000u))
/**
* @brief Helper to declare LC3 Broadcast 48_3_1 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_BROADCAST_PRESET_48_3_1(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_48KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_7_5, _loc, 90U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(7500u, 90u, 4u, 15u, 40000u))
/**
* @brief Helper to declare LC3 Broadcast 48_4_1 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_BROADCAST_PRESET_48_4_1(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_48KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_10, _loc, 120u, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(10000u, 120u, 4u, 20u, 40000u))
/**
* @brief Helper to declare LC3 Broadcast 48_5_1 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_BROADCAST_PRESET_48_5_1(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_48KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_7_5, _loc, 117u, \
1, _stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(7500u, 117u, 4u, 15u, 40000u))
/**
* @brief Helper to declare LC3 Broadcast 48_6_1 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_BROADCAST_PRESET_48_6_1(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_48KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_10, _loc, 155u, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(10000u, 155u, 4u, 20u, 40000u))
/**
* @brief Helper to declare LC3 Broadcast 8_1_2 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
/* Following presets are for broadcast high reliability audio data */
#define BT_BAP_LC3_BROADCAST_PRESET_8_1_2(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_8KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_7_5, _loc, 26u, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(7500u, 26u, 4u, 45u, 40000u))
/**
* @brief Helper to declare LC3 Broadcast 8_2_2 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_BROADCAST_PRESET_8_2_2(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_8KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_10, _loc, 30U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(10000u, 30u, 4u, 60u, 40000u))
/**
* @brief Helper to declare LC3 Broadcast 16_1_2 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_BROADCAST_PRESET_16_1_2(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_16KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_7_5, _loc, 30U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(7500u, 30u, 4u, 45u, 40000u))
/**
* @brief Helper to declare LC3 Broadcast 16_2_2 codec configuration
*
* Mandatory to support as both broadcast source and sink
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_BROADCAST_PRESET_16_2_2(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_16KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_10, _loc, 40U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(10000u, 40u, 4u, 60u, 40000u))
/**
* @brief Helper to declare LC3 Broadcast 24_1_2 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_BROADCAST_PRESET_24_1_2(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_24KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_7_5, _loc, 45U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(7500u, 45u, 4u, 45u, 40000u))
/**
* @brief Helper to declare LC3 Broadcast 24_2_2 codec configuration
*
* Mandatory to support as broadcast sink
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_BROADCAST_PRESET_24_2_2(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_24KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_10, _loc, 60U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(10000u, 60u, 4u, 60u, 40000u))
/**
* @brief Helper to declare LC3 Broadcast 32_1_2 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_BROADCAST_PRESET_32_1_2(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_32KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_7_5, _loc, 60U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(7500u, 60u, 4u, 45u, 40000u))
/**
* @brief Helper to declare LC3 Broadcast 32_2_2 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_BROADCAST_PRESET_32_2_2(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_32KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_10, _loc, 80U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(10000u, 80u, 4u, 60u, 40000u))
/**
* @brief Helper to declare LC3 Broadcast 441_1_2 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_BROADCAST_PRESET_441_1_2(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_44KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_7_5, _loc, 97U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_FRAMED(8163u, 97u, 4u, 54u, 40000u))
/**
* @brief Helper to declare LC3 Broadcast 441_2_2 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_BROADCAST_PRESET_441_2_2(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_44KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_10, _loc, 130U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_FRAMED(10884u, 130u, 4u, 60u, 40000u))
/**
* @brief Helper to declare LC3 Broadcast 48_1_2 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_BROADCAST_PRESET_48_1_2(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_48KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_7_5, _loc, 75U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(7500u, 75u, 4u, 50u, 40000u))
/**
* @brief Helper to declare LC3 Broadcast 48_2_2 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_BROADCAST_PRESET_48_2_2(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_48KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_10, _loc, 100U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(10000u, 100u, 4u, 65u, 40000u))
/**
* @brief Helper to declare LC3 Broadcast 48_3_2 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_BROADCAST_PRESET_48_3_2(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_48KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_7_5, _loc, 90U, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(7500u, 90u, 4u, 50u, 40000u))
/**
* @brief Helper to declare LC3 Broadcast 48_4_2 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_BROADCAST_PRESET_48_4_2(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_48KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_10, _loc, 120u, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(10000u, 120u, 4u, 65u, 40000u))
/**
* @brief Helper to declare LC3 Broadcast 48_5_2 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_BROADCAST_PRESET_48_5_2(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_48KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_7_5, _loc, 117u, \
1, _stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(7500u, 117u, 4u, 50u, 40000u))
/**
* @brief Helper to declare LC3 Broadcast 48_6_2 codec configuration
*
* @param _loc Audio channel location bitfield (@ref bt_audio_location)
* @param _stream_context Stream context (``BT_AUDIO_CONTEXT_*``)
*/
#define BT_BAP_LC3_BROADCAST_PRESET_48_6_2(_loc, _stream_context) \
BT_BAP_LC3_PRESET(BT_AUDIO_CODEC_LC3_CONFIG(BT_AUDIO_CODEC_CFG_FREQ_48KHZ, \
BT_AUDIO_CODEC_CFG_DURATION_10, _loc, 155u, 1, \
_stream_context), \
BT_AUDIO_CODEC_QOS_UNFRAMED(10000u, 155u, 4u, 65u, 40000u))
#ifdef __cplusplus
}
#endif
/** @} */
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_BAP_LC3_PRESET_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/audio/bap_lc3_preset.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 11,388 |
```objective-c
/**
* @file
* @brief Bluetooth Common Audio Profile (CAP) APIs.
*/
/*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_CAP_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_CAP_H_
/**
* @brief Common Audio Profile (CAP)
*
* @defgroup bt_cap Common Audio Profile (CAP)
*
* @since 3.2
* @version 0.8.0
*
* @ingroup bluetooth
* @{
*
* Common Audio Profile (CAP) provides procedures to start, update, and stop unicast and broadcast
* Audio Streams on individual or groups of devices using procedures in the Basic Audio Profile
* (BAP). This profile also provides procedures to control volume and device input on groups of
* devices using procedures in the Volume Control Profile (VCP) and the Microphone Control Profile
* (MICP). This profile specification also refers to the Common Audio Service (CAS).
*/
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <zephyr/bluetooth/audio/audio.h>
#include <zephyr/bluetooth/audio/bap.h>
#include <zephyr/bluetooth/audio/csip.h>
#include <zephyr/bluetooth/addr.h>
#include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/conn.h>
#include <zephyr/bluetooth/iso.h>
#include <zephyr/net/buf.h>
#ifdef __cplusplus
extern "C" {
#endif
/** @brief Abstract Audio Broadcast Source structure. */
struct bt_cap_broadcast_source;
/**
* @brief Register the Common Audio Service.
*
* This will register and enable the service and make it discoverable by
* clients. This will also register a Coordinated Set Identification
* Service instance.
*
* This shall only be done as a server, and requires
* @kconfig{BT_CAP_ACCEPTOR_SET_MEMBER}. If @kconfig{BT_CAP_ACCEPTOR_SET_MEMBER}
* is not enabled, the Common Audio Service will by statically registered.
*
* @param[in] param Coordinated Set Identification Service register
* parameters.
* @param[out] svc_inst Pointer to the registered Coordinated Set
* Identification Service.
*
* @return 0 if success, errno on failure.
*/
int bt_cap_acceptor_register(const struct bt_csip_set_member_register_param *param,
struct bt_csip_set_member_svc_inst **svc_inst);
/** Callback structure for CAP procedures */
struct bt_cap_initiator_cb {
#if defined(CONFIG_BT_BAP_UNICAST_CLIENT) || defined(__DOXYGEN__)
/**
* @brief Callback for bt_cap_initiator_unicast_discover().
*
* @param conn The connection pointer supplied to
* bt_cap_initiator_unicast_discover().
* @param err 0 if Common Audio Service was found else -ENODATA.
* @param member Pointer to the set member. NULL if err != 0.
* @param csis_inst The Coordinated Set Identification Service if
* Common Audio Service was found and includes a
* Coordinated Set Identification Service.
* NULL on error or if remote device does not include
* Coordinated Set Identification Service. NULL if err != 0.
*/
void (*unicast_discovery_complete)(
struct bt_conn *conn, int err,
const struct bt_csip_set_coordinator_set_member *member,
const struct bt_csip_set_coordinator_csis_inst *csis_inst);
/**
* @brief Callback for bt_cap_initiator_unicast_audio_start().
*
* @param err 0 if success, BT_GATT_ERR() with a
* specific ATT (BT_ATT_ERR_*) error code or -ECANCELED if cancelled
* by bt_cap_initiator_unicast_audio_cancel().
* @param conn Pointer to the connection where the error
* occurred. NULL if @p err is 0 or if cancelled by
* bt_cap_initiator_unicast_audio_cancel()
*/
void (*unicast_start_complete)(int err, struct bt_conn *conn);
/**
* @brief Callback for bt_cap_initiator_unicast_audio_update().
*
* @param err 0 if success, BT_GATT_ERR() with a
* specific ATT (BT_ATT_ERR_*) error code or -ECANCELED if cancelled
* by bt_cap_initiator_unicast_audio_cancel().
* @param conn Pointer to the connection where the error
* occurred. NULL if @p err is 0 or if cancelled by
* bt_cap_initiator_unicast_audio_cancel()
*/
void (*unicast_update_complete)(int err, struct bt_conn *conn);
/**
* @brief Callback for bt_cap_initiator_unicast_audio_stop().
*
* @param err 0 if success, BT_GATT_ERR() with a
* specific ATT (BT_ATT_ERR_*) error code or -ECANCELED if cancelled
* by bt_cap_initiator_unicast_audio_cancel().
* @param conn Pointer to the connection where the error
* occurred. NULL if @p err is 0 or if cancelled by
* bt_cap_initiator_unicast_audio_cancel()
*/
void (*unicast_stop_complete)(int err, struct bt_conn *conn);
#endif /* CONFIG_BT_BAP_UNICAST_CLIENT */
};
/**
* @brief Discovers audio support on a remote device.
*
* This will discover the Common Audio Service (CAS) on the remote device, to
* verify if the remote device supports the Common Audio Profile.
*
* @param conn Connection to a remote server.
*
* @retval 0 Success
* @retval -EINVAL @p conn is NULL
* @retval -ENOTCONN @p conn is not connected
* @retval -ENOMEM Could not allocated memory for the request
*/
int bt_cap_initiator_unicast_discover(struct bt_conn *conn);
/** Type of CAP set */
enum bt_cap_set_type {
/** The set is an ad-hoc set */
BT_CAP_SET_TYPE_AD_HOC,
/** The set is a CSIP Coordinated Set */
BT_CAP_SET_TYPE_CSIP,
};
/** Represents a Common Audio Set member that are either in a Coordinated or ad-hoc set */
union bt_cap_set_member {
/** Connection pointer if the type is BT_CAP_SET_TYPE_AD_HOC. */
struct bt_conn *member;
/** CSIP Coordinated Set struct used if type is BT_CAP_SET_TYPE_CSIP. */
struct bt_csip_set_coordinator_csis_inst *csip;
};
/**
* @brief Common Audio Profile stream structure.
*
* Streams represents a Basic Audio Profile (BAP) stream and operation callbacks.
* See @ref bt_bap_stream for additional information.
*/
struct bt_cap_stream {
/** The underlying BAP audio stream */
struct bt_bap_stream bap_stream;
/** Audio stream operations */
struct bt_bap_stream_ops *ops;
};
/**
* @brief Register Audio operations for a Common Audio Profile stream.
*
* Register Audio operations for a stream.
*
* @param stream Stream object.
* @param ops Stream operations structure.
*/
void bt_cap_stream_ops_register(struct bt_cap_stream *stream, struct bt_bap_stream_ops *ops);
/**
* @brief Send data to Common Audio Profile stream without timestamp
*
* See bt_bap_stream_send() for more information
*
* @note Support for sending must be supported, determined by @kconfig{CONFIG_BT_AUDIO_TX}.
*
* @param stream Stream object.
* @param buf Buffer containing data to be sent.
* @param seq_num Packet Sequence number. This value shall be incremented for each call to this
* function and at least once per SDU interval for a specific channel.
*
* @retval -EINVAL if stream object is NULL
* @retval Any return value from bt_bap_stream_send()
*/
int bt_cap_stream_send(struct bt_cap_stream *stream, struct net_buf *buf, uint16_t seq_num);
/**
* @brief Send data to Common Audio Profile stream with timestamp
*
* See bt_bap_stream_send() for more information
*
* @note Support for sending must be supported, determined by @kconfig{CONFIG_BT_AUDIO_TX}.
*
* @param stream Stream object.
* @param buf Buffer containing data to be sent.
* @param seq_num Packet Sequence number. This value shall be incremented for each call to this
* function and at least once per SDU interval for a specific channel.
* @param ts Timestamp of the SDU in microseconds (us). This value can be used to transmit
* multiple SDUs in the same SDU interval in a CIG or BIG.
*
* @retval -EINVAL if stream object is NULL
* @retval Any return value from bt_bap_stream_send()
*/
int bt_cap_stream_send_ts(struct bt_cap_stream *stream, struct net_buf *buf, uint16_t seq_num,
uint32_t ts);
/**
* @brief Get ISO transmission timing info for a Common Audio Profile stream
*
* See bt_bap_stream_get_tx_sync() for more information
*
* @note Support for sending must be supported, determined by @kconfig{CONFIG_BT_AUDIO_TX}.
*
* @param[in] stream Stream object.
* @param[out] info Transmit info object.
*
* @retval -EINVAL if stream object is NULL
* @retval Any return value from bt_bap_stream_get_tx_sync()
*/
int bt_cap_stream_get_tx_sync(struct bt_cap_stream *stream, struct bt_iso_tx_info *info);
/** Stream specific parameters for the bt_cap_initiator_unicast_audio_start() function */
struct bt_cap_unicast_audio_start_stream_param {
/** Coordinated or ad-hoc set member. */
union bt_cap_set_member member;
/** @brief Stream for the @p member */
struct bt_cap_stream *stream;
/** Endpoint reference for the @p stream */
struct bt_bap_ep *ep;
/**
* @brief Codec configuration.
*
* The @p codec_cfg.meta shall include a list of CCIDs
* (@ref BT_AUDIO_METADATA_TYPE_CCID_LIST) as well as a non-0
* stream context (@ref BT_AUDIO_METADATA_TYPE_STREAM_CONTEXT) bitfield.
*
* This value is assigned to the @p stream, and shall remain valid while the stream is
* non-idle.
*/
struct bt_audio_codec_cfg *codec_cfg;
};
/** Parameters for the bt_cap_initiator_unicast_audio_start() function */
struct bt_cap_unicast_audio_start_param {
/** The type of the set. */
enum bt_cap_set_type type;
/** The number of parameters in @p stream_params */
size_t count;
/** Array of stream parameters */
struct bt_cap_unicast_audio_start_stream_param *stream_params;
};
/** Stream specific parameters for the bt_cap_initiator_unicast_audio_update() function */
struct bt_cap_unicast_audio_update_stream_param {
/** Stream to update */
struct bt_cap_stream *stream;
/** The length of @p meta. */
size_t meta_len;
/**
* @brief The new metadata.
*
* The metadata shall contain a list of CCIDs as well as a non-0 context bitfield.
*/
uint8_t *meta;
};
/** Parameters for the bt_cap_initiator_unicast_audio_update() function */
struct bt_cap_unicast_audio_update_param {
/** The type of the set. */
enum bt_cap_set_type type;
/** The number of parameters in @p stream_params */
size_t count;
/** Array of stream parameters */
struct bt_cap_unicast_audio_update_stream_param *stream_params;
};
/** Parameters for the bt_cap_initiator_unicast_audio_stop() function */
struct bt_cap_unicast_audio_stop_param {
/** The type of the set. */
enum bt_cap_set_type type;
/** The number of streams in @p streams */
size_t count;
/** Array of streams to stop */
struct bt_cap_stream **streams;
};
/**
* @brief Register Common Audio Profile Initiator callbacks
*
* @param cb The callback structure. Shall remain static.
*
* @return 0 on success or negative error value on failure.
*/
int bt_cap_initiator_register_cb(const struct bt_cap_initiator_cb *cb);
/**
* @brief Unregister Common Audio Profile Initiator callbacks
*
* @param cb The callback structure that was previously registered.
*
* @retval 0 Success
* @retval -EINVAL @p cb is NULL or @p cb was not registered
*/
int bt_cap_initiator_unregister_cb(const struct bt_cap_initiator_cb *cb);
/**
* @brief Setup and start unicast audio streams for a set of devices.
*
* The result of this operation is that the streams in @p param will be
* initialized and will be usable for streaming audio data.
* The @p unicast_group value can be used to update and stop the streams.
*
* @note @kconfig{CONFIG_BT_CAP_INITIATOR} and
* @kconfig{CONFIG_BT_BAP_UNICAST_CLIENT} must be enabled for this function
* to be enabled.
*
* @param param Parameters to start the audio streams.
*
* @return 0 on success or negative error value on failure.
*/
int bt_cap_initiator_unicast_audio_start(const struct bt_cap_unicast_audio_start_param *param);
/**
* @brief Update unicast audio streams.
*
* This will update the metadata of one or more streams.
*
* @note @kconfig{CONFIG_BT_CAP_INITIATOR} and
* @kconfig{CONFIG_BT_BAP_UNICAST_CLIENT} must be enabled for this function
* to be enabled.
*
* @param param Update parameters.
*
* @return 0 on success or negative error value on failure.
*/
int bt_cap_initiator_unicast_audio_update(const struct bt_cap_unicast_audio_update_param *param);
/**
* @brief Stop unicast audio streams.
*
* This will stop one or more streams.
*
* @note @kconfig{CONFIG_BT_CAP_INITIATOR} and
* @kconfig{CONFIG_BT_BAP_UNICAST_CLIENT} must be enabled for this function
* to be enabled.
*
* @param param Stop parameters.
*
* @return 0 on success or negative error value on failure.
*/
int bt_cap_initiator_unicast_audio_stop(const struct bt_cap_unicast_audio_stop_param *param);
/**
* @brief Cancel any current Common Audio Profile procedure
*
* This will stop the current procedure from continuing and making it possible to run a new
* Common Audio Profile procedure.
*
* It is recommended to do this if any existing procedure takes longer time than expected, which
* could indicate a missing response from the Common Audio Profile Acceptor.
*
* This does not send any requests to any Common Audio Profile Acceptors involved with the current
* procedure, and thus notifications from the Common Audio Profile Acceptors may arrive after this
* has been called. It is thus recommended to either only use this if a procedure has stalled, or
* wait a short while before starting any new Common Audio Profile procedure after this has been
* called to avoid getting notifications from the cancelled procedure. The wait time depends on
* the connection interval, the number of devices in the previous procedure and the behavior of the
* Common Audio Profile Acceptors.
*
* The respective callbacks of the procedure will be called as part of this with the connection
* pointer set to 0 and the err value set to -ECANCELED.
*
* @retval 0 on success
* @retval -EALREADY if no procedure is active
*/
int bt_cap_initiator_unicast_audio_cancel(void);
/**
* Parameters part of @p bt_cap_initiator_broadcast_subgroup_param for
* bt_cap_initiator_broadcast_audio_create()
*/
struct bt_cap_initiator_broadcast_stream_param {
/** Audio stream */
struct bt_cap_stream *stream;
/** The length of the %p data array.
*
* The BIS specific data may be omitted and this set to 0.
*/
size_t data_len;
/** BIS Codec Specific Configuration */
uint8_t *data;
};
/**
* Parameters part of @p bt_cap_initiator_broadcast_create_param for
* bt_cap_initiator_broadcast_audio_create()
*/
struct bt_cap_initiator_broadcast_subgroup_param {
/** The number of parameters in @p stream_params */
size_t stream_count;
/** Array of stream parameters */
struct bt_cap_initiator_broadcast_stream_param *stream_params;
/** Subgroup Codec configuration. */
struct bt_audio_codec_cfg *codec_cfg;
};
/** Parameters for * bt_cap_initiator_broadcast_audio_create() */
struct bt_cap_initiator_broadcast_create_param {
/** The number of parameters in @p subgroup_params */
size_t subgroup_count;
/** Array of stream parameters */
struct bt_cap_initiator_broadcast_subgroup_param *subgroup_params;
/** Quality of Service configuration. */
struct bt_audio_codec_qos *qos;
/**
* @brief Broadcast Source packing mode.
*
* @ref BT_ISO_PACKING_SEQUENTIAL or @ref BT_ISO_PACKING_INTERLEAVED.
*
* @note This is a recommendation to the controller, which the controller may ignore.
*/
uint8_t packing;
/** Whether or not to encrypt the streams. */
bool encryption;
/**
* @brief 16-octet broadcast code.
*
* Only valid if @p encrypt is true.
*
* If the value is a string or a the value is less than 16 octets,
* the remaining octets shall be 0.
*
* Example:
* The string "Broadcast Code" shall be
* [42 72 6F 61 64 63 61 73 74 20 43 6F 64 65 00 00]
*/
uint8_t broadcast_code[BT_AUDIO_BROADCAST_CODE_SIZE];
#if defined(CONFIG_BT_ISO_TEST_PARAMS) || defined(__DOXYGEN__)
/**
* @brief Immediate Repetition Count
*
* The number of times the scheduled payloads are transmitted in a given event.
*
* Value range from @ref BT_ISO_IRC_MIN to @ref BT_ISO_IRC_MAX.
*/
uint8_t irc;
/**
* @brief Pre-transmission offset
*
* Offset used for pre-transmissions.
*
* Value range from @ref BT_ISO_PTO_MIN to @ref BT_ISO_PTO_MAX.
*/
uint8_t pto;
/**
* @brief ISO interval
*
* Time between consecutive BIS anchor points.
*
* Value range from @ref BT_ISO_ISO_INTERVAL_MIN to @ref BT_ISO_ISO_INTERVAL_MAX.
*/
uint16_t iso_interval;
#endif /* CONFIG_BT_ISO_TEST_PARAMS */
};
/**
* @brief Create a Common Audio Profile broadcast source.
*
* Create a new audio broadcast source with one or more audio streams.
*
* @note @kconfig{CONFIG_BT_CAP_INITIATOR} and
* @kconfig{CONFIG_BT_BAP_BROADCAST_SOURCE} must be enabled for this function
* to be enabled.
*
* @param[in] param Parameters to start the audio streams.
* @param[out] broadcast_source Pointer to the broadcast source created.
*
* @return 0 on success or negative error value on failure.
*/
int bt_cap_initiator_broadcast_audio_create(
const struct bt_cap_initiator_broadcast_create_param *param,
struct bt_cap_broadcast_source **broadcast_source);
/**
* @brief Start Common Audio Profile broadcast source.
*
* The broadcast source will be visible for scanners once this has been called,
* and the device will advertise audio announcements.
*
* This will allow the streams in the broadcast source to send audio by calling
* bt_bap_stream_send().
*
* @note @kconfig{CONFIG_BT_CAP_INITIATOR} and
* @kconfig{CONFIG_BT_BAP_BROADCAST_SOURCE} must be enabled for this function
* to be enabled.
*
* @param broadcast_source Pointer to the broadcast source.
* @param adv Pointer to an extended advertising set with
* periodic advertising configured.
*
* @return 0 on success or negative error value on failure.
*/
int bt_cap_initiator_broadcast_audio_start(struct bt_cap_broadcast_source *broadcast_source,
struct bt_le_ext_adv *adv);
/**
* @brief Update broadcast audio streams for a Common Audio Profile broadcast source.
*
* @note @kconfig{CONFIG_BT_CAP_INITIATOR} and
* @kconfig{CONFIG_BT_BAP_BROADCAST_SOURCE} must be enabled for this function
* to be enabled.
*
* @param broadcast_source The broadcast source to update.
* @param meta The new metadata. The metadata shall contain a list
* of CCIDs as well as a non-0 context bitfield.
* @param meta_len The length of @p meta.
*
* @return 0 on success or negative error value on failure.
*/
int bt_cap_initiator_broadcast_audio_update(struct bt_cap_broadcast_source *broadcast_source,
const uint8_t meta[], size_t meta_len);
/**
* @brief Stop broadcast audio streams for a Common Audio Profile broadcast source.
*
* @note @kconfig{CONFIG_BT_CAP_INITIATOR} and
* @kconfig{CONFIG_BT_BAP_BROADCAST_SOURCE} must be enabled for this function
* to be enabled.
*
* @param broadcast_source The broadcast source to stop. The audio streams
* in this will be stopped and reset.
*
* @return 0 on success or negative error value on failure.
*/
int bt_cap_initiator_broadcast_audio_stop(struct bt_cap_broadcast_source *broadcast_source);
/**
* @brief Delete Common Audio Profile broadcast source
*
* This can only be done after the broadcast source has been stopped by calling
* bt_cap_initiator_broadcast_audio_stop() and after the
* bt_bap_stream_ops.stopped() callback has been called for all streams in the
* broadcast source.
*
* @note @kconfig{CONFIG_BT_CAP_INITIATOR} and
* @kconfig{CONFIG_BT_BAP_BROADCAST_SOURCE} must be enabled for this function
* to be enabled.
*
* @param broadcast_source The broadcast source to delete.
* The @p broadcast_source will be invalidated.
*
* @return 0 on success or negative error value on failure.
*/
int bt_cap_initiator_broadcast_audio_delete(struct bt_cap_broadcast_source *broadcast_source);
/**
* @brief Get the broadcast ID of a Common Audio Profile broadcast source
*
* This will return the 3-octet broadcast ID that should be advertised in the
* extended advertising data with @ref BT_UUID_BROADCAST_AUDIO_VAL as
* @ref BT_DATA_SVC_DATA16.
*
* See table 3.14 in the Basic Audio Profile v1.0.1 for the structure.
*
* @param[in] broadcast_source Pointer to the broadcast source.
* @param[out] broadcast_id Pointer to the 3-octet broadcast ID.
*
* @return int 0 if on success, errno on error.
*/
int bt_cap_initiator_broadcast_get_id(const struct bt_cap_broadcast_source *broadcast_source,
uint32_t *const broadcast_id);
/**
* @brief Get the Broadcast Audio Stream Endpoint of a Common Audio Profile broadcast source
*
* This will encode the BASE of a broadcast source into a buffer, that can be
* used for advertisement. The encoded BASE will thus be encoded as
* little-endian. The BASE shall be put into the periodic advertising data
* (see bt_le_per_adv_set_data()).
*
* See table 3.15 in the Basic Audio Profile v1.0.1 for the structure.
*
* @param broadcast_source Pointer to the broadcast source.
* @param base_buf Pointer to a buffer where the BASE will be inserted.
*
* @return int 0 if on success, errno on error.
*/
int bt_cap_initiator_broadcast_get_base(struct bt_cap_broadcast_source *broadcast_source,
struct net_buf_simple *base_buf);
/** Parameters for bt_cap_initiator_unicast_to_broadcast() */
struct bt_cap_unicast_to_broadcast_param {
/** The source unicast group with the streams. */
struct bt_bap_unicast_group *unicast_group;
/**
* @brief Whether or not to encrypt the streams.
*
* If set to true, then the broadcast code in @p broadcast_code
* will be used to encrypt the streams.
*/
bool encrypt;
/**
* @brief 16-octet broadcast code.
*
* Only valid if @p encrypt is true.
*
* If the value is a string or a the value is less than 16 octets,
* the remaining octets shall be 0.
*
* Example:
* The string "Broadcast Code" shall be
* [42 72 6F 61 64 63 61 73 74 20 43 6F 64 65 00 00]
*/
uint8_t broadcast_code[BT_ISO_BROADCAST_CODE_SIZE];
};
/**
* @brief Hands over the data streams in a unicast group to a broadcast source.
*
* The streams in the unicast group will be stopped and the unicast group
* will be deleted. This can only be done for source streams.
*
* @note @kconfig{CONFIG_BT_CAP_INITIATOR},
* @kconfig{CONFIG_BT_BAP_UNICAST_CLIENT} and
* @kconfig{CONFIG_BT_BAP_BROADCAST_SOURCE} must be enabled for this function
* to be enabled.
*
* @param param The parameters for the handover.
* @param source The resulting broadcast source.
*
* @return 0 on success or negative error value on failure.
*/
int bt_cap_initiator_unicast_to_broadcast(const struct bt_cap_unicast_to_broadcast_param *param,
struct bt_cap_broadcast_source **source);
/** Parameters for bt_cap_initiator_broadcast_to_unicast() */
struct bt_cap_broadcast_to_unicast_param {
/**
* @brief The source broadcast source with the streams.
*
* The broadcast source will be stopped and deleted.
*/
struct bt_cap_broadcast_source *broadcast_source;
/** The type of the set. */
enum bt_cap_set_type type;
/**
* @brief The number of set members in @p members.
*
* This value shall match the number of streams in the
* @p broadcast_source.
*
*/
size_t count;
/** Coordinated or ad-hoc set members. */
union bt_cap_set_member **members;
};
/**
* @brief Hands over the data streams in a broadcast source to a unicast group.
*
* The streams in the broadcast source will be stopped and the broadcast source
* will be deleted.
*
* @note @kconfig{CONFIG_BT_CAP_INITIATOR},
* @kconfig{CONFIG_BT_BAP_UNICAST_CLIENT} and
* @kconfig{CONFIG_BT_BAP_BROADCAST_SOURCE} must be enabled for this function
* to be enabled.
*
* @param[in] param The parameters for the handover.
* @param[out] unicast_group The resulting broadcast source.
*
* @return 0 on success or negative error value on failure.
*/
int bt_cap_initiator_broadcast_to_unicast(const struct bt_cap_broadcast_to_unicast_param *param,
struct bt_bap_unicast_group **unicast_group);
/** Callback structure for CAP procedures */
struct bt_cap_commander_cb {
/**
* @brief Callback for bt_cap_initiator_unicast_discover().
*
* @param conn The connection pointer supplied to
* bt_cap_initiator_unicast_discover().
* @param err 0 if Common Audio Service was found else -ENODATA.
* @param member Pointer to the set member. NULL if err != 0.
* @param csis_inst The Coordinated Set Identification Service if
* Common Audio Service was found and includes a
* Coordinated Set Identification Service.
* NULL on error or if remote device does not include
* Coordinated Set Identification Service. NULL if err != 0.
*/
void (*discovery_complete)(struct bt_conn *conn, int err,
const struct bt_csip_set_coordinator_set_member *member,
const struct bt_csip_set_coordinator_csis_inst *csis_inst);
#if defined(CONFIG_BT_VCP_VOL_CTLR) || defined(__DOXYGEN__)
/**
* @brief Callback for bt_cap_commander_change_volume().
*
* @param conn Pointer to the connection where the error
* occurred. NULL if @p err is 0 or if cancelled by
* bt_cap_commander_cancel()
* @param err 0 on success, BT_GATT_ERR() with a
* specific ATT (BT_ATT_ERR_*) error code or -ECANCELED if cancelled
* by bt_cap_commander_cancel().
*/
void (*volume_changed)(struct bt_conn *conn, int err);
/**
* @brief Callback for bt_cap_commander_change_volume_mute_state().
*
* @param conn Pointer to the connection where the error
* occurred. NULL if @p err is 0 or if cancelled by
* bt_cap_commander_cancel()
* @param err 0 on success, BT_GATT_ERR() with a
* specific ATT (BT_ATT_ERR_*) error code or -ECANCELED if cancelled
* by bt_cap_commander_cancel().
*/
void (*volume_mute_changed)(struct bt_conn *conn, int err);
#if defined(CONFIG_BT_VCP_VOL_CTLR_VOCS) || defined(__DOXYGEN__)
/**
* @brief Callback for bt_cap_commander_change_volume_offset().
*
* @param conn Pointer to the connection where the error
* occurred. NULL if @p err is 0 or if cancelled by
* bt_cap_commander_cancel()
* @param err 0 on success, BT_GATT_ERR() with a
* specific ATT (BT_ATT_ERR_*) error code or -ECANCELED if cancelled
* by bt_cap_commander_cancel().
*/
void (*volume_offset_changed)(struct bt_conn *conn, int err);
#endif /* CONFIG_BT_VCP_VOL_CTLR_VOCS */
#endif /* CONFIG_BT_VCP_VOL_CTLR */
#if defined(CONFIG_BT_MICP_MIC_CTLR) || defined(__DOXYGEN__)
/**
* @brief Callback for bt_cap_commander_change_microphone_mute_state().
*
* @param conn Pointer to the connection where the error
* occurred. NULL if @p err is 0 or if cancelled by
* bt_cap_commander_cancel()
* @param err 0 on success, BT_GATT_ERR() with a
* specific ATT (BT_ATT_ERR_*) error code or -ECANCELED if cancelled
* by bt_cap_commander_cancel().
*/
void (*microphone_mute_changed)(struct bt_conn *conn, int err);
#if defined(CONFIG_BT_MICP_MIC_CTLR_AICS) || defined(__DOXYGEN__)
/**
* @brief Callback for bt_cap_commander_change_microphone_gain_setting().
*
* @param conn Pointer to the connection where the error
* occurred. NULL if @p err is 0 or if cancelled by
* bt_cap_commander_cancel()
* @param err 0 on success, BT_GATT_ERR() with a
* specific ATT (BT_ATT_ERR_*) error code or -ECANCELED if cancelled
* by bt_cap_commander_cancel().
*/
void (*microphone_gain_changed)(struct bt_conn *conn, int err);
#endif /* CONFIG_BT_MICP_MIC_CTLR_AICS */
#endif /* CONFIG_BT_MICP_MIC_CTLR */
#if defined(CONFIG_BT_BAP_BROADCAST_ASSISTANT) || defined(__DOXYGEN__)
/**
* @brief Callback for bt_cap_commander_broadcast_reception_start().
*
* @param conn Pointer to the connection where the error
* occurred. NULL if @p err is 0 or if cancelled by
* bt_cap_commander_cancel()
* @param err 0 on success, BT_GATT_ERR() with a
* specific ATT (BT_ATT_ERR_*) error code or -ECANCELED if cancelled
* by bt_cap_commander_cancel().
*/
void (*broadcast_reception_start)(struct bt_conn *conn, int err);
#endif /* CONFIG_BT_BAP_BROADCAST_ASSISTANT */
};
/**
* @brief Register Common Audio Profile Commander callbacks
*
* @param cb The callback structure. Shall remain static.
*
* @retval 0 Success
* @retval -EINVAL @p cb is NULL
* @retval -EALREADY Callbacks are already registered
*/
int bt_cap_commander_register_cb(const struct bt_cap_commander_cb *cb);
/**
* @brief Unregister Common Audio Profile Commander callbacks
*
* @param cb The callback structure that was previously registered.
*
* @retval 0 Success
* @retval -EINVAL @p cb is NULL or @p cb was not registered
*/
int bt_cap_commander_unregister_cb(const struct bt_cap_commander_cb *cb);
/**
* @brief Discovers audio support on a remote device.
*
* This will discover the Common Audio Service (CAS) on the remote device, to
* verify if the remote device supports the Common Audio Profile.
*
* @note @kconfig{CONFIG_BT_CAP_COMMANDER} must be enabled for this function. If
* @kconfig{CONFIG_BT_CAP_INITIATOR} is also enabled, it does not matter if
* bt_cap_commander_discover() or bt_cap_initiator_unicast_discover() is used.
*
* @param conn Connection to a remote server.
*
* @retval 0 Success
* @retval -EINVAL @p conn is NULL
* @retval -ENOTCONN @p conn is not connected
* @retval -ENOMEM Could not allocated memory for the request
* @retval -EBUSY Already doing discovery for @p conn
*/
int bt_cap_commander_discover(struct bt_conn *conn);
/**
* @brief Cancel any current Common Audio Profile commander procedure
*
* This will stop the current procedure from continuing and making it possible to run a new
* Common Audio Profile procedure.
*
* It is recommended to do this if any existing procedure takes longer time than expected, which
* could indicate a missing response from the Common Audio Profile Acceptor.
*
* This does not send any requests to any Common Audio Profile Acceptors involved with the
* current procedure, and thus notifications from the Common Audio Profile Acceptors may
* arrive after this has been called. It is thus recommended to either only use this if a
* procedure has stalled, or wait a short while before starting any new Common Audio Profile
* procedure after this has been called to avoid getting notifications from the cancelled
* procedure. The wait time depends on the connection interval, the number of devices in the
* previous procedure and the behavior of the Common Audio Profile Acceptors.
*
* The respective callbacks of the procedure will be called as part of this with the connection
* pointer set to NULL and the err value set to -ECANCELED.
*
* @retval 0 on success
* @retval -EALREADY if no procedure is active
*/
int bt_cap_commander_cancel(void);
/**
* Parameters part of @ref bt_cap_commander_broadcast_reception_start_param for
* bt_cap_commander_broadcast_reception_start()
*/
struct bt_cap_commander_broadcast_reception_start_member_param {
/** Coordinated or ad-hoc set member. */
union bt_cap_set_member member;
/** Address of the advertiser. */
bt_addr_le_t addr;
/** SID of the advertising set. */
uint8_t adv_sid;
/**
* @brief Periodic advertising interval in milliseconds.
*
* BT_BAP_PA_INTERVAL_UNKNOWN if unknown.
*/
uint16_t pa_interval;
/** 24-bit broadcast ID */
uint32_t broadcast_id;
/**
* @brief Pointer to array of subgroups
*
* At least one bit in one of the subgroups bis_sync parameters shall be set.
*/
struct bt_bap_bass_subgroup subgroups[CONFIG_BT_BAP_BASS_MAX_SUBGROUPS];
/** Number of subgroups */
size_t num_subgroups;
};
/** Parameters for starting broadcast reception */
struct bt_cap_commander_broadcast_reception_start_param {
/** The type of the set. */
enum bt_cap_set_type type;
/** The set of devices for this procedure */
struct bt_cap_commander_broadcast_reception_start_member_param *param;
/** The number of parameters in @p param */
size_t count;
};
/**
* @brief Starts the reception of broadcast audio on one or more remote Common Audio Profile
* Acceptors
*
* @param param The parameters to start the broadcast audio
*
* @return 0 on success or negative error value on failure.
*/
int bt_cap_commander_broadcast_reception_start(
const struct bt_cap_commander_broadcast_reception_start_param *param);
/** Parameters for stopping broadcast reception */
struct bt_cap_commander_broadcast_reception_stop_param {
/** The type of the set. */
enum bt_cap_set_type type;
/** Coordinated or ad-hoc set member. */
union bt_cap_set_member *members;
/** The number of members in @p members */
size_t count;
};
/**
* @brief Stops the reception of broadcast audio on one or more remote Common Audio Profile
* Acceptors
*
* @param param The parameters to stop the broadcast audio
*
* @return 0 on success or negative error value on failure.
*/
int bt_cap_commander_broadcast_reception_stop(
const struct bt_cap_commander_broadcast_reception_stop_param *param);
/** Parameters for changing absolute volume */
struct bt_cap_commander_change_volume_param {
/** The type of the set. */
enum bt_cap_set_type type;
/** Coordinated or ad-hoc set member. */
union bt_cap_set_member *members;
/** The number of members in @p members */
size_t count;
/** The absolute volume to set */
uint8_t volume;
};
/**
* @brief Change the volume on one or more Common Audio Profile Acceptors
*
* @param param The parameters for the volume change
*
* @return 0 on success or negative error value on failure.
*/
int bt_cap_commander_change_volume(const struct bt_cap_commander_change_volume_param *param);
/**
* Parameters part of @ref bt_cap_commander_change_volume_offset_param for
* bt_cap_commander_change_volume_offset()
*/
struct bt_cap_commander_change_volume_offset_member_param {
/** Coordinated or ad-hoc set member. */
union bt_cap_set_member member;
/**
* @brief The offset to set
*
* Value shall be between @ref BT_VOCS_MIN_OFFSET and @ref BT_VOCS_MAX_OFFSET
*/
int16_t offset;
};
/** Parameters for changing volume offset */
struct bt_cap_commander_change_volume_offset_param {
/** The type of the set. */
enum bt_cap_set_type type;
/** The set of devices for this procedure */
struct bt_cap_commander_change_volume_offset_member_param *param;
/** The number of parameters in @p param */
size_t count;
};
/**
* @brief Change the volume offset on one or more Common Audio Profile Acceptors
*
* @param param The parameters for the volume offset change
*
* @return 0 on success or negative error value on failure.
*/
int bt_cap_commander_change_volume_offset(
const struct bt_cap_commander_change_volume_offset_param *param);
/** Parameters for changing volume mute state */
struct bt_cap_commander_change_volume_mute_state_param {
/** The type of the set. */
enum bt_cap_set_type type;
/** Coordinated or ad-hoc set member. */
union bt_cap_set_member *members;
/** The number of members in @p members */
size_t count;
/**
* @brief The volume mute state to set
*
* true to mute, and false to unmute
*/
bool mute;
};
/**
* @brief Change the volume mute state on one or more Common Audio Profile Acceptors
*
* @param param The parameters for the volume mute state change
*
* @return 0 on success or negative error value on failure.
*/
int bt_cap_commander_change_volume_mute_state(
const struct bt_cap_commander_change_volume_mute_state_param *param);
/** Parameters for changing microphone mute state */
struct bt_cap_commander_change_microphone_mute_state_param {
/** The type of the set. */
enum bt_cap_set_type type;
/** Coordinated or ad-hoc set member. */
union bt_cap_set_member *members;
/** The number of members in @p members */
size_t count;
/**
* @brief The microphone mute state to set
*
* true to mute, and false to unmute
*/
bool mute;
};
/**
* @brief Change the microphone mute state on one or more Common Audio Profile Acceptors
*
* @param param The parameters for the microphone mute state change
*
* @return 0 on success or negative error value on failure.
*/
int bt_cap_commander_change_microphone_mute_state(
const struct bt_cap_commander_change_microphone_mute_state_param *param);
/**
* Parameters part of @ref bt_cap_commander_change_microphone_gain_setting_param for
* bt_cap_commander_change_microphone_gain_setting()
*/
struct bt_cap_commander_change_microphone_gain_setting_member_param {
/** Coordinated or ad-hoc set member. */
union bt_cap_set_member member;
/** @brief The microphone gain setting to set */
int8_t gain;
};
/** Parameters for changing microphone mute state */
struct bt_cap_commander_change_microphone_gain_setting_param {
/** The type of the set. */
enum bt_cap_set_type type;
/** The set of devices for this procedure */
struct bt_cap_commander_change_microphone_gain_setting_member_param *param;
/** The number of parameters in @p param */
size_t count;
};
/**
* @brief Change the microphone gain setting on one or more Common Audio Profile Acceptors
*
* @param param The parameters for the microphone gain setting change
*
* @return 0 on success or negative error value on failure.
*/
int bt_cap_commander_change_microphone_gain_setting(
const struct bt_cap_commander_change_microphone_gain_setting_param *param);
#ifdef __cplusplus
}
#endif
/**
* @}
*/
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_CAP_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/audio/cap.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 9,070 |
```objective-c
/*
*
*/
/**
* @file
* @brief Public API for retention API
*/
#ifndef ZEPHYR_INCLUDE_RETENTION_
#define ZEPHYR_INCLUDE_RETENTION_
#include <stdint.h>
#include <stddef.h>
#include <sys/types.h>
#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/types.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Retention API
* @defgroup retention_api Retention API
* @since 3.4
* @version 0.1.0
* @ingroup os_services
* @{
*/
typedef ssize_t (*retention_size_api)(const struct device *dev);
typedef int (*retention_is_valid_api)(const struct device *dev);
typedef int (*retention_read_api)(const struct device *dev, off_t offset, uint8_t *buffer,
size_t size);
typedef int (*retention_write_api)(const struct device *dev, off_t offset,
const uint8_t *buffer, size_t size);
typedef int (*retention_clear_api)(const struct device *dev);
struct retention_api {
retention_size_api size;
retention_is_valid_api is_valid;
retention_read_api read;
retention_write_api write;
retention_clear_api clear;
};
/**
* @brief Returns the size of the retention area.
*
* @param dev Retention device to use.
*
* @retval Positive value indicating size in bytes on success, else negative errno
* code.
*/
ssize_t retention_size(const struct device *dev);
/**
* @brief Checks if the underlying data in the retention area is valid or not.
*
* @param dev Retention device to use.
*
* @retval 1 If successful and data is valid.
* @retval 0 If data is not valid.
* @retval -ENOTSUP If there is no header/checksum configured for the retention area.
* @retval -errno Error code code.
*/
int retention_is_valid(const struct device *dev);
/**
* @brief Reads data from the retention area.
*
* @param dev Retention device to use.
* @param offset Offset to read data from.
* @param buffer Buffer to store read data in.
* @param size Size of data to read.
*
* @retval 0 If successful.
* @retval -errno Error code code.
*/
int retention_read(const struct device *dev, off_t offset, uint8_t *buffer, size_t size);
/**
* @brief Writes data to the retention area (underlying data does not need to be
* cleared prior to writing), once function returns with a success code, the
* data will be classed as valid if queried using retention_is_valid().
*
* @param dev Retention device to use.
* @param offset Offset to write data to.
* @param buffer Data to write.
* @param size Size of data to be written.
*
* @retval 0 on success else negative errno code.
*/
int retention_write(const struct device *dev, off_t offset, const uint8_t *buffer, size_t size);
/**
* @brief Clears all data in the retention area (sets it to 0)
*
* @param dev Retention device to use.
*
* @retval 0 on success else negative errno code.
*/
int retention_clear(const struct device *dev);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_INCLUDE_RETENTION_ */
``` | /content/code_sandbox/include/zephyr/retention/retention.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 753 |
```objective-c
/*
*
*/
/**
* @file
* @brief Public API for boot mode interface
*/
#ifndef ZEPHYR_INCLUDE_RETENTION_BOOTMODE_
#define ZEPHYR_INCLUDE_RETENTION_BOOTMODE_
#include <stdint.h>
#include <stddef.h>
#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/types.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Boot mode interface
* @defgroup boot_mode_interface Boot mode interface
* @ingroup retention_api
* @{
*/
enum BOOT_MODE_TYPES {
/** Default (normal) boot, to user application */
BOOT_MODE_TYPE_NORMAL = 0x00,
/** Bootloader boot mode (e.g. serial recovery for MCUboot) */
BOOT_MODE_TYPE_BOOTLOADER,
};
/**
* @brief Checks if the boot mode of the device is set to a specific value.
*
* @param boot_mode Expected boot mode to check.
*
* @retval 1 If successful and boot mode matches.
* @retval 0 If boot mode does not match.
* @retval -errno Error code code.
*/
int bootmode_check(uint8_t boot_mode);
/**
* @brief Sets boot mode of device.
*
* @param boot_mode Boot mode value to set.
*
* @retval 0 If successful.
* @retval -errno Error code code.
*/
int bootmode_set(uint8_t boot_mode);
/**
* @brief Clear boot mode value (sets to 0) - which corresponds to
* #BOOT_MODE_TYPE_NORMAL.
*
* @retval 0 If successful.
* @retval -errno Error code code.
*/
int bootmode_clear(void);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_INCLUDE_RETENTION_BOOTMODE_ */
``` | /content/code_sandbox/include/zephyr/retention/bootmode.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 385 |
```objective-c
/*
*
*/
/**
* @file
* @brief Public API for boot mode interface
*/
#ifndef ZEPHYR_INCLUDE_RETENTION_BLINFO_
#define ZEPHYR_INCLUDE_RETENTION_BLINFO_
#include <stdint.h>
#include <stddef.h>
#include <zephyr/kernel.h>
#if defined(CONFIG_RETENTION_BOOTLOADER_INFO_TYPE_MCUBOOT)
#include <bootutil/boot_status.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Bootloader info interface
* @defgroup bootloader_info_interface Bootloader info interface
* @since 3.5
* @version 0.1.0
* @ingroup retention_api
* @{
*/
#if defined(CONFIG_RETENTION_BOOTLOADER_INFO_OUTPUT_FUNCTION) || defined(__DOXYGEN__)
/**
* @brief Returns bootinfo information.
*
* @param key The information to return (for MCUboot: minor TLV).
* @param val Where the return information will be placed.
* @param val_len_max The maximum size of the provided buffer.
*
* @retval >= 0 If successful (contains length of read value)
* @retval -EOVERFLOW If the data is too large to fit the supplied buffer.
* @retval -EIO If the requested key was not found.
* @retval -errno Error code.
*/
int blinfo_lookup(uint16_t key, char *val, int val_len_max);
#endif
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_INCLUDE_RETENTION_BLINFO_ */
``` | /content/code_sandbox/include/zephyr/retention/blinfo.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 323 |
```objective-c
/**
* @file
* @brief Public APIs for Bluetooth Telephone Bearer Service.
*
*
*/
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_TBS_H_
#define ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_TBS_H_
/**
* @brief Telephone Bearer Service (TBS)
*
* @defgroup bt_tbs Telephone Bearer Service (TBS)
*
* @since 3.0
* @version 0.8.0
*
* @ingroup bluetooth
* @{
*
* The Telephone Bearer Service (TBS) provide procedures to discover telephone bearers and control
* calls.
*/
#include <stdint.h>
#include <stdbool.h>
#include <zephyr/bluetooth/conn.h>
#include <zephyr/sys/util_macro.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @name Call States
* @{
*/
/** A remote party is calling (incoming call). */
#define BT_TBS_CALL_STATE_INCOMING 0x00
/**
* The process to call the remote party has started on the server, but the remote party is not
* being alerted (outgoing call).
*/
#define BT_TBS_CALL_STATE_DIALING 0x01
/** A remote party is being alerted (outgoing call). */
#define BT_TBS_CALL_STATE_ALERTING 0x02
/** The call is in an active conversation. */
#define BT_TBS_CALL_STATE_ACTIVE 0x03
/**
* The call is connected but held locally. Locally Held implies that either the server or the
* client can affect the state.
*/
#define BT_TBS_CALL_STATE_LOCALLY_HELD 0x04
/**
*The call is connected but held remotely. Remotely Held means that the state is controlled by the
* remote party of a call.
*/
#define BT_TBS_CALL_STATE_REMOTELY_HELD 0x05
/** The call is connected but held both locally and remotely. */
#define BT_TBS_CALL_STATE_LOCALLY_AND_REMOTELY_HELD 0x06
/** @} */
/**
* @name Terminate Reason
* @{
*/
/** The URI value used to originate a call was formed improperly. */
#define BT_TBS_REASON_BAD_REMOTE_URI 0x00
/** The call failed. */
#define BT_TBS_REASON_CALL_FAILED 0x01
/** The remote party ended the call. */
#define BT_TBS_REASON_REMOTE_ENDED_CALL 0x02
/** The call ended from the server. */
#define BT_TBS_REASON_SERVER_ENDED_CALL 0x03
/** The line was busy. */
#define BT_TBS_REASON_LINE_BUSY 0x04
/** Network congestion. */
#define BT_TBS_REASON_NETWORK_CONGESTED 0x05
/** The client terminated the call. */
#define BT_TBS_REASON_CLIENT_TERMINATED 0x06
/** No service. */
#define BT_TBS_REASON_NO_SERVICE 0x07
/** No answer. */
#define BT_TBS_REASON_NO_ANSWER 0x08
/** Unspecified. */
#define BT_TBS_REASON_UNSPECIFIED 0x09
/** @} */
/**
* @name Control point error codes
* @{
*/
/** The opcode write was successful. */
#define BT_TBS_RESULT_CODE_SUCCESS 0x00
/** An invalid opcode was used for the Call Control Point write. */
#define BT_TBS_RESULT_CODE_OPCODE_NOT_SUPPORTED 0x01
/** The requested operation cannot be completed. */
#define BT_TBS_RESULT_CODE_OPERATION_NOT_POSSIBLE 0x02
/** The Call Index used for the Call Control Point write is invalid. */
#define BT_TBS_RESULT_CODE_INVALID_CALL_INDEX 0x03
/**
* The opcode written to the Call Control Point was received when the current Call State for the
* Call Index was not in the expected state.
*/
#define BT_TBS_RESULT_CODE_STATE_MISMATCH 0x04
/** Lack of internal resources to complete the requested action. */
#define BT_TBS_RESULT_CODE_OUT_OF_RESOURCES 0x05
/** The Outgoing URI is incorrect or invalid when an Originate opcode is sent. */
#define BT_TBS_RESULT_CODE_INVALID_URI 0x06
/** @} */
/**
* @name Optional feature bits
*
* Optional features that can be supported. See bt_tbs_client_read_optional_opcodes() on how to
* read these from a remote device
* @{
*/
/** Local Hold and Local Retrieve Call Control Point Opcodes supported */
#define BT_TBS_FEATURE_HOLD BIT(0)
/** Join Call Control Point Opcode supported */
#define BT_TBS_FEATURE_JOIN BIT(1)
/** @} */
/**
* @name Signal strength value limits
* @{
*/
/** No service */
#define BT_TBS_SIGNAL_STRENGTH_NO_SERVICE 0
/** Maximum signal strength */
#define BT_TBS_SIGNAL_STRENGTH_MAX 100
/** Signal strength is unknown */
#define BT_TBS_SIGNAL_STRENGTH_UNKNOWN 255
/** @} */
/**
* @name Bearer Technology
* @{
*/
/** 3G */
#define BT_TBS_TECHNOLOGY_3G 0x01
/** 4G */
#define BT_TBS_TECHNOLOGY_4G 0x02
/** Long-term evolution (LTE) */
#define BT_TBS_TECHNOLOGY_LTE 0x03
/** Wifi */
#define BT_TBS_TECHNOLOGY_WIFI 0x04
/** 5G */
#define BT_TBS_TECHNOLOGY_5G 0x05
/** Global System for Mobile Communications (GSM) */
#define BT_TBS_TECHNOLOGY_GSM 0x06
/** Code-Division Multiple Access (CDMA) */
#define BT_TBS_TECHNOLOGY_CDMA 0x07
/** 2G */
#define BT_TBS_TECHNOLOGY_2G 0x08
/** Wideband Code-Division Multiple Access (WCDMA) */
#define BT_TBS_TECHNOLOGY_WCDMA 0x09
/** @} */
/**
* @name Call status flags bitfield
* @{
*/
/** Inband ringtone enabled */
#define BT_TBS_STATUS_FLAG_INBAND_RINGTONE BIT(0)
/** Server is in silent mod */
#define BT_TBS_STATUS_FLAG_SILENT_MOD BIT(1)
/** @} */
/**
* @name Call flags bitfield
* @{
*/
/** If set, call is outgoing else incoming */
#define BT_TBS_CALL_FLAG_OUTGOING BIT(0)
/** If set call is withheld, else not withheld */
#define BT_TBS_CALL_FLAG_WITHHELD BIT(1)
/** If set call is withheld by network, else provided by network */
#define BT_TBS_CALL_FLAG_WITHHELD_BY_NETWORK BIT(2)
/** @} */
/**
* @brief The GTBS index denotes whenever a callback is from a
* Generic Telephone Bearer Service (GTBS) instance, or
* whenever the client should perform on action on the GTBS instance of the
* server, rather than any of the specific Telephone Bearer Service instances.
*/
#define BT_TBS_GTBS_INDEX 0xFF
/** @brief Opaque Telephone Bearer Service instance. */
struct bt_tbs_instance;
/**
* @brief Callback function for client originating a call.
*
* @param conn The connection used.
* @param call_index The call index.
* @param uri The URI. The value may change, so should be
* copied if persistence is wanted.
*
* @return true if the call request was accepted and remote party is alerted.
*/
typedef bool (*bt_tbs_originate_call_cb)(struct bt_conn *conn,
uint8_t call_index,
const char *uri);
/**
* @brief Callback function for client terminating a call.
*
* The call may be either terminated by the client or the server.
*
* @param conn The connection used.
* @param call_index The call index.
* @param reason The termination BT_TBS_REASON_* reason.
*/
typedef void (*bt_tbs_terminate_call_cb)(struct bt_conn *conn,
uint8_t call_index,
uint8_t reason);
/**
* @brief Callback function for client joining calls.
*
* @param conn The connection used.
* @param call_index_count The number of call indexes to join.
* @param call_indexes The call indexes.
*/
typedef void (*bt_tbs_join_calls_cb)(struct bt_conn *conn,
uint8_t call_index_count,
const uint8_t *call_indexes);
/**
* @brief Callback function for client request call state change
*
* @param conn The connection used.
* @param call_index The call index.
*/
typedef void (*bt_tbs_call_change_cb)(struct bt_conn *conn,
uint8_t call_index);
/**
* @brief Callback function for authorizing a client.
*
* Only used if BT_TBS_AUTHORIZATION is enabled.
*
* @param conn The connection used.
*
* @return true if authorized, false otherwise
*/
typedef bool (*bt_tbs_authorize_cb)(struct bt_conn *conn);
/**
* @brief Struct to hold the Telephone Bearer Service callbacks
*
* These can be registered for usage with bt_tbs_register_cb().
*/
struct bt_tbs_cb {
/** Client originating call */
bt_tbs_originate_call_cb originate_call;
/** Client terminating call */
bt_tbs_terminate_call_cb terminate_call;
/** Client holding call */
bt_tbs_call_change_cb hold_call;
/** Client accepting call */
bt_tbs_call_change_cb accept_call;
/** Client retrieving call */
bt_tbs_call_change_cb retrieve_call;
/** Client joining calls */
bt_tbs_join_calls_cb join_calls;
/** Callback to authorize a client */
bt_tbs_authorize_cb authorize;
};
/**
* @brief Accept an alerting call.
*
* @param call_index The index of the call that will be accepted.
*
* @return int BT_TBS_RESULT_CODE_* if positive or 0,
* errno value if negative.
*/
int bt_tbs_accept(uint8_t call_index);
/**
* @brief Hold a call.
*
* @param call_index The index of the call that will be held.
*
* @return int BT_TBS_RESULT_CODE_* if positive or 0,
* errno value if negative.
*/
int bt_tbs_hold(uint8_t call_index);
/**
* @brief Retrieve a call.
*
* @param call_index The index of the call that will be retrieved.
*
* @return int BT_TBS_RESULT_CODE_* if positive or 0,
* errno value if negative.
*/
int bt_tbs_retrieve(uint8_t call_index);
/**
* @brief Terminate a call.
*
* @param call_index The index of the call that will be terminated.
*
* @return int BT_TBS_RESULT_CODE_* if positive or 0,
* errno value if negative.
*/
int bt_tbs_terminate(uint8_t call_index);
/**
* @brief Originate a call
*
* @param[in] bearer_index The index of the Telephone Bearer.
* @param[in] uri The remote URI.
* @param[out] call_index Pointer to a value where the new call_index will be
* stored.
*
* @return int A call index on success (positive value),
* errno value on fail.
*/
int bt_tbs_originate(uint8_t bearer_index, char *uri, uint8_t *call_index);
/**
* @brief Join calls
*
* @param call_index_cnt The number of call indexes to join
* @param call_indexes Array of call indexes to join.
*
* @return int BT_TBS_RESULT_CODE_* if positive or 0,
* errno value if negative.
*/
int bt_tbs_join(uint8_t call_index_cnt, uint8_t *call_indexes);
/**
* @brief Notify the server that the remote party answered the call.
*
* @param call_index The index of the call that was answered.
*
* @return int BT_TBS_RESULT_CODE_* if positive or 0,
* errno value if negative.
*/
int bt_tbs_remote_answer(uint8_t call_index);
/**
* @brief Notify the server that the remote party held the call.
*
* @param call_index The index of the call that was held.
*
* @return int BT_TBS_RESULT_CODE_* if positive or 0,
* errno value if negative.
*/
int bt_tbs_remote_hold(uint8_t call_index);
/**
* @brief Notify the server that the remote party retrieved the call.
*
* @param call_index The index of the call that was retrieved.
*
* @return int BT_TBS_RESULT_CODE_* if positive or 0,
* errno value if negative.
*/
int bt_tbs_remote_retrieve(uint8_t call_index);
/**
* @brief Notify the server that the remote party terminated the call.
*
* @param call_index The index of the call that was terminated.
*
* @return int BT_TBS_RESULT_CODE_* if positive or 0,
* errno value if negative.
*/
int bt_tbs_remote_terminate(uint8_t call_index);
/**
* @brief Notify the server of an incoming call.
*
* @param bearer_index The index of the Telephone Bearer.
* @param to The URI that is receiving the call.
* @param from The URI of the remote caller.
* @param friendly_name The friendly name of the remote caller.
*
* @return int New call index if positive or 0,
* errno value if negative.
*/
int bt_tbs_remote_incoming(uint8_t bearer_index, const char *to,
const char *from, const char *friendly_name);
/**
* @brief Set a new bearer provider.
*
* @param bearer_index The index of the Telephone Bearer or BT_TBS_GTBS_INDEX
* for GTBS.
* @param name The new bearer provider name.
*
* @return int BT_TBS_RESULT_CODE_* if positive or 0,
* errno value if negative.
*/
int bt_tbs_set_bearer_provider_name(uint8_t bearer_index, const char *name);
/**
* @brief Set a new bearer technology.
*
* @param bearer_index The index of the Telephone Bearer or BT_TBS_GTBS_INDEX
* for GTBS.
* @param new_technology The new bearer technology.
*
* @return int BT_TBS_RESULT_CODE_* if positive or 0,
* errno value if negative.
*/
int bt_tbs_set_bearer_technology(uint8_t bearer_index, uint8_t new_technology);
/**
* @brief Update the signal strength reported by the server.
*
* @param bearer_index The index of the Telephone Bearer or
* BT_TBS_GTBS_INDEX for GTBS.
* @param new_signal_strength The new signal strength.
*
* @return int BT_TBS_RESULT_CODE_* if positive or 0,
* errno value if negative.
*/
int bt_tbs_set_signal_strength(uint8_t bearer_index,
uint8_t new_signal_strength);
/**
* @brief Sets the feature and status value.
*
* @param bearer_index The index of the Telephone Bearer or BT_TBS_GTBS_INDEX
* for GTBS.
* @param status_flags The new feature and status value.
*
* @return int BT_TBS_RESULT_CODE_* if positive or 0,
* errno value if negative.
*/
int bt_tbs_set_status_flags(uint8_t bearer_index, uint16_t status_flags);
/**
* @brief Sets the URI scheme list of a bearer.
*
* @param bearer_index The index of the Telephone Bearer.
* @param uri_list List of URI prefixes (e.g. {"skype", "tel"}).
* @param uri_count Number of URI prefixies in @p uri_list.
*
* @return BT_TBS_RESULT_CODE_* if positive or 0, errno value if negative.
*/
int bt_tbs_set_uri_scheme_list(uint8_t bearer_index, const char **uri_list,
uint8_t uri_count);
/**
* @brief Register the callbacks for TBS.
*
* @param cbs Pointer to the callback structure.
*/
void bt_tbs_register_cb(struct bt_tbs_cb *cbs);
/** @brief Prints all calls of all services to the debug log */
void bt_tbs_dbg_print_calls(void);
/** Struct to hold a call state */
struct bt_tbs_client_call_state {
/** Index of the call */
uint8_t index;
/** State of the call (see BT_TBS_CALL_STATE_*) */
uint8_t state;
/** Call flags (see BT_TBS_CALL_FLAG_*) */
uint8_t flags;
} __packed;
/** Struct to hold a call as the Telephone Bearer Service client */
struct bt_tbs_client_call {
/** Call information */
struct bt_tbs_client_call_state call_info;
/** The remove URI */
char *remote_uri;
};
/**
* @brief Callback function for ccp_discover.
*
* @param conn The connection that was used to discover CCP for a
* device.
* @param err Error value. BT_TBS_CLIENT_RESULT_CODE_*,
* GATT error or errno value.
* @param tbs_count Number of TBS instances on peer device.
* @param gtbs_found Whether or not the server has a Generic TBS instance.
*/
typedef void (*bt_tbs_client_discover_cb)(struct bt_conn *conn, int err,
uint8_t tbs_count, bool gtbs_found);
/**
* @brief Callback function for writing values to peer device.
*
* @param conn The connection used in the function.
* @param err Error value. BT_TBS_CLIENT_RESULT_CODE_*,
* GATT error or errno value.
* @param inst_index The index of the TBS instance that was updated.
*/
typedef void (*bt_tbs_client_write_value_cb)(struct bt_conn *conn, int err,
uint8_t inst_index);
/**
* @brief Callback function for the CCP call control functions.
*
* @param conn The connection used in the function.
* @param err Error value. BT_TBS_CLIENT_RESULT_CODE_*,
* GATT error or errno value.
* @param inst_index The index of the TBS instance that was updated.
* @param call_index The call index. For #bt_tbs_client_originate_call this will
* always be 0, and does not reflect the actual call index.
*/
typedef void (*bt_tbs_client_cp_cb)(struct bt_conn *conn, int err,
uint8_t inst_index, uint8_t call_index);
/**
* @brief Callback function for functions that read a string value.
*
* @param conn The connection used in the function.
* @param err Error value. BT_TBS_CLIENT_RESULT_CODE_*,
* GATT error or errno value.
* @param inst_index The index of the TBS instance that was updated.
* @param value The Null-terminated string value. The value is not kept
* by the client, so must be copied to be saved.
*/
typedef void (*bt_tbs_client_read_string_cb)(struct bt_conn *conn, int err,
uint8_t inst_index,
const char *value);
/**
* @brief Callback function for functions that read an integer value.
*
* @param conn The connection used in the function.
* @param err Error value. BT_TBS_CLIENT_RESULT_CODE_*,
* GATT error or errno value.
* @param inst_index The index of the TBS instance that was updated.
* @param value The integer value.
*/
typedef void (*bt_tbs_client_read_value_cb)(struct bt_conn *conn, int err,
uint8_t inst_index, uint32_t value);
/**
* @brief Callback function for ccp_read_termination_reason.
*
* @param conn The connection used in the function.
* @param err Error value. BT_TBS_CLIENT_RESULT_CODE_*,
* GATT error or errno value.
* @param inst_index The index of the TBS instance that was updated.
* @param call_index The call index.
* @param reason The termination reason.
*/
typedef void (*bt_tbs_client_termination_reason_cb)(struct bt_conn *conn,
int err, uint8_t inst_index,
uint8_t call_index,
uint8_t reason);
/**
* @brief Callback function for ccp_read_current_calls.
*
* @param conn The connection used in the function.
* @param err Error value. BT_TBS_CLIENT_RESULT_CODE_*,
* GATT error or errno value.
* @param inst_index The index of the TBS instance that was updated.
* @param call_count Number of calls read.
* @param calls Array of calls. The array is not kept by
* the client, so must be copied to be saved.
*/
typedef void (*bt_tbs_client_current_calls_cb)(struct bt_conn *conn, int err,
uint8_t inst_index,
uint8_t call_count,
const struct bt_tbs_client_call *calls);
/**
* @brief Callback function for ccp_read_call_state.
*
* @param conn The connection used in the function.
* @param err Error value. BT_TBS_CLIENT_RESULT_CODE_*,
* GATT error or errno value.
* @param inst_index The index of the TBS instance that was updated.
* @param call_count Number of call states read.
* @param call_states Array of call states. The array is not kept by
* the client, so must be copied to be saved.
*/
typedef void (*bt_tbs_client_call_states_cb)(struct bt_conn *conn, int err,
uint8_t inst_index,
uint8_t call_count,
const struct bt_tbs_client_call_state *call_states);
/**
* @brief Struct to hold the Telephone Bearer Service client callbacks
*
* These can be registered for usage with bt_tbs_client_register_cb().
*/
struct bt_tbs_client_cb {
/** Discovery has completed */
bt_tbs_client_discover_cb discover;
#if defined(CONFIG_BT_TBS_CLIENT_ORIGINATE_CALL) || defined(__DOXYGEN__)
/** Originate call has completed */
bt_tbs_client_cp_cb originate_call;
#endif /* defined(CONFIG_BT_TBS_CLIENT_ORIGINATE_CALL) */
#if defined(CONFIG_BT_TBS_CLIENT_TERMINATE_CALL) || defined(__DOXYGEN__)
/** Terminate call has completed */
bt_tbs_client_cp_cb terminate_call;
#endif /* defined(CONFIG_BT_TBS_CLIENT_TERMINATE_CALL) */
#if defined(CONFIG_BT_TBS_CLIENT_HOLD_CALL) || defined(__DOXYGEN__)
/** Hold call has completed */
bt_tbs_client_cp_cb hold_call;
#endif /* defined(CONFIG_BT_TBS_CLIENT_HOLD_CALL) */
#if defined(CONFIG_BT_TBS_CLIENT_ACCEPT_CALL) || defined(__DOXYGEN__)
/** Accept call has completed */
bt_tbs_client_cp_cb accept_call;
#endif /* defined(CONFIG_BT_TBS_CLIENT_ACCEPT_CALL) */
#if defined(CONFIG_BT_TBS_CLIENT_RETRIEVE_CALL) || defined(__DOXYGEN__)
/** Retrieve call has completed */
bt_tbs_client_cp_cb retrieve_call;
#endif /* defined(CONFIG_BT_TBS_CLIENT_RETRIEVE_CALL) */
#if defined(CONFIG_BT_TBS_CLIENT_JOIN_CALLS) || defined(__DOXYGEN__)
/** Join calls has completed */
bt_tbs_client_cp_cb join_calls;
#endif /* defined(CONFIG_BT_TBS_CLIENT_JOIN_CALLS) */
#if defined(CONFIG_BT_TBS_CLIENT_BEARER_PROVIDER_NAME) || defined(__DOXYGEN__)
/** Bearer provider name has been read */
bt_tbs_client_read_string_cb bearer_provider_name;
#endif /* defined(CONFIG_BT_TBS_CLIENT_BEARER_PROVIDER_NAME) */
#if defined(CONFIG_BT_TBS_CLIENT_BEARER_UCI) || defined(__DOXYGEN__)
/** Bearer UCI has been read */
bt_tbs_client_read_string_cb bearer_uci;
#endif /* defined(CONFIG_BT_TBS_CLIENT_BEARER_UCI) */
#if defined(CONFIG_BT_TBS_CLIENT_BEARER_TECHNOLOGY) || defined(__DOXYGEN__)
/** Bearer technology has been read */
bt_tbs_client_read_value_cb technology;
#endif /* defined(CONFIG_BT_TBS_CLIENT_BEARER_TECHNOLOGY) */
#if defined(CONFIG_BT_TBS_CLIENT_BEARER_URI_SCHEMES_SUPPORTED_LIST) || defined(__DOXYGEN__)
/** Bearer URI list has been read */
bt_tbs_client_read_string_cb uri_list;
#endif /* defined(CONFIG_BT_TBS_CLIENT_BEARER_URI_SCHEMES_SUPPORTED_LIST) */
#if defined(CONFIG_BT_TBS_CLIENT_BEARER_SIGNAL_STRENGTH) || defined(__DOXYGEN__)
/** Bearer signal strength has been read */
bt_tbs_client_read_value_cb signal_strength;
#endif /* defined(CONFIG_BT_TBS_CLIENT_BEARER_SIGNAL_STRENGTH) */
#if defined(CONFIG_BT_TBS_CLIENT_READ_BEARER_SIGNAL_INTERVAL) || defined(__DOXYGEN__)
/** Bearer signal interval has been read */
bt_tbs_client_read_value_cb signal_interval;
#endif /* defined(CONFIG_BT_TBS_CLIENT_READ_BEARER_SIGNAL_INTERVAL) */
#if defined(CONFIG_BT_TBS_CLIENT_BEARER_LIST_CURRENT_CALLS) || defined(__DOXYGEN__)
/** Bearer current calls has been read */
bt_tbs_client_current_calls_cb current_calls;
#endif /* defined(CONFIG_BT_TBS_CLIENT_BEARER_LIST_CURRENT_CALLS) */
#if defined(CONFIG_BT_TBS_CLIENT_CCID) || defined(__DOXYGEN__)
/** Bearer CCID has been read */
bt_tbs_client_read_value_cb ccid;
#endif /* defined(CONFIG_BT_TBS_CLIENT_CCID) */
#if defined(CONFIG_BT_TBS_CLIENT_INCOMING_URI) || defined(__DOXYGEN__)
/** Bearer call URI has been read */
bt_tbs_client_read_string_cb call_uri;
#endif /* defined(CONFIG_BT_TBS_CLIENT_INCOMING_URI) */
#if defined(CONFIG_BT_TBS_CLIENT_STATUS_FLAGS) || defined(__DOXYGEN__)
/** Bearer status flags has been read */
bt_tbs_client_read_value_cb status_flags;
#endif /* defined(CONFIG_BT_TBS_CLIENT_STATUS_FLAGS) */
/** Bearer call states has been read */
bt_tbs_client_call_states_cb call_state;
#if defined(CONFIG_BT_TBS_CLIENT_OPTIONAL_OPCODES) || defined(__DOXYGEN__)
/** Bearer optional opcodes has been read */
bt_tbs_client_read_value_cb optional_opcodes;
#endif /* defined(CONFIG_BT_TBS_CLIENT_OPTIONAL_OPCODES) */
/** Bearer terminate reason has been read */
bt_tbs_client_termination_reason_cb termination_reason;
#if defined(CONFIG_BT_TBS_CLIENT_INCOMING_CALL) || defined(__DOXYGEN__)
/** Bearer remote URI has been read */
bt_tbs_client_read_string_cb remote_uri;
#endif /* defined(CONFIG_BT_TBS_CLIENT_INCOMING_CALL) */
#if defined(CONFIG_BT_TBS_CLIENT_CALL_FRIENDLY_NAME) || defined(__DOXYGEN__)
/** Bearer friendly name has been read */
bt_tbs_client_read_string_cb friendly_name;
#endif /* defined(CONFIG_BT_TBS_CLIENT_CALL_FRIENDLY_NAME) */
};
/**
* @brief Discover TBS for a connection. This will start a GATT
* discover and setup handles and subscriptions.
*
* @param conn The connection to discover TBS for.
*
* @return int 0 on success, GATT error value on fail.
*/
int bt_tbs_client_discover(struct bt_conn *conn);
/**
* @brief Set the outgoing URI for a TBS instance on the peer device.
*
* @param conn The connection to the TBS server.
* @param inst_index The index of the TBS instance.
* @param uri The Null-terminated URI string.
*
* @return int 0 on success, errno value on fail.
*/
int bt_tbs_client_set_outgoing_uri(struct bt_conn *conn, uint8_t inst_index,
const char *uri);
/**
* @brief Set the signal strength reporting interval for a TBS instance.
*
* @param conn The connection to the TBS server.
* @param inst_index The index of the TBS instance.
* @param interval The interval to write (0-255 seconds).
*
* @return int 0 on success, errno value on fail.
*
* @note @kconfig{CONFIG_BT_TBS_CLIENT_SET_BEARER_SIGNAL_INTERVAL} must be set
* for this function to be effective.
*/
int bt_tbs_client_set_signal_strength_interval(struct bt_conn *conn,
uint8_t inst_index,
uint8_t interval);
/**
* @brief Request to originate a call.
*
* @param conn The connection to the TBS server.
* @param inst_index The index of the TBS instance.
* @param uri The URI of the callee.
*
* @return int 0 on success, errno value on fail.
*
* @note @kconfig{CONFIG_BT_TBS_CLIENT_ORIGINATE_CALL} must be set
* for this function to be effective.
*/
int bt_tbs_client_originate_call(struct bt_conn *conn, uint8_t inst_index,
const char *uri);
/**
* @brief Request to terminate a call
*
* @param conn The connection to the TBS server.
* @param inst_index The index of the TBS instance.
* @param call_index The call index to terminate.
*
* @return int 0 on success, errno value on fail.
*
* @note @kconfig{CONFIG_BT_TBS_CLIENT_TERMINATE_CALL} must be set
* for this function to be effective.
*/
int bt_tbs_client_terminate_call(struct bt_conn *conn, uint8_t inst_index,
uint8_t call_index);
/**
* @brief Request to hold a call
*
* @param conn The connection to the TBS server.
* @param inst_index The index of the TBS instance.
* @param call_index The call index to place on hold.
*
* @return int 0 on success, errno value on fail.
*
* @note @kconfig{CONFIG_BT_TBS_CLIENT_HOLD_CALL} must be set
* for this function to be effective.
*/
int bt_tbs_client_hold_call(struct bt_conn *conn, uint8_t inst_index,
uint8_t call_index);
/**
* @brief Accept an incoming call
*
* @param conn The connection to the TBS server.
* @param inst_index The index of the TBS instance.
* @param call_index The call index to accept.
*
* @return int 0 on success, errno value on fail.
*
* @note @kconfig{CONFIG_BT_TBS_CLIENT_ACCEPT_CALL} must be set
* for this function to be effective.
*/
int bt_tbs_client_accept_call(struct bt_conn *conn, uint8_t inst_index,
uint8_t call_index);
/**
* @brief Retrieve call from (local) hold.
*
* @param conn The connection to the TBS server.
* @param inst_index The index of the TBS instance.
* @param call_index The call index to retrieve.
*
* @return int 0 on success, errno value on fail.
*
* @note @kconfig{CONFIG_BT_TBS_CLIENT_RETRIEVE_CALL} must be set
* for this function to be effective.
*/
int bt_tbs_client_retrieve_call(struct bt_conn *conn, uint8_t inst_index,
uint8_t call_index);
/**
* @brief Join multiple calls.
*
* @param conn The connection to the TBS server.
* @param inst_index The index of the TBS instance.
* @param call_indexes Array of call indexes.
* @param count Number of call indexes in the call_indexes array.
*
* @return int 0 on success, errno value on fail.
*
* @note @kconfig{CONFIG_BT_TBS_CLIENT_JOIN_CALLS} must be set
* for this function to be effective.
*/
int bt_tbs_client_join_calls(struct bt_conn *conn, uint8_t inst_index,
const uint8_t *call_indexes, uint8_t count);
/**
* @brief Read the bearer provider name of a TBS instance.
*
* @param conn The connection to the TBS server.
* @param inst_index The index of the TBS instance.
*
* @return int 0 on success, errno value on fail.
*
* @note @kconfig{CONFIG_BT_TBS_CLIENT_BEARER_PROVIDER_NAME} must be set
* for this function to be effective.
*/
int bt_tbs_client_read_bearer_provider_name(struct bt_conn *conn,
uint8_t inst_index);
/**
* @brief Read the UCI of a TBS instance.
*
* @param conn The connection to the TBS server.
* @param inst_index The index of the TBS instance.
*
* @return int 0 on success, errno value on fail.
*
* @note @kconfig{CONFIG_BT_TBS_CLIENT_BEARER_UCI} must be set
* for this function to be effective.
*/
int bt_tbs_client_read_bearer_uci(struct bt_conn *conn, uint8_t inst_index);
/**
* @brief Read the technology of a TBS instance.
*
* @param conn The connection to the TBS server.
* @param inst_index The index of the TBS instance.
*
* @return int 0 on success, errno value on fail.
*
* @note @kconfig{CONFIG_BT_TBS_CLIENT_BEARER_TECHNOLOGY} must be set
* for this function to be effective.
*/
int bt_tbs_client_read_technology(struct bt_conn *conn, uint8_t inst_index);
/**
* @brief Read the URI schemes list of a TBS instance.
*
* @param conn The connection to the TBS server.
* @param inst_index The index of the TBS instance.
*
* @return int 0 on success, errno value on fail.
*
* @note @kconfig{CONFIG_BT_TBS_CLIENT_BEARER_URI_SCHEMES_SUPPORTED_LIST} must be set
* for this function to be effective.
*/
int bt_tbs_client_read_uri_list(struct bt_conn *conn, uint8_t inst_index);
/**
* @brief Read the current signal strength of a TBS instance.
*
* @param conn The connection to the TBS server.
* @param inst_index The index of the TBS instance.
*
* @return int 0 on success, errno value on fail.
*
* @note @kconfig{CONFIG_BT_TBS_CLIENT_BEARER_SIGNAL_STRENGTH} must be set
* for this function to be effective.
*/
int bt_tbs_client_read_signal_strength(struct bt_conn *conn,
uint8_t inst_index);
/**
* @brief Read the signal strength reporting interval of a TBS instance.
*
* @param conn The connection to the TBS server.
* @param inst_index The index of the TBS instance.
*
* @return int 0 on success, errno value on fail.
*
* @note @kconfig{CONFIG_BT_TBS_CLIENT_READ_BEARER_SIGNAL_INTERVAL} must be set
* for this function to be effective.
*/
int bt_tbs_client_read_signal_interval(struct bt_conn *conn,
uint8_t inst_index);
/**
* @brief Read the list of current calls of a TBS instance.
*
* @param conn The connection to the TBS server.
* @param inst_index The index of the TBS instance.
*
* @return int 0 on success, errno value on fail.
*
* @note @kconfig{CONFIG_BT_TBS_CLIENT_BEARER_LIST_CURRENT_CALLS} must be set
* for this function to be effective.
*/
int bt_tbs_client_read_current_calls(struct bt_conn *conn, uint8_t inst_index);
/**
* @brief Read the content ID of a TBS instance.
*
* @param conn The connection to the TBS server.
* @param inst_index The index of the TBS instance.
*
* @return int 0 on success, errno value on fail.
*
* @note @kconfig{CONFIG_BT_TBS_CLIENT_CCID} must be set
* for this function to be effective.
*/
int bt_tbs_client_read_ccid(struct bt_conn *conn, uint8_t inst_index);
/**
* @brief Read the call target URI of a TBS instance.
*
* @param conn The connection to the TBS server.
* @param inst_index The index of the TBS instance.
*
* @return int 0 on success, errno value on fail.
*
* @note @kconfig{CONFIG_BT_TBS_CLIENT_INCOMING_URI} must be set
* for this function to be effective.
*/
int bt_tbs_client_read_call_uri(struct bt_conn *conn, uint8_t inst_index);
/**
* @brief Read the feature and status value of a TBS instance.
*
* @param conn The connection to the TBS server.
* @param inst_index The index of the TBS instance.
*
* @return int 0 on success, errno value on fail.
*
* @note @kconfig{CONFIG_BT_TBS_CLIENT_STATUS_FLAGS} must be set
* for this function to be effective.
*/
int bt_tbs_client_read_status_flags(struct bt_conn *conn, uint8_t inst_index);
/**
* @brief Read the states of the current calls of a TBS instance.
*
* @param conn The connection to the TBS server.
* @param inst_index The index of the TBS instance.
*
* @return int 0 on success, errno value on fail.
*/
int bt_tbs_client_read_call_state(struct bt_conn *conn, uint8_t inst_index);
/**
* @brief Read the remote URI of a TBS instance.
*
* @param conn The connection to the TBS server.
* @param inst_index The index of the TBS instance.
*
* @return int 0 on success, errno value on fail.
*
* @note @kconfig{CONFIG_BT_TBS_CLIENT_INCOMING_CALL} must be set
* for this function to be effective.
*/
int bt_tbs_client_read_remote_uri(struct bt_conn *conn, uint8_t inst_index);
/**
* @brief Read the friendly name of a call for a TBS instance.
*
* @param conn The connection to the TBS server.
* @param inst_index The index of the TBS instance.
*
* @return int 0 on success, errno value on fail.
*
* @note @kconfig{CONFIG_BT_TBS_CLIENT_CALL_FRIENDLY_NAME} must be set
* for this function to be effective.
*/
int bt_tbs_client_read_friendly_name(struct bt_conn *conn, uint8_t inst_index);
/**
* @brief Read the supported opcode of a TBS instance.
*
* @param conn The connection to the TBS server.
* @param inst_index The index of the TBS instance.
*
* @return int 0 on success, errno value on fail.
*
* @note @kconfig{CONFIG_BT_TBS_CLIENT_OPTIONAL_OPCODES} must be set
* for this function to be effective.
*/
int bt_tbs_client_read_optional_opcodes(struct bt_conn *conn,
uint8_t inst_index);
/**
* @brief Register the callbacks for CCP.
*
* @param cbs Pointer to the callback structure.
*/
void bt_tbs_client_register_cb(const struct bt_tbs_client_cb *cbs);
/**
* @brief Look up Telephone Bearer Service instance by CCID
*
* @param conn The connection to the TBS server.
* @param ccid The CCID to lookup a service instance for.
*
* @return Pointer to a Telephone Bearer Service instance if found else NULL.
*
* @note @kconfig{CONFIG_BT_TBS_CLIENT_CCID} must be set
* for this function to be effective.
*/
struct bt_tbs_instance *bt_tbs_client_get_by_ccid(const struct bt_conn *conn,
uint8_t ccid);
#ifdef __cplusplus
}
#endif
/** @} */
#endif /* ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_TBS_H_ */
``` | /content/code_sandbox/include/zephyr/bluetooth/audio/tbs.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 8,556 |
```objective-c
/*
*
*/
#ifndef ZEPHYR_INCLUDE_SYSCALL_HANDLER_H_
#define ZEPHYR_INCLUDE_SYSCALL_HANDLER_H_
/**
* @brief User mode and Syscall APIs
* @defgroup syscall_apis User mode and Syscall APIs
* @ingroup internal_api
* @{
*/
#if defined(CONFIG_USERSPACE) || defined(__DOXYGEN__)
#ifndef _ASMLANGUAGE
#include <zephyr/kernel.h>
#include <zephyr/arch/arch_interface.h>
#include <zephyr/sys/math_extras.h>
#include <stdbool.h>
#include <zephyr/logging/log.h>
extern const _k_syscall_handler_t _k_syscall_table[K_SYSCALL_LIMIT];
enum _obj_init_check {
_OBJ_INIT_TRUE = 0,
_OBJ_INIT_FALSE = -1,
_OBJ_INIT_ANY = 1
};
/**
* Return true if we are currently handling a system call from user mode
*
* Inside z_vrfy functions, we always know that we are handling
* a system call invoked from user context.
*
* However, some checks that are only relevant to user mode must
* instead be placed deeper within the implementation. This
* API is useful to conditionally make these checks.
*
* For performance reasons, whenever possible, checks should be placed
* in the relevant z_vrfy function since these are completely skipped
* when a syscall is invoked.
*
* This will return true only if we are handling a syscall for a
* user thread. If the system call was invoked from supervisor mode,
* or we are not handling a system call, this will return false.
*
* @note This is an internal API. Do not use unless you are extending
* functionality in the Zephyr tree.
*
* @return whether the current context is handling a syscall for a user
* mode thread
*/
static inline bool k_is_in_user_syscall(void)
{
/* This gets set on entry to the syscall's generated z_mrsh
* function and then cleared on exit. This code path is only
* encountered when a syscall is made from user mode, system
* calls from supervisor mode bypass everything directly to
* the implementation function.
*/
return !k_is_in_isr() && (_current->syscall_frame != NULL);
}
/**
* Ensure a system object is a valid object of the expected type
*
* Searches for the object and ensures that it is indeed an object
* of the expected type, that the caller has the right permissions on it,
* and that the object has been initialized.
*
* This function is intended to be called on the kernel-side system
* call handlers to validate kernel object pointers passed in from
* userspace.
*
* @param ko Kernel object metadata pointer, or NULL
* @param otype Expected type of the kernel object, or K_OBJ_ANY if type
* doesn't matter
* @param init Indicate whether the object needs to already be in initialized
* or uninitialized state, or that we don't care
* @note This is an internal API. Do not use unless you are extending
* functionality in the Zephyr tree.
*
* @return 0 If the object is valid
* -EBADF if not a valid object of the specified type
* -EPERM If the caller does not have permissions
* -EINVAL Object is not initialized
*/
int k_object_validate(struct k_object *ko, enum k_objects otype,
enum _obj_init_check init);
/**
* Dump out error information on failed k_object_validate() call
*
* @param retval Return value from k_object_validate()
* @param obj Kernel object we were trying to verify
* @param ko If retval=-EPERM, struct k_object * that was looked up, or NULL
* @param otype Expected type of the kernel object
* @note This is an internal API. Do not use unless you are extending
* functionality in the Zephyr tree.
*
*/
void k_object_dump_error(int retval, const void *obj,
struct k_object *ko, enum k_objects otype);
/**
* Kernel object validation function
*
* Retrieve metadata for a kernel object. This function is implemented in
* the gperf script footer, see gen_kobject_list.py
*
* @param obj Address of kernel object to get metadata
* @return Kernel object's metadata, or NULL if the parameter wasn't the
* memory address of a kernel object
* @note This is an internal API. Do not use unless you are extending
* functionality in the Zephyr tree.
*
*/
struct k_object *k_object_find(const void *obj);
typedef void (*_wordlist_cb_func_t)(struct k_object *ko, void *context);
/**
* Iterate over all the kernel object metadata in the system
*
* @param func function to run on each struct k_object
* @param context Context pointer to pass to each invocation
* @note This is an internal API. Do not use unless you are extending
* functionality in the Zephyr tree.
*
*/
void k_object_wordlist_foreach(_wordlist_cb_func_t func, void *context);
/**
* Copy all kernel object permissions from the parent to the child
*
* @param parent Parent thread, to get permissions from
* @param child Child thread, to copy permissions to
* @note This is an internal API. Do not use unless you are extending
* functionality in the Zephyr tree.
*
*/
void k_thread_perms_inherit(struct k_thread *parent, struct k_thread *child);
/**
* Grant a thread permission to a kernel object
*
* @param ko Kernel object metadata to update
* @param thread The thread to grant permission
* @note This is an internal API. Do not use unless you are extending
* functionality in the Zephyr tree.
*
*/
void k_thread_perms_set(struct k_object *ko, struct k_thread *thread);
/**
* Revoke a thread's permission to a kernel object
*
* @param ko Kernel object metadata to update
* @param thread The thread to grant permission
* @note This is an internal API. Do not use unless you are extending
* functionality in the Zephyr tree.
*
*/
void k_thread_perms_clear(struct k_object *ko, struct k_thread *thread);
/**
* Revoke access to all objects for the provided thread
*
* @note Unlike k_thread_perms_clear(), this function will not clear
* permissions on public objects.
*
* @note This is an internal API. Do not use unless you are extending
* functionality in the Zephyr tree.
*
* @param thread Thread object to revoke access
*/
void k_thread_perms_all_clear(struct k_thread *thread);
/**
* Clear initialization state of a kernel object
*
* Intended for thread objects upon thread exit, or for other kernel objects
* that were released back to an object pool.
*
* @param obj Address of the kernel object
*
* @note This is an internal API. Do not use unless you are extending
* functionality in the Zephyr tree.
*/
void k_object_uninit(const void *obj);
/**
* Initialize and reset permissions to only access by the caller
*
* Intended for scenarios where objects are fetched from slab pools
* and may have had different permissions set during prior usage.
*
* This is only intended for pools of objects, where such objects are
* acquired and released to the pool. If an object has already been used,
* we do not want stale permission information hanging around, the object
* should only have permissions on the caller. Objects which are not
* managed by a pool-like mechanism should not use this API.
*
* The object will be marked as initialized and the calling thread
* granted access to it.
*
* @param obj Address of the kernel object
* @note This is an internal API. Do not use unless you are extending
* functionality in the Zephyr tree.
*/
void k_object_recycle(const void *obj);
/**
* @brief Obtain the size of a C string passed from user mode
*
* Given a C string pointer and a maximum size, obtain the true
* size of the string (not including the trailing NULL byte) just as
* if calling strnlen() on it, with the same semantics of strnlen() with
* respect to the return value and the maxlen parameter.
*
* Any memory protection faults triggered by the examination of the string
* will be safely handled and an error code returned.
*
* NOTE: Doesn't guarantee that user mode has actual access to this
* string, you will need to still do a K_SYSCALL_MEMORY_READ()
* with the obtained size value to guarantee this.
*
* @param src String to measure size of
* @param maxlen Maximum number of characters to examine
* @param err Pointer to int, filled in with -1 on memory error, 0 on
* success
* @return undefined on error, or strlen(src) if that is less than maxlen, or
* maxlen if there were no NULL terminating characters within the
* first maxlen bytes.
* @note This is an internal API. Do not use unless you are extending
* functionality in the Zephyr tree.
*/
static inline size_t k_usermode_string_nlen(const char *src, size_t maxlen,
int *err)
{
return arch_user_string_nlen(src, maxlen, err);
}
/**
* @brief Copy data from userspace into a resource pool allocation
*
* Given a pointer and a size, allocate a similarly sized buffer in the
* caller's resource pool and copy all the data within it to the newly
* allocated buffer. This will need to be freed later with k_free().
*
* Checks are done to ensure that the current thread would have read
* access to the provided buffer.
*
* @param src Source memory address
* @param size Size of the memory buffer
* @return An allocated buffer with the data copied within it, or NULL
* if some error condition occurred
* @note This is an internal API. Do not use unless you are extending
* functionality in the Zephyr tree.
*/
void *k_usermode_alloc_from_copy(const void *src, size_t size);
/**
* @brief Copy data from user mode
*
* Given a userspace pointer and a size, copies data from it into a provided
* destination buffer, performing checks to ensure that the caller would have
* appropriate access when in user mode.
*
* @param dst Destination memory buffer
* @param src Source memory buffer, in userspace
* @param size Number of bytes to copy
* @retval 0 On success
* @retval EFAULT On memory access error
* @note This is an internal API. Do not use unless you are extending
* functionality in the Zephyr tree.
*/
int k_usermode_from_copy(void *dst, const void *src, size_t size);
/**
* @brief Copy data to user mode
*
* Given a userspace pointer and a size, copies data to it from a provided
* source buffer, performing checks to ensure that the caller would have
* appropriate access when in user mode.
*
* @param dst Destination memory buffer, in userspace
* @param src Source memory buffer
* @param size Number of bytes to copy
* @retval 0 On success
* @retval EFAULT On memory access error
* @note This is an internal API. Do not use unless you are extending
* functionality in the Zephyr tree.
*/
int k_usermode_to_copy(void *dst, const void *src, size_t size);
/**
* @brief Copy a C string from userspace into a resource pool allocation
*
* Given a C string and maximum length, duplicate the string using an
* allocation from the calling thread's resource pool. This will need to be
* freed later with k_free().
*
* Checks are performed to ensure that the string is valid memory and that
* the caller has access to it in user mode.
*
* @param src Source string pointer, in userspace
* @param maxlen Maximum size of the string including trailing NULL
* @return The duplicated string, or NULL if an error occurred.
* @note This is an internal API. Do not use unless you are extending
* functionality in the Zephyr tree.
*/
char *k_usermode_string_alloc_copy(const char *src, size_t maxlen);
/**
* @brief Copy a C string from userspace into a provided buffer
*
* Given a C string and maximum length, copy the string into a buffer.
*
* Checks are performed to ensure that the string is valid memory and that
* the caller has access to it in user mode.
*
* @param dst Destination buffer
* @param src Source string pointer, in userspace
* @param maxlen Maximum size of the string including trailing NULL
* @retval 0 on success
* @retval EINVAL if the source string is too long with respect
* to maxlen
* @retval EFAULT On memory access error
* @note This is an internal API. Do not use unless you are extending
* functionality in the Zephyr tree.
*/
int k_usermode_string_copy(char *dst, const char *src, size_t maxlen);
/**
* @brief Induce a kernel oops
*
* This macro can be used to induce a kernel oops which will kill the
* calling thread.
*
* @param expr Expression to be evaluated
*
* @note This is an internal API. Do not use unless you are extending
* functionality in the Zephyr tree.
*/
#define K_OOPS(expr) \
do { \
if (expr) { \
arch_syscall_oops(_current->syscall_frame); \
} \
} while (false)
/**
* @brief Runtime expression check for system call arguments
*
* Used in handler functions to perform various runtime checks on arguments,
* and generate a kernel oops if anything is not expected, printing a custom
* message.
*
* @param expr Boolean expression to verify, a false result will trigger an
* oops
* @param fmt Printf-style format string (followed by appropriate variadic
* arguments) to print on verification failure
* @return False on success, True on failure
* @note This is an internal API. Do not use unless you are extending
* functionality in the Zephyr tree.
*/
#define K_SYSCALL_VERIFY_MSG(expr, fmt, ...) ({ \
bool expr_copy = !(expr); \
if (expr_copy) { \
TOOLCHAIN_IGNORE_WSHADOW_BEGIN \
LOG_MODULE_DECLARE(os, CONFIG_KERNEL_LOG_LEVEL); \
TOOLCHAIN_IGNORE_WSHADOW_END \
LOG_ERR("syscall %s failed check: " fmt, \
__func__, ##__VA_ARGS__); \
} \
expr_copy; })
/**
* @brief Runtime expression check for system call arguments
*
* Used in handler functions to perform various runtime checks on arguments,
* and generate a kernel oops if anything is not expected.
*
* @param expr Boolean expression to verify, a false result will trigger an
* oops. A stringified version of this expression will be printed.
* @return 0 on success, nonzero on failure
* @note This is an internal API. Do not use unless you are extending
* functionality in the Zephyr tree.
*/
#define K_SYSCALL_VERIFY(expr) K_SYSCALL_VERIFY_MSG(expr, #expr)
/**
* @brief Macro to check if size is negative
*
* K_SYSCALL_MEMORY can be called with signed/unsigned types
* and because of that if we check if size is greater or equal to
* zero, many static analyzers complain about no effect expression.
*
* @param ptr Memory area to examine
* @param size Size of the memory area
* @return true if size is valid, false otherwise
* @note This is an internal API. Do not use unless you are extending
* functionality in the Zephyr tree.
*/
#define K_SYSCALL_MEMORY_SIZE_CHECK(ptr, size) \
(((uintptr_t)(ptr) + (size)) >= (uintptr_t)(ptr))
/**
* @brief Runtime check that a user thread has read and/or write permission to
* a memory area
*
* Checks that the particular memory area is readable and/or writeable by the
* currently running thread if the CPU was in user mode, and generates a kernel
* oops if it wasn't. Prevents userspace from getting the kernel to read and/or
* modify memory the thread does not have access to, or passing in garbage
* pointers that would crash/pagefault the kernel if dereferenced.
*
* @param ptr Memory area to examine
* @param size Size of the memory area
* @param write If the thread should be able to write to this memory, not just
* read it
* @return 0 on success, nonzero on failure
* @note This is an internal API. Do not use unless you are extending
* functionality in the Zephyr tree.
*/
#define K_SYSCALL_MEMORY(ptr, size, write) \
K_SYSCALL_VERIFY_MSG(K_SYSCALL_MEMORY_SIZE_CHECK(ptr, size) \
&& !Z_DETECT_POINTER_OVERFLOW(ptr, size) \
&& (arch_buffer_validate((void *)(ptr), (size), (write)) \
== 0), \
"Memory region %p (size %zu) %s access denied", \
(void *)(ptr), (size_t)(size), \
(write) ? "write" : "read")
/**
* @brief Runtime check that a user thread has read permission to a memory area
*
* Checks that the particular memory area is readable by the currently running
* thread if the CPU was in user mode, and generates a kernel oops if it
* wasn't. Prevents userspace from getting the kernel to read memory the thread
* does not have access to, or passing in garbage pointers that would
* crash/pagefault the kernel if dereferenced.
*
* @param ptr Memory area to examine
* @param size Size of the memory area
* @return 0 on success, nonzero on failure
* @note This is an internal API. Do not use unless you are extending
* functionality in the Zephyr tree.
*/
#define K_SYSCALL_MEMORY_READ(ptr, size) \
K_SYSCALL_MEMORY(ptr, size, 0)
/**
* @brief Runtime check that a user thread has write permission to a memory area
*
* Checks that the particular memory area is readable and writable by the
* currently running thread if the CPU was in user mode, and generates a kernel
* oops if it wasn't. Prevents userspace from getting the kernel to read or
* modify memory the thread does not have access to, or passing in garbage
* pointers that would crash/pagefault the kernel if dereferenced.
*
* @param ptr Memory area to examine
* @param size Size of the memory area
* @return 0 on success, nonzero on failure
*
* @note This is an internal API. Do not use unless you are extending
* functionality in the Zephyr tree.
*/
#define K_SYSCALL_MEMORY_WRITE(ptr, size) \
K_SYSCALL_MEMORY(ptr, size, 1)
#define K_SYSCALL_MEMORY_ARRAY(ptr, nmemb, size, write) \
({ \
size_t product; \
K_SYSCALL_VERIFY_MSG(!size_mul_overflow((size_t)(nmemb), \
(size_t)(size), \
&product), \
"%zux%zu array is too large", \
(size_t)(nmemb), (size_t)(size)) || \
K_SYSCALL_MEMORY(ptr, product, write); \
})
/**
* @brief Validate user thread has read permission for sized array
*
* Used when the memory region is expressed in terms of number of elements and
* each element size, handles any overflow issues with computing the total
* array bounds. Otherwise see _SYSCALL_MEMORY_READ.
*
* @param ptr Memory area to examine
* @param nmemb Number of elements in the array
* @param size Size of each array element
* @return 0 on success, nonzero on failure
* @note This is an internal API. Do not use unless you are extending
* functionality in the Zephyr tree.
*/
#define K_SYSCALL_MEMORY_ARRAY_READ(ptr, nmemb, size) \
K_SYSCALL_MEMORY_ARRAY(ptr, nmemb, size, 0)
/**
* @brief Validate user thread has read/write permission for sized array
*
* Used when the memory region is expressed in terms of number of elements and
* each element size, handles any overflow issues with computing the total
* array bounds. Otherwise see _SYSCALL_MEMORY_WRITE.
*
* @param ptr Memory area to examine
* @param nmemb Number of elements in the array
* @param size Size of each array element
* @return 0 on success, nonzero on failure
* @note This is an internal API. Do not use unless you are extending
* functionality in the Zephyr tree.
*/
#define K_SYSCALL_MEMORY_ARRAY_WRITE(ptr, nmemb, size) \
K_SYSCALL_MEMORY_ARRAY(ptr, nmemb, size, 1)
static inline int k_object_validation_check(struct k_object *ko,
const void *obj,
enum k_objects otype,
enum _obj_init_check init)
{
int ret;
ret = k_object_validate(ko, otype, init);
#ifdef CONFIG_LOG
if (ret != 0) {
k_object_dump_error(ret, obj, ko, otype);
}
#else
ARG_UNUSED(obj);
#endif
return ret;
}
#define K_SYSCALL_IS_OBJ(ptr, type, init) \
K_SYSCALL_VERIFY_MSG(k_object_validation_check( \
k_object_find((const void *)(ptr)), \
(const void *)(ptr), \
(type), (init)) == 0, "access denied")
/**
* @brief Runtime check driver object pointer for presence of operation
*
* Validates if the driver object is capable of performing a certain operation.
*
* @param ptr Untrusted device instance object pointer
* @param api_name Name of the driver API struct (e.g. gpio_driver_api)
* @param op Driver operation (e.g. manage_callback)
*
* @return 0 on success, nonzero on failure
*
* @note This is an internal API. Do not use unless you are extending
* functionality in the Zephyr tree.
*/
#define K_SYSCALL_DRIVER_OP(ptr, api_name, op) \
({ \
struct api_name *__device__ = (struct api_name *) \
((const struct device *)(ptr))->api; \
K_SYSCALL_VERIFY_MSG(__device__->op != NULL, \
"Operation %s not defined for driver " \
"instance %p", \
# op, __device__); \
})
/**
* @brief Runtime check that device object is of a specific driver type
*
* Checks that the driver object passed in is initialized, the caller has
* correct permissions, and that it belongs to the specified driver
* subsystems. Additionally, all devices store a structure pointer of the
* driver's API. If this doesn't match the value provided, the check will fail.
*
* This provides an easy way to determine if a device object not only
* belongs to a particular subsystem, but is of a specific device driver
* implementation. Useful for defining out-of-subsystem system calls
* which are implemented for only one driver.
*
* @param _device Untrusted device pointer
* @param _dtype Expected kernel object type for the provided device pointer
* @param _api Expected driver API structure memory address
* @return 0 on success, nonzero on failure
* @note This is an internal API. Do not use unless you are extending
* functionality in the Zephyr tree.
*/
#define K_SYSCALL_SPECIFIC_DRIVER(_device, _dtype, _api) \
({ \
const struct device *_dev = (const struct device *)_device; \
K_SYSCALL_OBJ(_dev, _dtype) || \
K_SYSCALL_VERIFY_MSG(_dev->api == _api, \
"API structure mismatch"); \
})
/**
* @brief Runtime check kernel object pointer for non-init functions
*
* Calls k_object_validate and triggers a kernel oops if the check fails.
* For use in system call handlers which are not init functions; a fatal
* error will occur if the object is not initialized.
*
* @param ptr Untrusted kernel object pointer
* @param type Expected kernel object type
* @return 0 on success, nonzero on failure
* @note This is an internal API. Do not use unless you are extending
* functionality in the Zephyr tree.
*/
#define K_SYSCALL_OBJ(ptr, type) \
K_SYSCALL_IS_OBJ(ptr, type, _OBJ_INIT_TRUE)
/**
* @brief Runtime check kernel object pointer for non-init functions
*
* See description of _SYSCALL_IS_OBJ. No initialization checks are done.
* Intended for init functions where objects may be re-initialized at will.
*
* @param ptr Untrusted kernel object pointer
* @param type Expected kernel object type
* @return 0 on success, nonzero on failure
* @note This is an internal API. Do not use unless you are extending
* functionality in the Zephyr tree.
*/
#define K_SYSCALL_OBJ_INIT(ptr, type) \
K_SYSCALL_IS_OBJ(ptr, type, _OBJ_INIT_ANY)
/**
* @brief Runtime check kernel object pointer for non-init functions
*
* See description of _SYSCALL_IS_OBJ. Triggers a fatal error if the object is
* initialized. Intended for init functions where objects, once initialized,
* can only be re-used when their initialization state expires due to some
* other mechanism.
*
* @param ptr Untrusted kernel object pointer
* @param type Expected kernel object type
* @return 0 on success, nonzero on failure
* @note This is an internal API. Do not use unless you are extending
* functionality in the Zephyr tree.
*/
#define K_SYSCALL_OBJ_NEVER_INIT(ptr, type) \
K_SYSCALL_IS_OBJ(ptr, type, _OBJ_INIT_FALSE)
#include <zephyr/driver-validation.h>
#endif /* _ASMLANGUAGE */
#endif /* CONFIG_USERSPACE */
/**
* @}
*/
#endif /* ZEPHYR_INCLUDE_SYSCALL_HANDLER_H_ */
``` | /content/code_sandbox/include/zephyr/internal/syscall_handler.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 5,585 |
```objective-c
/*
*
*/
#ifndef ZEPHYR_MISC_LOREM_IPSUM_H_
#define ZEPHYR_MISC_LOREM_IPSUM_H_
#include <zephyr/toolchain.h>
/*
* N.B. These strings are generally only used for tests and samples. They are not part of any
* official Zephyr API, but were moved to reduce duplication.
*/
/* Generated by path_to_url
* 1 paragraph, 69 words, 445 bytes of Lorem Ipsum
*/
#define LOREM_IPSUM_SHORT \
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, " \
"sed do eiusmod tempor incididunt ut labore et dolore magna " \
"aliqua. Ut enim ad minim veniam, quis nostrud exercitation " \
"ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis " \
"aute irure dolor in reprehenderit in voluptate velit esse " \
"cillum dolore eu fugiat nulla pariatur. Excepteur sint " \
"occaecat cupidatat non proident, sunt in culpa qui officia " \
"deserunt mollit anim id est laborum."
#define LOREM_IPSUM_SHORT_STRLEN 445
BUILD_ASSERT(sizeof(LOREM_IPSUM_SHORT) == LOREM_IPSUM_SHORT_STRLEN + 1);
/* Generated by path_to_url
* 2 paragraphs, 173 words, 1160 bytes of Lorem Ipsum
*/
#define LOREM_IPSUM \
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus a varius sapien. " \
"Suspendisse interdum nulla et enim elementum faucibus. Vestibulum nec est libero. Duis " \
"leo orci, tincidunt a interdum ut, porttitor ac arcu. Etiam porttitor pretium nibh, non " \
"laoreet nisl vulputate vitae. Vestibulum sit amet odio sit amet nibh faucibus mattis " \
"eget at ex. Nam non arcu vitae nisi congue eleifend. Suspendisse sagittis, leo at " \
"blandit semper, arcu neque tristique dolor, eu consequat urna quam non tortor. " \
"Suspendisse ut ullamcorper lectus. Nullam ut accumsan lacus, sed iaculis leo. " \
"Suspendisse potenti. Duis ullamcorper velit tellus, ac dictum tellus ultricies quis." \
"\n" \
"Curabitur tellus eros, congue a sem et, mattis fermentum velit. Donec sollicitudin " \
"faucibus enim eu vehicula. Aliquam pulvinar lectus et finibus laoreet. Praesent at " \
"tempor ex. Aenean blandit nunc viverra enim vulputate, et dictum turpis elementum. " \
"Donec porttitor in dolor a ultricies. Cras neque ipsum, blandit sed varius at, semper " \
"quis justo. Meanness ac metus ex. Pellentesque eu tortor eget nisl tempor pretium. " \
"Donec elit enim, ultrices sit amet est vitae, sollicitudin bibendum egestas."
#define LOREM_IPSUM_STRLEN 1160
BUILD_ASSERT(sizeof(LOREM_IPSUM) == LOREM_IPSUM_STRLEN + 1);
#endif /* ZEPHYR_MISC_LOREM_IPSUM_H_ */
``` | /content/code_sandbox/include/zephyr/misc/lorem_ipsum.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 762 |
```objective-c
/*
*
*/
/**
* @brief hawkBit Firmware Over-the-Air for Zephyr Project.
* @defgroup hawkbit hawkBit Firmware Over-the-Air
* @ingroup third_party
* @{
*/
#ifndef ZEPHYR_INCLUDE_MGMT_HAWKBIT_H_
#define ZEPHYR_INCLUDE_MGMT_HAWKBIT_H_
#include <zephyr/net/tls_credentials.h>
#define HAWKBIT_JSON_URL "/default/controller/v1"
/**
* @brief Response message from hawkBit.
*
* @details These messages are used to inform the server and the
* user about the process status of the hawkBit and also
* used to standardize the errors that may occur.
*
*/
enum hawkbit_response {
HAWKBIT_NETWORKING_ERROR,
HAWKBIT_UNCONFIRMED_IMAGE,
HAWKBIT_PERMISSION_ERROR,
HAWKBIT_METADATA_ERROR,
HAWKBIT_DOWNLOAD_ERROR,
HAWKBIT_OK,
HAWKBIT_UPDATE_INSTALLED,
HAWKBIT_NO_UPDATE,
HAWKBIT_CANCEL_UPDATE,
HAWKBIT_NOT_INITIALIZED,
HAWKBIT_PROBE_IN_PROGRESS,
};
/**
* @brief hawkBit configuration structure.
*
* @details This structure is used to store the hawkBit configuration
* settings.
*/
struct hawkbit_runtime_config {
char *server_addr;
uint16_t server_port;
char *auth_token;
sec_tag_t tls_tag;
};
/**
* @brief Callback to provide the custom data to the hawkBit server.
*
* @details This callback is used to provide the custom data to the hawkBit server.
* The custom data is used to provide the hawkBit server with the device specific
* data.
*
* @param device_id The device ID.
* @param buffer The buffer to store the json.
* @param buffer_size The size of the buffer.
*/
typedef int (*hawkbit_config_device_data_cb_handler_t)(const char *device_id, uint8_t *buffer,
const size_t buffer_size);
/**
* @brief Set the custom data callback.
*
* @details This function is used to set the custom data callback.
* The callback is used to provide the custom data to the hawkBit server.
*
* @param cb The callback function.
*
* @retval 0 on success.
* @retval -EINVAL if the callback is NULL.
*/
int hawkbit_set_custom_data_cb(hawkbit_config_device_data_cb_handler_t cb);
/**
* @brief Init the flash partition
*
* @retval 0 on success.
* @retval -errno if init fails.
*/
int hawkbit_init(void);
/**
* @brief Runs hawkBit probe and hawkBit update automatically
*
* @details The hawkbit_autohandler handles the whole process
* in pre-determined time intervals.
*/
void hawkbit_autohandler(void);
/**
* @brief The hawkBit probe verify if there is some update to be performed.
*
* @retval HAWKBIT_NETWORKING_ERROR fail to connect to the hawkBit server.
* @retval HAWKBIT_UNCONFIRMED_IMAGE image is unconfirmed.
* @retval HAWKBIT_PERMISSION_ERROR fail to get the permission to access the hawkBit server.
* @retval HAWKBIT_METADATA_ERROR fail to parse or to encode the metadata.
* @retval HAWKBIT_DOWNLOAD_ERROR fail while downloading the update package.
* @retval HAWKBIT_OK if the image was already updated.
* @retval HAWKBIT_UPDATE_INSTALLED if an update was installed. Reboot is required to apply it.
* @retval HAWKBIT_NO_UPDATE if no update was available.
* @retval HAWKBIT_CANCEL_UPDATE if the update was cancelled by the server.
* @retval HAWKBIT_NOT_INITIALIZED if hawkBit is not initialized.
* @retval HAWKBIT_PROBE_IN_PROGRESS if probe is currently running.
*/
enum hawkbit_response hawkbit_probe(void);
/**
* @brief Request system to reboot.
*/
void hawkbit_reboot(void);
/**
* @brief Callback to get the device identity.
*
* @param id Pointer to the buffer to store the device identity
* @param id_max_len The maximum length of the buffer
*/
typedef bool (*hawkbit_get_device_identity_cb_handler_t)(char *id, int id_max_len);
/**
* @brief Set the device identity callback.
*
* @details This function is used to set a custom device identity callback.
*
* @param cb The callback function.
*
* @retval 0 on success.
* @retval -EINVAL if the callback is NULL.
*/
int hawkbit_set_device_identity_cb(hawkbit_get_device_identity_cb_handler_t cb);
/**
* @brief Set the hawkBit server configuration settings.
*
* @param config Configuration settings to set.
* @retval 0 on success.
* @retval -EAGAIN if probe is currently running.
*/
int hawkbit_set_config(struct hawkbit_runtime_config *config);
/**
* @brief Get the hawkBit server configuration settings.
*
* @return Configuration settings.
*/
struct hawkbit_runtime_config hawkbit_get_config(void);
/**
* @brief Set the hawkBit server address.
*
* @param addr_str Server address to set.
* @retval 0 on success.
* @retval -EAGAIN if probe is currently running.
*/
static inline int hawkbit_set_server_addr(char *addr_str)
{
struct hawkbit_runtime_config set_config = {
.server_addr = addr_str, .server_port = 0, .auth_token = NULL, .tls_tag = 0};
return hawkbit_set_config(&set_config);
}
/**
* @brief Set the hawkBit server port.
*
* @param port Server port to set.
* @retval 0 on success.
* @retval -EAGAIN if probe is currently running.
*/
static inline int hawkbit_set_server_port(uint16_t port)
{
struct hawkbit_runtime_config set_config = {
.server_addr = NULL, .server_port = port, .auth_token = NULL, .tls_tag = 0};
return hawkbit_set_config(&set_config);
}
/**
* @brief Set the hawkBit security token.
*
* @param token Security token to set.
* @retval 0 on success.
* @retval -EAGAIN if probe is currently running.
*/
static inline int hawkbit_set_ddi_security_token(char *token)
{
struct hawkbit_runtime_config set_config = {
.server_addr = NULL, .server_port = 0, .auth_token = token, .tls_tag = 0};
return hawkbit_set_config(&set_config);
}
/**
* @brief Set the hawkBit TLS tag
*
* @param tag TLS tag to set.
* @retval 0 on success.
* @retval -EAGAIN if probe is currently running.
*/
static inline int hawkbit_set_tls_tag(sec_tag_t tag)
{
struct hawkbit_runtime_config set_config = {
.server_addr = NULL, .server_port = 0, .auth_token = NULL, .tls_tag = tag};
return hawkbit_set_config(&set_config);
}
/**
* @brief Get the hawkBit server address.
*
* @return Server address.
*/
static inline char *hawkbit_get_server_addr(void)
{
return hawkbit_get_config().server_addr;
}
/**
* @brief Get the hawkBit server port.
*
* @return Server port.
*/
static inline uint16_t hawkbit_get_server_port(void)
{
return hawkbit_get_config().server_port;
}
/**
* @brief Get the hawkBit security token.
*
* @return Security token.
*/
static inline char *hawkbit_get_ddi_security_token(void)
{
return hawkbit_get_config().auth_token;
}
/**
* @brief Get the hawkBit TLS tag.
*
* @return TLS tag.
*/
static inline sec_tag_t hawkbit_get_tls_tag(void)
{
return hawkbit_get_config().tls_tag;
}
/**
* @brief Get the hawkBit action id.
*
* @return Action id.
*/
int32_t hawkbit_get_action_id(void);
/**
* @brief Resets the hawkBit action id, that is saved in settings.
*
* @details This should be done after changing the hawkBit server.
*
* @retval 0 on success.
* @retval -EAGAIN if probe is currently running.
* @retval -EIO if the action id could not be reset.
*
*/
int hawkbit_reset_action_id(void);
/**
* @}
*/
#endif /* _HAWKBIT_H_ */
``` | /content/code_sandbox/include/zephyr/mgmt/hawkbit.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 1,744 |
```objective-c
/*
*
*/
/**
* @brief UpdateHub Firmware Over-the-Air for Zephyr Project.
* @defgroup updatehub UpdateHub Firmware Over-the-Air
* @ingroup third_party
* @{
*/
#ifndef ZEPHYR_INCLUDE_MGMT_UPDATEHUB_H_
#define ZEPHYR_INCLUDE_MGMT_UPDATEHUB_H_
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Responses messages from UpdateHub.
*
* @details These messages are used to inform the server and the
* user about the process status of the UpdateHub and also
* used to standardize the errors that may occur.
*
*/
enum updatehub_response {
UPDATEHUB_NETWORKING_ERROR = 0,
UPDATEHUB_INCOMPATIBLE_HARDWARE,
UPDATEHUB_UNCONFIRMED_IMAGE,
UPDATEHUB_METADATA_ERROR,
UPDATEHUB_DOWNLOAD_ERROR,
UPDATEHUB_INSTALL_ERROR,
UPDATEHUB_FLASH_INIT_ERROR,
UPDATEHUB_OK,
UPDATEHUB_HAS_UPDATE,
UPDATEHUB_NO_UPDATE,
};
/**
* @brief Runs UpdateHub probe and UpdateHub update automatically.
*
* @details The updatehub_autohandler handles the whole process
* in pre-determined time intervals.
*/
__syscall void updatehub_autohandler(void);
/**
* @brief The UpdateHub probe verify if there is some update to be performed.
*
* @return UPDATEHUB_HAS_UPDATE has an update available.
* @return UPDATEHUB_NO_UPDATE no update available.
* @return UPDATEHUB_NETWORKING_ERROR fail to connect to the UpdateHub server.
* @return UPDATEHUB_INCOMPATIBLE_HARDWARE if Incompatible hardware.
* @return UPDATEHUB_METADATA_ERROR fail to parse or to encode the metadata.
*/
__syscall enum updatehub_response updatehub_probe(void);
/**
* @brief Apply the update package.
*
* @details Must be used after the UpdateHub probe, if you have updates to
* be made, will perform the installation of the new image and the hardware
* will rebooting.
*
* @return Return UPDATEHUB_OK if success
* @return UPDATEHUB_NETWORKING_ERROR if fail to connect to the server.
* @return UPDATEHUB_DOWNLOAD_ERROR fail while downloading the update package.
* @return UPDATEHUB_INSTALL_ERROR fail while installing the update package.
* @return UPDATEHUB_FLASH_INIT_ERROR fail to initialize the flash.
*/
__syscall enum updatehub_response updatehub_update(void);
/**
* @brief Confirm that image is running as expected.
*
* @details Must be used before the UpdateHub probe. It should be one of first
* actions after reboot.
*
* @return Return 0 if success otherwise a negative 'errno' value.
*/
__syscall int updatehub_confirm(void);
/**
* @brief Request system to reboot.
*
* @return Return 0 if success otherwise a negative 'errno' value.
*/
__syscall int updatehub_reboot(void);
#ifdef __cplusplus
}
#endif
/**
* @}
*/
#include <zephyr/syscalls/updatehub.h>
#endif /* ZEPHYR_INCLUDE_MGMT_UPDATEHUB_H_ */
``` | /content/code_sandbox/include/zephyr/mgmt/updatehub.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 644 |
```objective-c
/*
*
*/
#ifndef H_SMP_CLIENT_
#define H_SMP_CLIENT_
#include <zephyr/kernel.h>
#include <zephyr/net/buf.h>
#include <mgmt/mcumgr/transport/smp_internal.h>
#include <zephyr/mgmt/mcumgr/smp/smp.h>
#include <zephyr/mgmt/mcumgr/transport/smp.h>
/**
* @brief MCUmgr SMP client API
* @defgroup mcumgr_smp_client SMP client API
* @ingroup mcumgr
* @{
*/
/**
* @brief SMP client object
*/
struct smp_client_object {
/** Must be the first member. */
struct k_work work;
/** FIFO for client TX queue */
struct k_fifo tx_fifo;
/** SMP transport object */
struct smp_transport *smpt;
/** SMP SEQ */
uint8_t smp_seq;
};
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initialize a SMP client object.
*
* @param smp_client The Client to construct.
* @param smp_type SMP transport type for discovering transport object
*
* @return 0 if successful
* @return mcumgr_err_t code on failure
*/
int smp_client_object_init(struct smp_client_object *smp_client, int smp_type);
/**
* @brief Response callback for SMP send.
*
* @param nb net_buf for response
* @param user_data same user data that was provided as part of the request
*
* @return 0 on success.
* @return @ref mcumgr_err_t code on failure.
*/
typedef int (*smp_client_res_fn)(struct net_buf *nb, void *user_data);
/**
* @brief SMP client response handler.
*
* @param nb response net_buf
* @param res_hdr Parsed SMP header
*
* @return 0 on success.
* @return @ref mcumgr_err_t code on failure.
*/
int smp_client_single_response(struct net_buf *nb, const struct smp_hdr *res_hdr);
/**
* @brief Allocate buffer and initialize with SMP header.
*
* @param smp_client SMP client object
* @param group SMP group id
* @param command_id SMP command id
* @param op SMP operation type
* @param version SMP MCUmgr version
*
* @return A newly-allocated buffer net_buf on success
* @return NULL on failure.
*/
struct net_buf *smp_client_buf_allocation(struct smp_client_object *smp_client, uint16_t group,
uint8_t command_id, uint8_t op,
enum smp_mcumgr_version_t version);
/**
* @brief Free a SMP client buffer.
*
* @param nb The net_buf to free.
*/
void smp_client_buf_free(struct net_buf *nb);
/**
* @brief SMP client data send request.
*
* @param smp_client SMP client object
* @param nb net_buf packet for send
* @param cb Callback for response handler
* @param user_data user defined data pointer which will be returned back to response callback
* @param timeout_in_sec Timeout in seconds for send process. Client will retry transport
* based CONFIG_SMP_CMD_RETRY_TIME
*
* @return 0 on success.
* @return @ref mcumgr_err_t code on failure.
*/
int smp_client_send_cmd(struct smp_client_object *smp_client, struct net_buf *nb,
smp_client_res_fn cb, void *user_data, int timeout_in_sec);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* H_SMP_CLIENT_ */
``` | /content/code_sandbox/include/zephyr/mgmt/mcumgr/smp/smp_client.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 762 |
```objective-c
/*
*
*/
/**
* @file
* @brief Open Supervised Device Protocol (OSDP) public API header file.
*/
#ifndef _OSDP_H_
#define _OSDP_H_
#include <zephyr/kernel.h>
#include <stdint.h>
#include <zephyr/sys/slist.h>
#ifdef __cplusplus
extern "C" {
#endif
#define OSDP_CMD_TEXT_MAX_LEN 32 /**< Max length of text for text command */
#define OSDP_CMD_KEYSET_KEY_MAX_LEN 32 /**< Max length of key data for keyset command */
#define OSDP_EVENT_MAX_DATALEN 64 /**< Max length of event data */
/**
* @brief Command sent from CP to Control digital output of PD.
*/
struct osdp_cmd_output {
/**
* Output number.
*
* 0 = First Output, 1 = Second Output, etc.
*/
uint8_t output_no;
/**
* Control code.
*
* - 0 - NOP do not alter this output
* - 1 - set the permanent state to OFF, abort timed operation (if any)
* - 2 - set the permanent state to ON, abort timed operation (if any)
* - 3 - set the permanent state to OFF, allow timed operation to complete
* - 4 - set the permanent state to ON, allow timed operation to complete
* - 5 - set the temporary state to ON, resume perm state on timeout
* - 6 - set the temporary state to OFF, resume permanent state on timeout
*/
uint8_t control_code;
/**
* Time in units of 100 ms
*/
uint16_t timer_count;
};
/**
* @brief LED Colors as specified in OSDP for the on_color/off_color parameters.
*/
enum osdp_led_color_e {
OSDP_LED_COLOR_NONE, /**< No color */
OSDP_LED_COLOR_RED, /**< Red */
OSDP_LED_COLOR_GREEN, /**< Green */
OSDP_LED_COLOR_AMBER, /**< Amber */
OSDP_LED_COLOR_BLUE, /**< Blue */
OSDP_LED_COLOR_SENTINEL /**< Max value */
};
/**
* @brief LED params sub-structure. Part of LED command. See @ref osdp_cmd_led.
*/
struct osdp_cmd_led_params {
/** Control code.
*
* Temporary Control Code:
* - 0 - NOP - do not alter this LED's temporary settings.
* - 1 - Cancel any temporary operation and display this LED's permanent state immediately.
* - 2 - Set the temporary state as given and start timer immediately.
*
* Permanent Control Code:
* - 0 - NOP - do not alter this LED's permanent settings.
* - 1 - Set the permanent state as given.
*/
uint8_t control_code;
/**
* The ON duration of the flash, in units of 100 ms.
*/
uint8_t on_count;
/**
* The OFF duration of the flash, in units of 100 ms.
*/
uint8_t off_count;
/**
* Color to set during the ON timer (see @ref osdp_led_color_e).
*/
uint8_t on_color;
/**
* Color to set during the OFF timer (see @ref osdp_led_color_e).
*/
uint8_t off_color;
/**
* Time in units of 100 ms (only for temporary mode).
*/
uint16_t timer_count;
};
/**
* @brief Sent from CP to PD to control the behaviour of it's on-board LEDs
*/
struct osdp_cmd_led {
/**
* Reader number. 0 = First Reader, 1 = Second Reader, etc.
*/
uint8_t reader;
/**
* LED number. 0 = first LED, 1 = second LED, etc.
*/
uint8_t led_number;
/**
* Ephemeral LED status descriptor.
*/
struct osdp_cmd_led_params temporary;
/**
* Permanent LED status descriptor.
*/
struct osdp_cmd_led_params permanent;
};
/**
* @brief Sent from CP to control the behaviour of a buzzer in the PD.
*/
struct osdp_cmd_buzzer {
/**
* Reader number. 0 = First Reader, 1 = Second Reader, etc.
*/
uint8_t reader;
/**
* Control code.
* - 0 - no tone
* - 1 - off
* - 2 - default tone
* - 3+ - TBD
*/
uint8_t control_code;
/**
* The ON duration of the sound, in units of 100 ms.
*/
uint8_t on_count;
/**
* The OFF duration of the sound, in units of 100 ms.
*/
uint8_t off_count;
/**
* The number of times to repeat the ON/OFF cycle; 0: forever.
*/
uint8_t rep_count;
};
/**
* @brief Command to manipulate any display units that the PD supports.
*/
struct osdp_cmd_text {
/**
* Reader number. 0 = First Reader, 1 = Second Reader, etc.
*/
uint8_t reader;
/**
* Control code.
* - 1 - permanent text, no wrap
* - 2 - permanent text, with wrap
* - 3 - temp text, no wrap
* - 4 - temp text, with wrap
*/
uint8_t control_code;
/**
* Duration to display temporary text, in seconds
*/
uint8_t temp_time;
/**
* Row to display the first character (1-indexed)
*/
uint8_t offset_row;
/**
* Column to display the first character (1-indexed)
*/
uint8_t offset_col;
/**
* Number of characters in the string
*/
uint8_t length;
/**
* The string to display
*/
uint8_t data[OSDP_CMD_TEXT_MAX_LEN];
};
/**
* @brief Sent in response to a COMSET command. Set communication parameters to
* PD. Must be stored in PD non-volatile memory.
*/
struct osdp_cmd_comset {
/**
* Unit ID to which this PD will respond after the change takes effect.
*/
uint8_t address;
/**
* Baud rate.
*
* Valid values: 9600, 19200, 38400, 115200, 230400.
*/
uint32_t baud_rate;
};
/**
* @brief This command transfers an encryption key from the CP to a PD.
*
* @param type Type of keys:
* - 0x01 Secure Channel Base Key
* @param length Number of bytes of key data - (Key Length in bits + 7) / 8
* @param data Key data
*/
struct osdp_cmd_keyset {
/**
* Type of keys:
* - 0x01 Secure Channel Base Key
*/
uint8_t type;
/**
* Number of bytes of key data - (Key Length in bits + 7) / 8
*/
uint8_t length;
/**
* Key data
*/
uint8_t data[OSDP_CMD_KEYSET_KEY_MAX_LEN];
};
/**
* @brief OSDP application exposed commands
*/
enum osdp_cmd_e {
OSDP_CMD_OUTPUT = 1, /**< Output control command */
OSDP_CMD_LED, /**< Reader LED control command */
OSDP_CMD_BUZZER, /**< Reader buzzer control command */
OSDP_CMD_TEXT, /**< Reader text output command */
OSDP_CMD_KEYSET, /**< Encryption Key Set Command */
OSDP_CMD_COMSET, /**< PD Communication Configuration Command */
OSDP_CMD_SENTINEL /**< Max command value */
};
/**
* @brief OSDP Command Structure. This is a wrapper for all individual OSDP
* commands.
*/
struct osdp_cmd {
/** @cond INTERNAL_HIDDEN */
sys_snode_t node;
/** @endcond */
/**
* Command ID.
* Used to select specific commands in union.
*/
enum osdp_cmd_e id;
/** Command */
union {
struct osdp_cmd_led led; /**< LED command structure */
struct osdp_cmd_buzzer buzzer; /**< Buzzer command structure */
struct osdp_cmd_text text; /**< Text command structure */
struct osdp_cmd_output output; /**< Output command structure */
struct osdp_cmd_comset comset; /**< Comset command structure */
struct osdp_cmd_keyset keyset; /**< Keyset command structure */
};
};
/**
* @brief Various card formats that a PD can support. This is sent to CP
* when a PD must report a card read.
*/
enum osdp_event_cardread_format_e {
OSDP_CARD_FMT_RAW_UNSPECIFIED, /**< Unspecified card format */
OSDP_CARD_FMT_RAW_WIEGAND, /**< Wiegand card format */
OSDP_CARD_FMT_ASCII, /**< ASCII card format */
OSDP_CARD_FMT_SENTINEL /**< Max card format value */
};
/**
* @brief OSDP event cardread
*
* @note When @a format is set to OSDP_CARD_FMT_RAW_UNSPECIFIED or
* OSDP_CARD_FMT_RAW_WIEGAND, the length is expressed in bits. OTOH, when it is
* set to OSDP_CARD_FMT_ASCII, the length is in bytes. The number of bytes to
* read from the @a data field must be interpreted accordingly.
*/
struct osdp_event_cardread {
/**
* Reader number. 0 = First Reader, 1 = Second Reader, etc.
*/
int reader_no;
/**
* Format of the card being read.
*/
enum osdp_event_cardread_format_e format;
/**
* Direction of data in @a data array.
* - 0 - Forward
* - 1 - Backward
*/
int direction;
/**
* Length of card data in bytes or bits depending on @a format
*/
int length;
/**
* Card data of @a length bytes or bits bits depending on @a format
*/
uint8_t data[OSDP_EVENT_MAX_DATALEN];
};
/**
* @brief OSDP Event Keypad
*/
struct osdp_event_keypress {
/**
* Reader number.
* In context of readers attached to current PD, this number indicated this number. This is
* not supported by LibOSDP.
*/
int reader_no;
/**
* Length of keypress data in bytes
*/
int length;
/**
* Keypress data of @a length bytes
*/
uint8_t data[OSDP_EVENT_MAX_DATALEN];
};
/**
* @brief OSDP PD Events
*/
enum osdp_event_type {
OSDP_EVENT_CARDREAD, /**< Card read event */
OSDP_EVENT_KEYPRESS, /**< Keypad press event */
OSDP_EVENT_SENTINEL /**< Max event value */
};
/**
* @brief OSDP Event structure.
*/
struct osdp_event {
/** @cond INTERNAL_HIDDEN */
sys_snode_t node;
/** @endcond */
/**
* Event type.
* Used to select specific event in union.
*/
enum osdp_event_type type;
/** Event */
union {
struct osdp_event_keypress keypress; /**< Keypress event structure */
struct osdp_event_cardread cardread; /**< Card read event structure */
};
};
/**
* @brief Callback for PD command notifications. After it has been registered
* with `osdp_pd_set_command_callback`, this method is invoked when the PD
* receives a command from the CP.
*
* @param arg pointer that will was passed to the arg param of
* `osdp_pd_set_command_callback`.
* @param cmd pointer to the received command.
*
* @retval 0 if LibOSDP must send a `osdp_ACK` response
* @retval -ve if LibOSDP must send a `osdp_NAK` response
* @retval +ve and modify the passed `struct osdp_cmd *cmd` if LibOSDP must send
* a specific response. This is useful for sending manufacturer specific
* reply ``osdp_MFGREP``.
*/
typedef int (*pd_command_callback_t)(void *arg, struct osdp_cmd *cmd);
/**
* @brief Callback for CP event notifications. After it has been registered with
* `osdp_cp_set_event_callback`, this method is invoked when the CP receives an
* event from the PD.
*
* @param arg Opaque pointer provided by the application during callback
* registration.
* @param pd the offset (0-indexed) of this PD in kconfig `OSDP_PD_ADDRESS_LIST`
* @param ev pointer to osdp_event struct (filled by libosdp).
*
* @retval 0 on handling the event successfully.
* @retval -ve on errors.
*/
typedef int (*cp_event_callback_t)(void *arg, int pd, struct osdp_event *ev);
#if defined(CONFIG_OSDP_MODE_PD) || defined(__DOXYGEN__)
/**
* @name Peripheral Device mode APIs
* @note These are only available when @kconfig{CONFIG_OSDP_MODE_PD} is enabled.
* @{
*/
/**
* @brief Set callback method for PD command notification. This callback is
* invoked when the PD receives a command from the CP.
*
* @param cb The callback function's pointer
* @param arg A pointer that will be passed as the first argument of `cb`
*/
void osdp_pd_set_command_callback(pd_command_callback_t cb, void *arg);
/**
* @brief API to notify PD events to CP. These events are sent to the CP as an
* alternate response to a POLL command.
*
* @param event pointer to event struct. Must be filled by application.
*
* @retval 0 on success
* @retval -1 on failure
*/
int osdp_pd_notify_event(const struct osdp_event *event);
/**
* @}
*/
#else /* CONFIG_OSDP_MODE_PD */
/**
* @brief Generic command enqueue API.
*
* @param pd the offset (0-indexed) of this PD in kconfig `OSDP_PD_ADDRESS_LIST`
* @param cmd command pointer. Must be filled by application.
*
* @retval 0 on success
* @retval -1 on failure
*
* @note This method only adds the command on to a particular PD's command
* queue. The command itself can fail due to various reasons.
*/
int osdp_cp_send_command(int pd, struct osdp_cmd *cmd);
/**
* @brief Set callback method for CP event notification. This callback is
* invoked when the CP receives an event from the PD.
*
* @param cb The callback function's pointer
* @param arg A pointer that will be passed as the first argument of `cb`
*/
void osdp_cp_set_event_callback(cp_event_callback_t cb, void *arg);
#endif /* CONFIG_OSDP_MODE_PD */
#if defined(CONFIG_OSDP_SC_ENABLED) || defined(__DOXYGEN__)
/**
* @name OSDP Secure Channel APIs
* @note These are only available when @kconfig{CONFIG_OSDP_SC_ENABLED} is
* enabled.
* @{
*/
/**
* Get the current SC status mask.
* @return SC status mask
*/
uint32_t osdp_get_sc_status_mask(void);
/**
* @}
*/
#endif
#ifdef __cplusplus
}
#endif
#endif /* _OSDP_H_ */
``` | /content/code_sandbox/include/zephyr/mgmt/osdp.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 3,278 |
```objective-c
/*
*
*/
#ifndef ZEPHYR_INCLUDE_ZEPHYR_MCUMGR_GRP_ZBASIC_H_
#define ZEPHYR_INCLUDE_ZEPHYR_MCUMGR_GRP_ZBASIC_H_
#ifdef __cplusplus
extern "C" {
#endif
/**
* Command IDs for zephyr basic management group.
*/
#define ZEPHYR_MGMT_GRP_BASIC_CMD_ERASE_STORAGE 0 /* Command to erase storage partition */
/**
* Command result codes for statistics management group.
*/
enum zephyr_basic_group_err_code_t {
/** No error, this is implied if there is no ret value in the response */
ZEPHYRBASIC_MGMT_ERR_OK = 0,
/** Unknown error occurred. */
ZEPHYRBASIC_MGMT_ERR_UNKNOWN,
/** Opening of the flash area has failed. */
ZEPHYRBASIC_MGMT_ERR_FLASH_OPEN_FAILED,
/** Querying the flash area parameters has failed. */
ZEPHYRBASIC_MGMT_ERR_FLASH_CONFIG_QUERY_FAIL,
/** Erasing the flash area has failed. */
ZEPHYRBASIC_MGMT_ERR_FLASH_ERASE_FAILED,
};
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_INCLUDE_ZEPHYR_MCUMGR_GRP_ZBASIC_H_ */
``` | /content/code_sandbox/include/zephyr/mgmt/mcumgr/grp/zephyr/zephyr_basic.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 259 |
```objective-c
/*
*
*/
/**
* @file
* @brief SMP - Simple Management Protocol.
*
* SMP is a basic protocol that sits on top of the mgmt layer. SMP requests
* and responses have the following format:
*
* [Offset 0]: Mgmt header
* [Offset 8]: CBOR map of command-specific key-value pairs.
*
* SMP request packets may contain multiple concatenated requests. Each
* request must start at an offset that is a multiple of 4, so padding should
* be inserted between requests as necessary. Requests are processed
* sequentially from the start of the packet to the end. Each response is sent
* individually in its own packet. If a request elicits an error response,
* processing of the packet is aborted.
*/
#ifndef H_SMP_
#define H_SMP_
#include <zephyr/net/buf.h>
#include <zephyr/mgmt/mcumgr/transport/smp.h>
#include <zcbor_common.h>
#ifdef __cplusplus
extern "C" {
#endif
/** SMP MCUmgr protocol version, part of the SMP header */
enum smp_mcumgr_version_t {
/** Version 1: the original protocol */
SMP_MCUMGR_VERSION_1 = 0,
/** Version 2: adds more detailed error reporting capabilities */
SMP_MCUMGR_VERSION_2,
};
struct cbor_nb_reader {
struct net_buf *nb;
/* CONFIG_MCUMGR_SMP_CBOR_MAX_DECODING_LEVELS + 2 translates to minimal
* zcbor backup states.
*/
zcbor_state_t zs[CONFIG_MCUMGR_SMP_CBOR_MAX_DECODING_LEVELS + 2];
};
struct cbor_nb_writer {
struct net_buf *nb;
zcbor_state_t zs[CONFIG_MCUMGR_SMP_CBOR_MAX_ENCODING_LEVELS + 2];
#if defined(CONFIG_MCUMGR_SMP_SUPPORT_ORIGINAL_PROTOCOL)
uint16_t error_group;
uint16_t error_ret;
#endif
};
/**
* @brief Allocates a net_buf for holding an mcumgr request or response.
*
* @return A newly-allocated buffer net_buf on success;
* NULL on failure.
*/
struct net_buf *smp_packet_alloc(void);
/**
* @brief Frees an mcumgr net_buf
*
* @param nb The net_buf to free.
*/
void smp_packet_free(struct net_buf *nb);
/**
* @brief Decodes, encodes, and transmits SMP packets.
*/
struct smp_streamer {
struct smp_transport *smpt;
struct cbor_nb_reader *reader;
struct cbor_nb_writer *writer;
#ifdef CONFIG_MCUMGR_SMP_VERBOSE_ERR_RESPONSE
const char *rc_rsn;
#endif
};
/**
* @brief Processes a single SMP request packet and sends all corresponding responses.
*
* Processes all SMP requests in an incoming packet. Requests are processed
* sequentially from the start of the packet to the end. Each response is sent
* individually in its own packet. If a request elicits an error response,
* processing of the packet is aborted. This function consumes the supplied
* request buffer regardless of the outcome.
*
* @param streamer The streamer providing the required SMP callbacks.
* @param req The request packet to process.
*
* @return 0 on success, #mcumgr_err_t code on failure.
*/
int smp_process_request_packet(struct smp_streamer *streamer, void *req);
/**
* @brief Appends an "err" response
*
* This appends an err response to a pending outgoing response which contains a
* result code for a specific group. Note that error codes are specific to the
* command group they are emitted from).
*
* @param zse The zcbor encoder to use.
* @param group The group which emitted the error.
* @param ret The command result code to add.
*
* @return true on success, false on failure (memory error).
*/
bool smp_add_cmd_err(zcbor_state_t *zse, uint16_t group, uint16_t ret);
/** @deprecated Deprecated after Zephyr 3.4, use smp_add_cmd_err() instead */
__deprecated inline bool smp_add_cmd_ret(zcbor_state_t *zse, uint16_t group, uint16_t ret)
{
return smp_add_cmd_err(zse, group, ret);
}
#if defined(CONFIG_MCUMGR_SMP_SUPPORT_ORIGINAL_PROTOCOL)
/** @typedef smp_translate_error_fn
* @brief Translates a SMP version 2 error response to a legacy SMP version 1 error code.
*
* @param ret The SMP version 2 group error value.
*
* @return #enum mcumgr_err_t Legacy SMP version 1 error code to return to client.
*/
typedef int (*smp_translate_error_fn)(uint16_t err);
#endif
#ifdef __cplusplus
}
#endif
#endif /* H_SMP_ */
``` | /content/code_sandbox/include/zephyr/mgmt/mcumgr/smp/smp.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 1,046 |
```objective-c
/*
*
*/
#ifndef H_FS_MGMT_
#define H_FS_MGMT_
#ifdef __cplusplus
extern "C" {
#endif
/**
* Command IDs for file system management group.
*/
#define FS_MGMT_ID_FILE 0
#define FS_MGMT_ID_STAT 1
#define FS_MGMT_ID_HASH_CHECKSUM 2
#define FS_MGMT_ID_SUPPORTED_HASH_CHECKSUM 3
#define FS_MGMT_ID_OPENED_FILE 4
/**
* Command result codes for file system management group.
*/
enum fs_mgmt_err_code_t {
/** No error, this is implied if there is no ret value in the response */
FS_MGMT_ERR_OK = 0,
/** Unknown error occurred. */
FS_MGMT_ERR_UNKNOWN,
/** The specified file name is not valid. */
FS_MGMT_ERR_FILE_INVALID_NAME,
/** The specified file does not exist. */
FS_MGMT_ERR_FILE_NOT_FOUND,
/** The specified file is a directory, not a file. */
FS_MGMT_ERR_FILE_IS_DIRECTORY,
/** Error occurred whilst attempting to open a file. */
FS_MGMT_ERR_FILE_OPEN_FAILED,
/** Error occurred whilst attempting to seek to an offset in a file. */
FS_MGMT_ERR_FILE_SEEK_FAILED,
/** Error occurred whilst attempting to read data from a file. */
FS_MGMT_ERR_FILE_READ_FAILED,
/** Error occurred whilst trying to truncate file. */
FS_MGMT_ERR_FILE_TRUNCATE_FAILED,
/** Error occurred whilst trying to delete file. */
FS_MGMT_ERR_FILE_DELETE_FAILED,
/** Error occurred whilst attempting to write data to a file. */
FS_MGMT_ERR_FILE_WRITE_FAILED,
/**
* The specified data offset is not valid, this could indicate that the file on the device
* has changed since the previous command. The length of the current file on the device is
* returned as "len", the user application needs to decide how to handle this (e.g. the
* hash of the file could be requested and compared with the hash of the length of the
* file being uploaded to see if they match or not).
*/
FS_MGMT_ERR_FILE_OFFSET_NOT_VALID,
/** The requested offset is larger than the size of the file on the device. */
FS_MGMT_ERR_FILE_OFFSET_LARGER_THAN_FILE,
/** The requested checksum or hash type was not found or is not supported by this build. */
FS_MGMT_ERR_CHECKSUM_HASH_NOT_FOUND,
/** The specified mount point was not found or is not mounted. */
FS_MGMT_ERR_MOUNT_POINT_NOT_FOUND,
/** The specified mount point is that of a read-only filesystem. */
FS_MGMT_ERR_READ_ONLY_FILESYSTEM,
/** The operation cannot be performed because the file is empty with no contents. */
FS_MGMT_ERR_FILE_EMPTY,
};
#ifdef __cplusplus
}
#endif
#endif
``` | /content/code_sandbox/include/zephyr/mgmt/mcumgr/grp/fs_mgmt/fs_mgmt.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 607 |
```objective-c
/*
*
*/
#ifndef H_MGMT_MCUMGR_GRP_FS_MGMT_CHKSUM_
#define H_MGMT_MCUMGR_GRP_FS_MGMT_CHKSUM_
#include <zephyr/kernel.h>
#include <zephyr/fs/fs.h>
#ifdef __cplusplus
extern "C" {
#endif
/** @typedef fs_mgmt_hash_checksum_handler_fn
* @brief Function that gets called to generate a hash or checksum.
*
* @param file Opened file context
* @param output Output buffer for hash/checksum
* @param out_len Updated with size of input data
* @param len Maximum length of data to perform hash/checksum on
*
* @return 0 on success, negative error code on failure.
*/
typedef int (*fs_mgmt_hash_checksum_handler_fn)(struct fs_file_t *file, uint8_t *output,
size_t *out_len, size_t len);
/**
* @brief A collection of handlers for an entire hash/checksum group.
*/
struct fs_mgmt_hash_checksum_group {
/** Entry list node. */
sys_snode_t node;
/** Array of handlers; one entry per name. */
const char *group_name;
/** Byte string or numerical output. */
bool byte_string;
/** Size (in bytes) of output. */
uint8_t output_size;
/** Hash/checksum function pointer. */
fs_mgmt_hash_checksum_handler_fn function;
};
/** @typedef fs_mgmt_hash_checksum_list_cb
* @brief Function that gets called with hash/checksum details
*
* @param group Details about a supported hash/checksum
* @param user_data User-supplied value to calling function
*/
typedef void (*fs_mgmt_hash_checksum_list_cb)(const struct fs_mgmt_hash_checksum_group *group,
void *user_data);
/**
* @brief Registers a full hash/checksum group.
*
* @param group The group to register.
*/
void fs_mgmt_hash_checksum_register_group(struct fs_mgmt_hash_checksum_group *group);
/**
* @brief Unregisters a full hash/checksum group.
*
* @param group The group to register.
*/
void fs_mgmt_hash_checksum_unregister_group(struct fs_mgmt_hash_checksum_group *group);
/**
* @brief Finds a registered hash/checksum handler.
*
* @param name The name of the hash/checksum group to find.
*
* @return The requested hash/checksum handler on success;
* NULL on failure.
*/
const struct fs_mgmt_hash_checksum_group *fs_mgmt_hash_checksum_find_handler(const char *name);
/**
* @brief Runs a callback with all supported hash/checksum types.
*
* @param cb The callback function to call with each hash/checksum type.
* @param user_data Data to pass back with the callback function.
*/
void fs_mgmt_hash_checksum_find_handlers(fs_mgmt_hash_checksum_list_cb cb, void *user_data);
#ifdef __cplusplus
}
#endif
#endif /* ifndef H_MGMT_MCUMGR_GRP_FS_MGMT_CHKSUM_ */
``` | /content/code_sandbox/include/zephyr/mgmt/mcumgr/grp/fs_mgmt/fs_mgmt_hash_checksum.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 605 |
```objective-c
/*
*
*/
#ifndef H_MCUMGR_FS_MGMT_CALLBACKS_
#define H_MCUMGR_FS_MGMT_CALLBACKS_
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief MCUmgr fs_mgmt callback API
* @defgroup mcumgr_callback_api_fs_mgmt MCUmgr fs_mgmt callback API
* @ingroup mcumgr_callback_api
* @{
*/
/** The type of operation that is being requested for a given file access callback. */
enum fs_mgmt_file_access_types {
/** Access to read file (file upload). */
FS_MGMT_FILE_ACCESS_READ,
/** Access to write file (file download). */
FS_MGMT_FILE_ACCESS_WRITE,
/** Access to get status of file. */
FS_MGMT_FILE_ACCESS_STATUS,
/** Access to calculate hash or checksum of file. */
FS_MGMT_FILE_ACCESS_HASH_CHECKSUM,
};
/**
* Structure provided in the #MGMT_EVT_OP_FS_MGMT_FILE_ACCESS notification callback: This callback
* function is used to notify the application about a pending file read/write request and to
* authorise or deny it. Access will be allowed so long as all notification handlers return
* #MGMT_ERR_EOK, if one returns an error then access will be denied.
*/
struct fs_mgmt_file_access {
/** Specifies the type of the operation that is being requested. */
enum fs_mgmt_file_access_types access;
/**
* Path and filename of file be accesses, note that this can be changed by handlers to
* redirect file access if needed (as long as it does not exceed the maximum path string
* size).
*/
char *filename;
};
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif
``` | /content/code_sandbox/include/zephyr/mgmt/mcumgr/grp/fs_mgmt/fs_mgmt_callbacks.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 354 |
```objective-c
/*
*
*/
#ifndef H_MCUMGR_SETTINGS_MGMT_CALLBACKS_
#define H_MCUMGR_SETTINGS_MGMT_CALLBACKS_
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief MCUmgr settings_mgmt callback API
* @defgroup mcumgr_callback_api_settings_mgmt MCUmgr settings_mgmt callback API
* @ingroup mcumgr_callback_api
* @{
*/
enum settings_mgmt_access_types {
SETTINGS_ACCESS_READ,
SETTINGS_ACCESS_WRITE,
SETTINGS_ACCESS_DELETE,
SETTINGS_ACCESS_COMMIT,
SETTINGS_ACCESS_LOAD,
SETTINGS_ACCESS_SAVE,
};
/**
* Structure provided in the #MGMT_EVT_OP_SETTINGS_MGMT_ACCESS notification callback: This
* callback function is used to notify the application about a pending setting
* read/write/delete/load/save/commit request and to authorise or deny it. Access will be allowed
* so long as no handlers return an error, if one returns an error then access will be denied.
*/
struct settings_mgmt_access {
/** Type of access */
enum settings_mgmt_access_types access;
/**
* Key name for accesses (only set for SETTINGS_ACCESS_READ, SETTINGS_ACCESS_WRITE and
* SETTINGS_ACCESS_DELETE). Note that this can be changed by handlers to redirect settings
* access if needed (as long as it does not exceed the maximum setting string size) if
* CONFIG_MCUMGR_GRP_SETTINGS_BUFFER_TYPE_STACK is selected, of maximum size
* CONFIG_MCUMGR_GRP_SETTINGS_NAME_LEN.
*
* Note: This string *must* be NULL terminated.
*/
#ifdef CONFIG_MCUMGR_GRP_SETTINGS_BUFFER_TYPE_HEAP
const char *name;
#else
char *name;
#endif
/** Data provided by the user (only set for SETTINGS_ACCESS_WRITE) */
const uint8_t *val;
/** Length of data provided by the user (only set for SETTINGS_ACCESS_WRITE) */
const size_t *val_length;
};
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif
``` | /content/code_sandbox/include/zephyr/mgmt/mcumgr/grp/settings_mgmt/settings_mgmt_callbacks.h | objective-c | 2016-05-26T17:54:19 | 2024-08-16T18:09:06 | zephyr | zephyrproject-rtos/zephyr | 10,307 | 403 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.