Skip to content
Open
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
16 changes: 10 additions & 6 deletions service/stacks/zephyr/sal_avrcp_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ static void zblue_on_ct_passthrough_rsp(struct bt_avrcp_ct* ct, uint8_t tid, bt_
static void zblue_on_ct_notification_rsp(struct bt_avrcp_ct* ct, uint8_t tid, uint8_t status, uint8_t event_id, struct bt_avrcp_event_data* data);
static void zblue_on_ct_get_element_attrs_rsp(struct bt_avrcp_ct* ct, uint8_t tid, uint8_t status, struct net_buf* buf);
static void zblue_on_ct_get_play_status_rsp(struct bt_avrcp_ct* ct, uint8_t tid, uint8_t status, struct net_buf* buf);
static bt_status_t avrcp_control_disconnect(bt_controller_id_t id, bt_address_t* bd_addr, void* user_data);
#endif

#ifdef CONFIG_BLUETOOTH_AVRCP_ABSOLUTE_VOLUME
Expand Down Expand Up @@ -147,6 +146,8 @@ static struct bt_avrcp_tg_cb avrcp_tg_cbks = {
};
#endif /* CONFIG_BLUETOOTH_AVRCP_TARGET || CONFIG_BLUETOOTH_AVRCP_ABSOLUTE_VOLUME */

static bt_status_t bt_sal_avrcp_disconnect(bt_controller_id_t id, bt_address_t* bd_addr, void* user_data);

#ifdef AVRCP_SDP_BY_APP
#if defined(CONFIG_BLUETOOTH_AVRCP_CONTROL) || defined(CONFIG_BLUETOOTH_AVRCP_ABSOLUTE_VOLUME)
static struct bt_sdp_attribute avrcp_ct_attrs[] = {
Expand Down Expand Up @@ -733,7 +734,7 @@ static void zblue_on_ct_connected(struct bt_conn* conn, struct bt_avrcp_ct* ct)
msg->data.conn_state.reason = PROFILE_REASON_UNSPECIFIED;
bt_sal_avrcp_control_event_callback(msg);
bt_sal_cm_profile_connected_callback(&avrcp_info->bd_addr, PROFILE_AVRCP_CT, CONN_ID_DEFAULT);
bt_sal_profile_disconnect_register(&avrcp_info->bd_addr, PROFILE_AVRCP_CT, CONN_ID_DEFAULT, PRIMARY_ADAPTER, avrcp_control_disconnect, NULL);
bt_sal_profile_disconnect_register(&avrcp_info->bd_addr, PROFILE_AVRCP_CT, CONN_ID_DEFAULT, PRIMARY_ADAPTER, bt_sal_avrcp_disconnect, NULL);
}

static void zblue_on_ct_disconnected(struct bt_avrcp_ct* ct)
Expand Down Expand Up @@ -1052,6 +1053,9 @@ static void zblue_on_tg_connected(struct bt_conn* conn, struct bt_avrcp_tg* tg)
msg->data.conn_state.conn_state = PROFILE_STATE_CONNECTED;
msg->data.conn_state.reason = PROFILE_REASON_UNSPECIFIED;
bt_sal_avrcp_target_event_callback(msg);

bt_sal_cm_profile_connected_callback(&avrcp_info->bd_addr, PROFILE_AVRCP_TG, CONN_ID_DEFAULT);
bt_sal_profile_disconnect_register(&avrcp_info->bd_addr, PROFILE_AVRCP_TG, CONN_ID_DEFAULT, PRIMARY_ADAPTER, bt_sal_avrcp_disconnect, NULL);
Comment on lines +1056 to +1058
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The connection-manager integration for TG connect/disconnect is wrapped in #ifdef CONFIG_BLUETOOTH_AVRCP_TARGET. However, BLUETOOTH_AVRCP_ABSOLUTE_VOLUME can be enabled without BLUETOOTH_AVRCP_TARGET (see root Kconfig), and this file still registers TG callbacks in that configuration. In that case the TG connection will still not be registered for disconnect handling, so disabling Bluetooth may continue to leave the TG connection up. Consider widening the preprocessor guard to include CONFIG_BLUETOOTH_AVRCP_ABSOLUTE_VOLUME (or moving these CM calls outside the TARGET-only guard) so any configuration that brings up a TG link registers/unregisters it with the connection manager.

Copilot uses AI. Check for mistakes.
#endif
}

Expand All @@ -1073,6 +1077,8 @@ static void zblue_on_tg_disconnected(struct bt_avrcp_tg* tg)
msg->data.conn_state.conn_state = PROFILE_STATE_DISCONNECTED;
msg->data.conn_state.reason = PROFILE_REASON_UNSPECIFIED;
bt_sal_avrcp_target_event_callback(msg);

bt_sal_cm_profile_disconnected_callback(&avrcp_info->bd_addr, PROFILE_AVRCP_TG, CONN_ID_DEFAULT);
#endif
Comment on lines +1080 to 1082
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same conditional-compilation issue on the disconnect side: bt_sal_cm_profile_disconnected_callback() is only called when CONFIG_BLUETOOTH_AVRCP_TARGET is set, but TG connections can exist when only CONFIG_BLUETOOTH_AVRCP_ABSOLUTE_VOLUME is enabled. If the TG disconnect isn’t reported to the connection manager, its disconnect handler node may remain registered and can interfere with later disconnect sequencing.

Suggested change
bt_sal_cm_profile_disconnected_callback(&avrcp_info->bd_addr, PROFILE_AVRCP_TG, CONN_ID_DEFAULT);
#endif
#endif
bt_sal_cm_profile_disconnected_callback(&avrcp_info->bd_addr, PROFILE_AVRCP_TG, CONN_ID_DEFAULT);

Copilot uses AI. Check for mistakes.

bt_list_remove_avrcp_info(avrcp_info);
Expand Down Expand Up @@ -1416,8 +1422,7 @@ bt_status_t bt_sal_avrcp_control_connect(bt_controller_id_t id, bt_address_t* ad
#endif
}

#ifdef CONFIG_BLUETOOTH_AVRCP_CONTROL
static bt_status_t avrcp_control_disconnect(bt_controller_id_t id, bt_address_t* bd_addr, void* user_data)
static bt_status_t bt_sal_avrcp_disconnect(bt_controller_id_t id, bt_address_t* bd_addr, void* user_data)
{
zblue_avrcp_info_t* avrcp_info;
int err;
Expand All @@ -1444,12 +1449,11 @@ static bt_status_t avrcp_control_disconnect(bt_controller_id_t id, bt_address_t*
bt_list_remove(bt_avrcp_conn, avrcp_info);
return BT_STATUS_FAIL;
}
#endif

bt_status_t bt_sal_avrcp_control_disconnect(bt_controller_id_t id, bt_address_t* addr)
{
#ifdef CONFIG_BLUETOOTH_AVRCP_CONTROL
return bt_sal_profile_disconnect_request(addr, PROFILE_AVRCP_CT, CONN_ID_DEFAULT, id, avrcp_control_disconnect, NULL);
return bt_sal_profile_disconnect_request(addr, PROFILE_AVRCP_CT, CONN_ID_DEFAULT, id, bt_sal_avrcp_disconnect, NULL);
#else
return BT_STATUS_NOT_SUPPORTED;
#endif
Expand Down
Loading