Commit 3f7224a9 authored by Lyle Zhu's avatar Lyle Zhu Committed by Benjamin Cabé
Browse files

Bluetooth: Classic: HFP_AG: Update the callback `sco_disconnected()`

Change the arguments of HFP AG callback `sco_disconnected()` to SCO
conn and disconnection reason.

Signed-off-by: default avatarLyle Zhu <lyle.zhu@nxp.com>
parent 4f2dc5f1
Loading
Loading
Loading
Loading
+7 −0
Changes for doc/releases/migration-guide-4.2.rst: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -227,6 +227,13 @@ Bluetooth Host
  each role may be different. Any existing uses/checks for ``BT_ISO_CHAN_TYPE_CONNECTED``
  can be replaced with an ``||`` of the two. (:github:`75549`)

Bluetooth Classic
=================

* The parameters of HFP AG callback ``sco_disconnected`` of the struct :c:struct:`bt_hfp_ag_cb`
  have been changed to SCO connection object ``struct bt_conn *sco_conn`` and the disconnection
  reason of the SCO connection ``uint8_t reason``.

Networking
**********

+3 −3
Changes for include/zephyr/bluetooth/classic/hfp_ag.h: 3 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -111,10 +111,10 @@ struct bt_hfp_ag_cb {
	 *  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.
	 *  @param conn SCO/eSCO Connection object.
	 *  @param reason BT_HCI_ERR_* reason for the disconnection.
	 */
	void (*sco_disconnected)(struct bt_hfp_ag *ag);
	void (*sco_disconnected)(struct bt_conn *sco_conn, uint8_t reason);

	/** HF memory dialing request Callback
	 *
+2 −2
Changes for samples/bluetooth/handsfree_ag/src/main.c: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -63,9 +63,9 @@ static void ag_sco_connected(struct bt_hfp_ag *ag, struct bt_conn *sco_conn)
	printk("HFP AG SCO connected!\n");
}

static void ag_sco_disconnected(struct bt_hfp_ag *ag)
static void ag_sco_disconnected(struct bt_conn *sco_conn, uint8_t reason)
{
	printk("HFP AG SCO disconnected!\n");
	printk("HFP AG SCO disconnected %u!\n", reason);
}

static void ag_ringing(struct bt_hfp_ag_call *call, bool in_band)
+2 −2
Changes for subsys/bluetooth/host/classic/hfp_ag.c: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -2029,8 +2029,8 @@ static void hfp_ag_sco_disconnected(struct bt_sco_chan *chan, uint8_t reason)

	call = get_call_with_flag(ag, BT_HFP_AG_CALL_OPEN_SCO, true);

	if ((bt_ag) && bt_ag->sco_disconnected) {
		bt_ag->sco_disconnected(ag);
	if ((bt_ag != NULL) && bt_ag->sco_disconnected) {
		bt_ag->sco_disconnected(chan->sco, reason);
	}

	if (!call) {
+31 −7
Changes for subsys/bluetooth/host/classic/shell/hfp.c: 31 added lines, 7 removed lines.
Original line number Diff line number Diff line
@@ -73,14 +73,26 @@ static void hf_disconnected(struct bt_hfp_hf *hf)

static void hf_sco_connected(struct bt_hfp_hf *hf, struct bt_conn *sco_conn)
{
	bt_shell_print("HF SCO connected");
	hf_sco_conn = sco_conn;
	bt_shell_print("HF SCO connected %p", sco_conn);

	if (hf_sco_conn != NULL) {
		bt_shell_warn("HF SCO conn %p exists", hf_sco_conn);
		return;
	}

	hf_sco_conn = bt_conn_ref(sco_conn);
}

static void hf_sco_disconnected(struct bt_conn *sco_conn, uint8_t reason)
{
	bt_shell_print("HF SCO disconnected");
	bt_shell_print("HF SCO disconnected %p (reason %u)", sco_conn, reason);

	if (hf_sco_conn == sco_conn) {
		bt_conn_unref(hf_sco_conn);
		hf_sco_conn = NULL;
	} else {
		bt_shell_warn("Unknown SCO disconnected (%p != %p)", hf_sco_conn, sco_conn);
	}
}

void hf_service(struct bt_hfp_hf *hf, uint32_t value)
@@ -998,14 +1010,26 @@ static void ag_disconnected(struct bt_hfp_ag *ag)

static void ag_sco_connected(struct bt_hfp_ag *ag, struct bt_conn *sco_conn)
{
	bt_shell_print("ag sco connected");
	hfp_ag_sco_conn = sco_conn;
	bt_shell_print("AG SCO connected %p", sco_conn);

	if (hfp_ag_sco_conn != NULL) {
		bt_shell_warn("AG SCO conn %p exists", hfp_ag_sco_conn);
		return;
	}

	hfp_ag_sco_conn = bt_conn_ref(sco_conn);
}

static void ag_sco_disconnected(struct bt_hfp_ag *ag)
static void ag_sco_disconnected(struct bt_conn *sco_conn, uint8_t reason)
{
	bt_shell_print("ag sco disconnected");
	bt_shell_print("AG SCO disconnected %p (reason %u)", sco_conn, reason);

	if (hfp_ag_sco_conn == sco_conn) {
		bt_conn_unref(hfp_ag_sco_conn);
		hfp_ag_sco_conn = NULL;
	} else {
		bt_shell_warn("Unknown SCO disconnected (%p != %p)", hfp_ag_sco_conn, sco_conn);
	}
}

static int ag_memory_dial(struct bt_hfp_ag *ag, const char *location, char **number)