Reading and writing BLE connection interval (and other parameters)

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
JaPo_3883311
Level 1
Level 1
First like received

Background: running a BLE GATT server on a PSoC 6 MCU and a GATT client on an Android phone. Server sends large amounts of data to the client using notifications. To maximize throughput, various connection parameters are configured before data transfer begins.

One of the key parameters I need to set is connection interval. Currently I request a connection interval change from the PSoC/server side using Cy_BLE_L2CAP_LeConnectionParamUpdateRequest(). After receiving a response signaled by the event CY_BLE_EVT_L2CAP_CONN_PARAM_UPDATE_RSP, my application learns the ultimate result of the request when CY_BLE_EVT_GAP_CONNECTION_UPDATE_COMPLETE fires and reports the newly selected connection interval in its event parameter.

My application assumes that the last connection interval reported by CY_BLE_EVT_GAP_CONNECTION_UPDATE_COMPLETE is the one currently in use (unless the event has not fired since the initial negotiation of connection parameters). My first question: Is this a valid assumption? If not, how can my application check what the current connection interval is? And a similar question: how can my application read the connection parameters negotiated by client/server during connection initialization?

I suspect that the above assumption is not valid because sometimes the app achieves a throughput rate that shouldn't be possible given the connection interval last reported by CY_BLE_EVT_GAP_CONNECTION_UPDATE_COMPLETE. Also, the rate changes drastically each time the client/server reconnect, even though the reported interval stays unchanged. It seems likely that my connection parameter updates are being silently overwritten.

Speaking more generally, I'm finding it difficult to configure BLE connections with any degree of determinism because parameters like connection interval tend to be obscured -- written and sometimes even read by API requests that don't always trigger their corresponding response events. Throughput is critical to my application so I need absolute control over a handful of parameters including connection interval and Data Length Extension (DLE). I understand that you can't always get the parameter values you want because of device- and implementation-specific limitations on both client and server sides, and that's fine, but my app at least needs to be able to reliably read current values.

Thanks in advance.

0 Likes
1 Solution
GyanC_36
Employee
Employee
250 replies posted 100 replies posted 50 replies posted

Hi Jamison,

    Your understanding is absolutely correct, whenever there is a Connection parameter update procedure ( Either initiated by master or requested by slave to initiate the connection parameter update procedure ), the  CY_BLE_EVT_GAP_CONNECTION_UPDATE_COMPLETE event will trigger with the new connection parameters set and you can read the struct to confirm the new parameters.

Just on reset or just after a power cycle instant  , you may get a slightly high throughput because initially all the internal data buffers will be empty and on continuous pushing the data from application to BLE stack eventually you will see a decrease in throughput.

Also for better throughput please make sure that your MTU size is the highest possible.

You can also refer a code example available in PSoC Creator. Just navigate to PSoC Creator -> File-> Code Examples ->

CE222046 – PSoC 6 BLE Throughput Measurement

-Gyan

View solution in original post

3 Replies
GyanC_36
Employee
Employee
250 replies posted 100 replies posted 50 replies posted

Hi Jamison,

    Your understanding is absolutely correct, whenever there is a Connection parameter update procedure ( Either initiated by master or requested by slave to initiate the connection parameter update procedure ), the  CY_BLE_EVT_GAP_CONNECTION_UPDATE_COMPLETE event will trigger with the new connection parameters set and you can read the struct to confirm the new parameters.

Just on reset or just after a power cycle instant  , you may get a slightly high throughput because initially all the internal data buffers will be empty and on continuous pushing the data from application to BLE stack eventually you will see a decrease in throughput.

Also for better throughput please make sure that your MTU size is the highest possible.

You can also refer a code example available in PSoC Creator. Just navigate to PSoC Creator -> File-> Code Examples ->

CE222046 – PSoC 6 BLE Throughput Measurement

-Gyan

Thanks for the reply. Is there any way to read the current connection parameters on the server/slave side without receiving a CY_BLE_EVT_GAP_CONNECTION_UPDATE_COMPLETE event?

Hi Jamison,

   There is no other way. What you can do is , you can store the value of current connection parameters in some variable when you update the connection parameter and receive the event CY_BLE_EVT_GAP_CONNECTION_UPDATE_COMPLETE to know the parameters.

-Gyan