Skip to content

Commit

Permalink
applications: nrf_desktop: Include check for scanning in scan_stop
Browse files Browse the repository at this point in the history
Make check for scanning part of the scan_stop function to simplify
implementation.

Jira: NCSDK-20843

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
  • Loading branch information
MarekPieta authored and nordicjm committed Aug 21, 2023
1 parent ed0d5b0 commit 7e18e9d
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions applications/nrf_desktop/src/modules/ble_scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ static void broadcast_scan_state(bool active)

static void scan_stop(void)
{
if (!scanning) {
return;
}

int err = bt_scan_stop();

if (err == -EALREADY) {
Expand Down Expand Up @@ -324,9 +328,7 @@ static void scan_start(void)
size_t bond_count = count_bond();
int err;

if (scanning) {
scan_stop();
}
scan_stop();

if (IS_ENABLED(CONFIG_DESKTOP_BLE_SCAN_PM_EVENTS) && scan_blocked) {
LOG_INF("Power down mode - scanning blocked");
Expand Down Expand Up @@ -506,10 +508,7 @@ static bool handle_hid_report_event(const struct hid_report_event *event)

/* Do not scan when devices are in use. */
scan_counter = 0;

if (scanning) {
scan_stop();
}
scan_stop();

return false;
}
Expand Down Expand Up @@ -646,10 +645,7 @@ static bool handle_ble_discovery_complete_event(const struct ble_discovery_compl

static bool handle_power_down_event(const struct power_down_event *event)
{
if (scanning) {
scan_stop();
}

scan_stop();
scan_blocked = true;
(void)k_work_cancel_delayable(&scan_start_trigger);

Expand Down

0 comments on commit 7e18e9d

Please sign in to comment.