2 Replies Latest reply on Oct 2, 2017 6:41 AM by epr_1639216

    BLE store bonding data problem

      Hi there!


      I'm using a CYBLE-222005-00 module, with security configuration for bonding with JustWorks since my device has NoInput/NoOuput (see attachement). However, the saving of the bonding data does not seem to work. After a wake-up from hibernate, I cannot re-connect with the previously bonded Smartphone getting a CYBLE_EVT_GAP_AUTH_FAILED event from the BLE stack.


      Here is what I do in he code:

      On the callback event CYBLE_EVT_GAP_AUTH_COMPLETE I call

      while(CYBLE_ERROR_OK != CyBle_StoreBondingData(0));

      and later I get the event CYBLE_EVT_PENDING_FLASH_WRITE where I do nothing in the code. This event seems to be triggered even when I don't call the CyBle_StoreBondingData() method before...


      Is there a way to check, if the bonding data is stored correctly in the flash or am I missing some other things?


      Thanks for your help!

        • 1. Re: BLE store bonding data problem

          Problem was, that I was calling the CyBle_StoreBondingData at the wrong place in the code (in the callback handler of the BLE stack). Now I added the following lines to my main routine and it works! :-)


          if((cyBle_pendingFlashWrite != 0u) && (CyBle_GetState() == CYBLE_STATE_CONNECTED))
                  CYBLE_API_RESULT_T apiResult;
                  apiResult = CyBle_StoreBondingData(0u);
                  printf("Store bonding data, status: %x \r\n", apiResult);
          • 2. Re: BLE store bonding data problem

            Yeah; Calling flash write routines during an interrupt handler is probably not the best idea

            Possibly it could be caused by not calling the CyBle_ProcessEvents() between calls to the CyBle_StoreBondingData(0u) function, but idk for sure.