- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I need an example or instruction on how to read a voltage and write it to Gatt DB so I can get it on an app when desired. It's for monitoring a 12v battery level and triggering charge indicators with in the app. How do I do this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
PSoC 6 supports two functions; Cy_BLE_GATTS_WriteAttributeValuePeer and Cy_BLE_GATTS_WriteAttributeValueLocal to trigger attribute write from peer and local device respectively. Please use Cy_BLE_GATTS_WriteAttributeValueLocal for a locally initiated attribute value write.
- Fill appropriate values in GATT handle value pair.
/* Local variable that stores handle value pair */
cy_stc_ble_gatt_handle_value_pair_t locHandleValuePair =
{
.attrHandle = CY_BLE_CS_CUSTOM_CHARACTERISTIC_CHAR_HANDLE,
.value.len = 1,
.value.val = &bVal
};
- Once the ADC conversion is complete, initiate local GATT database write using Cy_BLE_GATTS_WriteAttributeValueLocal. Cy_BLE_GCy_BLE_GATTS_WriteAttributeValueLocalATTS_WriteAttributeValueLocalA
Cy_BLE_GATTS_WriteAttributeValueLocal(&locHandleValuePair);
Please refer to PDL documentation for more details (select PSoC Creator Help > Documentation > Peripheral Driver Library).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can update the GATT database using CyBle_GattsWriteAttributeValue once the ADC conversion is complete/new data is present. I have appended code snippet for your reference.
CYBLE_GATT_HANDLE_VALUE_PAIR_T locHandleValuePair;
locHandleValuePair.attrHandle = CYBLE_CS_CUSTOM_CHARACTERISTIC_CHAR_HANDLE;
locHandleValuePair.value.len = 1;
locHandleValuePair.value.val = &bVal;
CyBle_GattsWriteAttributeValue( &locHandleValuePair, 0, &connectionHandle , CYBLE_GATT_DB_LOCALLY_INITIATED );
You can also use the battery service in your application. You can refer to https://www.cypress.com/video-library/PSoC/psoc-4-ble-101-3-add-battery-service/108396
For more details on the CyBle_GattsWriteAttributeValue API, please refer to Updating an Attribute’s Value in GATT DB of a BLE GATT Server - KBA219298
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have basically the same question. I note that the OP applied a tag for "PSOC 063" to their post but the response refers to code and KB articles for PSOC 4.
I also note that the BLE component for the PSoC 6 devices uses different structures and functions with a different naming convention.
Can you please provide example code for a PSoC 6 and/or references to PSoC 6 KB articles?
Susan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
PSoC 6 supports two functions; Cy_BLE_GATTS_WriteAttributeValuePeer and Cy_BLE_GATTS_WriteAttributeValueLocal to trigger attribute write from peer and local device respectively. Please use Cy_BLE_GATTS_WriteAttributeValueLocal for a locally initiated attribute value write.
- Fill appropriate values in GATT handle value pair.
/* Local variable that stores handle value pair */
cy_stc_ble_gatt_handle_value_pair_t locHandleValuePair =
{
.attrHandle = CY_BLE_CS_CUSTOM_CHARACTERISTIC_CHAR_HANDLE,
.value.len = 1,
.value.val = &bVal
};
- Once the ADC conversion is complete, initiate local GATT database write using Cy_BLE_GATTS_WriteAttributeValueLocal. Cy_BLE_GCy_BLE_GATTS_WriteAttributeValueLocalATTS_WriteAttributeValueLocalA
Cy_BLE_GATTS_WriteAttributeValueLocal(&locHandleValuePair);
Please refer to PDL documentation for more details (select PSoC Creator Help > Documentation > Peripheral Driver Library).