Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions subsys/bluetooth/host/classic/hfp_hf.c
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ static void hf_query_current_calls(struct bt_hfp_hf *hf)
return;
}

if (atomic_test_bit(hf->flags, BT_HFP_HF_FLAG_CLCC_PENDING)) {
if (atomic_test_and_set_bit(hf->flags, BT_HFP_HF_FLAG_CLCC_PENDING)) {
k_work_reschedule(&hf->deferred_work, K_MSEC(HF_ENHANCED_CALL_STATUS_TIMEOUT));
return;
}
Expand Down Expand Up @@ -1091,8 +1091,8 @@ static void ag_indicator_handle_call(struct bt_hfp_hf *hf, uint32_t value)

LOG_DBG("call %d", value);

if (value != 0) {
atomic_set_bit(hf->flags, BT_HFP_HF_FLAG_CLCC_PENDING);
if ((value != 0) && atomic_test_bit(hf->flags, BT_HFP_HF_FLAG_INITIATING)) {
atomic_set_bit(hf->flags, BT_HFP_HF_FLAG_QUERY_CALLS);
}

if (value) {
Expand Down Expand Up @@ -1153,8 +1153,9 @@ static void ag_indicator_handle_call_setup(struct bt_hfp_hf *hf, uint32_t value)

LOG_DBG("call setup %d", value);

if (value != BT_HFP_CALL_SETUP_NONE) {
atomic_set_bit(hf->flags, BT_HFP_HF_FLAG_CLCC_PENDING);
if ((value != BT_HFP_CALL_SETUP_NONE) &&
atomic_test_bit(hf->flags, BT_HFP_HF_FLAG_INITIATING)) {
atomic_set_bit(hf->flags, BT_HFP_HF_FLAG_QUERY_CALLS);
}

switch (value) {
Expand Down Expand Up @@ -1258,8 +1259,9 @@ static void ag_indicator_handle_call_held(struct bt_hfp_hf *hf, uint32_t value)

LOG_DBG("call setup %d", value);

if (value != BT_HFP_CALL_HELD_NONE) {
atomic_set_bit(hf->flags, BT_HFP_HF_FLAG_CLCC_PENDING);
if ((value != BT_HFP_CALL_HELD_NONE) &&
atomic_test_bit(hf->flags, BT_HFP_HF_FLAG_INITIATING)) {
atomic_set_bit(hf->flags, BT_HFP_HF_FLAG_QUERY_CALLS);
}

switch (value) {
Expand Down Expand Up @@ -2077,9 +2079,12 @@ static int at_cmd_init_start(struct bt_hfp_hf *hf)
hf->cmd_init_seq++;
}

if ((ARRAY_SIZE(cmd_init_list) <= hf->cmd_init_seq) &&
atomic_test_and_clear_bit(hf->flags, BT_HFP_HF_FLAG_CLCC_PENDING)) {
k_work_reschedule(&hf->deferred_work, K_MSEC(HF_ENHANCED_CALL_STATUS_TIMEOUT));
if (ARRAY_SIZE(cmd_init_list) <= hf->cmd_init_seq) {
atomic_clear_bit(hf->flags, BT_HFP_HF_FLAG_INITIATING);
if (atomic_test_and_clear_bit(hf->flags, BT_HFP_HF_FLAG_QUERY_CALLS)) {
k_work_reschedule(&hf->deferred_work,
K_MSEC(HF_ENHANCED_CALL_STATUS_TIMEOUT));
}
}

return err;
Expand Down Expand Up @@ -2308,6 +2313,8 @@ int hf_slc_establish(struct bt_hfp_hf *hf)

LOG_DBG("");

atomic_set_bit(hf->flags, BT_HFP_HF_FLAG_INITIATING);

hf->cmd_init_seq = 0;
err = slc_init_start(hf);
if (err < 0) {
Expand Down
2 changes: 2 additions & 0 deletions subsys/bluetooth/host/classic/hfp_hf_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ enum {
BT_HFP_HF_FLAG_CLCC_PENDING, /* HFP HF CLCC is pending */
BT_HFP_HF_FLAG_VRE_ACTIVATE, /* VRE is activated */
BT_HFP_HF_FLAG_BINP, /* +BINP result code is received */
BT_HFP_HF_FLAG_INITIATING, /* HF is in initiating state */
BT_HFP_HF_FLAG_QUERY_CALLS, /* Require to query list of current calls */
/* Total number of flags - must be at the end of the enum */
BT_HFP_HF_NUM_FLAGS,
};
Expand Down