Browse Source

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: Lyle Zhu <lyle.zhu@nxp.com>
pull/88425/head
Lyle Zhu 3 months ago committed by Benjamin Cabé
parent
commit
3f7224a926
  1. 7
      doc/releases/migration-guide-4.2.rst
  2. 6
      include/zephyr/bluetooth/classic/hfp_ag.h
  3. 4
      samples/bluetooth/handsfree_ag/src/main.c
  4. 4
      subsys/bluetooth/host/classic/hfp_ag.c
  5. 42
      subsys/bluetooth/host/classic/shell/hfp.c

7
doc/releases/migration-guide-4.2.rst

@ -227,6 +227,13 @@ Bluetooth Host @@ -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
**********

6
include/zephyr/bluetooth/classic/hfp_ag.h

@ -111,10 +111,10 @@ struct bt_hfp_ag_cb { @@ -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
*

4
samples/bluetooth/handsfree_ag/src/main.c

@ -63,9 +63,9 @@ static void ag_sco_connected(struct bt_hfp_ag *ag, struct bt_conn *sco_conn) @@ -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)

4
subsys/bluetooth/host/classic/hfp_ag.c

@ -2029,8 +2029,8 @@ static void hfp_ag_sco_disconnected(struct bt_sco_chan *chan, uint8_t reason) @@ -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) {

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

@ -73,14 +73,26 @@ static void hf_disconnected(struct bt_hfp_hf *hf) @@ -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");
hf_sco_conn = NULL;
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) @@ -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");
hfp_ag_sco_conn = NULL;
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)

Loading…
Cancel
Save