Commit 7ec51764 authored by Emil Gydesen's avatar Emil Gydesen Committed by Henrik Brix Andersen
Browse files

Bluetooth: BAP: Shell: Print broadcast ID and broadcast name when scanning



When scanning, the broadcast_scan_recv now prints the broadcast ID
and the broadcast name (if found). Without this, it is not possible
to use the shell to scan for an unknown broadcast ID or broadcast
name.

Signed-off-by: default avatarEmil Gydesen <emil.gydesen@nordicsemi.no>
parent 5416b3a1
Loading
Loading
Loading
Loading
+11 −12
Original line number Diff line number Diff line
@@ -2384,7 +2384,7 @@ static uint16_t interval_to_sync_timeout(uint16_t interval)
	return (uint16_t)timeout;
}

static bool scan_check_and_sync_broadcast(struct bt_data *data, void *user_data)
static bool scan_check_and_get_broadcast_values(struct bt_data *data, void *user_data)
{
	struct bt_broadcast_info *sr_info = (struct bt_broadcast_info *)user_data;
	struct bt_uuid_16 adv_uuid;
@@ -2427,17 +2427,11 @@ static void broadcast_scan_recv(const struct bt_le_scan_recv_info *info, struct

	sr_info.broadcast_id = BT_BAP_INVALID_BROADCAST_ID;

	if ((auto_scan.broadcast_info.broadcast_id == BT_BAP_INVALID_BROADCAST_ID) &&
	    (strlen(auto_scan.broadcast_info.broadcast_name) == 0U)) {
		/* no op */
		return;
	}

	if (!passes_scan_filter(info, ad)) {
		return;
	}

	bt_data_parse(ad, scan_check_and_sync_broadcast, (void *)&sr_info);
	bt_data_parse(ad, scan_check_and_get_broadcast_values, (void *)&sr_info);

	/* Verify that it is a BAP broadcaster*/
	if (sr_info.broadcast_id == BT_BAP_INVALID_BROADCAST_ID) {
@@ -2446,6 +2440,15 @@ static void broadcast_scan_recv(const struct bt_le_scan_recv_info *info, struct

	bt_addr_le_to_str(info->addr, addr_str, sizeof(addr_str));

	bt_shell_print("Found broadcaster with ID 0x%06X (%s) and addr %s and sid 0x%02X ",
		       sr_info.broadcast_id, sr_info.broadcast_name, addr_str, info->sid);

	if ((auto_scan.broadcast_info.broadcast_id == BT_BAP_INVALID_BROADCAST_ID) &&
	    (strlen(auto_scan.broadcast_info.broadcast_name) == 0U)) {
		/* no op */
		return;
	}

	if (sr_info.broadcast_id == auto_scan.broadcast_info.broadcast_id) {
		identified_broadcast = true;
	} else if ((strlen(auto_scan.broadcast_info.broadcast_name) != 0U) &&
@@ -2462,10 +2465,6 @@ static void broadcast_scan_recv(const struct bt_le_scan_recv_info *info, struct
		struct bt_le_per_adv_sync_param create_params = {0};
		int err;

		bt_shell_print(
			"Found broadcaster with ID 0x%06X and addr %s and sid 0x%02X ",
			sr_info.broadcast_id, addr_str, info->sid);

		err = bt_le_scan_stop();
		if (err != 0) {
			bt_shell_error("Could not stop scan: %d", err);