How to read and write in a BLE server using PCOC 4 as client (custom Profile)

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

cross mob
BrSg_4288716
Level 1
Level 1

Hello,

I'm currently building a BLE CLIENT in PSOC 4 BLE.

Using the tutorials and examples provided here i was able to make the full GAP communication and connect to my peripheral device making it a GAT server.

But currently i not sure how to start exchanging information, like writing in the server, reading information or subscribing for notifications.

As i'm using a Custom profile i saw comments saying that i should use functions like: CyBle_GattcReadCharacteristicValue() and  CyBle_GattcWriteCharacteristicValue().

But the keep returning CYBLE_GATT_ERR_INVALID_HANDLE. How do i write the characteristic handle in these functions?

For example i have a characteristic i want to read at 0x0201.

How do i transform this in the in the right format?

@Edit:

After some more looking in to it i found the way i should do this but have no ideia on how to implement this, the steps should be:

1) Discover the services and Characteristics using the functions: CyBle_GattcDiscoverAllPrimaryServices() and CyBle_GattcDiscoverAllCharacteristics().

2) This should create some sort of handle for each of the services and Characteristics.

3) I have to put this handle inside some sort of structure and send it as the second parameter of the read and write functions.

Is this right? Could anyone more experienced shed some light?

@Edit2:

There may be another way that i also am not able to make it work by using CyBle_GattcReadUsingCharacteristicUuid() and etc.

It also does not acept my CYBLE_GATTC_READ_BY_TYPE_REQ_T as a valid parameter an returns invalid parameter.

Thanks!

0 Likes
1 Solution
emwo_4376811
Level 1
Level 1

Check out the central peripheral project using custom profile here.

View solution in original post

0 Likes
2 Replies
emwo_4376811
Level 1
Level 1

Check out the central peripheral project using custom profile here.

0 Likes

Hello,

Thank you for the answer!

Just saw it and it also helps my most recent problem of handling notifications from a peripheral.

0 Likes