1 Reply Latest reply on Mar 16, 2017 11:38 PM by hima

    Profile Event handlers: Where do they come from?

    user_13524663


      I originally posted this as a question but figured it out and think that others might have the same question when they use an example BLE project.

         


      I was trying to determine a method for building BLE code and was going through the example project BLE Proximity01 to gain some insight using the Cypress BLE component datasheet. So, I started reading about the Proximity Profile in the BLE datasheet and noted that the Link Loss Service is required and the Tx Power Service is optional.

         


      In main.c I found the call and code for the CyBle_Start(AppCallBack) event handler but not for:

         


      /* Register the event handler for LLS specific events */
      CyBle_LlsRegisterAttrCallback(LlsServiceAppEventHandler);

         


      /* Register the event handler for TPS specific events */
      CyBle_TpsRegisterAttrCallback(TpsServiceAppEventHandler);

         


      These are found in CYBLE_lls.c and CYBLE_tps.c, respectively. I assumed that they were automatically generated because those files are in the Generated Source directory. This assumption was correct as I found when I created a BLE project from scratch.

         


      When you add the BLE component you need to configure it. Selecting the Profile, Profile role and GAP role will set up PSoC Creator to create the required Profile Event Handlers whe you build the project. Look at the appropriate Profile section in the General Tab - Profile section of the BLE datasheet to see which Service(s) is(are) required. Their three letter acronym file, such as BLE_lls.c, BLE_lls.h, BLE_tps.c and BLE_tps.h for the Proximity profile, will be found in the Generated_Source/BLE directory.

         


      When you locate these file just add the appropriate event handler calls in main.c, as shown above. If you are unsure as to how they should be stated, search for "registerattrcallback" in the appropriate BLE_xxs.h file to confirm that you have entered it correctly.

         


      You must code the event handler CyBle_Start() yourself, to account for what you think the design might encounter and how to handle the various events as identified by their enumerations. I am not sure whether this is a consideration for these profile specific event handlers, however. Perhaps it can be safely assumed that Cypress has designed PSoC Creator's generated defaults to handle them properly.

         


      This isn't exactly clear from the BLE datasheet.