Bluetooth: Audio: Update VCS API to use bt_vcs
Update the VCS API to use the bt_vcs struct instead of the bt_conn. This is create a more simple API that uses a, remote or loca, instance pointer, rather than a specified connection (for remote) or NULL (for local) operations. Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
parent
a1c7a48ee3
commit
0043c741a5
8 changed files with 640 additions and 516 deletions
|
@ -79,8 +79,8 @@ struct bt_vcs_included {
|
|||
* This will register and enable the service and make it discoverable by
|
||||
* clients.
|
||||
*
|
||||
* @param param Volume Control Service register parameters.
|
||||
* @param[out] vcs Pointer to the registered Volume Control Service.
|
||||
* @param param Volume Control Service register parameters.
|
||||
* @param[out] vcs Pointer to the registered Volume Control Service.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
|
@ -94,20 +94,19 @@ int bt_vcs_register(struct bt_vcs_register_param *param, struct bt_vcs **vcs);
|
|||
* Volume Offset Control Service (Volume Offset Control Service) or
|
||||
* Audio Input Control Service (AICS) instances.
|
||||
*
|
||||
* @param conn Connection to peer device, or NULL to get server value.
|
||||
* @param vcs Volume Control Service instance pointer.
|
||||
* @param[out] included Pointer to store the result in.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcs_included_get(struct bt_conn *conn, struct bt_vcs_included *included);
|
||||
int bt_vcs_included_get(struct bt_vcs *vcs, struct bt_vcs_included *included);
|
||||
|
||||
/**
|
||||
* @brief Callback function for bt_vcs_discover.
|
||||
*
|
||||
* This callback is only used for the client.
|
||||
*
|
||||
* @param conn The connection that was used to discover
|
||||
* Volume Control Service.
|
||||
* @param vcs Volume Control Service instance pointer.
|
||||
* @param err Error value. 0 on success, GATT error on positive value
|
||||
* or errno on negative value.
|
||||
* @param vocs_count Number of Volume Offset Control Service instances
|
||||
|
@ -115,7 +114,7 @@ int bt_vcs_included_get(struct bt_conn *conn, struct bt_vcs_included *included);
|
|||
* @param aics_count Number of Audio Input Control Service instances on
|
||||
* peer device.
|
||||
*/
|
||||
typedef void (*bt_vcs_discover_cb)(struct bt_conn *conn, int err,
|
||||
typedef void (*bt_vcs_discover_cb)(struct bt_vcs *vcs, int err,
|
||||
uint8_t vocs_count, uint8_t aics_count);
|
||||
|
||||
/**
|
||||
|
@ -125,14 +124,13 @@ typedef void (*bt_vcs_discover_cb)(struct bt_conn *conn, int err,
|
|||
* Called when the value is remotely read as the client.
|
||||
* Called if the value is changed by either the server or client.
|
||||
*
|
||||
* @param conn NULL if local server read or write, otherwise the connection
|
||||
* to the peer device if remotely read or written.
|
||||
* @param vcs Volume Control Service instance pointer.
|
||||
* @param err Error value. 0 on success, GATT error on positive value
|
||||
* or errno on negative value.
|
||||
* @param volume The volume of the Volume Control Service server.
|
||||
* @param mute The mute setting of the Volume Control Service server.
|
||||
*/
|
||||
typedef void (*bt_vcs_state_cb)(struct bt_conn *conn, int err, uint8_t volume,
|
||||
typedef void (*bt_vcs_state_cb)(struct bt_vcs *vcs, int err, uint8_t volume,
|
||||
uint8_t mute);
|
||||
|
||||
/**
|
||||
|
@ -142,24 +140,22 @@ typedef void (*bt_vcs_state_cb)(struct bt_conn *conn, int err, uint8_t volume,
|
|||
* Called when the value is remotely read as the client.
|
||||
* Called if the value is changed by either the server or client.
|
||||
*
|
||||
* @param conn NULL if local server read or write, otherwise the connection
|
||||
* to the peer device if remotely read or written.
|
||||
* @param vcs Volume Control Service instance pointer.
|
||||
* @param err Error value. 0 on success, GATT error on positive value
|
||||
* or errno on negative value.
|
||||
* @param flags The flags of the Volume Control Service server.
|
||||
*/
|
||||
typedef void (*bt_vcs_flags_cb)(struct bt_conn *conn, int err, uint8_t flags);
|
||||
typedef void (*bt_vcs_flags_cb)(struct bt_vcs *vcs, int err, uint8_t flags);
|
||||
|
||||
/**
|
||||
* @brief Callback function for writes.
|
||||
*
|
||||
* This callback is only used for the client.
|
||||
*
|
||||
* @param conn NULL if local server read or write, otherwise the connection
|
||||
* to the peer device if remotely read or written.
|
||||
* @param vcs Volume Control Service instance pointer.
|
||||
* @param err Error value. 0 on success, GATT error on fail.
|
||||
*/
|
||||
typedef void (*bt_vcs_write_cb)(struct bt_conn *conn, int err);
|
||||
typedef void (*bt_vcs_write_cb)(struct bt_vcs *vcs, int err);
|
||||
|
||||
struct bt_vcs_cb {
|
||||
/* Volume Control Service */
|
||||
|
@ -193,8 +189,8 @@ struct bt_vcs_cb {
|
|||
*
|
||||
* 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.
|
||||
* @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.
|
||||
*/
|
||||
|
@ -217,152 +213,149 @@ int bt_vcs_vol_step_set(uint8_t volume_step);
|
|||
/**
|
||||
* @brief Read the Volume Control Service volume state.
|
||||
*
|
||||
* @param conn Connection to the peer device,
|
||||
* or NULL to read local server value.
|
||||
* @param vcs Volume Control Service instance pointer.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcs_vol_get(struct bt_conn *conn);
|
||||
int bt_vcs_vol_get(struct bt_vcs *vcs);
|
||||
|
||||
/**
|
||||
* @brief Read the Volume Control Service flags.
|
||||
*
|
||||
* @param conn Connection to peer device, or NULL to read local server value.
|
||||
* @param vcs Volume Control Service instance pointer.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcs_flags_get(struct bt_conn *conn);
|
||||
int bt_vcs_flags_get(struct bt_vcs *vcs);
|
||||
|
||||
/**
|
||||
* @brief Turn the volume down by one step on the server.
|
||||
*
|
||||
* @param conn Connection to peer device, or NULL to read local server value.
|
||||
* @param vcs Volume Control Service instance pointer.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcs_vol_down(struct bt_conn *conn);
|
||||
int bt_vcs_vol_down(struct bt_vcs *vcs);
|
||||
|
||||
/**
|
||||
* @brief Turn the volume up by one step on the server.
|
||||
*
|
||||
* @param conn Connection to peer device, or NULL to read local server value.
|
||||
* @param vcs Volume Control Service instance pointer.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcs_vol_up(struct bt_conn *conn);
|
||||
int bt_vcs_vol_up(struct bt_vcs *vcs);
|
||||
|
||||
/**
|
||||
* @brief Turn the volume down and unmute the server.
|
||||
*
|
||||
* @param conn Connection to peer device, or NULL to read local server value.
|
||||
* @param vcs Volume Control Service instance pointer.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcs_unmute_vol_down(struct bt_conn *conn);
|
||||
int bt_vcs_unmute_vol_down(struct bt_vcs *vcs);
|
||||
|
||||
/**
|
||||
* @brief Turn the volume up and unmute the server.
|
||||
*
|
||||
* @param conn Connection to peer device, or NULL to read local server value.
|
||||
* @param vcs Volume Control Service instance pointer.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcs_unmute_vol_up(struct bt_conn *conn);
|
||||
int bt_vcs_unmute_vol_up(struct bt_vcs *vcs);
|
||||
|
||||
/**
|
||||
* @brief Set the volume on the server
|
||||
*
|
||||
* @param conn Connection to peer device, or NULL to set local server value.
|
||||
* @param vcs Volume Control Service instance pointer.
|
||||
* @param volume The absolute volume to set.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcs_vol_set(struct bt_conn *conn, uint8_t volume);
|
||||
int bt_vcs_vol_set(struct bt_vcs *vcs, uint8_t volume);
|
||||
|
||||
/**
|
||||
* @brief Unmute the server.
|
||||
*
|
||||
* @param conn Connection to peer device, or NULL to read local server value.
|
||||
* @param vcs Volume Control Service instance pointer.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcs_unmute(struct bt_conn *conn);
|
||||
int bt_vcs_unmute(struct bt_vcs *vcs);
|
||||
|
||||
/**
|
||||
* @brief Mute the server.
|
||||
*
|
||||
* @param conn Connection to peer device, or NULL to read local server value.
|
||||
* @param vcs Volume Control Service instance pointer.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcs_mute(struct bt_conn *conn);
|
||||
int bt_vcs_mute(struct bt_vcs *vcs);
|
||||
|
||||
/**
|
||||
* @brief Read the Volume Offset Control Service offset state.
|
||||
*
|
||||
* @param conn Connection to peer device, or NULL to read local server value.
|
||||
* @param vcs Volume Control Service instance pointer.
|
||||
* @param inst Pointer to the Volume Offset Control Service instance.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcs_vocs_state_get(struct bt_conn *conn, struct bt_vocs *inst);
|
||||
int bt_vcs_vocs_state_get(struct bt_vcs *vcs, struct bt_vocs *inst);
|
||||
|
||||
/**
|
||||
* @brief Read the Volume Offset Control Service location.
|
||||
*
|
||||
* @param conn Connection to peer device, or NULL to read local server value.
|
||||
* @param vcs Volume Control Service instance pointer.
|
||||
* @param inst Pointer to the Volume Offset Control Service instance.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcs_vocs_location_get(struct bt_conn *conn, struct bt_vocs *inst);
|
||||
int bt_vcs_vocs_location_get(struct bt_vcs *vcs, struct bt_vocs *inst);
|
||||
|
||||
/**
|
||||
* @brief Set the Volume Offset Control Service location.
|
||||
*
|
||||
* @param conn Connection to peer device, or NULL to set local server
|
||||
* value.
|
||||
* @param vcs Volume Control Service instance pointer.
|
||||
* @param inst Pointer to the Volume Offset Control Service instance.
|
||||
* @param location The location to set.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcs_vocs_location_set(struct bt_conn *conn, struct bt_vocs *inst,
|
||||
int bt_vcs_vocs_location_set(struct bt_vcs *vcs, struct bt_vocs *inst,
|
||||
uint8_t location);
|
||||
|
||||
/**
|
||||
* @brief Set the Volume Offset Control Service offset state.
|
||||
*
|
||||
* @param conn Connection to peer device, or NULL to set local server value.
|
||||
* @param vcs Volume Control Service instance pointer.
|
||||
* @param inst Pointer to the Volume Offset Control Service instance.
|
||||
* @param offset The offset to set (-255 to 255).
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcs_vocs_state_set(struct bt_conn *conn, struct bt_vocs *inst,
|
||||
int bt_vcs_vocs_state_set(struct bt_vcs *vcs, struct bt_vocs *inst,
|
||||
int16_t offset);
|
||||
|
||||
/**
|
||||
* @brief Read the Volume Offset Control Service output description.
|
||||
*
|
||||
* @param conn Connection to peer device, or NULL to read local server value.
|
||||
* @param vcs Volume Control Service instance pointer.
|
||||
* @param inst Pointer to the Volume Offset Control Service instance.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcs_vocs_description_get(struct bt_conn *conn, struct bt_vocs *inst);
|
||||
int bt_vcs_vocs_description_get(struct bt_vcs *vcs, struct bt_vocs *inst);
|
||||
|
||||
/**
|
||||
* @brief Set the Volume Offset Control Service description.
|
||||
*
|
||||
* @param conn Connection to peer device, or NULL to set local server
|
||||
* value.
|
||||
* @param vcs Volume Control Service instance pointer.
|
||||
* @param inst Pointer to the Volume Offset Control Service instance.
|
||||
* @param description The description to set.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcs_vocs_description_set(struct bt_conn *conn, struct bt_vocs *inst,
|
||||
int bt_vcs_vocs_description_set(struct bt_vcs *vcs, struct bt_vocs *inst,
|
||||
const char *description);
|
||||
|
||||
/**
|
||||
|
@ -371,11 +364,12 @@ int bt_vcs_vocs_description_set(struct bt_conn *conn, struct bt_vocs *inst,
|
|||
* Audio Input Control Services are activated by default, but this will allow
|
||||
* the server to deactivate an Audio Input Control Service.
|
||||
*
|
||||
* @param vcs Volume Control Service instance pointer.
|
||||
* @param inst Pointer to the Audio Input Control Service instance.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcs_aics_deactivate(struct bt_aics *inst);
|
||||
int bt_vcs_aics_deactivate(struct bt_vcs *vcs, struct bt_aics *inst);
|
||||
|
||||
/**
|
||||
* @brief Activates an Audio Input Control Service instance.
|
||||
|
@ -384,125 +378,125 @@ int bt_vcs_aics_deactivate(struct bt_aics *inst);
|
|||
* the server to reactivate an Audio Input Control Service instance after it has
|
||||
* been deactivated with @ref bt_vcs_aics_deactivate.
|
||||
*
|
||||
* @param vcs Volume Control Service instance pointer.
|
||||
* @param inst Pointer to the Audio Input Control Service instance.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcs_aics_activate(struct bt_aics *inst);
|
||||
int bt_vcs_aics_activate(struct bt_vcs *vcs, struct bt_aics *inst);
|
||||
|
||||
/**
|
||||
* @brief Read the Audio Input Control Service input state.
|
||||
*
|
||||
* @param conn Connection to peer device, or NULL to read local server value.
|
||||
* @param vcs Volume Control Service instance pointer.
|
||||
* @param inst Pointer to the Audio Input Control Service instance.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcs_aics_state_get(struct bt_conn *conn, struct bt_aics *inst);
|
||||
int bt_vcs_aics_state_get(struct bt_vcs *vcs, struct bt_aics *inst);
|
||||
|
||||
/**
|
||||
* @brief Read the Audio Input Control Service gain settings.
|
||||
*
|
||||
* @param conn Connection to peer device, or NULL to read local server value.
|
||||
* @param vcs Volume Control Service instance pointer.
|
||||
* @param inst Pointer to the Audio Input Control Service instance.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcs_aics_gain_setting_get(struct bt_conn *conn, struct bt_aics *inst);
|
||||
int bt_vcs_aics_gain_setting_get(struct bt_vcs *vcs, struct bt_aics *inst);
|
||||
|
||||
/**
|
||||
* @brief Read the Audio Input Control Service input type.
|
||||
*
|
||||
* @param conn Connection to peer device, or NULL to read local server value.
|
||||
* @param vcs Volume Control Service instance pointer.
|
||||
* @param inst Pointer to the Audio Input Control Service instance.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcs_aics_type_get(struct bt_conn *conn, struct bt_aics *inst);
|
||||
int bt_vcs_aics_type_get(struct bt_vcs *vcs, struct bt_aics *inst);
|
||||
|
||||
/**
|
||||
* @brief Read the Audio Input Control Service input status.
|
||||
*
|
||||
* @param conn Connection to peer device, or NULL to read local server value.
|
||||
* @param vcs Volume Control Service instance pointer.
|
||||
* @param inst Pointer to the Audio Input Control Service instance.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcs_aics_status_get(struct bt_conn *conn, struct bt_aics *inst);
|
||||
int bt_vcs_aics_status_get(struct bt_vcs *vcs, struct bt_aics *inst);
|
||||
|
||||
/**
|
||||
* @brief Mute the Audio Input Control Service input.
|
||||
*
|
||||
* @param conn Connection to peer device, or NULL to set local server value.
|
||||
* @param vcs Volume Control Service instance pointer.
|
||||
* @param inst Pointer to the Audio Input Control Service instance.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcs_aics_mute(struct bt_conn *conn, struct bt_aics *inst);
|
||||
int bt_vcs_aics_mute(struct bt_vcs *vcs, struct bt_aics *inst);
|
||||
|
||||
/**
|
||||
* @brief Unmute the Audio Input Control Service input.
|
||||
*
|
||||
* @param conn Connection to peer device, or NULL to set local server value.
|
||||
* @param vcs Volume Control Service instance pointer.
|
||||
* @param inst Pointer to the Audio Input Control Service instance.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcs_aics_unmute(struct bt_conn *conn, struct bt_aics *inst);
|
||||
int bt_vcs_aics_unmute(struct bt_vcs *vcs, struct bt_aics *inst);
|
||||
|
||||
/**
|
||||
* @brief Set input gain to manual.
|
||||
*
|
||||
* @param conn Connection to peer device, or NULL to set local server value.
|
||||
* @param vcs Volume Control Service instance pointer.
|
||||
* @param inst Pointer to the Audio Input Control Service instance.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcs_aics_manual_gain_set(struct bt_conn *conn, struct bt_aics *inst);
|
||||
int bt_vcs_aics_manual_gain_set(struct bt_vcs *vcs, struct bt_aics *inst);
|
||||
|
||||
/**
|
||||
* @brief Set the input gain to automatic.
|
||||
*
|
||||
* @param conn Connection to peer device, or NULL to set local server value.
|
||||
* @param vcs Volume Control Service instance pointer.
|
||||
* @param inst Pointer to the Audio Input Control Service instance.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcs_aics_automatic_gain_set(struct bt_conn *conn, struct bt_aics *inst);
|
||||
int bt_vcs_aics_automatic_gain_set(struct bt_vcs *vcs, struct bt_aics *inst);
|
||||
|
||||
/**
|
||||
* @brief Set the input gain.
|
||||
*
|
||||
* @param conn Connection to peer device, or NULL to set local server value.
|
||||
* @param vcs Volume Control Service instance pointer.
|
||||
* @param inst Pointer to the Audio Input Control Service instance.
|
||||
* @param gain The gain in dB to set (-128 to 127).
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcs_aics_gain_set(struct bt_conn *conn, struct bt_aics *inst,
|
||||
int bt_vcs_aics_gain_set(struct bt_vcs *vcs, struct bt_aics *inst,
|
||||
int8_t gain);
|
||||
|
||||
/**
|
||||
* @brief Read the Audio Input Control Service description.
|
||||
*
|
||||
* @param conn Connection to peer device, or NULL to read local server value.
|
||||
* @param vcs Volume Control Service instance pointer.
|
||||
* @param inst Pointer to the Audio Input Control Service instance.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcs_aics_description_get(struct bt_conn *conn, struct bt_aics *inst);
|
||||
int bt_vcs_aics_description_get(struct bt_vcs *vcs, struct bt_aics *inst);
|
||||
|
||||
/**
|
||||
* @brief Set the Audio Input Control Service description.
|
||||
*
|
||||
* @param conn Connection to peer device, or NULL to set local server
|
||||
* value.
|
||||
* @param vcs Volume Control Service instance pointer.
|
||||
* @param inst Pointer to the Audio Input Control Service instance.
|
||||
* @param description The description to set.
|
||||
*
|
||||
* @return 0 if success, errno on failure.
|
||||
*/
|
||||
int bt_vcs_aics_description_set(struct bt_conn *conn, struct bt_aics *inst,
|
||||
int bt_vcs_aics_description_set(struct bt_vcs *vcs, struct bt_aics *inst,
|
||||
const char *description);
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue