8 Replies Latest reply on Apr 28, 2019 10:27 PM by GyanC_36

    RPA doesn't seem to work

    DeCo_1926091

      I'm clearly doing something wrong with the attached program.  Everything seems to work OK except when (I think) iOS changes it's resolvable address.  This occurs after the program has been running about half an hour.  The program is designed to run on a custom PCB but for this test I've been running it on a Pioneer board with a CYBLE-214015-01 module which uses BT 4.2.  I'm communicating with it via BLE with the LightBlue app on an iPad 2 Air with the latest iOS installed.  None of Pioneer's switches or indicators are required for the test I'm working on.

       

      What is supposed to happen is that after programming the PSoC 2 BLE and starting the LightBlue app (having "forgotten" the device if it appears in the iOS settings-Bluetooth) the program connects, pairs and bonds with the iPad.  This works OK.  I can turn off the LightBlue app and restart it and the two devices reconnect.  I can cycle power to the Pioneer board and they reconnect as they should.  This can be repeated a number of times with everything working well.  However, if I let the two devices sit and do nothing to them for half an hour or so then quit the app and restart it or cycle power to the Pioneer board they will no longer connect.

       

      If I change the code on line146 of BLEApplication.c to make the filter policy 'scan any, connect any' (instead of scan any, connect using whitelist) this problem does not occur.  My thinking is that the whitelist function is failing because the RPA has changed and the PSoC 4 is not handling it correctly because I've done something wrong in the code.

       

      I'd be really grateful is someone could take a look at this and tell me what's wrong.

       

      Thanks much,

      Dennis

        • 1. Re: RPA doesn't seem to work
          GyanC_36

          Hi Dennis,

           

            In the below code snippet , in both of the conditions the RPA resolution is disabled in your code. When there is a device in bonded list ( also added in whitelist) , you should enable the resolution before restarting advertisement.

           

          Could you try by passing a '1' as argument in RPA resolution API when there is a device in bonded list and test ?

           

          """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

           

          if(bondedDevList.count != 0u)

              {

                  apiResult = CyBle_GapSetAddressResolutionEnable(0u);            /*was 1u */     GYAN -> pass 1 as argument.

                  UART_UartPutString("Resolution enabled\r\n");

                  /*Start advertising at 0 dBm power if a device is stored on whitelist*/

                  setTxPowerLevel(CYBLE_LL_PWR_LVL_0_DBM);        

                  cyBle_discoveryModeInfo.advParam->advFilterPolicy= CYBLE_GAPP_SCAN_ANY_CONN_WHITELIST;

                  UART_UartPutString("Start advertising WITH whitelist.\n\r");

              }

              else

              {               

                  /*Start advertising at low power if no device on whitelist*/

                  apiResult = CyBle_GapSetAddressResolutionEnable(0u);   

                  UART_UartPutString("Resolution disabled\r\n");

                  setTxPowerLevel(CYBLE_LL_PWR_LVL_NEG_18_DBM);

                  cyBle_discoveryModeInfo.advParam->advFilterPolicy=CYBLE_GAPP_SCAN_ANY_CONN_ANY;

                  UART_UartPutString("Start advertising WITHOUT whitelist.\n\r");

              }

              CyBle_GappStartAdvertisement(CYBLE_ADVERTISING_FAST);

           

          """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

          -Gyan

          1 of 1 people found this helpful
          • 2. Re: RPA doesn't seem to work
            DeCo_1926091

            Hi Gyan,

             

            Thanks for your reply.  I actually had it the way you suggested and it didn't work.  I then changed it to be 0u for a test but I forgot to change it back before posting the code.  Sorry for the confusion.  So your suggestion did not solve the problem.

             

            Dennis

            • 3. Re: RPA doesn't seem to work
              DeCo_1926091

              Hi Gyan,

               

              I made the change you suggested (enabled the address resolution if bondedDevList.count != 0u.  I also set up to use the passkey as in your example.  I can connect to it with the iPad and all works OK.  If I end the app and restart it, it reconnects.  However, if I cycle power to the pioneer board it will not reconnect.  The only way I can sort of get it to work is by not enabling the address resolution.  Of course, then it will only work until the iPad changes address.

               

              Any other suggestions?

               

              Thanks,

              Dennis

              • 4. Re: RPA doesn't seem to work
                GyanC_36

                Hi Dennis,

                 

                  The whitelist information stores in RAM. So on power cycle ,it will erase ( basically the ID address which we put in whitelist )and because of CYBLE_GAPP_SCAN_CONN_WHITELIST_ONLY filter policy the client device will not be able to scan the server device.

                 

                So, I think we need to add the Client ID address into whitelist on power cycle /hard reset. Could you please try it?

                 

                 

                -Gyan

                 

                 

                1 of 1 people found this helpful
                • 5. Re: RPA doesn't seem to work
                  DeCo_1926091

                  Hi Gyan,

                   

                  I thought I could try this but I guess I just don't really know how to do it.

                  Would you be kind enough to help me with it?

                   

                  Thanks,

                  Dennis

                  • 6. Re: RPA doesn't seem to work
                    GyanC_36

                    Hi Dennis,

                     

                        Please find the attached project. You need to restore both Resolving List and Whitelist ( for ID address) on Power cycle/ Hard Reset.

                     

                    line #36 to 54 are the ones , I have added to restore both Resolving List and Whitelist.

                     

                    Note: Please note that the first bonded device always gets a BD handle equal to 4, second one gets 3 and so on upto 1. So, while extracting the bonded information we need to take care of it.

                     

                    -Gyan

                    1 of 1 people found this helpful
                    • 7. Re: RPA doesn't seem to work
                      DeCo_1926091

                      Hi Gyan,

                       

                      That seems to have solved my problem.  Thanks, so much.

                       

                      Only thing now is that I really don't understand how it works.  I was under the impression that writing to flash required a special API such as CyBle_StoreAppData.  Would you please explain what is happening in the code you sent?

                       

                      Thanks,

                      Dennis

                      • 8. Re: RPA doesn't seem to work
                        GyanC_36

                        Hi Dennis,

                         

                             CyBle_StoreBondingData(0u) internally calls CyBle_StoreAppData() API to store the bonding information ( Security keys ) into Flash.

                         

                        Since as I told earlier , Resolving List and Whitelist are the part of Controller RAM and on power cycle this information will be erased and we need to restore this from the bonding information.

                         

                        So, in the code  we are checking if the devices are already bonded and if resolving list /whitelist has erased ( means Power Cycle/Reset) then we are restoring this information from Flash to Controller RAM.

                         

                        CyBle_GapGetPeerDevSecurityKeyInfo() API is reading the bonded device's info from FLASH.

                         

                         

                        Regards,

                        Gyan

                         

                         

                         

                         

                         

                         

                         

                        1 of 1 people found this helpful