Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

applications: nrf5340_audio: Check connectable flag for CIS gateway #11667

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions applications/nrf5340_audio/src/bluetooth/le_audio_cis_gateway.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <zephyr/zbus/zbus.h>
#include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/gap.h>
#include <zephyr/bluetooth/audio/audio.h>
#include <zephyr/bluetooth/hci.h>
#include <zephyr/bluetooth/audio/bap.h>
Expand Down Expand Up @@ -1104,14 +1105,13 @@ static void ad_parse(struct net_buf_simple *p_ad, const bt_addr_le_t *addr)
}
}

static void on_device_found(const bt_addr_le_t *addr, int8_t rssi, uint8_t type,
struct net_buf_simple *p_ad)
static void on_device_found(const struct bt_le_scan_recv_info *info, struct net_buf_simple *p_ad)
{
switch (type) {
switch (info->adv_type) {
case BT_GAP_ADV_TYPE_ADV_DIRECT_IND:
/* Direct advertising has no payload, so no need to parse */
if (bonded_num) {
bt_foreach_bond(BT_ID_DEFAULT, bond_connect, (void *)addr);
bt_foreach_bond(BT_ID_DEFAULT, bond_connect, (void *)info->addr);
}
break;
case BT_GAP_ADV_TYPE_ADV_IND:
Expand All @@ -1120,15 +1120,18 @@ static void on_device_found(const bt_addr_le_t *addr, int8_t rssi, uint8_t type,
/* Fall through */
case BT_GAP_ADV_TYPE_SCAN_RSP:
/* Note: May lead to connection creation */
if (bonded_num < CONFIG_BT_MAX_PAIRED) {
ad_parse(p_ad, addr);
if ((bonded_num < CONFIG_BT_MAX_PAIRED) &&
(info->adv_props & BT_GAP_ADV_PROP_CONNECTABLE)) {
ad_parse(p_ad, info->addr);
}
break;
default:
break;
}
}

struct bt_le_scan_cb scan_callback = {.recv = on_device_found};

static void ble_acl_start_scan(void)
{
int ret;
Expand All @@ -1151,7 +1154,7 @@ static void ble_acl_start_scan(void)
LOG_INF("All bonded slots filled, will not accept new devices");
}

ret = bt_le_scan_start(scan_param, on_device_found);
ret = bt_le_scan_start(scan_param, NULL);
if (ret && ret != -EALREADY) {
LOG_WRN("Scanning failed to start: %d", ret);
return;
Expand Down Expand Up @@ -1524,6 +1527,7 @@ static int initialize(le_audio_receive_cb recv_cb, le_audio_timestamp_cb timestm
#endif /* CONFIG_BT_MCS */

bt_conn_cb_register(&conn_callbacks);
bt_le_scan_cb_register(&scan_callback);

initialized = true;

Expand Down