This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

More trouble with changing BLE connection interval

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:

  1. Am I calling the correction functions to update the ble connection interval in the first place?
  2. 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?
  3. 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

Parents
  • FormerMember
    0 FormerMember

    When wanting to update the connection parameters from a peripheral, the peripheral sends a "connection parameter update request" to the central. The central has three options when it receives a "connection parameter update request": Accept, reject, or ignore.

    In either case, the result from the "connection parameter update request" should be reflected by the connection parameters in the event BLE_GAP_EVT_CONN_PARAM_UPDATE, see this message sequence chart.

    The error code 22 = 0x16 = BLE_HCI_LOCAL_HOST_TERMINATED_CONNECTION

    Is it possible that it is your application that is triggering a disconnect, by calling sd_ble_gap_disconnect()?

  • I've never seen it establish any connection interval that is not 24, so I think there's something else that is wrong. Surely others with an iphone are able to change the connection interval. I will do some more debugging once I get another dev board and combine it with a bluetooth sniffer. I'll post pack in a couple days with more info and/or a solution.

Reply
  • I've never seen it establish any connection interval that is not 24, so I think there's something else that is wrong. Surely others with an iphone are able to change the connection interval. I will do some more debugging once I get another dev board and combine it with a bluetooth sniffer. I'll post pack in a couple days with more info and/or a solution.

Children
No Data
Related