- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have my PSoC4 set up as a GATT server. I've created a couple of characteristics that I would like to be both readable and writeable by the client. So far I've been able to write to the characteristics from the client, but I can't read them.
When I attempt to read, the client always gets zero and the PSoC4 gets a CYBLE_EVT_GATTS_READ_CHAR_VAL_ACCESS_REQ event.
I'm not quite understanding the documentation on how I'm supposed to respond to this event or make the characteristic readable. Is there some callback I need to define? Is there an API function I should call in the event handler when I get the read access request event?
Thanks!
Solved! Go to Solution.
- Labels:
-
BLE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Use the following function: CYBLE_GATT_ERR_CODE_T CyBle_GattsWriteAttributeValue(handlevaluepair, offset, connhandle, flags)
It should allow you to write values to the GATT DB once the CyBle_Start() has initialized the BLE stack. Try using it to write all of the default values at bootup; Setting the default values in the BLE component GUI should also work, but it sounds like you want a programmatically changeable value at bootup rather than a compile-time constant put into the default value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
From the documentation:
/** Event parameter type is CYBLE_GATTS_CHAR_VAL_READ_REQ_T. It is triggered on server side
when client sends read request and when characteristic has CYBLE_GATT_DB_ATTR_CHAR_VAL_RD_EVENT
property set. This event could be ignored by application unless it need to response by error response which
needs to be set in gattErrorCode field of event parameter. */
CYBLE_EVT_GATTS_READ_CHAR_VAL_ACCESS_REQ,
So, you should be able to merely return from the event in the callback and everything should work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I wish. When I use CySmart, I always get 0 when I do a read.
When I use my custom android app, it seems to get whatever I last wrote, but it won't read the default value....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What do you mean by "default value"? The value that the program initializes the DB to? Or is there some other default value that you are setting on bootup/during runtime that you expect it to return?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In order to make the characteristic readable, it depends on the BLE settings for the BLE component in the schematic document (double click it to bring up the GATT settings and profile/services)
Try looking at the sample GATT server project here: https://github.com/cypresssemiconductorco/PSoC-4-BLE/tree/master/100_Projects_in_100_Days/Day006_Cen...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, there is a value that is set at boot-up time. My plan is to store some user data in non-volatile flash so that the device will start up with some user configurable settings from the previous session at each new boot. I think there has to be a way to make those settings visible to the user after the device boots up.
I have set it to be readable in the schematic component and it actually does appear that once the characteristic has been written via bluetooth, it can be read back via bluetooth. However, if the device generates a new value at boot up or at any other time, I don't see how to make that new value readable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Use the following function: CYBLE_GATT_ERR_CODE_T CyBle_GattsWriteAttributeValue(handlevaluepair, offset, connhandle, flags)
It should allow you to write values to the GATT DB once the CyBle_Start() has initialized the BLE stack. Try using it to write all of the default values at bootup; Setting the default values in the BLE component GUI should also work, but it sounds like you want a programmatically changeable value at bootup rather than a compile-time constant put into the default value.