How to Write to the Gatt Database?

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

cross mob
Anonymous
Not applicable

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?

   

CYBLE_GATT_HANDLE_VALUE_PAIR_T ->CYBLE_GATT_VALUE_T -> value(uint8).

   

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_GATT_HANDLE_VALUE_PAIR_T handleValue;
    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

0 Likes
1 Solution
Anonymous
Not applicable

Hi,

   

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.

   

Regards,

   

- Madhu Sudhan

View solution in original post

0 Likes
2 Replies
Anonymous
Not applicable

Hi,

   

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.

   

Regards,

   

- Madhu Sudhan

0 Likes
Anonymous
Not applicable

Hello Madhu

   

 Thank you for the reply, it works fine now.

   

Best Regards Jonas.V

0 Likes