You are here

How to Write to the Gatt Database? | Cypress Semiconductor

How to Write to the Gatt Database?

Summary: 2 Replies, Latest post by Jonas.V on 02 May 2016 07:36 AM PDT
Verified Answers: 1
Last post
Log in to post new comments.
Jonas.V's picture
4 posts

Hello my name is Jonas and is a student in sweden and have recently begun working on a project with PSoC BLE using the PSoC Creator.

I have created a custom Profile and I am testing various ways of sending my data but seem to be having troubles with CyBle_GattWriteAttributeValue().

In the profile I can create several different fields with different variable types.

But the function for the server to write data to the database CyBle_GattWriteAttributeValue gives me a few questions.
It requires several parameters, most notably the variable  CYBLE_GATT_HANDLE_VALUE_PAIR_T which handles the data.

This variable handles several data values, as the attributeHandle (where to put stuff?) but also the datafields containing a pointer to the actual data aswell as some information about the data.
This field, seems to only be able to contain a pointer to a uint8 variable?


If I decide I want a field with a uint16 for example, how do I write to this field?
And how do I write to different fields if decide to use more than one?
Perhaps I am misunderstanding something regarding the use of the function or the variable type CYBLE_GATT_HANDLE_VALUE_PAIR_T?
Basic idea of what I am trying to do(but how would i change the.

  uint8 bvalue = 10;
    CYBLE_CONN_HANDLE_T connHandle;
    handleValue.attrHandle = CYBLE_MEDDELANDE_MED_CHAR_HANDLE;
    handleValue.value.len = 1;
    handleValue.value.val = &bvalue;

CyBle_GattsWriteAttributeValue(&handleValue, 0, &cyBle_connHandle, CYBLE_GATT_DB_LOCALLY_INITIATED);

Help, discussions or a pointer where to look would be most appreciated.

Best Regards Jonas

mady's picture
Cypress Employee
962 posts


For a uint16 values, you need to split it into high byte and low byte. Place the low byte in the bvalue[0] and high byte in the bvalue[1].

Basically, it is always stored as an array of uint8.


- Madhu Sudhan

Jonas.V's picture
4 posts

Hello Madhu

 Thank you for the reply, it works fine now.

Best Regards Jonas.V


Log in to post new comments.