Soft Device Scan Parms not being set correctly from struct

I set my scan params in the following init code.

 

/**@brief Function for initializing the scanning and setting the filters.
 */
static void scan_init(void)
{   
    ret_code_t          err_code;
    nrf_ble_scan_init_t init_scan;
    ble_gap_scan_params_t const m_scan_param =
    {
      .active        = 0x01,
      .interval      = NRF_BLE_SCAN_SCAN_INTERVAL,
      .window        = NRF_BLE_SCAN_SCAN_WINDOW,
      .filter_policy = BLE_GAP_SCAN_FP_ACCEPT_ALL, //BLE_GAP_SCAN_FP_WHITELIST,
      .timeout       = 0,
      .scan_phys     = BLE_GAP_PHY_1MBPS,
    };

    memset(&init_scan, 0, sizeof(init_scan));
    /**< Scan parameters requested for scanning and connection. */
    init_scan.p_scan_param     = &m_scan_param;
    init_scan.connect_if_match = false;
    init_scan.conn_cfg_tag     = APP_BLE_CONN_CFG_TAG;

    err_code = nrf_ble_scan_init(&m_scan, &init_scan, scan_evt_handler);
    APP_ERROR_CHECK(err_code);

}

The interval and scan window are both set to 100. However, when I watch the variables in debug mode, the variables are as follows. 

Any idea how they are being set so wrong? No other references to these variables in the code anywhere except here and when I start scanning following the advertising period ending (60 seconds).

Parents Reply
  • Hi,

    Are you sure that you are looking at the correct struct, in the debug view?

    What are the values of the parameters you set? (NRF_BLE_SCAN_SCAN_INTERVAL, NRF_BLE_SCAN_SCAN_WINDOW, etc.)

    Interval and window of 0x6401 and 0x6400 look a bit suspicious to me, typically one would set them to the same if one wants 100 % duty cycle.

    Do you see the same values when using the code example from the documentation, as you did with your values earlier?

    Regards,
    Terje

Children
Related