From aa775c99d44cb8618ea042306912bd251cb66208 Mon Sep 17 00:00:00 2001 From: Filip Kubicz Date: Wed, 23 Jan 2019 15:35:05 +0100 Subject: [PATCH] samples: nrf_desktop: Do not fail on advertising restart 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 --- samples/nrf_desktop/src/modules/ble_adv.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/samples/nrf_desktop/src/modules/ble_adv.c b/samples/nrf_desktop/src/modules/ble_adv.c index c1959c98d224..77e64d94d58c 100644 --- a/samples/nrf_desktop/src/modules/ble_adv.c +++ b/samples/nrf_desktop/src/modules/ble_adv.c @@ -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)); } }