From 18997508fbf7171c2b7ae908dc62d8d879c11c00 Mon Sep 17 00:00:00 2001 From: Jui-Chou Chung Date: Fri, 11 Aug 2023 19:52:49 +0800 Subject: [PATCH] application: nrf5340_audio: Fix num_conn not set and zbus wait time Fix num_conn not initialized properly which could cause the CIS gateway cannot establish connection properly. Fix zbus publish wait time in le_audio_event_publish. Signed-off-by: Jui-Chou Chung --- .../nrf5340_audio/src/bluetooth/bt_management/bt_mgmt.c | 2 +- applications/nrf5340_audio/src/bluetooth/le_audio.h | 1 + applications/nrf5340_audio/src/bluetooth/le_audio_bis_gateway.c | 2 +- applications/nrf5340_audio/src/bluetooth/le_audio_bis_headset.c | 2 +- applications/nrf5340_audio/src/bluetooth/le_audio_cis_gateway.c | 2 +- applications/nrf5340_audio/src/bluetooth/le_audio_cis_headset.c | 2 +- 6 files changed, 6 insertions(+), 5 deletions(-) diff --git a/applications/nrf5340_audio/src/bluetooth/bt_management/bt_mgmt.c b/applications/nrf5340_audio/src/bluetooth/bt_management/bt_mgmt.c index 0ec4ccbaabf1..f76289e9aecb 100644 --- a/applications/nrf5340_audio/src/bluetooth/bt_management/bt_mgmt.c +++ b/applications/nrf5340_audio/src/bluetooth/bt_management/bt_mgmt.c @@ -75,7 +75,7 @@ static void connected_cb(struct bt_conn *conn, uint8_t err) { int ret; char addr[BT_ADDR_LE_STR_LEN]; - uint8_t num_conn; + uint8_t num_conn = 0; uint16_t conn_handle; enum ble_hci_vs_tx_power conn_tx_pwr; struct bt_mgmt_msg msg; diff --git a/applications/nrf5340_audio/src/bluetooth/le_audio.h b/applications/nrf5340_audio/src/bluetooth/le_audio.h index a0d108ca4ce6..f38aa25eca33 100644 --- a/applications/nrf5340_audio/src/bluetooth/le_audio.h +++ b/applications/nrf5340_audio/src/bluetooth/le_audio.h @@ -11,6 +11,7 @@ #include #include +#define LE_AUDIO_ZBUS_EVENT_WAIT_TIME K_MSEC(5) #define LE_AUDIO_SDU_SIZE_OCTETS(bitrate) (bitrate / (1000000 / CONFIG_AUDIO_FRAME_DURATION_US) / 8) #if (CONFIG_AUDIO_SAMPLE_RATE_48000_HZ) diff --git a/applications/nrf5340_audio/src/bluetooth/le_audio_bis_gateway.c b/applications/nrf5340_audio/src/bluetooth/le_audio_bis_gateway.c index 3dcc7130b615..a07b715c1301 100644 --- a/applications/nrf5340_audio/src/bluetooth/le_audio_bis_gateway.c +++ b/applications/nrf5340_audio/src/bluetooth/le_audio_bis_gateway.c @@ -75,7 +75,7 @@ static void le_audio_event_publish(enum le_audio_evt_type event) msg.event = event; - ret = zbus_chan_pub(&le_audio_chan, &msg, K_NO_WAIT); + ret = zbus_chan_pub(&le_audio_chan, &msg, LE_AUDIO_ZBUS_EVENT_WAIT_TIME); ERR_CHK(ret); } diff --git a/applications/nrf5340_audio/src/bluetooth/le_audio_bis_headset.c b/applications/nrf5340_audio/src/bluetooth/le_audio_bis_headset.c index 380f9a2f654f..51b1e6029a8e 100644 --- a/applications/nrf5340_audio/src/bluetooth/le_audio_bis_headset.c +++ b/applications/nrf5340_audio/src/bluetooth/le_audio_bis_headset.c @@ -77,7 +77,7 @@ static void le_audio_event_publish(enum le_audio_evt_type event) msg.event = event; - ret = zbus_chan_pub(&le_audio_chan, &msg, K_NO_WAIT); + ret = zbus_chan_pub(&le_audio_chan, &msg, LE_AUDIO_ZBUS_EVENT_WAIT_TIME); ERR_CHK(ret); } diff --git a/applications/nrf5340_audio/src/bluetooth/le_audio_cis_gateway.c b/applications/nrf5340_audio/src/bluetooth/le_audio_cis_gateway.c index 8513132b7b9d..8c448f75a673 100644 --- a/applications/nrf5340_audio/src/bluetooth/le_audio_cis_gateway.c +++ b/applications/nrf5340_audio/src/bluetooth/le_audio_cis_gateway.c @@ -112,7 +112,7 @@ static void le_audio_event_publish(enum le_audio_evt_type event, struct bt_conn msg.event = event; msg.conn = conn; - ret = zbus_chan_pub(&le_audio_chan, &msg, K_NO_WAIT); + ret = zbus_chan_pub(&le_audio_chan, &msg, LE_AUDIO_ZBUS_EVENT_WAIT_TIME); ERR_CHK(ret); } diff --git a/applications/nrf5340_audio/src/bluetooth/le_audio_cis_headset.c b/applications/nrf5340_audio/src/bluetooth/le_audio_cis_headset.c index cb9d6c3c5006..14bfc8a519a6 100644 --- a/applications/nrf5340_audio/src/bluetooth/le_audio_cis_headset.c +++ b/applications/nrf5340_audio/src/bluetooth/le_audio_cis_headset.c @@ -77,7 +77,7 @@ static void le_audio_event_publish(enum le_audio_evt_type event, struct bt_conn msg.event = event; msg.conn = conn; - ret = zbus_chan_pub(&le_audio_chan, &msg, K_NO_WAIT); + ret = zbus_chan_pub(&le_audio_chan, &msg, LE_AUDIO_ZBUS_EVENT_WAIT_TIME); ERR_CHK(ret); }