Skip to content

Commit c322b35

Browse files
alexsvenkoffes
authored andcommitted
applications: nrf5340_audio: Move ACL update to discovery complete
- Update ACL interval when discovery is done - Moved to make sure controller is not busy - OCT-3661 Signed-off-by: Alexander Svensen <alexander.svensen@nordicsemi.no>
1 parent ef71ad6 commit c322b35

3 files changed

Lines changed: 39 additions & 28 deletions

File tree

applications/nrf5340_audio/include/zbus_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ enum le_audio_evt_type {
3434
LE_AUDIO_EVT_SYNC_LOST,
3535
LE_AUDIO_EVT_NO_VALID_CFG,
3636
LE_AUDIO_EVT_COORD_SET_DISCOVERED,
37+
LE_AUDIO_EVT_DISCOVERY_COMPLETE,
3738
};
3839

3940
struct le_audio_msg {

applications/nrf5340_audio/src/bluetooth/bt_stream/unicast/unicast_client.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,8 @@ static void discover_cb(struct bt_conn *conn, int err, enum bt_audio_dir dir)
898898
return;
899899
}
900900

901+
le_audio_event_publish(LE_AUDIO_EVT_DISCOVERY_COMPLETE, conn, NULL, dir);
902+
901903
srv_store_unlock();
902904
k_work_submit(&cap_start_work);
903905
}

applications/nrf5340_audio/unicast_client/main.c

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -281,34 +281,6 @@ static void le_audio_msg_sub_thread(void)
281281
break;
282282

283283
case LE_AUDIO_EVT_CONFIG_RECEIVED:
284-
struct bt_conn_info conn_info;
285-
uint16_t interval = 0;
286-
287-
ret = bt_conn_get_info(msg.conn, &conn_info);
288-
if (ret) {
289-
LOG_ERR("Failed to get conn info");
290-
} else {
291-
interval = BT_GAP_US_TO_CONN_INTERVAL(conn_info.le.interval_us);
292-
}
293-
294-
/* Only update conn param once */
295-
if (((IS_ENABLED(CONFIG_BT_AUDIO_TX) && msg.dir == BT_AUDIO_DIR_SINK) ||
296-
(!IS_ENABLED(CONFIG_BT_AUDIO_TX) && msg.dir == BT_AUDIO_DIR_SOURCE)) &&
297-
interval != CONFIG_BLE_ACL_CONN_INTERVAL_SLOW) {
298-
struct bt_le_conn_param param;
299-
300-
/* Set the ACL interval up to allow more time for ISO packets */
301-
param.interval_min = CONFIG_BLE_ACL_CONN_INTERVAL_SLOW;
302-
param.interval_max = CONFIG_BLE_ACL_CONN_INTERVAL_SLOW;
303-
param.latency = CONFIG_BLE_ACL_SLAVE_LATENCY;
304-
param.timeout = CONFIG_BLE_ACL_SUP_TIMEOUT;
305-
306-
ret = bt_conn_le_param_update(msg.conn, &param);
307-
if (ret) {
308-
LOG_WRN("Failed to update conn parameters: %d", ret);
309-
}
310-
}
311-
312284
LOG_DBG("LE audio config received");
313285

314286
ret = unicast_client_config_get(msg.stream, &bitrate_bps,
@@ -378,6 +350,42 @@ static void le_audio_msg_sub_thread(void)
378350
/* Nothing to do. */
379351
break;
380352

353+
case LE_AUDIO_EVT_DISCOVERY_COMPLETE:
354+
LOG_DBG("Discovery complete event received");
355+
356+
/* Only update conn param once */
357+
struct bt_conn_info conn_info;
358+
uint16_t interval = 0;
359+
360+
ret = bt_conn_get_info(msg.conn, &conn_info);
361+
if (ret) {
362+
LOG_ERR("Failed to get conn info");
363+
} else {
364+
interval = BT_GAP_US_TO_CONN_INTERVAL(conn_info.le.interval_us);
365+
}
366+
367+
if (((IS_ENABLED(CONFIG_BT_AUDIO_TX) && msg.dir == BT_AUDIO_DIR_SINK) ||
368+
(!IS_ENABLED(CONFIG_BT_AUDIO_TX) && msg.dir == BT_AUDIO_DIR_SOURCE)) &&
369+
interval != CONFIG_BLE_ACL_CONN_INTERVAL_SLOW) {
370+
struct bt_le_conn_param param;
371+
372+
/* Set the ACL interval up to allow more time for ISO packets */
373+
param.interval_min = CONFIG_BLE_ACL_CONN_INTERVAL_SLOW;
374+
param.interval_max = CONFIG_BLE_ACL_CONN_INTERVAL_SLOW;
375+
param.latency = CONFIG_BLE_ACL_SLAVE_LATENCY;
376+
param.timeout = CONFIG_BLE_ACL_SUP_TIMEOUT;
377+
378+
ret = bt_conn_le_param_update(msg.conn, &param);
379+
if (ret) {
380+
LOG_WRN("Failed to update conn parameters: %d", ret);
381+
}
382+
383+
LOG_DBG("Updated ACL conn interval to %3.2f ms for conn 0x%p",
384+
1.25 * CONFIG_BLE_ACL_CONN_INTERVAL_SLOW, msg.conn);
385+
}
386+
387+
break;
388+
381389
default:
382390
LOG_WRN("Unexpected/unhandled le_audio event: %d", msg.event);
383391
break;

0 commit comments

Comments
 (0)