diff --git a/tests/bluetooth/tester/src/audio/btp_cap.c b/tests/bluetooth/tester/src/audio/btp_cap.c index f8da879ae10..6563a761e7e 100644 --- a/tests/bluetooth/tester/src/audio/btp_cap.c +++ b/tests/bluetooth/tester/src/audio/btp_cap.c @@ -697,6 +697,11 @@ static uint8_t btp_cap_broadcast_source_release(const void *cmd, uint16_t cmd_le LOG_DBG(""); + /* If no source has been created yet, there is nothing to release */ + if (source == NULL || source->cap_broadcast == NULL) { + return BTP_STATUS_SUCCESS; + } + err = bt_cap_initiator_broadcast_audio_delete(source->cap_broadcast); if (err != 0) { LOG_DBG("Unable to delete broadcast source: %d", err); @@ -744,7 +749,11 @@ static uint8_t btp_cap_broadcast_adv_stop(const void *cmd, uint16_t cmd_len, LOG_DBG(""); err = tester_gap_padv_stop(); - if (err != 0) { + if (err == -ESRCH) { + /* Ext adv hasn't been created yet */ + return BTP_STATUS_SUCCESS; + } else if (err != 0) { + LOG_DBG("Failed to stop periodic adv, err: %d", err); return BTP_STATUS_FAILED; } @@ -786,6 +795,11 @@ static uint8_t btp_cap_broadcast_source_stop(const void *cmd, uint16_t cmd_len, struct btp_bap_broadcast_local_source *source = btp_bap_broadcast_local_source_get(cp->source_id); + /* If no source has been started yet, there is nothing to stop */ + if (source == NULL || source->cap_broadcast == NULL) { + return BTP_STATUS_SUCCESS; + } + err = bt_cap_initiator_broadcast_audio_stop(source->cap_broadcast); if (err != 0) { LOG_ERR("Failed to stop audio source: %d", err); diff --git a/tests/bluetooth/tester/src/btp_gap.c b/tests/bluetooth/tester/src/btp_gap.c index 4c9b4ff7f34..b344f76d19a 100644 --- a/tests/bluetooth/tester/src/btp_gap.c +++ b/tests/bluetooth/tester/src/btp_gap.c @@ -1548,7 +1548,8 @@ int tester_gap_padv_stop(void) int err; if (ext_adv == NULL) { - return -EINVAL; + /* Ext adv not yet created */ + return -ESRCH; } /* Enable Periodic Advertising */