3 Replies Latest reply on Jan 24, 2015 3:29 PM by user_78878863

    BLE Custom Service generated code

    bill.zimmer

      Is there any documentation on creating custom services in psoc-ble??    

         

      I am trying to create an interface similar to the TI SensorTag and when I create the custom service with custom characteristics in the profile then generate the application, I don't see any generated code for the custom service.  

         

      Am I missing something???

         

       

         

      Bill

        • 1. Re: BLE Custom Service generated code
          user_78878863

          When I add a custom service, with custom characteristics, I get two files generated: CYBLE_custom.h / CYBLE_custom.c. They contain all the UUID definitions and the structure definitions for your service.

             

          Apart from that, there is nothing generated, but I don't see what should be done there? What code do you expect to be generated?

             

          In your code, you need to handle the CYBLE_EVT_GATTS_WRITE_REQ event to capture all the writes to your own custom attributes. Maybe you need to write to your attributes and generate notifications - that can be done from the main loop or a timer interrupt. Again, this is nothing that can be generated.

          • 2. Re: BLE Custom Service generated code
            bill.zimmer

            That was helpful, it appears I am making this more complex than it really is.

               

             

               

            Can you point me to the api to  write to your attributes and generate notifications, or better yet, some reference code for a custom profile that provides data to a client??

               

             

               

            Thanks in advance

               

             

               

            Bill

            • 3. Re: BLE Custom Service generated code
              user_78878863

              I assume you have read a BLE introduction, so you know how BLE and the attribute handling (GATT profile) works. Maybe read AN91627 (http://www.cypress.com/?rID=102504 ) for an explanation.

                 

              I actually took the heart rate sensor example project and looked at how its implemented, Creator generates a lot of code for this profile and the service, that has everything you need.

                 

              To write an attribute, use the CyBle_GattsWriteAttributeValue function. To generate a notification, use CyBle_GattsNotification(). Just look at the API documentation, or how its used in the sample projects.

                 

              In the end, the standard profiles do the same a custom service would do, its just that they have predefined attributes and UUIDs, and their behaviour is defined. There is nothing special about them... (Cypress just provides a simplified API to use them, but their internals are not that complicated).