2 Replies Latest reply on Aug 30, 2018 6:42 AM by kegrc_3159731

    Custom BLE Service not available with Fixed Stack OTA Bootloader

      Hello, I am currently in the process of adding a Fixed Stack OTA BLE Bootloader to an existing project, and having issues getting the custom BLE service to appear while the Bootloadable project is running.  The Bootloader was implemented by following the Cypress BLE_OTA_FixedStack_Bootloader example and the custom service of the existing project was moved to the Bootloader BLE component. 

      The InitializeBootloaderSRAM() function from the BLE_OTA_FixedStack_Bootloader example is being used to initialize the BLE component in the Bootloadable project.

      I have already tried setting the trim capacitor, and enabling/disabling the bootloader service (line 84).

      The Bootloader and Bootloadable projects both compile and run on the target device.

      The BLE component has the following profile configuration which is required for the application.

      Profile:          Custom

      Profile role:   Client and Server (GATT Client and  Server)

      GAP role:     Peripheral and Central

       

       

      Prior to implementing the Bootloader, the custom BLE service of the existing project was working just fine.

      iOS and Android applications could connect to the existing project via BLE and read//write data to the custom service.

       

      Now that the BLE component has been moved to the Bootloader, the iOS application can connect to the Bootloadable project, but cannot see the custom service.

      When the iOS application calls the Discover Services method, nothing is returned from the Bootloadable project.

      I can see that the CYBLE_EVT_GAP_DEVICE_CONNECTED event is triggered when I connect with the iOS app, but the CYBLE_EVT_GATTS_WRITE_REQ is not triggered with subsequent attempts to read/write data to the custom service.

       

      It almost feels like custom services need to be turned on in the Bootloadable application now that the BLE component resides in the Bootloader, but I do not know how to do that.  Any input would be greatly appreciated.

        • 1. Re: Custom BLE Service not available with Fixed Stack OTA Bootloader
          GeonaP_26

          Please follow steps elaborated in section: 'Adding Services' of OTA Fixed Stack project document and let me know if it helps.

          • 2. Re: Custom BLE Service not available with Fixed Stack OTA Bootloader

            geon, thank you for the response.

            I did add the new custom service according to Step 1 in the linked OTA Fixed Stack document.

            In the existing project I started from, I only had to call the CyBle_Start() function to get the services working.

             

            I wound up solving the issue, and it turned out to be a mismatch of the GAP security settings in the BLE component.

            When implementing the bootloader functionality, I started with the Bootloader project from the BLE_OTA_FixedStack_Bootloader example, then copied over the custom service from the existing BLE component, to the new one, and failed to check the GAP security settings which were different from what the phone application was expecting.

            To find the error, I had added some serial output to the BLE callback, printing out the uint32 event number every time the callback was executed.

             

            void bleCallback(uint32 event, void *event_param)
            {
                ...
                
                if (event != CYBLE_EVT_GAPC_SCAN_PROGRESS_RESULT)
                {
                    char eventBuffer[10];
                    sprintf(eventBuffer, "%lu", event);;
                    send_serial(eventBuffer);
                }
            
            ...
            }
            

             

            When connecting to the target with the iOS application, I could see that the CYBLE_EVT_GAP_AUTH_FAILED event was getting called twice.

            I looked in the CyBle_Stack.h file to find the following.

            /** Authentication process failed between two devices. The return value of type 
               CYBLE_GAP_AUTH_FAILED_REASON_T indicates the reason for failure. */
            CYBLE_EVT_GAP_AUTH_FAILED,
            

             

             

            This led to adding the following code to the BLE callback, found from this example.

            case CYBLE_EVT_GAP_AUTH_FAILED:
            authFailReason = ((CYBLE_GAP_AUTH_FAILED_REASON_T *)event_param);
            char authFailReasonCode[3];
            snprintf(authFailReasonCode, sizeof(authFailReasonCode), "%lu", (uint32)(*authFailReason));
            send_serial("*   Authentication Fail");
            send_serial(authFailReasonCode);
            

             

             

            The authentication reason code corresponded to CYBLE_GAP_AUTH_ERROR_INSUFFICIENT_ENCRYPTION_KEY_SIZE.

            Reading the BLE_OTA_FixedStack_Bootloader.pdf, I found a mention on security on page 21.

             

            I then used the PC CySmart application to match the security settings set in the GAP BLE component, and CySmart was able to see all of the services and actively exchange data with them.  I changed the BLE component GAP settings to match what the iOS application was expecting, and the application was able to access all of the expected services again.  So they were there, it just wasn't apparent that the authentication was failing with the iOS application.