3 Replies Latest reply on Jul 13, 2016 6:35 AM by graeme.parker

    BLE_FindMe Example - adding custom service

    graeme.parker

      Hi

         

      So I am using he FindMe example code in Creator 3.3. Using CySmart I can interact with the target via the BLE PC dongle.

         

      I have added a custom service with two characteristics. The first is a uint8[16] array which I can write to using the PSoC and these values are returned in CySmart (as expected). The second characteristic is a uint8 which has the property WriteWithoutResponse (as does the alertLevel of the included service).

         

      Simply, how do I get the PSoC to take action when the 2nd characteristic is written to using CySmart?

         

      Thanks.

        • 1. Re: BLE_FindMe Example - adding custom service
          cjoachim_1597296

          By looking at the CYBLE_EVT_GATTS_WRITE_REQ event in your event handler and see if the Attribute to be written (param->attrHandle) is the one of your custom service Characteristic (you find your Attribute Handle in the generated file BLE_custom.h)?

          • 2. Re: BLE_FindMe Example - adding custom service
            graeme.parker

            Thanks for the speedy reply. Of course if I understood what you were saying I'd just be replying with a thank you. However...

               

            I have:

               

            #if(CYBLE_GATT_ROLE_SERVER)
                    case CYBLE_EVT_GATTS_WRITE_REQ:
                        CyBle_WriteReqHandler((CYBLE_GATTS_WRITE_REQ_PARAM_T *)eventParam);
                        break;

               

            In BLE_eventHandler.c.

               

            And my handles in BLE_custom.h:

               

            #define CYBLE_SCDATA_SERVICE_HANDLE   (0x0011u) /* Handle of SCData service */
            #define CYBLE_SCDATA_LOGDATA_DECL_HANDLE   (0x0012u) /* Handle of LogData characteristic declaration */
            #define CYBLE_SCDATA_LOGDATA_CHAR_HANDLE   (0x0013u) /* Handle of LogData characteristic */
            #define CYBLE_SCDATA_COMMAND_DECL_HANDLE   (0x0014u) /* Handle of Command characteristic declaration */
            #define CYBLE_SCDATA_COMMAND_CHAR_HANDLE   (0x0015u) /* Handle of Command characteristic */

               

            But I'm not sure what I should do next.

            • 3. Re: BLE_FindMe Example - adding custom service
              graeme.parker

              Been doing a bit of debugging to see what is happening. Quite tricky as you can't single step as it always ends up in an ISR. However, when CySmart does a write to either the alert characterstic or the custom one (both writewithoutresponse) then the BLE_eventHandler takes this case:

                 

                      case CYBLE_EVT_GATTS_WRITE_CMD_REQ:
                          if((cyBle_eventHandlerFlag & CYBLE_CALLBACK) != 0u)
                          {
                              (void)CyBle_IassWriteCmdEventHandler((CYBLE_GATTS_WRITE_REQ_PARAM_T *)eventParam);
                          }

                 

              Which (I guess it's the CMD option because of the writenoresponse) then (in CyBle_IassWriteCmdEventHandler) currently does nothing if the event is a write to my custom characteristic.

                 

              I'll probably be back, but do have something to work on now.

                 

              Ta.