Skip to content

Commit c09cf23

Browse files
lylezhu2012kartben
authored andcommitted
Bluetooth: HFP_AG: Add ACL conn to the connected callback
If the AG works as Data Channel Acceptor, the ACL conn cannot be known by the application of AG. Similar with HF, add ACL conn as the first parameter to the `connected` callback of AG. Signed-off-by: Lyle Zhu <[email protected]>
1 parent ec0d473 commit c09cf23

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

include/zephyr/bluetooth/classic/hfp_ag.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,10 @@ struct bt_hfp_ag_cb {
8484
* If this callback is provided it will be called whenever the
8585
* AG connection completes.
8686
*
87+
* @param conn Connection object.
8788
* @param ag HFP AG object.
8889
*/
89-
void (*connected)(struct bt_hfp_ag *ag);
90+
void (*connected)(struct bt_conn *conn, struct bt_hfp_ag *ag);
9091
/** HF disconnected callback to application
9192
*
9293
* If this callback is provided it will be called whenever the

samples/bluetooth/handsfree_ag/src/main.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,12 @@ struct k_work_delayable call_remote_accept_work;
4040
NET_BUF_POOL_DEFINE(sdp_discover_pool, 10, BT_L2CAP_BUF_SIZE(CONFIG_BT_L2CAP_TX_MTU),
4141
CONFIG_BT_CONN_TX_USER_DATA_SIZE, NULL);
4242

43-
static void ag_connected(struct bt_hfp_ag *ag)
43+
static void ag_connected(struct bt_conn *conn, struct bt_hfp_ag *ag)
4444
{
45+
if (conn != default_conn) {
46+
printk("The conn %p is not aligned with ACL conn %p", conn, default_conn);
47+
}
48+
4549
if (!hfp_ag) {
4650
hfp_ag = ag;
4751
}

subsys/bluetooth/host/classic/hfp_ag.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ static void bt_hfp_ag_set_state(struct bt_hfp_ag *ag, bt_hfp_state_t state)
231231
break;
232232
case BT_HFP_CONNECTED:
233233
if (bt_ag && bt_ag->connected) {
234-
bt_ag->connected(ag);
234+
bt_ag->connected(ag->acl_conn, ag);
235235
}
236236
break;
237237
case BT_HFP_DISCONNECTING:

subsys/bluetooth/host/classic/shell/hfp.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -982,8 +982,11 @@ static void ag_remove_a_call(struct bt_hfp_ag_call *call)
982982
}
983983
}
984984

985-
static void ag_connected(struct bt_hfp_ag *ag)
985+
static void ag_connected(struct bt_conn *conn, struct bt_hfp_ag *ag)
986986
{
987+
if (conn != default_conn) {
988+
bt_shell_warn("The conn %p is not aligned with ACL conn %p", conn, default_conn);
989+
}
987990
hfp_ag = ag;
988991
bt_shell_print("ag connected");
989992
}

0 commit comments

Comments
 (0)