diff --git a/subsys/bluetooth/audio/tbs.c b/subsys/bluetooth/audio/tbs.c index 9159d2b23247dc9..33e90c2017d8b04 100644 --- a/subsys/bluetooth/audio/tbs.c +++ b/subsys/bluetooth/audio/tbs.c @@ -307,18 +307,22 @@ static void tbs_set_terminate_reason(struct tbs_service_inst *inst, static uint8_t next_free_call_index(void) { for (int i = 0; i < CONFIG_BT_TBS_MAX_CALLS; i++) { - static uint8_t next_call_index = 1; - const struct bt_tbs_call *call = lookup_call(next_call_index); - - if (call == NULL) { - return next_call_index++; - } + static uint8_t next_call_index = 0; + const struct bt_tbs_call *call; + /* For each new call, the call index should be incremented */ next_call_index++; - if (next_call_index == UINT8_MAX) { + + if (next_call_index == BT_TBS_FREE_CALL_INDEX) { /* call_index = 0 reserved for outgoing calls */ next_call_index = 1; } + + call = lookup_call(next_call_index); + + if (call == NULL) { + return next_call_index; + } } LOG_DBG("No more free call spots");