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

[nrf fromtree] Bluetooth: Host: Log when connecting while scanning ma… #2305

Merged
merged 1 commit into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions subsys/bluetooth/host/conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -3756,6 +3756,12 @@
return -ENOMEM;
}

if (BT_LE_STATES_SCAN_INIT(bt_dev.le.states) &&
bt_le_explicit_scanner_running() &&
!bt_le_explicit_scanner_uses_same_params(create_param)) {

Check notice on line 3761 in subsys/bluetooth/host/conn.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

subsys/bluetooth/host/conn.c:3761 - if (BT_LE_STATES_SCAN_INIT(bt_dev.le.states) && - bt_le_explicit_scanner_running() && + if (BT_LE_STATES_SCAN_INIT(bt_dev.le.states) && bt_le_explicit_scanner_running() &&
LOG_WRN("Use same scan and connection create params to obtain best performance");
}

create_param_setup(create_param);

#if defined(CONFIG_BT_SMP)
Expand Down
17 changes: 17 additions & 0 deletions subsys/bluetooth/host/scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -2414,3 +2414,20 @@
{
return atomic_test_bit(scan_state.scan_flags, BT_LE_SCAN_USER_EXPLICIT_SCAN);
}

bool bt_le_explicit_scanner_uses_same_params(const struct bt_conn_le_create_param *create_param)
{
if (scan_state.explicit_scan_param.window != create_param->window ||
scan_state.explicit_scan_param.interval != create_param->interval){
return false;
}

if (scan_state.explicit_scan_param.options & BT_LE_SCAN_OPT_CODED) {
if (scan_state.explicit_scan_param.window_coded != create_param->window_coded ||
scan_state.explicit_scan_param.interval_coded != create_param->interval_coded){
return false;

Check notice on line 2428 in subsys/bluetooth/host/scan.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

subsys/bluetooth/host/scan.c:2428 - scan_state.explicit_scan_param.interval != create_param->interval){ + scan_state.explicit_scan_param.interval != create_param->interval) { return false; } if (scan_state.explicit_scan_param.options & BT_LE_SCAN_OPT_CODED) { if (scan_state.explicit_scan_param.window_coded != create_param->window_coded || - scan_state.explicit_scan_param.interval_coded != create_param->interval_coded){ + scan_state.explicit_scan_param.interval_coded != create_param->interval_coded) {
}
}

return true;
}
10 changes: 10 additions & 0 deletions subsys/bluetooth/host/scan.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,14 @@ int bt_le_scan_user_remove(enum bt_le_scan_user flag);
* Check if the explicit scanner was enabled.
*/
bool bt_le_explicit_scanner_running(void);

/**
* Check if an explicit scanner uses the same parameters
*
* @param create_param Parameters used for connection establishment.
*
* @return true If explicit scanner uses the same parameters
* @return false If explicit scanner uses different parameters
*/
bool bt_le_explicit_scanner_uses_same_params(const struct bt_conn_le_create_param *create_param);
#endif /* defined SUBSYS_BLUETOOTH_HOST_SCAN_H_ */
Loading