You are here

GATT services discovery | Cypress Semiconductor

GATT services discovery

Summary: 2 Replies, Latest post by Fabrizio Restori on 20 Jun 2016 09:24 AM PDT
Verified Answers: 1
Last post
Log in to post new comments.
rfc_1549836's picture
25 posts

I'm trying to get data from a custom GAP peripheral, GATT server.
The peripheral sent data, and I can read GATT DB from CySmart, of course the services are unknown, but the data can be read and write.
Now, starting from PSoC_4_BLE_Central_IAS example, I try to read the same data.
•    After the call back function initialization CyBle_Start(StackEventHandler) and CyBle_ProcessEvents(); I manage the events I scan for device CyBle_GapcStartScan(CYBLE_SCANNING_FAST);  
•    and after the CYBLE_EVT_GAPC_SCAN_PROGRESS_RESULT I get advertising data from evetparameter pointer.
•    Found my device, I connect it by CyBle_GapcConnectDevice(&connectPeriphDevice);
•    did this, I start GATT discovery calling  CyBle_GattcStartDiscovery(connHandle) that does not return any event parameter (the documentation says this) and
•    I need to discover my GATT services and attributes. I've used CyBle_GattcDiscoverAllPrimaryServices(connHandle); and CYBLE_EVT_GATTC_DISCOVERY_COMPLETEe event are generated
from here  I'm not understand how continue.
Where are the discovered services?
Does CYBLE_EVT_GATTC_DISCOVERY_COMPLETE returns an evetparameter? (reading the BLE documentation, this is not clear).
The examples on central function are very few, Can I have some help?

Thanks, Fabrizio

mady's picture
Cypress Employee
964 posts


After you call the GattcDiscoverAllPrimaryServices API, you will get the discovery data in chunks called (group) from the peripheral. Each time you receive a group, you will get the CYBLE_EVT_GATTC_READ_BY_GROUP_TYPE_RSP. You can obtain the data from the event parameter when you get this event. After all the discovery data is sent in multiple CYBLE_EVT_GATTC_READ_BY_GROUP_TYPE_RSP events, you will finally get the CYBLE_EVT_GATTC_DISCOVERY_COMPLETE event.

I have attached a Central / Clinet project which discovers all primary services and characteristics from a server and displays them.

Please find it attached. Use a UART Serial terminal (Like teraterm / coolterm) to test the project.


- Madhu Sudhan

rfc_1549836's picture
25 posts

Thanks Madhu, your help is helpful, but it generates, to me, some doubts and I need to understand.

On my previous try I've used, after the connection, the CyBle_GattcStartDiscovery() function with the return of CYBLE_EVT_GATTC_DISCOVERY_COMPLETE event.
Then I've called CyBle_GattcDiscoverAllPrimaryServices() and  waited the CYBLE_EVT_GATTC_READ_BY_GROUP_TYPE_RSP event, that never appeared.
This seemed the right way. On my opinion.

In your example CyBle_GattcStartDiscovery() was never used, instead after the connection, if I've correctly interpreted your code,  you call CyBle_GattcDiscoverAllPrimaryServices() and other.

I've done the same and I've received CYBLE_EVT_GATTC_READ_BY_GROUP_TYPE_RSP,  two time, and CYBLE_EVT_GATTC_ERROR_RSP at the end, so this indicates that I've two services (not yet analyzed).

My question is: why CyBle_GattcStartDiscovery() doesn't return what I expected? What is the use of CyBle_GattcStartDiscovery()?

Regards, Fabrizio

Log in to post new comments.