Compare commits

...

4 Commits

Author SHA1 Message Date
huangyulong3 69698271e5 bluetooth: add CRYPTO_MBEDTLS dependency to BT_HOST_CRYPTO
bug: v/90636

BT_HOST_CRYPTO selects MBEDTLS and MBEDTLS_PSA_CRYPTO_C but does not
select their prerequisite CRYPTO_MBEDTLS. In BLE-only configurations
(without BT_CLASSIC), the dependency chain that normally enables
CRYPTO_MBEDTLS through other paths is broken, causing olddefconfig to
fail with unmet dependency error. Add select CRYPTO_MBEDTLS to ensure
the crypto library is always available when BT_HOST_CRYPTO is enabled.

Signed-off-by: huangyulong3 <huangyulong3@xiaomi.com>
2026-05-12 10:55:54 +08:00
huangyulong3 5ea0a86564 bluetooth: add CONFIG_BT_GATT_CLIENT guard for ATT over BR MTU flag
bug: v/90624

In att.c, the ATT over BR connection path unconditionally references
BT_CONN_ATT_MTU_EXCHANGED flag which is only defined when CONFIG_BT_GATT_CLIENT
is enabled (in conn_internal.h). When building BREDR-only configuration without
GATT Client, this causes undeclared identifier compilation error. Add
#if defined(CONFIG_BT_GATT_CLIENT) guard around the flag usage.

Signed-off-by: huangyulong3 <huangyulong3@xiaomi.com>
2026-05-12 10:55:54 +08:00
Lu Jia 1052bb0052 bluetooth: avrcp: fix label/case followed by declaration in notification rsp
bug: v/90707

In process_register_notification_rsp() and build_notification_rsp_data(),
a declaration immediately followed a goto label and a switch case label.
C forbids a declaration directly after a label, which triggered static
analysis errors (ERR_EXPECTED_EXPRESSION and ERR_UNDECLARED_VAR_USE for
failed_evt / identifier) and is technically ill-formed pre-C23.

Wrap the affected sections in compound statements so the labels are
followed by statements rather than declarations. No functional change.

Signed-off-by: Lu Jia <jialu@xiaomi.com>
2026-05-09 15:25:03 +08:00
huangyulong3 e937a254ea zblue: fix compilation errors
Fix compilation errors in bluetooth classic headers and port layer:
- Add missing declarations in a2dp.h and sdp.h
- Add missing includes in avdtp_internal.h
- Fix defines.c port section issues

Signed-off-by: openvela <openvela@xiaomi.com>
2026-05-08 09:52:52 +08:00
7 changed files with 42 additions and 17 deletions

View File

@ -476,6 +476,9 @@ struct bt_a2dp_cb {
* bt_a2dp_err_code or bt_avdtp_err_code
*/
void (*config_rsp)(struct bt_a2dp_stream *stream, uint8_t rsp_err_code);
int (*get_config_req)(struct bt_a2dp_stream *stream, uint8_t *rsp_err_code);
void (*get_config_rsp)(struct bt_a2dp_stream *stream,
struct bt_a2dp_codec_cfg *config, uint8_t rsp_err_code);
/**
* @brief Stream establishment request callback
*

View File

@ -576,6 +576,8 @@ struct bt_sdp_discover_params {
struct net_buf_pool *pool;
/** Discover type */
uint8_t type;
void (*disconnected)(struct bt_conn *conn,
const struct bt_sdp_discover_params *params);
};
/** @brief Allows user to start SDP discovery session.

View File

@ -115,6 +115,12 @@ const struct bt_conn_cb *_bt_conn_cb_list[] = {
};
/* bt_conn_cb END */
/* bt_sco_conn_cb START */
struct bt_sco_conn_cb *_bt_sco_conn_cb_list[] = {
NULL,
};
/* bt_sco_conn_cb END */
/* net_buf_pool START */
extern struct net_buf_pool sine_tx_pool;
extern struct net_buf_pool tx_pool;
@ -149,7 +155,7 @@ extern struct net_buf_pool prep_pool;
extern struct net_buf_pool att_pool;
extern struct net_buf_pool acl_in_pool;
extern struct net_buf_pool acl_tx_pool;
extern struct net_buf_pool dummy_pool;
struct net_buf_pool dummy_pool;
// extern struct net_buf_pool a2dp_tx_pool; // for Zephyr shell
extern struct net_buf_pool bt_a2dp_tx_pool; // for openvela sal

View File

@ -168,6 +168,7 @@ source "$APPSDIR/external/zblue/zblue/subsys/bluetooth/audio/Kconfig"
config BT_HOST_CRYPTO
bool "Use crypto functionality implemented in the Bluetooth host"
default y if !BT_CTLR_CRYPTO
select CRYPTO_MBEDTLS if !BUILD_WITH_TFM
select MBEDTLS if !BUILD_WITH_TFM
select MBEDTLS_PSA_CRYPTO_C if !BUILD_WITH_TFM
select PSA_WANT_KEY_TYPE_AES

