3 Replies Latest reply on Sep 18, 2017 10:56 AM by e.pratt_1639216

    How to read attribute values from remote device?



      I am novice to BLE Development.In my project i want to perform read & write operation between CY8CKIT048-PSOC 4 board and android app.

      In that i have successfully performed write operation using custom profile->custom Service & characteristic.

      Now i am stuck for READ operation from android app.

      I want to know whole cycle of operations performed when i click on READ in my android app,which event will be occurred in event handler & with the help of which function i can read attribute values to android app.

        • 1. Re: How to read attribute values from remote device?

          There may be orthogonal events like authentication requests, MTU exchange requests, etc. that can occurr, but generally

          You need to make sure that your characteristic is allowed for reading based on the configuration settings of authentication, encryption, etc.

          Afaik, you shouldn't need to explicitly handle the read request from the android phone in your callback if you have it setup properly. The DB on the BLE peripheral device should be sending the value upon request if allowed. Can you tell us what you have tried? Or what issues you are running into specifically?

          1 of 1 people found this helpful
          • 2. Re: How to read attribute values from remote device?

            Hi pratt,

            While looking for above issue i get some solutions but they(solutions) come with some more queries.

            CYBLE_EVT_GATTS_WRITE_REQ event is responsible for writing data from ble client to ble server.

            CyBle_GattsWriteAttributeValue() with this function we can write attribute value to server database what ever we got from client.


            Now,BLE comonent Datasheet says that

            CYBLE_EVT_GATTS_READ_CHAR_VAL_ACCESS_REQ event will be called when client initiates read request.

            CyBle_GattsReadAttributeValue() will be used to read attribute value from database.



            I am able to READ attribute value from server database without above mentioned event as well as CyBle_GattsReadAttributeValue().


            Please correct me if there is any misunderstanding with me.

            • 3. Re: How to read attribute values from remote device?

              1. yes, the CYBLE_EVT_GATTS_WRITE_REQ event is what you handle for writing values received from the Client onto the Server GATT DB.

              2. CYBLE_EVT_GATTS_READ_CHAR_VAL_ACCESS_REQ only occurs when the characteristic:

              /** 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. */

              Thus, you only need to handle the read event if you set the characteristic to require permissions of authentication or encryption for the client to access it.


              So you got one of the two correct