Hello, everyone!
I am using nRF52DK and SDK v17, and I am dealing with the example of ble_app_uart.
Using this example, I am testing how buttons control BLE scanning. As I was conducting the test, I realized that I could start a scan using the code below.
static void advertising_start(bool erase_bonds) { if (erase_bonds == true) { delete_bonds(); // Advertising is started by PM_EVT_PEERS_DELETE_SUCCEEDED event. } else { ret_code_t err_code; err_code = ble_advertising_start(&m_advertising, BLE_ADV_MODE_FAST); APP_ERROR_CHECK(err_code); } }
I knew how to start a scan like this, but I couldn't find a way to stop the scan.
As shown in the code below, the example ble_app_blinky saw that I could easily start and stop a scan using a different function.
I think this method is different from the example of the ble_app_uart, is it okay to use the same code? or is there another way?
I think this method is different from the example of the ble_app_uart, is it okay to use the same code? or is there another way?
static void advertising_start(void) //bluetooth scanning start { ret_code_t err_code; err_code = sd_ble_gap_adv_start(m_adv_handle, APP_BLE_CONN_CFG_TAG); APP_ERROR_CHECK(err_code); bsp_board_led_on(ADVERTISING_LED); //led1 } static void advertising_stop() { ret_code_t err_code; err_code = sd_ble_gap_adv_stop(m_adv_handle); APP_ERROR_CHECK(err_code); bsp_board_led_off(ADVERTISING_LED); //led1 }
Thank you for reading through!