2 Replies Latest reply on Oct 27, 2020 8:45 AM by DheerajK_81

    Help with ReadCharacteristicByUUID


      I'm using a donlge cysmart module with C#, I would like to know how can I see the info read. This is the part of the code I'm using to read the characteristic:

        err = GattClient.ReadCharacteristicByUUID(new CyReadCharacteristicByUUIDInfo(uuid, startHandle, endHandle));


      But I don't know how to read the characteristic itself.

        • 1. Re: Help with ReadCharacteristicByUUID

          I just saw on the API Reference Guide that I can use:

          virtual void OnCharacteristicReadByUUID (CyReadCharacteristicByUUIDResult result, CyStatus status)[virtual]

          But I'm not sure how to use this function.

          • 2. Re: Help with ReadCharacteristicByUUID

            When you configure the BLE Component to add different services and characteristics, handles to each of them are generated in the file BLE_config.h usually. Its not clear which device you are using.


            Lets say you configure the BLE component with the following settings:


            Then the following macros will be generated for you:

            #define CY_BLE_CAPSERV_SERVICE_HANDLE  (0x0010u) /* Handle of CAPSERV service */

            #define CY_BLE_CAPSERV_LED_DECL_HANDLE  (0x0011u) /* Handle of LED characteristic declaration */

            #define CY_BLE_CAPSERV_LED_CHAR_HANDLE  (0x0012u) /* Handle of LED characteristic */

            #define CY_BLE_CAPSERV_LED_LEDCCCD_DESC_HANDLE  (0x0013u) /* Handle of ledCCCD descriptor */

            #define CY_BLE_CAPSERV_FAN_DECL_HANDLE  (0x0014u) /* Handle of FAN characteristic declaration */

            #define CY_BLE_CAPSERV_FAN_CHAR_HANDLE  (0x0015u) /* Handle of FAN characteristic */


            So, in CySmart C# Application when using the API ReadCharacteristicByUUID here's how you would call it:

            GattClient.ReadCharacteristicByUUID(new CyReadCharacteristicByUUIDInfo(<UUID>, 0x0012, 0x0013));


            You need to then implement a GattCallback in this way:

            class GattClientCb : CyGattClientCallback{
                 public override void OnCharacteristicReadByUUID(CyReadCharacteristicByUUIDResult result, CyStatus status)
                            // Do something with the result


            You can find some CySmart examples attached for reference. Hope this helps