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

PSoC™ 6 Forum Discussions

SimonCanada
Level 2
Level 2
25 sign-ins 10 likes given First like received

I have two PSoC 6 BLE devices: a PSoC 6 BLE Pioneer board which acts as the peripheral, and a PSoC 6 BLE Prototyping board which acts as the central. I am trying to reduce power consumption between these two devices by extending the connection parameters Max Interval, Min Interval, Slave Latency and Connection Timeout. There is an example here: https://community.infineon.com/t5/Resource-Library/PSoC-6-BLE-Peripheral-Updating-Connection-Paramet... but this does not appear to work.

After the two devices are connected, I call Cy_BLE_L2CAP_LeConnectionParamUpdateRequest from the peripheral device to change the central device's settings set in the BLE component. This function returns a CY_BLE_SUCCESS when I call it. In the example, after doing this the code expects a CY_BLE_EVT_L2CAP_CONN_PARAM_UPDATE_RSP  event to be generated at the peripheral, but this does not happen, and the parameters on the link are not changed (shown by inspecting the power consumption of the peripheral via a current amplifier on my scope).

Please note I am not running the actual example itself. In the process of finding the example I had already checked out the API and had tried using the above L2CAP function and found it generates a CY_BLE_EVT_GAP_ENHANCE_CONN_COMPLETE  event which contains a structure cy_stc_ble_gap_enhance_conn_complete_param_t  at the central end and at the peripheral; the parameters of this struct show that the parameters have not changed but indicate an okay status for the event.

I had also seen that depending on whether link privacy is set up, different events related to the connection parameters get fired CY_BLE_EVT_GAP_DEVICE_CONNECTED  if it is not and CY_BLE_EVT_GAP_ENHANCE_CONN_COMPLETE  if it is: these events have different structs associated with them.

So my questions are: how do I get this functionality to work? and does it work with link privacy set?

0 Likes
1 Solution
PratikshaV
Moderator
Moderator
Moderator
50 solutions authored 10 likes received 100 replies posted

Hi @SimonCanada ,

Have you checked the code example available in this  https://community.infineon.com/t5/Resource-Library/PSoC-6-BLE-Peripheral-Updating-Connection-Paramet...  you can see values changed at the central side. Or else please can you share your project so that we can check at our end.

 

Thanks & Regards

Pratiksha V 

View solution in original post

0 Likes
3 Replies
PratikshaV
Moderator
Moderator
Moderator
50 solutions authored 10 likes received 100 replies posted

Hi @SimonCanada ,

Have you checked the code example available in this  https://community.infineon.com/t5/Resource-Library/PSoC-6-BLE-Peripheral-Updating-Connection-Paramet...  you can see values changed at the central side. Or else please can you share your project so that we can check at our end.

 

Thanks & Regards

Pratiksha V 

0 Likes
SimonCanada
Level 2
Level 2
25 sign-ins 10 likes given First like received

Hi Pratiksha V 

I was using that example to develop my code but I had not run it so I did try it with CySmart as the central and it did work. I modified the my peripheral code so now it is working with CySmart, and causes CySmart to change its parameters and send the peripheral a response which it  detects.

The main thing I had to do to emulate the example was to put a delay into my peripheral so it does not send the update request for a couple of seconds after it is connected.

But now I am getting a problem with my other device (the central) which detects the request but locks up trying to send the response back to the peripheral. Can you see a problem with this code?

cy_stc_ble_gap_conn_update_param_info_t * myConnParams;
cy_stc_ble_l2cap_conn_update_param_rsp_info_t * myRespParams;

/* This event is raised if the peer sends a parameters change
* request. In this case the central is expected to reply to
* L2CAP using the Cy_BLE_L2CAP_LeConnectionParamUpdateResponse()
* function to respond to the remote device, whether parameters are
* accepted or rejected. The event parameter pointer points to data of
* type cy_stc_ble_gap_conn_update_param_info_t.
*/
case CY_BLE_EVT_L2CAP_CONN_PARAM_UPDATE_REQ:
myConnParams = (cy_stc_ble_gap_conn_update_param_info_t *)eventParam;
uint32 connIntvMin = myConnParams->connIntvMin;
uint32 connIntvMax = myConnParams->connIntvMax;
uint32 supervisionTO = myConnParams->supervisionTO;
uint32 connLatency = myConnParams->connLatency;
uint32 ceLength = myConnParams->ceLength;
DEBUG_BLE("Conn param update REQ - intvmin=%d, intvmax=%d, Lat=%d, TO=%d, ceLen=%d\r\n",
(int)connIntvMin * 5 / 4, (int)connIntvMax * 5 / 4, (int)connLatency,
(int)supervisionTO * 10, (int)ceLength);
memset(myRespParams, 0, sizeof(&myRespParams));
myRespParams->bdHandle = conn_handle.bdHandle;
myRespParams->result = 0; // == we accept!
DEBUG_BLE("About to send resp\r\n");
apiResult = Cy_BLE_L2CAP_LeConnectionParamUpdateResponse(myRespParams);
DEBUG_BLE("Sent accept response to Conn param REQ\r\n");
break;

 

Thanks for any advice. This other app is based on the Throughput example.

0 Likes
SimonCanada
Level 2
Level 2
25 sign-ins 10 likes given First like received

Okay, I spotted the bugs in my code and it now works end to end.

The problem was caused by me stupidly creating myRespParams as a pointer and not as an actual struct, and then trying to use it with an uninitialised pointer. So the code ends up as

/* This event is raised if the peer sends a parameters change
* request. In this case the central is expected to reply to
* L2CAP using the Cy_BLE_L2CAP_LeConnectionParamUpdateResponse()
* function to respond to the remote device, whether parameters are
* accepted or rejected. The event parameter pointer points to data of
* type cy_stc_ble_gap_conn_update_param_info_t.
*/
case CY_BLE_EVT_L2CAP_CONN_PARAM_UPDATE_REQ:
myConnParams = (cy_stc_ble_gap_conn_update_param_info_t *)eventParam;
uint32 connIntvMin = myConnParams->connIntvMin;
uint32 connIntvMax = myConnParams->connIntvMax;
uint32 supervisionTO = myConnParams->supervisionTO;
uint32 connLatency = myConnParams->connLatency;
uint32 ceLength = myConnParams->ceLength;
DEBUG_BLE("Conn param update REQ - intvmin=%d, intvmax=%d, Lat=%d, TO=%d, ceLen=%d\r\n",
(int)connIntvMin * 5 / 4, (int)connIntvMax * 5 / 4, (int)connLatency,
(int)supervisionTO * 10, (int)ceLength);
myRespParams.bdHandle = conn_handle.bdHandle;
myRespParams.result = 0; // == we accept!
DEBUG_BLE("About to send resp\r\n");
apiResult = Cy_BLE_L2CAP_LeConnectionParamUpdateResponse(&myRespParams);
DEBUG_BLE("Sent accept response to Conn param REQ\r\n");
break;

Thanks for your help!

 

0 Likes