Skip to content

Commit 4b51190

Browse files
committed
[nrf fromtree] tests: bluetooth: tester: Make brcst_source_stop synchronous
- Add semaphore to make sure source is stopped before proceeding - This ensures source can be released after this command is finished Signed-off-by: Alexander Svensen <[email protected]> (cherry picked from commit 6d19fc2)
1 parent 37e4e88 commit 4b51190

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/bluetooth/tester/src/audio/btp_cap.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,19 @@ static void unicast_stop_complete_cb(int err, struct bt_conn *conn)
153153
BTP_CAP_UNICAST_START_STATUS_SUCCESS);
154154
}
155155

156+
static void broadcast_stopped_cb(struct bt_cap_broadcast_source *source, uint8_t reason)
157+
{
158+
LOG_DBG("");
159+
160+
k_sem_give(&source_stopped_sem);
161+
}
162+
156163
static struct bt_cap_initiator_cb cap_cb = {
157164
.unicast_discovery_complete = cap_discovery_complete_cb,
158165
.unicast_start_complete = unicast_start_complete_cb,
159166
.unicast_update_complete = unicast_update_complete_cb,
160167
.unicast_stop_complete = unicast_stop_complete_cb,
168+
.broadcast_stopped = broadcast_stopped_cb,
161169
};
162170

163171
static uint8_t btp_cap_supported_commands(const void *cmd, uint16_t cmd_len,
@@ -854,6 +862,14 @@ static uint8_t btp_cap_broadcast_source_stop(const void *cmd, uint16_t cmd_len,
854862
return BTP_STATUS_FAILED;
855863
}
856864

865+
/* Make sure source is stopped before proceeding */
866+
err = k_sem_take(&source_stopped_sem, K_SECONDS(1));
867+
if (err) {
868+
LOG_ERR("Semaphore timed out: %d", err);
869+
870+
return BTP_STATUS_FAILED;
871+
}
872+
857873
return BTP_STATUS_SUCCESS;
858874
}
859875

0 commit comments

Comments
 (0)