Skip to content

Commit a24fb02

Browse files
committed
samples: bluetooth: cleanup scan_start and delete_bonds functions
The scan_start and delete_bonds functions do not need return types. The functions have mostly been invoked without storing the return value and the places where the return value have been used, it is not strictly necessary. Clean this up. Also update some logs to align with other samples. Signed-off-by: Andreas Moltumyr <andreas.moltumyr@nordicsemi.no>
1 parent 49fa7cc commit a24fb02

2 files changed

Lines changed: 13 additions & 25 deletions

File tree

  • samples/bluetooth

samples/bluetooth/ble_hrs_central/src/main.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ static uint32_t active_conn_count(atomic_t *conn)
8080
return set_flag_count;
8181
}
8282

83-
static uint32_t scan_start(bool erase_bonds);
83+
static void scan_start(bool erase_bonds);
8484

8585
static void db_disc_handler(struct ble_db_discovery *db_discovery,
8686
struct ble_db_discovery_evt *evt)
@@ -225,7 +225,8 @@ static uint32_t peer_manager_init(void)
225225

226226
return NRF_SUCCESS;
227227
}
228-
static uint32_t delete_bonds(void)
228+
229+
static void delete_bonds(void)
229230
{
230231
uint32_t nrf_err;
231232

@@ -234,18 +235,14 @@ static uint32_t delete_bonds(void)
234235
nrf_err = pm_peers_delete();
235236
if (nrf_err) {
236237
LOG_ERR("Failed to delete bonds, nrf_error %#x", nrf_err);
237-
return nrf_err;
238238
}
239-
240-
return NRF_SUCCESS;
241239
}
242240

243241
static void allow_list_disable(void)
244242
{
245243
if (!allow_list_disabled) {
246244
LOG_INF("allow list temporarily disabled");
247245
allow_list_disabled = true;
248-
ble_scan_stop(&ble_scan);
249246
scan_start(false);
250247
}
251248
}
@@ -467,7 +464,7 @@ static uint32_t on_allow_list_req(void)
467464
return NRF_SUCCESS;
468465
}
469466

470-
static uint32_t scan_start(bool erase_bonds)
467+
static void scan_start(bool erase_bonds)
471468
{
472469
uint32_t nrf_err;
473470

@@ -477,12 +474,9 @@ static uint32_t scan_start(bool erase_bonds)
477474
} else {
478475
nrf_err = ble_scan_start(&ble_scan);
479476
if (nrf_err) {
480-
LOG_ERR("ble_scan_start failed, nrf_error %#x", nrf_err);
481-
return nrf_err;
477+
LOG_ERR("Failed to start scanning, nrf_error %#x", nrf_err);
482478
}
483479
}
484-
485-
return NRF_SUCCESS;
486480
}
487481

488482
static void conn_params_evt_handler(const struct ble_conn_params_evt *evt)

samples/bluetooth/ble_nus_central/src/main.c

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static uint8_t uarte_rx_buf[CONFIG_SAMPLE_NUS_CENTRAL_UART_RX_BUF_SIZE][2];
6767
static int buf_idx;
6868

6969
/* Forward declaration. */
70-
static uint32_t scan_start(void);
70+
static void scan_start(void);
7171

7272
#if defined(CONFIG_SAMPLE_NUS_CENTRAL_LPUARTE)
7373
static void lpuarte_rx_handler(char *data, size_t data_len)
@@ -301,7 +301,7 @@ static void on_ble_scan_evt(struct ble_scan_evt const *ble_scan_evt)
301301
break;
302302
case BLE_SCAN_EVT_SCAN_TIMEOUT:
303303
LOG_INF("Scan timed out");
304-
(void)scan_start();
304+
scan_start();
305305
break;
306306
default:
307307
break;
@@ -347,7 +347,7 @@ static void on_ble_nus_client_evt(struct ble_nus_client *ble_nus_c,
347347
break;
348348
case BLE_NUS_CLIENT_EVT_DISCONNECTED:
349349
LOG_INF("Disconnected");
350-
(void)scan_start();
350+
scan_start();
351351
break;
352352
case BLE_NUS_CLIENT_EVT_ERROR:
353353
LOG_ERR("NUS error, nrf_error %#x", ble_nus_evt->error.reason);
@@ -565,16 +565,14 @@ static uint32_t db_discovery_init(void)
565565
return nrf_err;
566566
}
567567

568-
static uint32_t scan_start(void)
568+
static void scan_start(void)
569569
{
570570
uint32_t nrf_err;
571571

572572
nrf_err = ble_scan_start(&ble_scan);
573573
if (nrf_err) {
574-
LOG_ERR("Failed to start ble_scanning, nrf_error %#x", nrf_err);
574+
LOG_ERR("Failed to start scanning, nrf_error %#x", nrf_err);
575575
}
576-
577-
return nrf_err;
578576
}
579577

580578
int main(void)
@@ -638,16 +636,12 @@ int main(void)
638636
goto idle;
639637
}
640638

641-
/** Start execution.*/
642-
LOG_INF("BLE NUS central example started");
643-
nrf_err = scan_start();
644-
if (nrf_err) {
645-
goto idle;
646-
}
647-
648639
#if !defined(CONFIG_SAMPLE_NUS_CENTRAL_LPUARTE)
649640
nrf_gpio_pin_write(BOARD_PIN_LED_0, BOARD_LED_ACTIVE_STATE);
650641
#endif
642+
LOG_INF("BLE NUS Central sample initialized");
643+
644+
scan_start();
651645

652646
idle:
653647
/** Enter main loop.*/

0 commit comments

Comments
 (0)