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:
parent
7d7d1cbf53
commit
b7c2ca4bdf
2 changed files with 35 additions and 4 deletions
|
@ -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_enabled, 0, 1);
|
||||||
static K_SEM_DEFINE(sem_stream_started, 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)
|
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++) {
|
for (size_t i = 0U; i < configured_sink_stream_count; i++) {
|
||||||
if (stream->ep == sinks[i].ep) {
|
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++;
|
len_to_send++;
|
||||||
if (len_to_send > codec_configuration.qos.sdu) {
|
if (len_to_send > codec_configuration.qos.sdu) {
|
||||||
|
|
|
@ -69,11 +69,25 @@ static const struct bt_data ad[] = {
|
||||||
BT_DATA(BT_DATA_SVC_DATA16, unicast_server_addata, ARRAY_SIZE(unicast_server_addata)),
|
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)
|
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++) {
|
for (size_t i = 0U; i < configured_source_stream_count; i++) {
|
||||||
if (stream == &source_streams[i].stream) {
|
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)
|
static enum bt_audio_dir stream_dir(const struct bt_bap_stream *stream)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue