Skip to content

Commit

Permalink
samples: nrf_desktop: Do not fail on advertising restart
Browse files Browse the repository at this point in the history
Ignore error when advertising cannot be started because some peer has
already connected.

There is a race between BLE connected event and a
scheduled work. Do not fail in a rare case where peer has already
connected, but this information was not yet propagated to advertising
module.

Signed-off-by: Filip Kubicz <[email protected]>
  • Loading branch information
Qbicz authored and pizi-nordic committed Jan 24, 2019
1 parent 9e12c21 commit aa775c9
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions samples/nrf_desktop/src/modules/ble_adv.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,18 @@ static void ble_adv_update_fn(struct k_work *work)
ad, ARRAY_SIZE(ad), sd, ARRAY_SIZE(sd));
}

if (err) {
if (err == -EIO) {
LOG_WRN("Already connected, do not advertise");
} else if (err) {
LOG_ERR("Failed to restart advertising (err %d)", err);
k_delayed_work_cancel(&vendor_section_remove);

module_set_state(MODULE_STATE_ERROR);
} else {
k_delayed_work_submit(&vendor_section_remove,
K_SECONDS(SWIFT_PAIR_SECTION_REMOVE_TIMEOUT));
return;
}

k_delayed_work_submit(&vendor_section_remove,
K_SECONDS(SWIFT_PAIR_SECTION_REMOVE_TIMEOUT));
}
}

Expand Down

0 comments on commit aa775c9

Please sign in to comment.