3 Replies Latest reply on Feb 8, 2017 1:46 AM by user_473032933

    Weird disconnection issue after several seconds

    user_473032933

      Hi all,

         

      In our BLE application, I am facing a weird disconnection issue.
      In general, the peripheral is working good, it is connected with the central device and it sends notifications.
      After several seconds it disconnects. It could be 10sec or a few minutes the time until the disconnection happens. The weird thing is that no disconnection events are propagated to the event stack handler function and as a result, I have no idea why it disconnects. Furthermore, since the disconnection event is not handled, the peripheral does not start advertising after disconnection so the central cannot re-establish connection.

         

      The rest functionality of the application is continued normally after disconnection and all interrupts, analog-to-digital conversions, UART/I2C transactions are working good. Only the BLE functionality stops operating. I would like to mention that notifications are sent very frequently. We send a notification packet every 50ms. I do not know if this has to do with the disconnection issue (availability of internal buffers or anything relative).

         

      Are there any ideas what could have happened?

         

      Best Regards,
      Yiannis

        • 1. Re: Weird disconnection issue after several seconds
          hima

          Hello Yiannis,

             

          1)Are you using low power modes in the code?

             

          2)Please let us know how you are detecting the disconnection, if the stack event is not generating?

             

          3)Have you made sure that the CyBle_ProcessEvents() once in every connection interval?

             

          Thanks,

             

          Hima

          • 2. Re: Weird disconnection issue after several seconds
            user_473032933

            Hima, thank you very much for your answer.

               

            1. Yes, I am using low power modes in the code. This could be related with the disconnections because when I remove the LowPowerImplementation (similar function to the Cypress examples which includes the CySysPmDeepSleep function) and put the device only in CySysPmSleep mode, then the disconnections are reduced dramatically... but there are still some.

               

            2. The disconnections are detected using the CySmart tool and the dongle. I enable notifications and the device is working good. It sends correct data to the CySmart. After a while, could be a few minutes, it disconnects. If I do not enable the notifications, I do not notice disconnections.

               

            3. I am sure that the CyBle_ProcessEvents() is called in every connection interval, unless I miss something. Main loop lasts 1ms. In the first 200-300us of this period, the processor executes processing. In the next 700-800us, the processor sleeps. The connection interval is min=30ms, max=40ms. The processor wakes up every 1ms, executes CyBle_ProcessEvents(), applies processing and then gets back to sleep. The CyBle_ProcessEvents() is called at least once per 1ms.

               

            Best Regards,
            Yiannis

            • 3. Re: Weird disconnection issue after several seconds
              user_473032933

              It seems that this error is an internal stack error or I cause with my code this error, I do not know.
              Since disconnection event is not propagated, I have no knowledge of the status and I continue to send notifications. The CYBLE_API_RESULT_T return value of the CyBle_GattsNotification() function is CYBLE_ERROR_MEMORY_ALLOCATION_FAILED.

                 

              The above apiResult is also noticed sometimes before disconnection happens. But rarely. When disconnection happens it is returned continuously, which is reasonable since connection is dead.

                 

              I will try to reduce the transmission load, hoping to resolve the issue. Any other workaround?

                 

              Thank you in advance.
              Yiannis