4 Replies Latest reply on May 4, 2017 7:21 AM by jack_1591761

    Issue reconnecting after failing to connect

    jack_1591761

      Hi 

         

      I have 2 proc boards communicating to each other (typical master and slave)

         

      The master attempts to connect to the slave and on connection the slave sends the master information. The master then disconnects from the slave and waits for 10 minutes before reconnecting. This continues indefinitely.

         

      In the event that the master fails to connect to the slave (e.g. when the slave is out of range or was powered off) it fails to connect and I get a connection timeout as expected. However whenever the master attempts to reconnect to the slave and the slave is available it fails to reconnect. I can turn the master off and on and it still fails to connect. the only way to fix this is to reprogram the master

         

      To connect I call CyBle_GapcConnectDevice((CYBLE_GAP_BD_ADDR_T*)&peerBdAddr) and it this works (usually) and in the event of a failed connection I call CySoftwareReset() to reset the master.

         

      Is it possible that when calling for a connection it stores this information such that a reset does not clear it? and in that case is there any way to clear this information? 

         

      I cannot call CyBle_GapDisconnect(connHandle.bdHandle) as I don't receive a connection handle if no connection is established.

         

      Due to confidentiality reasons I am unable to upload the full project

         

      Thanks in advance for the help

         

      Jack

        • 1. Re: Issue reconnecting after failing to connect
          e.pratt_1639216

          A CySoftwareReset() clears most software-related items, but I think there are some hardware function that it does NOT reset. That shouldn't be an issue for the BLE radio however; You could try calling CyBle_Stop() before resetting the unit if you want to test it.

             

          There are functions that will store connection data permanently into the flash, but you have to explicitly call the flash write functions for them to run/save the data to flash. Iirc, the CYBLE stack only queues connection-related data to be stored in flash if you set the unit to use bonding. It shouldn't be doing flash writes without your code interacting with it on purpose.

             

          When you say the master "reconnects", is this:

             

          After ten minutes?

             

          After it had already connected to the slave once?

             

          After failing to connect to the slave?

             

          I would assume you have tried using the debugger to catch it's stack/state when it crashes/fails?

             

          If not, then it could be your code is merely out of control :)

             

          Double check that you aren't scanning/advertising when attempting to connect to the slave;

             

          Double check your BLE radio states, as a lot of the functions have "prerequisites" before you can call them. 

          • 2. Re: Issue reconnecting after failing to connect
            user_1377889

            The CySoftwareReset() API resets the chip under software control, thus the name. It does not only clear the software components, it does a complete re-initialization of the chip.

               

             

               

            Bob

            • 3. Re: Issue reconnecting after failing to connect
              e.pratt_1639216

              Sorry @Bob, I didn't mean to imply that it skipped reinitialization; I meant that there is some hardware functionality that can't be reset through the use of CySoftwareReset(); (I believe I read this in the documentation for the function itself), but for most functionality it should reset just fine.

              • 4. Re: Issue reconnecting after failing to connect
                jack_1591761
                        Using CyBle_stop seems to have fixed the issue, it still takes a number of attempts to re establish a proper connection but I still get all my data from the slave device so I'm happy with the fix thank you very much Jack