Hello,
Check out ble_gap.h line 2467 - 2479. There it says that if sd_ble_gap_scan_start() returns NRF_ERROR_INVALID_LENGTH:
* @retval ::NRF_ERROR_INVALID_LENGTH The provided buffer length is invalid. See @ref BLE_GAP_SCAN_BUFFER_MIN.
A search for BLE_GAP_SCAN_BUFFER_MIN points to line 347 in ble_gap.h line 347. Line 341-346 says:
/**@defgroup BLE_GAP_SCAN_BUFFER_SIZE GAP Minimum scanner buffer size
*
* Scan buffers are used for storing advertising data received from an advertiser.
* If ble_gap_scan_params_t::extended is set to 0, @ref BLE_GAP_SCAN_BUFFER_MIN is the minimum scan buffer length.
* else the minimum scan buffer size is @ref BLE_GAP_SCAN_BUFFER_EXTENDED_MIN.
* @{ */
So it looks like your scan buffer is to short. The scan buffer is set in: main.c:
NRF_BLE_SCAN_DEF(m_scan); /**< Scanning Module instance. */
A macro that declares nrf_ble_scan_t m_scan in nrf_ble_scan.h.
In nrf_ble_scan.h you can also see that the scan_buffer_data, the buffer where the scanned advertisements are stored is set with a length of NRF_BLE_SCAN_BUFFER, which is probably defined to 31 in your sdk_config.h.
Try to increase this to BLE_GAP_SCAN_BUFFER_EXTENDED_MIN, or 255.
If you increase the NRF_BLE_SCAN_BUFFER in sdk_config.h from 31 to 255, does sd_ble_gap_scan_start() still return NRF_ERROR_INVALID_LENGTH?
Best regards,
Edvin
Thanks, Edvin, that really helps! :)