Hi,
We are developing a new internal engineering tool that mostly does passive scanning on the NRF52840 dongle connected over USB but I'd like to be able to switch to active scanning on demand.
I think what I'd like to do is have multiple scanning instances that have their own callbacks and initialize the active scanning one whenever I need it with a timeout of 30s or so and have the passive scan's callbacks always going on--I'd like them to happen at "the same time" if possible (aka they're both enabled at the same time). Is something like this possible to do in the current SDK15.3 + S140 6.1.0? Example below:
static nrf_ble_scan_t m_scan1; /**< Scanning Module instance. */
NRF_SDH_BLE_OBSERVER(m_passive_ble_obs,1,nrf_ble_scan_on_ble_evt,&m_scan1);
ble_gap_scan_params_t scan_params = {0};
scan_params.active = 0x00; /* Active scanning */
scan_params.interval = MSEC_TO_UNITS(5, UNIT_0_625_MS);
scan_params.window = MSEC_TO_UNITS(5, UNIT_0_625_MS);
scan_params.timeout = SCAN_TIMEOUT;
scan_params.scan_phys = BLE_GAP_PHY_1MBPS;
nrf_ble_scan_init_t scan_init;
memset(&scan_init, 0, sizeof(scan_init));
scan_init.p_scan_param = &scan_params;
scan_init.connect_if_match = false;
scan_init.conn_cfg_tag = false;
nrf_ble_scan_init(&m_scan1,&scan_init,passive_scan_evt_handler);
error_code = nrf_ble_scan_start(&m_scan1);
//separate file below
static nrf_ble_scan_t m_scan2; /**< Scanning Module instance. */
NRF_SDH_BLE_OBSERVER(m_active_ble_obs,2,nrf_ble_scan_on_ble_evt,&m_scan2);
ble_gap_scan_params_t scan_params = {0};
scan_params.active = 0x01; /* Active scanning */
scan_params.interval = MSEC_TO_UNITS(5, UNIT_0_625_MS);
scan_params.window = MSEC_TO_UNITS(5, UNIT_0_625_MS);
scan_params.timeout = SCAN_TIMEOUT;
scan_params.scan_phys = BLE_GAP_PHY_1MBPS;
nrf_ble_scan_init_t scan_init;
memset(&scan_init, 0, sizeof(scan_init));
scan_init.p_scan_param = &scan_params;
scan_init.connect_if_match = false;
scan_init.conn_cfg_tag = false;
nrf_ble_scan_init(&m_scan2,&scan_init,active_scan_evt_handler);
error_code = nrf_ble_scan_start(&m_scan2);
Secondly, if I cannot have two scanning instances at the same time, is there a recommended way to reinitialize the scan without stopping and re-starting?
Thanks,
Manny