Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,071 changes: 2,071 additions & 0 deletions include/zephyr/bluetooth/classic/bip.h

Large diffs are not rendered by default.

74 changes: 74 additions & 0 deletions include/zephyr/bluetooth/classic/obex.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@
#include <errno.h>
#include <stdbool.h>

#include <zephyr/bluetooth/uuid.h>

#ifdef __cplusplus
extern "C" {
#endif

#define BT_OBEX_MIN_MTU 255

/** @brief OBEX Response Code. */
enum __packed bt_obex_rsp_code {
/** Continue */
Expand Down Expand Up @@ -1151,6 +1155,57 @@ int bt_obex_add_header_body(struct net_buf *buf, uint16_t len, const uint8_t *bo
*/
int bt_obex_add_header_end_body(struct net_buf *buf, uint16_t len, const uint8_t *body);

/** @brief Add Header: a chunk (may be a final chunk) of the object body.
*
* The function is used to help to add body/end body for the upperlayer.
* When the tail room of the buffer is more than the passed body room, and the total length of
* buffer is not more than the mopl if the body has been added, the header end body will be
* added. Or, the header body will be added.
*
* @param buf Buffer needs to be sent.
* @param mopl The MOPL of the OBEX connection
* @param len Length of body.
* @param body Object Body.
* @param added_len The added length.
*
* @return 0 in case of success or negative value in case of error.
*/
static inline int bt_obex_add_header_body_or_end_body(struct net_buf *buf, uint16_t mopl,
uint16_t len, const uint8_t *body,
uint16_t *added_len)
{
uint16_t tx_len;
int err;

if ((buf == NULL) || (body == NULL) || (added_len == NULL) || (mopl < BT_OBEX_MIN_MTU) ||
(len == 0)) {
return -EINVAL;
}

tx_len = BT_OBEX_PDU_LEN(mopl);
if (tx_len <= buf->len) {
return -ENOMEM;
}

*added_len = 0;

tx_len = MIN((tx_len - buf->len), net_buf_tailroom(buf));
if (tx_len <= BT_OBEX_HDR_LEN_OF_HEADER_BODY) {
return 0;
}

tx_len = BT_OBEX_DATA_LEN_OF_HEADER_BODY(tx_len);
if (tx_len >= len) {
*added_len = len;
err = bt_obex_add_header_end_body(buf, len, body);
} else {
*added_len = tx_len;
err = bt_obex_add_header_body(buf, tx_len, body);
}

return err;
}

/** @brief Add Header: identifies the OBEX application, used to tell if talking to a peer.
*
* @param buf Buffer needs to be sent.
Expand Down Expand Up @@ -1671,6 +1726,25 @@ int bt_obex_get_header_srm_param(struct net_buf *buf, uint8_t *srm_param);
*/
int bt_obex_make_uuid(union bt_obex_uuid *uuid, const uint8_t *data, uint16_t len);

/** @brief Check if the string is valid
*
* @param id HEADER ID.
* @param len The length of string.
* @param str The address of string.
*
* @return true if the string is valid or false otherwise.
*/
bool bt_obex_string_is_valid(uint8_t id, uint16_t len, const uint8_t *str);

/** @brief Check whether the buf has the specified header
*
* @param buf Buffer needs to be sent.
* @param id The id of the header.
*
* @return true if the header is found or false otherwise.
*/
bool bt_obex_has_header(struct net_buf *buf, uint8_t id);

#ifdef __cplusplus
}
#endif
Expand Down
49 changes: 49 additions & 0 deletions include/zephyr/bluetooth/classic/sdp.h
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,32 @@ struct bt_sdp_record {
{ BT_SDP_TYPE_SIZE(BT_SDP_UINT16), BT_SDP_ARRAY_16(_features) } \
}

/**
* @brief SDP Supported Capabilities Attribute Declaration Macro.
*
* Helper macro to declare supported capabilities of a profile/protocol.
*
* @param _capabilities Capability mask as 8bit unsigned integer.
*/
#define BT_SDP_SUPPORTED_CAPABILITIES(_capabilities) \
{ \
BT_SDP_ATTR_SUPPORTED_CAPABILITIES, \
{ BT_SDP_TYPE_SIZE(BT_SDP_UINT8), BT_SDP_ARRAY_8(_capabilities) } \
}

/**
* @brief SDP Supported Functions Attribute Declaration Macro.
*
* Helper macro to declare supported functions of a profile/protocol.
*
* @param _functions Function mask as 32bit unsigned integer.
*/
#define BT_SDP_SUPPORTED_FUNCTIONS(_functions) \
{ \
BT_SDP_ATTR_SUPPORTED_FUNCTIONS, \
{ BT_SDP_TYPE_SIZE(BT_SDP_UINT32), BT_SDP_ARRAY_32(_functions) } \
}

/**
* @brief SDP Service Declaration Macro.
*
Expand Down Expand Up @@ -672,6 +698,7 @@ int bt_sdp_discover_cancel(struct bt_conn *conn,
/** @brief Protocols to be asked about specific parameters */
enum bt_sdp_proto {
BT_SDP_PROTO_RFCOMM = 0x0003,
BT_SDP_PROTO_OBEX = 0x0008,
BT_SDP_PROTO_AVDTP = 0x0019,
BT_SDP_PROTO_L2CAP = 0x0100,
};
Expand Down Expand Up @@ -737,6 +764,28 @@ int bt_sdp_get_profile_version(const struct net_buf *buf, uint16_t profile,
*/
int bt_sdp_get_features(const struct net_buf *buf, uint16_t *features);

/** @brief Get supported functions attribute value
*
* Allows if exposed by remote retrieve supported functions attribute.
*
* @param buf Buffer holding original raw record data from remote.
* @param functions On success object to be populated with support functions.
*
* @return 0 on success if feature found and valid, negative in case any error
*/
int bt_sdp_get_functions(const struct net_buf *buf, uint32_t *functions);

/** @brief Get GOEP L2CAP PSM attribute value
*
* Allows if exposed by remote retrieve supported GOEP L2CAP PSM attribute.
*
* @param buf Buffer holding original raw record data from remote.
* @param psm On success object to be populated with GOEP L2CAP PSM.
*
* @return 0 on success if feature found and valid, negative in case any error
*/
int bt_sdp_get_goep_l2cap_psm(const struct net_buf *buf, uint16_t *psm);

/** @brief Get Vendor ID
*
* Helper API extracting remote Vendor ID. To get it proper
Expand Down
4 changes: 4 additions & 0 deletions subsys/bluetooth/Kconfig.logging
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,10 @@ module = BT_GOEP
module-str = "Bluetooth Generic Object Exchange Profile (GOEP)"
source "subsys/logging/Kconfig.template.log_config_inherit"

module = BT_BIP
module-str = "Bluetooth Basic Imaging Profile (BIP)"
source "subsys/logging/Kconfig.template.log_config_inherit"

endmenu # Bluetooth Classic
endif # BT_CLASSIC

Expand Down
1 change: 1 addition & 0 deletions subsys/bluetooth/host/classic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ zephyr_library_sources_ifdef(CONFIG_BT_AVDTP avdtp.c)
zephyr_library_sources_ifdef(CONFIG_BT_AVRCP avrcp.c)
zephyr_library_sources_ifdef(CONFIG_BT_AVCTP avctp.c)
zephyr_library_sources_ifdef(CONFIG_BT_RFCOMM rfcomm.c)
zephyr_library_sources_ifdef(CONFIG_BT_BIP bip.c)

zephyr_library_sources_ifdef(
CONFIG_BT_CLASSIC
Expand Down
7 changes: 7 additions & 0 deletions subsys/bluetooth/host/classic/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,13 @@ config BT_OEBX_RSP_CODE_TO_STR

endif # BT_GOEP

config BT_BIP
bool "Bluetooth BIP Profile [EXPERIMENTAL]"
select BT_GOEP
select EXPERIMENTAL
help
This option enables the BIP profile

endif # BT_CLASSIC

endmenu
Loading