4 Replies Latest reply on May 16, 2018 2:35 AM by user_482772723

    CYBLE_EVT_GATTS_READ_REQ - Identify which characteristic was read

    user_460425683

      Hi,

         

      Is it possible to determine which characteristic was read when the CYBLE_EVT_GATTS_READ_REQ event is triggered?

         

      I would like to update the contents of a custom characteristic every time it is read to facilitate a memory dump process.  Currently it is a bit slow having to send a Write and then a Read for each block of data.  If each read caused the characteristic to be updated with the next block of data to allow the next read to get the next block, that would significantly improve performance for my application.

         

      Any thoughts as to how I could accomplish this?

         

      Thanks.

         

      - Chris

        • 1. Re: CYBLE_EVT_GATTS_READ_REQ - Identify which characteristic was read
          jrow

          Hi Chris,

             

          The CYBLE_EVT_GATTS_READ_CHAR_VAL_ACCESS_REQ stack event generates an event with the parameter of a pointer of type CYBLE_GATTS_CHAR_VAL_READ_REQ_T. This has the attrHandle member, which you should be able to use to identify the characteristic in question.

          1 of 1 people found this helpful
          • 2. Re: CYBLE_EVT_GATTS_READ_REQ - Identify which characteristic was read
            user_460425683

            Thanks jrow.  I will look into that and update this thread if everything works.

               

            - Chris

            • 3. Re: CYBLE_EVT_GATTS_READ_REQ - Identify which characteristic was read
              user_460425683

              This code appears to work well for this.

                 

              <code>

                 

              CYBLE_GATTS_CHAR_VAL_READ_REQ_T *rdReqParam;

                 

              ....

                 

              case CYBLE_EVT_GATTS_READ_CHAR_VAL_ACCESS_REQ:

                 

                 rdReqParam = (CYBLE_GATTS_CHAR_VAL_READ_REQ_T *) eventParam;

                 

                 if (rdReqParam->attrHandle == CYBLE_SERVICE_CHARACTERISTIC_CHAR_HANDLE) {

                 

                    // Act on it

                 

                 }

                 

                 break;

                 

              </code> 

              1 of 1 people found this helpful
              • 4. Re: CYBLE_EVT_GATTS_READ_REQ - Identify which characteristic was read
                user_482772723

                I had the same problem and it works fine, thanks!

                 

                jrow

                I have another question about CYBLE_EVT_GATTS_READ_CHAR_VAL_ACCESS_REQ . I notice that this stack event is called 6 times. Do you know why? I read the characteristic from Android phone and then in a CYBLE_EVT_GATTS_READ_CHAR_VAL_ACCESS_REQ stack event I read an eeprom and I update the characteristic value:

                 

                               /* Update READ EEPROM handle with new values */

                                readHandle.attrHandle = CYBLE_READ_EEPROM_SERVICE_READ_EEPROM_CHAR_HANDLE;

                                readHandle.value.len = 0x80 ;

                                readHandle.value.val = eeprom;           

                                                   

                                /* Update the READ EEPROM attribute value*/

                                CyBle_GattsWriteAttributeValue(&readHandle, 0x00, &cyBle_connHandle, 0);

                 

                Do you know what is happening?

                 

                Many thanks,

                 

                Raul.