Bluetooth Low Energy (a.k.a Bluetooth LE, BTLE, Bluetooth Smart)

change connection parameter

19 Dec 2015

Hi guys,

I want to know how i can change connection parameters for my BLE device (peripheral) ? do you have a code example please ?

Thanks in advance, Yacire.

21 Dec 2015
21 Dec 2015

Hi Rohit,

Thanks for the answer, so i just need to add in my code:

  1. define MIN_CONN_INTERVAL myNumberMin
  2. define MAX_CONN_INTERVAL myNumberMax
  3. define SLAVE_LATENCY myNumberLatency

I did it and it doesn't work ... Maybe because the Android phone don't take this parameters for the connection between the peers ...

I don't have to call a method in BLE API, like setAdvertisingInterval() for this parameters (connection interval & slave latency) ??

For advertisingInterval it works, but for others, not.


21 Dec 2015

Hi Yacire,

It is possible to set and update the preferred connection parameters by using the function Gap::setPreferredConnectionParams .

Note that it is always the central which decide what the actual connection parameters are. The peripheral can provide a hint of its preferred connection parameters but its up to the central to use them or not.

21 Dec 2015

Thanks a lot for your answer Vincent,

I will try this through the function Gap::setPreferredConnectionParams .

I know it is the Master which decide so we can't really drive the electrical consumption of the peripheral Ble device, when connected with Android phone (we can't set the connection parameters in Android Ble API) ?

Do you have any idea ? Yacire.

22 Dec 2015

Hi Yacire,

You can't set the connection parameter in Android BLE API, it is the same thing on iOS (see this document for iOS

On Android, their is no specific rules and implementations are free to do whatever they want. However, the connection interval chosen is generally equal to the maximum connection interval provided by the device.

The best thing to do is to use the function Gap::updateConnectionParams while there is a connection and test how your Android phone behave. Generally, Android phone update, somehow, connection parameters if the device ask for it.

23 Dec 2015

Thanks Vincent for your great help,

It works fine with the function Gap::updateConnectionParams and Android update correctly the connection paramters (but for information, it doesn't work with the Gap::setPreferredConnectionParams).

Edit (23/12/2015), Additional information from this post:

/\ "As you all pointed out, the problem were the connections parameters. Android does not have an API for controlling this until API 21 (Lollipop) but it's not necessary. If the peripheral tells the central to update the paramters it works fine. Pushing the limits, the parameters I used are the ones in the code below. However, I strongly recommend reading this answer from Petter as the limits could not be a good idea due to clock drifts." /\

And the code for updating connection parameters above in the link.


Please log in to post a reply.