1 2 3 Previous Next 31 Replies Latest reply on Sep 12, 2019 5:46 AM by JoMe_264151

    CySmart API C# example

      Wondering if there is a bare bones example in C# code using the CySmart API to setup and talk to the dongle ??


      The reference guide does not provide one, and its not clear to me at least how to properly start things up, etc..

        • 1. Re: CySmart API C# example

          You can get the  complete code from Cypress if you open a case. There are  no barebone examples that I know of.

          1 of 1 people found this helpful
          • 2. Re: CySmart API C# example

            Thanks.. I'll give that a go..

            • 3. Re: CySmart API C# example

              Apparently Cypress does not share the C# sources to the CySmart app, nor do they provide any other example as an option to help get an API driven application off the ground... not the 'helpful response' we were expecting..  we've suggested signing an NDA to get a peek.. we'll see how that goes.. sigh.. 


              Otherwise, their response to my case has been a bit disappointing:


              "Thanks for contacting Cypress Technical support. Currently we don't have any example source code using Cymsart API."


              And after a second inquiry about the CySmart code itself:


              "The CySmart source code for windows tool is internal and cannot be shared. We provide CySmart API reference guide available at http://www.cypress.com/documentation/software-and-drivers/cysmart-bluetooth-le-test-and-debug-tool."

              • 4. Re: CySmart API C# example

                I have attached a sample code for using CySmart C# APIs. I hope this helps. Let me know if you have any questions or if you face any problems with the code.

                1 of 1 people found this helpful
                • 5. Re: CySmart API C# example

                  grsr, Thank you very much for your samples!  I design electronics and develop embedded software/firmware.  I developed a Bluetooth instrument and needed to make a demo app but I don't know C#.  I was able to study and expand your samples.  Thanks!!!

                  • 6. Re: CySmart API C# example

                    Hi GRSR, 


                    ı will use your example code. this code read a data from psoc. I need send a data from computer to psoc. How can I do this ? 

                    • 7. Re: CySmart API C# example

                      If your question implies sending data from CySmart dongle (GATT client) to PSoC BLE (GATT server) then first the GATT client should discover attributes on the GATT server after establishing connection. Then you need to use the CySmart API WriteCharacteristic (CyGattWriteInfo info). The class CyGattWriteInfo will encapsulate the data you need to send. Try implementing the CySmart APIs for attribute discovery and characteristic read or write and let me know if you face any difficulties. The CySmart API reference guide is available at the link mentioned in post#4. Attach the project code if necessary.

                      • 8. Re: CySmart API C# example

                        Hi grsr,


                        Thank you very much for your samples!


                        It would be helpful if you can share what correct sequence should be done for reading data on  CySmart dongle (GATT client) that was sent from PSoC BLE (GATT server). Encapsulation using CySmart API WriteCharacteristic (CyGattWriteInfo info) working for me great, since CyGattWriteInfo(ushort handle, params byte[] value) has parameter "value" and I able to send notifications, once I need to receive I should use  ReadCharacteristic(CyGattReadInfo info), but CyGattReadInfo object has no value I can read? According to documentation this object holds the information necessary to read an attribute value, but were the value actually stored? 

                        • 9. Re: CySmart API C# example

                          If the GATT Server is notifying data to GATT Client, then you should not use ReadCharacteristic(CyGattReadInfo info) API. The GATT client shall receive notification as a callback "OnCharacteristicChanged" under CyGattClientCallback. The class CyCharacteristicChangedInfo will encapsulate the Handle-Value pair of the notified data. The ReadCharacteristic API should be used to read data that is already written into the GATT database of the GATT Server.

                          • 10. Re: CySmart API C# example

                            Hi grsr, 


                            Thanks for your answer!


                            Unfortunately "OnCharacteristicChanged" callback is not fired in my case, but while I'm using CySmart 1.2 application I able to see GATT Server's message under 0x010 hanle. What can be a possible reason?

                            • 11. Re: CySmart API C# example

                              You need to enable CCCD in CySmart C# code to receive notifications. If you are doing so, check if you have entered the correct attribute handle of the CCCD. Open CySmart 1.2 and check the attribute handle of the CCCD. It should equal the attribute handle of the characteristic to be notified + 1. Use this value in the C# code.

                              • 12. Re: CySmart API C# example

                                Hi grsr, 




                                Thank you about this code it's very helpful to me. I'm trying actually to make my own but I'm facing to a problem.


                                I want to use the ReadCharacteristic(CyGattReadInfo info) method to read a characteristic value but I'm unable to read it.


                                Can you help me ?


                                I called it with the parameter : "CyGattReadInfo GattInfo = new CyGattReadInfo(0x001E);" but when I call "err = GattClient.ReadCharacteristic(GattInfo);" it's an unknow name for visual studio. To read this data I made the callback but my problem is about to launch the read operation. I guess the problem is coming from my way to declare "ICyGattClient GattClient;" but I don't see how to manage with this object.


                                Thank you.


                                Best regards,



                                • 13. Re: CySmart API C# example

                                  Hello GRSR,


                                  Thank you for support!


                                  I’m doing following sequence:


                                  Step 1. override void OnCharacteristicChanged(CyCharacteristicChangedInfo info) and enabling public Action<CyCharacteristicChangedInfo> CharacteristicChangedHandler { get; set; }


                                  under class GattClientCb : CyGattClientCallback




                                  Step 2. Once m_gattClientCb initialized, I’m linking m_gattClientCb to CharacteristicChangedHandler (m_gattClientCb.CharacteristicChangedHandler = (info) => while here I’m using data GetPrintableValue(info.Value))


                                  Step 3. In main function I’m creating
                                  m_cyGattReadInfo = new CyGattReadInfo(0x0011); (0x0011 value taken from CySmart 1.2, I can see changes (received data) on 0x0010 handler, accourding to previous suggestion it should be equal to attribute handle of the characteristic to be notified + 1). And enabling m_peerDevice.GattClient.ReadCharacteristic(m_cyGattReadInfo);




                                  Step 4. No notification is received and no OnCharacteristicChanged event fired in this case.


                                  A’m I missing something?


                                  Please advice.

                                  • 14. Re: CySmart API C# example



                                    I am attaching another simple code example. This is a simple GUI that demosntrates scanning, connection, Write, Read and receiving notification.


                                    You can download the project from this link:




                                    Also, document for testing the project is attached here.




                                    - Madhu Sudhan

                                    1 2 3 Previous Next