samples: Bluetooth: Fix Tx ISO Data packet sequence number

Fix Tx ISO Data packet sequence number increment based on
the send timer timeout value.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit is contained in:
Vinayak Kariappa Chettimada 2023-06-02 06:46:29 +05:30 committed by Anas Nashif
commit b7c2ca4bdf
2 changed files with 35 additions and 4 deletions

View file

@ -58,11 +58,24 @@ static K_SEM_DEFINE(sem_stream_qos, 0, ARRAY_SIZE(sinks) + ARRAY_SIZE(sources));
static K_SEM_DEFINE(sem_stream_enabled, 0, 1);
static K_SEM_DEFINE(sem_stream_started, 0, 1);
#define AUDIO_DATA_TIMEOUT_US 1000000UL /* Send data every 1 second */
static uint16_t get_and_incr_seq_num(const struct bt_bap_stream *stream)
{
for (size_t i = 0U; i < configured_sink_stream_count; i++) {
if (stream->ep == sinks[i].ep) {
return sinks[i].seq_num++;
uint16_t seq_num;
seq_num = sinks[i].seq_num;
if (IS_ENABLED(CONFIG_LIBLC3)) {
sinks[i].seq_num++;
} else {
sinks[i].seq_num += (AUDIO_DATA_TIMEOUT_US /
codec_configuration.qos.interval);
}
return seq_num;
}
}
@ -322,7 +335,7 @@ static void audio_timer_timeout(struct k_work *work)
}
}
k_work_schedule(&audio_send_work, K_MSEC(1000));
k_work_schedule(&audio_send_work, K_USEC(AUDIO_DATA_TIMEOUT_US));
len_to_send++;
if (len_to_send > codec_configuration.qos.sdu) {

View file

@ -69,11 +69,25 @@ static const struct bt_data ad[] = {
BT_DATA(BT_DATA_SVC_DATA16, unicast_server_addata, ARRAY_SIZE(unicast_server_addata)),
};
#define AUDIO_DATA_TIMEOUT_US 1000000UL /* Send data every 1 second */
#define SDU_INTERVAL_US 10000UL /* 10 ms SDU interval */
static uint16_t get_and_incr_seq_num(const struct bt_bap_stream *stream)
{
for (size_t i = 0U; i < configured_source_stream_count; i++) {
if (stream == &source_streams[i].stream) {
return source_streams[i].seq_num++;
uint16_t seq_num;
seq_num = source_streams[i].seq_num;
if (IS_ENABLED(CONFIG_LIBLC3)) {
source_streams[i].seq_num++;
} else {
source_streams[i].seq_num += (AUDIO_DATA_TIMEOUT_US /
SDU_INTERVAL_US);
}
return seq_num;
}
}
@ -214,7 +228,11 @@ static void audio_timer_timeout(struct k_work *work)
}
}
k_work_schedule(&audio_send_work, K_MSEC(1000U));
#if defined(CONFIG_LIBLC3)
k_work_schedule(&audio_send_work, K_USEC(MAX_FRAME_DURATION_US));
#else
k_work_schedule(&audio_send_work, K_USEC(AUDIO_DATA_TIMEOUT_US));
#endif
}
static enum bt_audio_dir stream_dir(const struct bt_bap_stream *stream)