Change Connection Parameters


#1

Hi,

I would like to change the BLE connection Parameters on my Nano V2 using the Arduino IDE. Mainly the Connection Interval. The Nano is in the peripheral role and I use the following function:

ble.gap().setPreferredConnectionParams()

But the function always return BLE_ERROR_PARAM_OUT_OF_RANGE.

I know the following limits:

  1. minConnectionInterval: 7.5 ms - 4 s

  2. maxConnectionInterval: 7.5 ms - 4s

  3. slaveLatency: 0 - 499

  4. connectionSupervisionTimeout: 100ms - 32 s

I tried differend combination but i always get the out-of-range error. For example:

Gap::ConnectionParams_t *params;
params->minConnectionInterval = 100;
params->maxConnectionInterval = 200;
params->slaveLatency = 0;
params->connectionSupervisionTimeout = 400;
ble.gap().setPreferredConnectionParams(params);

Is there something wrong with my code? Or are there more Limits/constraints on the paramters ?


#2

I could solve my Problem by using ble.gap().updateConnectionParams(). No error occurs.

But I first changed the min- and maxConnectionInterval to 200ms, and now this value remains. I have done several other Connection Updates with other interval values, but the Intervall is still 200ms. Really strange. Seems that These value was saved somewhere…

I flashed the BLE Nano V2 several times but the Connection Interval remains 200 ms.

Any suggestions?


#3

Hi @blebeginner,

You have defined a pointer, but not the variable. the params points to null memory. Try the code below:

Gap::ConnectionParams_t params;
params.minConnectionInterval = 100;
params.maxConnectionInterval = 200;
params.slaveLatency = 0;
params.connectionSupervisionTimeout = 400;
ble.gap().setPreferredConnectionParams(&params);

This API updates connection parameters. In the central role this will initiate a Link Layer connection parameter update procedure. In the peripheral role, this will send the corresponding L2CAP request and wait for the central to perform the procedure. According to the Nordic SoftDevice API documentation, the parameter of this function is a pointer to desired connection parameters. If NULL is provided on a peripheral role, the parameters in the PPCP characteristic of the GAP service will be used instead. If NULL is provided on a central role and in response to a BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST, the peripheral request will be rejected. Again, the params you defined is pointer to NULL memory, instead of variable.

Best regards,
Guohui


#4

@guohui thank you for your Reply! Now it works. Such a stupid mistake…


#5

I am not able to update the minconnection interval. I am using the following code in the peripheral side:

Gap::ConnectionParams_t connectionParams;
connectionParams.minConnectionInterval = 12;
connectionParams.maxConnectionInterval = 12;
connectionParams.slaveLatency = 0;
connectionParams.connectionSupervisionTimeout = 500;
ble.gap().setPreferredConnectionParams(&connectionParams);

However, when I read the set values in the central side, both the min and max intervales are always set to 100ms. The code segment in the central side is as follows:

void connectionCallBack( const Gap::ConnectionCallbackParams_t *params ) {
Serial.println(params->connectionParams->minConnectionInterval, DEC);
Serial.println(params->connectionParams->maxConnectionInterval, DEC);
}

Am I missing something in the central side? Please let me know if anyone knows the proper way of changing these parameters.

Best,