Skip to content

Commit 5cf5bae

Browse files
committed
Applications: Audio: Added print on broadcast ID mismatch
- OCT-3255 - If broadcast name is found, but the ID has changed, print a message Signed-off-by: Kristoffer Rist Skøien <[email protected]>
1 parent 435c9af commit 5cf5bae

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

applications/nrf5340_audio/src/bluetooth/bt_management/scanning/bt_mgmt_scan_for_broadcast.c

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ static bool scan_check_broadcast_source(struct bt_data *data, void *user_data)
183183
static void scan_recv_cb(const struct bt_le_scan_recv_info *info, struct net_buf_simple *ad)
184184
{
185185
struct broadcast_source source = {.id = INVALID_BROADCAST_ID};
186+
static bool id_change_printed;
186187

187188
/* We are only interested in non-connectable periodic advertisers */
188189
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
191192

192193
bt_data_parse(ad, scan_check_broadcast_source, (void *)&source);
193194

194-
if (source.id != INVALID_BROADCAST_ID) {
195-
if (srch_brdcast_id < BRDCAST_ID_NOT_USED) {
196-
/* Valid srch_brdcast_id supplied */
197-
if (source.id != srch_brdcast_id) {
198-
/* Broadcaster does not match src_brdcast_id */
199-
return;
200-
}
195+
if (source.id == INVALID_BROADCAST_ID) {
196+
return;
197+
}
201198

202-
} else if (strncmp(source.name, srch_name, BLE_SEARCH_NAME_MAX_LEN) != 0) {
203-
/* Broadcaster does not match src_name */
199+
if (srch_brdcast_id < BRDCAST_ID_NOT_USED) {
200+
/* Valid srch_brdcast_id supplied */
201+
if (source.id != srch_brdcast_id) {
202+
/* Broadcaster does not match src_brdcast_id */
203+
if (!id_change_printed &&
204+
strncmp(source.name, srch_name, BLE_SEARCH_NAME_MAX_LEN) == 0) {
205+
LOG_INF("%s found with ID: 0x%06x\r\n"
206+
"Looking for ID: 0x%06x. Broadcaster may have changed ID",
207+
source.name, source.id, srch_brdcast_id);
208+
id_change_printed = true;
209+
}
204210
return;
205211
}
206212

207-
LOG_DBG("Broadcast source %s found, id: 0x%06x", source.name, source.id);
208-
periodic_adv_sync(info, source);
213+
} else if (strncmp(source.name, srch_name, BLE_SEARCH_NAME_MAX_LEN) != 0) {
214+
/* Broadcaster does not match src_name */
215+
return;
209216
}
217+
218+
LOG_DBG("Broadcast source %s found, id: 0x%06x", source.name, source.id);
219+
id_change_printed = false;
220+
periodic_adv_sync(info, source);
210221
}
211222

212223
static void pa_synced_cb(struct bt_le_per_adv_sync *sync,

0 commit comments

Comments
 (0)