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

cross mob

Updating an Attribute’s Value in GATT DB of a BLE GATT Server - KBA219298

Updating an Attribute’s Value in GATT DB of a BLE GATT Server - KBA219298

Anonymous
Not applicable

Version: **

 

Translation - Japanese: BLE GATTサーバのGATT DBでの属性値更新– KBA219298 - Community Translated (JA)

 

Question:

How do i update an attribute’s value in the GATT DB of a BLE GATT server?

 

Answer:

In a BLE GATT server, the profile-related data are structured in a database called the GATT database. The GATT database consists of the services, characteristics, characteristic descriptors, and declarations present on the server

 

In PSoC® Creator™, these attributes (characteristics, descriptors) can be initialized in the BLE Component configuration window, under the Profiles tab. If the characteristic value must be updated in runtime, the application can do so by using APIs and macros as follows:

 

In either of these cases, the length of the value source should be less than or equal to the length of the characteristic as configured in the BLE Component configuration.

 

  1. When the value must be locally updated by the server itself: A GATT characteristic is often used to reflect a real-time value in an application such a switch status or a sensor output, which would be read by a GATT client. To update the value of a characteristic, the application can use one of the following:     

    In either of these cases, the length of the value source should be less than or equal to the length of the characteristic as configured in the BLE Component configuration.

       
    1. The CyBle_GattsWriteAttributeValue() API and setting the last parameter to CYBLE_GATT_DB_LOCALLY_INITIATED
    2.  
    3. The CYBLE_GATT_DB_ATTR_SET_GEN_VALUE (handle,src,length) macro
  2. When the value must be updated because a GATT client sent a write request: In this case, use the CyBle_GattsWriteAttributeValue() API with the last parameter set to CYBLE_GATT_DB_PEER_INITIATED.

 

When the last parameter of the CyBle_GattsWriteAttributeValue() API is set to CYBLE_GATT_DB_LOCALLY_INITIATED, the API does not check for attribute permissions and will update the attribute value blindly. On the contrary, when the flag is set to CYBLE_GATT_DB_PEER_INITIATED, the API checks for attribute permissions before executing the write operation. If the client does not match the permissions required, the CyBle_GattsWriteAttributeValue() API will return a GATT Error code accordingly. Based on the return value, either a Write Response or an Error Response can be sent back to the client.

0 Likes
1777 Views