Hi
I'm facing a problem since I've upgraded to SD140 6.1 .
I'm running as multilink central, and want to keep scanning even after connection. I scan with the following parameters:
static ble_gap_scan_params_t m_scan_params = { .active = 0, .extended = 1, .report_incomplete_evts = 0, .scan_phys = BLE_GAP_PHY_1MBPS | BLE_GAP_PHY_CODED, .interval = 0x00A0, .window = 0x0050, .timeout = 0, .filter_policy = BLE_GAP_SCAN_FP_ACCEPT_ALL};
I have a peripheral set to CODED who advertise with whitelist that doesn't include the current central, but it advertises in its surroundings and with the same name that the scanner is looking for.
when the central gets adv_report from this sensor, it tries to connect (usually what happens is that it connects to the peripheral, and then fails on security check):
err_code = sd_ble_gap_connect(&p_adv_report->peer_addr, &m_scan_params, &m_connection_param, APP_BLE_CONN_CFG_TAG);
it returns NRF_SUCCESS, but I don't get any event back from ble_evt_handler() (as far as I know, once I called sd_ble_gap_connect(), it has to call back...).
inside ble_evt_handler() , I call scan_start() to restart scanning. but as nothing was returned the scan didn't restarted. so I moved the call to right after sd_ble_gap_connect().
inside scan_start(), when I call:
err_code = sd_ble_gap_scan_start(&m_scan_params, &m_scan_buffer);
I get an error: NRF_ERROR_INVALID_STATE
I then try to stop and start:
err_code = sd_ble_gap_scan_stop();
APP_ERROR_CHECK(err_code);
err_code = sd_ble_gap_scan_start(&m_scan_params, &m_scan_buffer);
APP_ERROR_CHECK(err_code);
but I get NRF_ERROR_INVALID_STATE from sd_ble_gap_scan_stop()
my questions are:
- why I'm not getting any event after connecting?
- why both sd_ble_gap_scan_start() and sd_ble_gap_scan_stop() returns NRF_ERROR_INVALID_STATE? as far as I understand, sd_ble_gap_scan_start() returns that error if a scan is already running (i tried to run it with scan_params = NULL and got NRF_ERROR_INVALID_STATE, so I'm guessing the only reason is that scan is already running), and sd_ble_gap_scan_stop() will return that error if scan is not running, so it doesn't makes sense...
thanks for the help