I've read as many posts regarding changing the ble connection interval as I can find but so far have been unsuccessful changing the ble connection interval. Below has been my strategy thus far:
Here are the initial connection parameters I'm using:
#define MIN_CONN_INTERVAL MSEC_TO_UNITS(14, UNIT_1_25_MS)
#define MAX_CONN_INTERVAL MSEC_TO_UNITS(100, UNIT_1_25_MS)
#define SLAVE_LATENCY 0
#define CONN_SUP_TIMEOUT MSEC_TO_UNITS(400, UNIT_10_MS)
After connecting to nRFConnect on my iphone, on_ble_evt() receives BLE_GAP_EVT_CONNECTED. At that point I read out:
max_conn_interval = p_ble_evt->evt.gap_evt.params.connected.conn_params.max_conn_interval;
min_conn_interval = p_ble_evt->evt.gap_evt.params.connected.conn_params.min_conn_interval;
Both values are 24.
I then call a function update_conn_params():
void update_conn_params() {
uint32_t err_code = 0;
ble_gap_conn_params_t p_conn_params;
memset(&p_conn_params, 0, sizeof(p_conn_params));
p_conn_params.min_conn_interval = MSEC_TO_UNITS(50, UNIT_1_25_MS);
p_conn_params.max_conn_interval = MSEC_TO_UNITS(100, UNIT_1_25_MS);
p_conn_params.slave_latency = 3;
p_conn_params.conn_sup_timeout = MSEC_TO_UNITS(2000, UNIT_1_25_MS);
err_code = ble_conn_params_change_conn_params(&p_conn_params);
APP_ERROR_CHECK(err_code);
NRF_LOG_INFO("max: %d\r\n", p_conn_params.max_conn_interval);
NRF_LOG_INFO("min: %d\r\n", p_conn_params.min_conn_interval);
}
I get this output: max: 80 min: 28 So ble_conn_params_change_conn_params does not modify p_conn_params here, and I'm expecting the new connection interval to be a minimum of 28.
Then, on_ble_evt() receives BLE_GAP_EVT_CONN_PARAMS_UPDATED. Here I read out
max_connection_interval = p_ble_evt->evt.gap_evt.params.conn_param_update.conn_params.max_conn_interval;
min_connection_interval = p_ble_evt->evt.gap_evt.params.conn_param_update.conn_params.min_conn_interval;
I read out: max_connection_interval = 24, min_connection_interval = 24. It looks like the connection interval has not changed.
My questions:
- Am I calling the correction functions to update the ble connection interval in the first place?
- Am I looking at the right values in code (p_ble_evt->evt.gap_evt.params.conn_param_update.conn_params.max_conn_interval) to read the updated connection interval?
- I know that the connection interval is ultimately decided by the central (iphone running nRFConnect). When implementing a custom app, say iOS, what control do I have over controlling the connection interval?
Currently I don't have a second PCA10040 to use to connect to nRFConnect on the computer to directly read the connection interval. I'm trying to get one as that would allow me to double check the values I'm getting.
EDIT: I am no longer getting a "Disconnected, reason 22" message, but I am receiving a BLE_CONN_PARAMS_EVT_FAILED event. Not sure what is causing this.
PCA10040 SDK13 iOS nrfConnect