View File

@ -3362,7 +3362,9 @@ static void bt_att_connected(struct bt_l2cap_chan *chan)
conn = br_chan->chan.conn;
/* ATT over BR negotiates MTU via L2CAP configuration. */
#if defined(CONFIG_BT_GATT_CLIENT)
atomic_set_bit(chan->conn->flags, BT_CONN_ATT_MTU_EXCHANGED);
#endif
SYS_SLIST_FOR_EACH_CONTAINER(&chan->conn->hdev->att_ctx->conn_cbs, callback, _node) {
if (callback->connected) {

View File

@ -256,6 +256,9 @@ struct bt_avdtp_ops_cb {
int (*set_configuration_ind)(struct bt_avdtp *session, struct bt_avdtp_sep *sep,
uint8_t int_seid, struct net_buf *buf, uint8_t *errcode);
int (*get_configuration_ind)(struct bt_avdtp *session, struct bt_avdtp_sep *sep,
struct net_buf *rsp_buf, uint8_t *errcode);
int (*re_configuration_ind)(struct bt_avdtp *session, struct bt_avdtp_sep *sep,
struct net_buf *buf, uint8_t *errcode);

View File

@ -1154,7 +1154,7 @@ static int process_register_notification_rsp(struct bt_avrcp *avrcp, uint8_t tid
return BT_AVRCP_STATUS_INVALID_PARAMETER;
}
break;
case BT_AVRCP_EVT_TRACK_CHANGED:
case BT_AVRCP_EVT_TRACK_CHANGED: {
if (buf->len < sizeof(event_data->identifier)) {
LOG_ERR("Invalid TRACK_CHANGED response length");
return BT_AVRCP_STATUS_INVALID_PARAMETER;
@ -1163,6 +1163,7 @@ static int process_register_notification_rsp(struct bt_avrcp *avrcp, uint8_t tid
memcpy(event_data->identifier, &identifier, sizeof(uint64_t));
break;
}
case BT_AVRCP_EVT_PLAYBACK_POS_CHANGED:
if (buf->len < sizeof(event_data->playback_pos)) {
LOG_ERR("Invalid PLAYBACK_POS_CHANGED response length");
@ -1268,23 +1269,29 @@ static int process_register_notification_rsp(struct bt_avrcp *avrcp, uint8_t tid
}
return BT_AVRCP_STATUS_OPERATION_COMPLETED;
notify_callback:
/* Find the event registered with this TID and clear ONLY that one */
uint8_t failed_evt = 0;
bool found = false;
/* Find the event registered with this TID and clear ONLY that one.
* The braces here form a compound statement so the label is followed
* by a statement (C forbids a declaration directly after a label).
*/
{
uint8_t failed_evt = 0;
bool found = false;
ARRAY_FOR_EACH(ct->ct_notify, i) {
if (ct->ct_notify[i].tid == tid && ct->ct_notify[i].cb != NULL) {
failed_evt = i;
ct->ct_notify[i].cb = NULL;
ct->ct_notify[i].interim_received = 0;
found = true;
break;
ARRAY_FOR_EACH(ct->ct_notify, i) {
if (ct->ct_notify[i].tid == tid && ct->ct_notify[i].cb != NULL) {
failed_evt = i;
ct->ct_notify[i].cb = NULL;
ct->ct_notify[i].interim_received = 0;
found = true;
break;
}
}
avrcp_ct_cb->notification(get_avrcp_ct(avrcp), tid, status,
found ? failed_evt : 0, NULL);
return BT_AVRCP_STATUS_OPERATION_COMPLETED;
}
avrcp_ct_cb->notification(get_avrcp_ct(avrcp), tid, status, found ? failed_evt : 0, NULL);
return BT_AVRCP_STATUS_OPERATION_COMPLETED;
}
static int process_set_absolute_volume_rsp(struct bt_avrcp *avrcp, uint8_t tid,
@ -4331,11 +4338,12 @@ static int build_notification_rsp_data(uint8_t event_id, struct bt_avrcp_event_d
}
net_buf_add_u8(buf, data->play_status);
break;
case BT_AVRCP_EVT_TRACK_CHANGED:
case BT_AVRCP_EVT_TRACK_CHANGED: {
uint64_t identifier = sys_get_be64(data->identifier);
net_buf_add_be64(buf, identifier);
break;
}
case BT_AVRCP_EVT_PLAYBACK_POS_CHANGED:
net_buf_add_be32(buf, data->playback_pos);
break;