This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

updating scan parameters

Hey guys. Is there any way we can change scan parameters at runtime. I want to update parameters from another device using uart, and when I tried to make scan interval and scan window a variable, the compiler throws an error saying it is constant and cannot be changed, I also tried to change in scanning file where we define scan parameters, but it is still the same. I only want to change scan interval and scan window.

I appreciate your suggestions/

Regards,

  • remove static from:
     

    ble_gap_scan_params_t m_scan_param =
    	{
    		.active        = 0x01,
    		.interval      = SCAN_INTERVAL,
    		.window        = SCAN_WINDOW,
    		.filter_policy = BLE_GAP_SCAN_FP_ACCEPT_ALL,
    		.timeout       = SCAN_DURATION,
    		.scan_phys     = BLE_GAP_PHY_1MBPS,
    		.extended      = false,
    	};
    


    or
    static ble_gap_scan_params_t m_scan_param =
    	{
    		.active        = 0x01,
    		.interval      = SCAN_INTERVAL,
    		.window        = SCAN_WINDOW,
    		.filter_policy = BLE_GAP_SCAN_FP_ACCEPT_ALL,
    		.timeout       = SCAN_DURATION,
    		.scan_phys     = BLE_GAP_PHY_1MBPS,
    		.extended      = false,
    	};
    m_scan_param.interval = var;


  • Hey! The question is relevant for me as well.
    How do I apply the new ble_gap_scan_params_t and ble_gap_conn_params_t?

    What structure is PM_RA_PROTECTION_MIN_WAIT_INTERVAL in?

  • Hi,

    Proton said:
    How do I apply the new ble_gap_scan_params_t and ble_gap_conn_params_t?

    If you use the scan module (nrf_ble_scan) then you need to pass the scan parameters to nrf_ble_scan_params_set() in order to update them (originally they are supplied with the call to nrf_ble_scan_init(). There is no api to update the connection parameters when using the scan module, though. You could modify the scan module to also set the connection parameters again when you call nrf_ble_scan_params_set() by adding it to the parameter list. Alternatively, as a less intrusive approach, you could write to the nrf_ble_scan_t instance directly, copying your updated connection parameters to nrf_ble_scan_t::conn_params.

    Proton said:
    What structure is PM_RA_PROTECTION_MIN_WAIT_INTERVAL in?

    It is a sdk_config.h configuration define for the peer manager module that specifies the minimum time before a new pairing attempt can be initiated after a failed attempt (and this is doubled every time on subsequent failures). 

Related