Skip to content

Commit

Permalink
bluetooth: audio: Add API to get MICP service ATT handles
Browse files Browse the repository at this point in the history
This is needed for upper tester.

Signed-off-by: Piotr Narajowski <piotr.narajowski@codecoup.pl>
  • Loading branch information
piotrnarajowski committed Jul 7, 2023
1 parent 935268e commit df6f074
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
30 changes: 30 additions & 0 deletions include/zephyr/bluetooth/audio/micp.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,36 @@ int bt_micp_mic_ctlr_mute_get(struct bt_micp_mic_ctlr *mic_ctlr);
* @return 0 if success, errno on failure.
*/
int bt_micp_mic_ctlr_cb_register(struct bt_micp_mic_ctlr_cb *cb);

/**
* @brief Get the start handle and end handle a Microphone Controller instance
*
* @param mic_ctlr Microphone Controller instance pointer.
* @param mute_handle Mute characteristic handle.
*
* @return 0 if success, errno on failure.
*/
int bt_micp_mic_ctlr_chrc_get(const struct bt_micp_mic_ctlr *mic_ctlr, uint16_t *mute_handle);

/**
* @brief Get handles of each characteristic of AICS.
*
* @param micp_included Included Services containing array of pointers to AICS instances.
* @param state_handle state handle.
* @param gain_handle gain handle.
* @param type_handle type handle.
* @param status_handle status handle.
* @param control_handle control handle.
* @param desc_handle desc handle.
*
* @return 0 if success, errno on failure.
*/
int bt_micp_mic_ctlr_aics_chrc_get(const struct bt_micp_included micp_included,
uint16_t *state_handle, uint16_t *gain_handle,
uint16_t *type_handle,
uint16_t *status_handle, uint16_t *control_handle,
uint16_t *desc_handle);

#ifdef __cplusplus
}
#endif
Expand Down
42 changes: 42 additions & 0 deletions subsys/bluetooth/audio/micp_mic_ctlr.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <zephyr/bluetooth/conn.h>
#include <zephyr/bluetooth/gatt.h>
#include <zephyr/bluetooth/audio/micp.h>
#include <../../subsys/bluetooth/audio/aics_internal.h>

#include <zephyr/logging/log.h>

Expand Down Expand Up @@ -515,6 +516,47 @@ int bt_micp_mic_ctlr_conn_get(const struct bt_micp_mic_ctlr *mic_ctlr, struct bt
return 0;
}

int bt_micp_mic_ctlr_chrc_get(const struct bt_micp_mic_ctlr *mic_ctlr, uint16_t *mute_handle)
{
CHECKIF(mic_ctlr == NULL)
{
LOG_DBG("NULL mic_ctlr pointer");
return -EINVAL;
}

if (mic_ctlr->conn == NULL) {
LOG_DBG("mic_ctlr pointer not associated with a connection. "
"Do discovery first");
return -ENOTCONN;
}

*mute_handle = mic_ctlr->mute_handle;

return 0;
}

int bt_micp_mic_ctlr_aics_chrc_get(const struct bt_micp_included micp_included,
uint16_t *state_handle, uint16_t *gain_handle,
uint16_t *type_handle,
uint16_t *status_handle, uint16_t *control_handle,
uint16_t *desc_handle)
{
CHECKIF(micp_included.aics == NULL)
{
LOG_DBG("NULL AICS instance");
return -EINVAL;
}

*state_handle = micp_included.aics[0]->cli.state_handle;
*gain_handle = micp_included.aics[0]->cli.gain_handle;
*type_handle = micp_included.aics[0]->cli.type_handle;
*status_handle = micp_included.aics[0]->cli.status_handle;
*control_handle = micp_included.aics[0]->cli.control_handle;
*desc_handle = micp_included.aics[0]->cli.desc_handle;

return 0;
}

int bt_micp_mic_ctlr_mute_get(struct bt_micp_mic_ctlr *mic_ctlr)
{
int err;
Expand Down

0 comments on commit df6f074

Please sign in to comment.