Skip to content

Commit f915f86

Browse files
lylezhu2012kartben
authored andcommitted
Bluetooth: HFP_AG: Set service availability
Add a function `bt_hfp_ag_service_availability` to set the service availability. Signed-off-by: Lyle Zhu <[email protected]>
1 parent dbd3887 commit f915f86

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

include/zephyr/bluetooth/classic/hfp_ag.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,17 @@ int bt_hfp_ag_roaming_status(struct bt_hfp_ag *ag, uint8_t status);
736736
*/
737737
int bt_hfp_ag_battery_level(struct bt_hfp_ag *ag, uint8_t level);
738738

739+
/** @brief Set service availability
740+
*
741+
* Set service availability.
742+
*
743+
* @param ag HFP AG object.
744+
* @param available service availability
745+
*
746+
* @return 0 in case of success or negative value in case of error.
747+
*/
748+
int bt_hfp_ag_service_availability(struct bt_hfp_ag *ag, bool available);
749+
739750
#ifdef __cplusplus
740751
}
741752
#endif

subsys/bluetooth/host/classic/hfp_ag.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4698,3 +4698,29 @@ int bt_hfp_ag_battery_level(struct bt_hfp_ag *ag, uint8_t level)
46984698

46994699
return err;
47004700
}
4701+
4702+
int bt_hfp_ag_service_availability(struct bt_hfp_ag *ag, bool available)
4703+
{
4704+
int err;
4705+
4706+
LOG_DBG("");
4707+
4708+
if (ag == NULL) {
4709+
return -EINVAL;
4710+
}
4711+
4712+
hfp_ag_lock(ag);
4713+
if (ag->state != BT_HFP_CONNECTED) {
4714+
hfp_ag_unlock(ag);
4715+
return -ENOTCONN;
4716+
}
4717+
hfp_ag_unlock(ag);
4718+
4719+
err = hfp_ag_update_indicator(ag, BT_HFP_AG_SERVICE_IND,
4720+
available ? 1 : 0, NULL, NULL);
4721+
if (err) {
4722+
LOG_ERR("Fail to set service availability err :(%d)", err);
4723+
}
4724+
4725+
return err;
4726+
}

0 commit comments

Comments
 (0)