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

[SOLVED] Can't set connection parameters in ble_conn_params_init

Hi, I'm building a peripheral app with SDK11 and a nRF52 microcontroller (softdevice 2.0.0). When connection parameters are set in ble_conn_params_init, this always leads to a NRF_ERROR_INVALID_PARAM even though parameters seem OK.

#define APP_TIMER_PRESCALER             0
#define APP_TIMER_OP_QUEUE_SIZE         4 

#define MIN_CONN_INTERVAL               MSEC_TO_UNITS(20, UNIT_1_25_MS)
#define MAX_CONN_INTERVAL               MSEC_TO_UNITS(75, UNIT_1_25_MS)
#define SLAVE_LATENCY                   0 
#define CONN_SUP_TIMEOUT                MSEC_TO_UNITS(4000, UNIT_10_MS)
#define FIRST_CONN_PARAMS_UPDATE_DELAY  APP_TIMER_TICKS(5000, APP_TIMER_PRESCALER)
#define NEXT_CONN_PARAMS_UPDATE_DELAY   APP_TIMER_TICKS(30000, APP_TIMER_PRESCALER)
#define MAX_CONN_PARAMS_UPDATE_COUNT    3 

.

  uint32_t               err_code;
  ble_conn_params_init_t cp_init;

  memset(&cp_init, 0, sizeof(cp_init));

  ble_gap_conn_params_t conn_params;
  memset(&conn_params, 0, sizeof(conn_params));
  conn_params.min_conn_interval = MIN_CONN_INTERVAL;
  conn_params.max_conn_interval = MAX_CONN_INTERVAL;
  conn_params.slave_latency = SLAVE_LATENCY;
  conn_params.conn_sup_timeout = CONN_SUP_TIMEOUT;

  cp_init.p_conn_params                  = &conn_params;
  cp_init.first_conn_params_update_delay = FIRST_CONN_PARAMS_UPDATE_DELAY;
  cp_init.next_conn_params_update_delay  = NEXT_CONN_PARAMS_UPDATE_DELAY;
  cp_init.max_conn_params_update_count   = MAX_CONN_PARAMS_UPDATE_COUNT;
  cp_init.start_on_notify_cccd_handle    = BLE_GATT_HANDLE_INVALID;
  cp_init.disconnect_on_fail             = false;
  cp_init.evt_handler                    = on_conn_params_evt;
  cp_init.error_handler                  = conn_params_error_handler;

  err_code = ble_conn_params_init(&cp_init);
  APP_ERROR_CHECK(err_code);

No errors when cp_init.p_conn_params = NULL. There is no example in SDK where p_conn_params isn't NULL.

Do you have any idea about why softdevice rejects it ?

Joris

  • I do not see anything wrong with the parameters either.

    Do they work if you do as in the examples, and provide the parameters on the call to sd_ble_gap_ppcp_set() in gap_params_init() rather than as part of cp_init in the call to ble_conn_params_init() in conn_params_init()?

    I do not know if I would be able to reproduce this without the rest of the code, as there are a lot of unknowns with regards to SoftDevice initialisation, order of operations in main() etc.

  • Hi Terje, I got the NRF_ERROR_INVALID_PARAM error when conn_params_init() was called before gap_params_init(). Now, I call gap_params_init() before conn_params_init() (as in SDK examples) and it works like a charm. Thanks for your help,

Related