Bluetooth: Audio: VCS client return pointer to instance on discover
Add return of instance pointer in bt_vcs_discover so that a client will get a bt_vcs pointer when doing discover, which will be used going forward in the API. Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
parent
db025e26a6
commit
c7375079cc
4 changed files with 16 additions and 7 deletions
|
@ -188,15 +188,17 @@ struct bt_vcs_cb {
|
|||
*
|
||||
* This will start a GATT discovery and setup handles and subscriptions.
|
||||
* This shall be called once before any other actions can be
|
||||
* executed for the peer device.
|
||||
* executed for the peer device, and the @ref bt_vcs_discover_cb callback
|
||||
* will notify when it is possible to start remote operations.
|
||||
*
|
||||
* This shall only be done as the client,
|
||||
*
|
||||
* @param conn The connection to discover Volume Control Service for.
|
||||
* @param[out] vcs Valid remote instance object on success.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcs_discover(struct bt_conn *conn);
|
||||
int bt_vcs_discover(struct bt_conn *conn, struct bt_vcs **vcs);
|
||||
|
||||
/**
|
||||
* @brief Set the Volume Control Service volume step size.
|
||||
|
|
|
@ -707,10 +707,11 @@ static void bt_vcs_client_init(void)
|
|||
}
|
||||
}
|
||||
|
||||
int bt_vcs_discover(struct bt_conn *conn)
|
||||
int bt_vcs_discover(struct bt_conn *conn, struct bt_vcs **vcs)
|
||||
{
|
||||
static bool initialized;
|
||||
struct bt_vcs_client *vcs_inst;
|
||||
int err;
|
||||
|
||||
/*
|
||||
* This will initiate a discover procedure. The procedure will do the
|
||||
|
@ -749,7 +750,11 @@ int bt_vcs_discover(struct bt_conn *conn)
|
|||
vcs_inst->discover_params.start_handle = BT_ATT_FIRST_ATTTRIBUTE_HANDLE;
|
||||
vcs_inst->discover_params.end_handle = BT_ATT_LAST_ATTTRIBUTE_HANDLE;
|
||||
|
||||
return bt_gatt_discover(conn, &vcs_inst->discover_params);
|
||||
err = bt_gatt_discover(conn, &vcs_inst->discover_params);
|
||||
if (err == 0) {
|
||||
*vcs = (struct bt_vcs *)&vcs_inst;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
int bt_vcs_client_cb_register(struct bt_vcs_cb *cb)
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include "bt.h"
|
||||
|
||||
static struct bt_vcs *vcs;
|
||||
static struct bt_vcs_included vcs_included;
|
||||
|
||||
static void vcs_discover_cb(struct bt_conn *conn, int err, uint8_t vocs_count,
|
||||
|
@ -349,7 +350,7 @@ static int cmd_vcs_client_discover(const struct shell *sh, size_t argc,
|
|||
return -ENOEXEC;
|
||||
}
|
||||
|
||||
result = bt_vcs_discover(default_conn);
|
||||
result = bt_vcs_discover(default_conn, &vcs);
|
||||
if (result != 0) {
|
||||
shell_print(sh, "Fail: %d", result);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
static struct bt_conn_cb conn_callbacks;
|
||||
extern enum bst_result_t bst_result;
|
||||
|
||||
static struct bt_vcs *vcs;
|
||||
static struct bt_vcs_included vcs_included;
|
||||
static volatile bool g_bt_init;
|
||||
static volatile bool g_is_connected;
|
||||
|
@ -575,7 +576,7 @@ static void test_main(void)
|
|||
|
||||
WAIT_FOR(g_mtu_exchanged);
|
||||
|
||||
err = bt_vcs_discover(g_conn);
|
||||
err = bt_vcs_discover(g_conn, &vcs);
|
||||
if (err) {
|
||||
FAIL("Failed to discover VCS %d", err);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue