From 5cf5bae9d6db77b2fc91cf9dff462bc644b54456 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristoffer=20Rist=20Sk=C3=B8ien?= Date: Mon, 9 Dec 2024 15:48:12 +0100 Subject: [PATCH] Applications: Audio: Added print on broadcast ID mismatch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - OCT-3255 - If broadcast name is found, but the ID has changed, print a message Signed-off-by: Kristoffer Rist Skøien --- .../scanning/bt_mgmt_scan_for_broadcast.c | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/applications/nrf5340_audio/src/bluetooth/bt_management/scanning/bt_mgmt_scan_for_broadcast.c b/applications/nrf5340_audio/src/bluetooth/bt_management/scanning/bt_mgmt_scan_for_broadcast.c index 49e91e68d90e..351162269e57 100644 --- a/applications/nrf5340_audio/src/bluetooth/bt_management/scanning/bt_mgmt_scan_for_broadcast.c +++ b/applications/nrf5340_audio/src/bluetooth/bt_management/scanning/bt_mgmt_scan_for_broadcast.c @@ -183,6 +183,7 @@ static bool scan_check_broadcast_source(struct bt_data *data, void *user_data) static void scan_recv_cb(const struct bt_le_scan_recv_info *info, struct net_buf_simple *ad) { struct broadcast_source source = {.id = INVALID_BROADCAST_ID}; + static bool id_change_printed; /* We are only interested in non-connectable periodic advertisers */ if ((info->adv_props & BT_GAP_ADV_PROP_CONNECTABLE) || info->interval == 0) { @@ -191,22 +192,32 @@ static void scan_recv_cb(const struct bt_le_scan_recv_info *info, struct net_buf bt_data_parse(ad, scan_check_broadcast_source, (void *)&source); - if (source.id != INVALID_BROADCAST_ID) { - if (srch_brdcast_id < BRDCAST_ID_NOT_USED) { - /* Valid srch_brdcast_id supplied */ - if (source.id != srch_brdcast_id) { - /* Broadcaster does not match src_brdcast_id */ - return; - } + if (source.id == INVALID_BROADCAST_ID) { + return; + } - } else if (strncmp(source.name, srch_name, BLE_SEARCH_NAME_MAX_LEN) != 0) { - /* Broadcaster does not match src_name */ + if (srch_brdcast_id < BRDCAST_ID_NOT_USED) { + /* Valid srch_brdcast_id supplied */ + if (source.id != srch_brdcast_id) { + /* Broadcaster does not match src_brdcast_id */ + if (!id_change_printed && + strncmp(source.name, srch_name, BLE_SEARCH_NAME_MAX_LEN) == 0) { + LOG_INF("%s found with ID: 0x%06x\r\n" + "Looking for ID: 0x%06x. Broadcaster may have changed ID", + source.name, source.id, srch_brdcast_id); + id_change_printed = true; + } return; } - LOG_DBG("Broadcast source %s found, id: 0x%06x", source.name, source.id); - periodic_adv_sync(info, source); + } else if (strncmp(source.name, srch_name, BLE_SEARCH_NAME_MAX_LEN) != 0) { + /* Broadcaster does not match src_name */ + return; } + + LOG_DBG("Broadcast source %s found, id: 0x%06x", source.name, source.id); + id_change_printed = false; + periodic_adv_sync(info, source); } static void pa_synced_cb(struct bt_le_per_adv_sync *sync,