Help with ReadCharacteristicByUUID

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

cross mob
JeVa_4767346
Level 1
Level 1
Welcome!

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.

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.
DheerajK_81
Moderator
Moderator
Moderator
First comment on KBA First comment on blog 5 questions asked

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:

pastedImage_2.png

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


Regards,
Dheeraj

View solution in original post

0 Likes
2 Replies
JeVa_4767346
Level 1
Level 1
Welcome!

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.

0 Likes
lock attach
Attachments are accessible only for community members.
DheerajK_81
Moderator
Moderator
Moderator
First comment on KBA First comment on blog 5 questions asked

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:

pastedImage_2.png

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


Regards,
Dheeraj

0 Likes