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

PSoC™ 6 Forum Discussions

Jdo300
Level 1
Level 1
10 sign-ins 5 questions asked 5 sign-ins

I've been studying code examples from the PSoC6 101 tutorial, along with the code for the BLE throughput example. I noticed that two different connection events are used, CY_BLE_EVT_GAP_DEVICE_CONNECTED, and CY_BLE_EVT_GATT_CONNECT_IND. What is the difference between these two events and does it matter which one I use to indicate the completion of a Bluetooth connection?

- Jason O

0 Likes
1 Solution
BragadeeshV
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hi @Jdo300 ,

The difference lies in what information you get when each of these events is called.

CY_BLE_EVT_GAP_DEVICE_CONNECTED indicates a connection establishment in the GAP peripheral at a GAP level. This event is generated only if Link Layer Privacy is not enabled in the BLE Component customizer. This event will give you the connection parameters such as peer address, connection interval, supervision timeout etc. 

CY_BLE_EVT_GATT_CONNECT_IND  indicates a connection establishment in the GAP peripheral at the GATT level. This event will tell you the connection handle such as bdHandle and attId of the current connection that is used to do characteristic read and writes with the peer device.

You will need both these events to get different parameters as stated above. 

Since CY_BLE_EVT_GAP_DEVICE_CONNECTED is the last event to get called after CY_BLE_EVT_GATT_CONNECT_IND, you can use the CY_BLE_EVT_GAP_DEVICE_CONNECTED to indicate that the connection is complete. Having said that, CY_BLE_EVT_GAP_DEVICE_CONNECTED is not called when Link Layer privacy is enabled. Instead CY_BLE_EVT_GAP_ENHANCE_CONN_COMPLETE is generated. Check the below thread to handle this event.

https://community.cypress.com/t5/PSoC-6-MCU/CY-BLE-EVT-GAP-DEVICE-CONNECTED-event-not-generated-in-P...

Regards,
Bragadeesh

View solution in original post

0 Likes
1 Reply
BragadeeshV
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hi @Jdo300 ,

The difference lies in what information you get when each of these events is called.

CY_BLE_EVT_GAP_DEVICE_CONNECTED indicates a connection establishment in the GAP peripheral at a GAP level. This event is generated only if Link Layer Privacy is not enabled in the BLE Component customizer. This event will give you the connection parameters such as peer address, connection interval, supervision timeout etc. 

CY_BLE_EVT_GATT_CONNECT_IND  indicates a connection establishment in the GAP peripheral at the GATT level. This event will tell you the connection handle such as bdHandle and attId of the current connection that is used to do characteristic read and writes with the peer device.

You will need both these events to get different parameters as stated above. 

Since CY_BLE_EVT_GAP_DEVICE_CONNECTED is the last event to get called after CY_BLE_EVT_GATT_CONNECT_IND, you can use the CY_BLE_EVT_GAP_DEVICE_CONNECTED to indicate that the connection is complete. Having said that, CY_BLE_EVT_GAP_DEVICE_CONNECTED is not called when Link Layer privacy is enabled. Instead CY_BLE_EVT_GAP_ENHANCE_CONN_COMPLETE is generated. Check the below thread to handle this event.

https://community.cypress.com/t5/PSoC-6-MCU/CY-BLE-EVT-GAP-DEVICE-CONNECTED-event-not-generated-in-P...

Regards,
Bragadeesh
0 Likes