1 2 Previous Next 19 Replies Latest reply on Sep 12, 2019 10:53 PM by PY_21

    bluetooth connection stops

    FaBr_4408376

      Hi, I am using the CYBLE-022001 (BLE profile HID over GATT) and an iPhone.  *This is my first post! Let me know if I left out any info*

       

      I am able to successfully pair my device to my iPhone and the connection is fine. When the device is on, my iPhone says "connected" and when the device is off, my iPhone says "not connected".  However, if I rapidly turn my device on and off, the two get "out of sync" and the iPhone will show it as "not connected" even though it is still paired and on.  I have tried restarting my phone and turning bluetooth on/off, but nothing will update the connection.  When the device is like this, all other functionalities of the device are normal.  If I unpair the device, it no longer advertises and the only way to get it to advertise and pair is to reset the device.

       

      In the code, the device advertises whenever the device is not in deep sleep mode, so I don't understand what is happening.

       

      Unfortunately, I do need to be a little vague because this is a work project.

       

      Thanks in advance.

        • 1. Re: bluetooth connection stops
          PY_21

          Hello,

           

          Are you switching off your device when it is connected with your iPhone? Please elaborate more on this.

          Please check the reason of disconnection in the Disconnect event of your peripheral project.

          Whenever the device is in disconnection state please restart the advertisement. This will makes the device to advertise again after disconnection.

          Can you please share your project so that we can check at our end.

           

          Thanks,

          P Yugandhar.

          • 2. Re: bluetooth connection stops
            FaBr_4408376

            Hi, yes I am connected when switching the device on and off.  I turn the device on, pair it to my iPhone, and check to make sure the connection is ok.  Then, I turn the device off and on quickly (maybe 5 or 6 times) and the iPhone eventually shows that the device is disconnected.  When I click on the name of the device, it is not able to connect and if I unpair, the device no longer advertises as a device with bluetooth capability.  The device should disconnect when turned off because it enters deep sleep after 10 seconds.  However, when the device is turned on, it should start advertising.  This problem occurs occasionally in other use cases, but this is the only one I can replicate.  When I turn the device on and off slowly, it doesn't seem to have a problem.

             

            Thanks!

            • 3. Re: bluetooth connection stops
              FaBr_4408376

              Do you have any resources to walk me through figuring out the reason of disconnection?

              • 4. Re: bluetooth connection stops
                PY_21

                Hello,

                 

                When the BLE device gets disconnected, the CYBLE_EVT_GAP_DEVICE_DISCONNECTED event is triggered. This event indicates that the CyBLE device is disconnected from the remote device or failed to establish a connection. The parameter returned with the event contains a pointer to the reason for disconnection, which is of type uint8.

                In firmware, you can get the event parameter value from the CYBLE_EVT_GAP_DEVICE_DISCONNECTED event as follows:

                Printf ("Error code is: 0x%x \r\n",*(uint8 *) eventParam);

                Check the error code in the BLE_Stach.h file in the project or find the corresponding description from the “HCI error commands” section in the BLE Core Specifications (Version 4.2, Vol 2, Part D, Section 1.3: List of error codes).

                 

                Thanks,

                P Yugandhar.

                • 5. Re: bluetooth connection stops
                  FaBr_4408376

                  Hi, when the device is turned on and off, the error code is 0x28 (instant passed).  Most of them time after this error code, it is able to connect again.  However, after several times of disconnecting and reconnecting, it appears to stop reconnecting and advertising.  Sometimes if it is turned on and off quickly, it will give the same error code and then not reconnect or advertise after this one time.

                  • 6. Re: bluetooth connection stops
                    FaBr_4408376

                    I have looked at other posts about instant passed errors, but I don’t think the troubleshooting is helpful for me.

                    - I am using cap-trim 0x9898, which is the recommended value for CYBLE 022001-00

                    - The device does not enter deepsleep mode while Bluetooth is in use

                    - I don’t think the connection parameters are being changed after connection is established. 

                    - BLESS interrupt has highest priority (0)

                    - CyBle_ProcessEvents is called in regular intervals (line 473 in main.c, previously attached)

                    - ISR code sets a variable that is checked inside main loop

                    - ECO is set to 24MHz. Are there any other clocks that I should check?

                    - After the 'instant passed' error code causes the advertising to stop, I cannot connect with CySmart Mobile App

                    • 7. Re: bluetooth connection stops
                      PY_21

                      Hello,

                       

                      Q: ECO is set to 24MHz. Are there any other clocks that I should check?

                      Ans: Please check external crystals parameter specifications mentioned in AN95089: PSoC/PRoC BLE Crystal Oscillator Selection and Tuning Techniques.

                      1. Please restart the advertisement in Disconnection event(CYBLE_EVT_GAP_DEVICE_DISCONNECTED) also. This will makes the device to advertise again after disconnection.

                      2. Could you please let me know why you are switching the peripheral device on and off when it is connected. Are you switching the device power for power saving consideration?

                       

                      Thanks,

                      P Yugandhar.

                      • 8. Re: bluetooth connection stops
                        FaBr_4408376

                        Hello,

                         

                        There is not an external crystal in our PCB design.  Is that a problem?

                         

                        1.  I have included the code to advertise after a disconnection event, but I still run into the problem that the device becomes undiscoverable after several "instant passed" errors.

                         

                        2.  I have noticed this problem during normal use of the device, but it only happens occasionally.  However, I have found that turning the device on and off is a very reliable way to cause the device to stop advertising.

                         

                        Thanks

                        • 9. Re: bluetooth connection stops
                          PY_21

                          Hello,

                           

                          1. An external WCO crystal is used to derive the 32.768-kHz clock that maintains link-layer timing synchronization when the BLE subsystem is in a low-power mode. The WCO may be turned OFF if BLE is not used or the BLESS DEEPSLEEP power mode is not used.

                          2. Could you please check with some other phones(if possible) and let us know the observations.

                          3. Please let me know how quickly you are switching the device on and off in a time.

                           

                          Thanks,

                          P Yugandhar.

                          • 10. Re: bluetooth connection stops
                            FaBr_4408376

                            Hi,

                             

                            1.  Are all of the crystals contained in the CYBLE component or does our circuit design need to change?

                            2. This problem occurs with iPhone 5 as well

                            3.  I am pressing the on/off button as slow as about 0.33 Hz and as fast as 1 Hz to cause the "instant passed" error.

                             

                            Thanks!

                            • 11. Re: bluetooth connection stops
                              FaBr_4408376

                              Hi,

                               

                              Update:  When the device stops advertising during normal use, it does not disconnect because of the "instant passed" error.  It seems that the device stops advertising after a "normal' disconnection event when the device enters deep sleep (error code: 0x16 - connection terminated by local host).  Usually it reconnects after the device wakes up, but sometimes it doesn't. It doesn't happen very often, so it is difficult to make observations and it happens during deep sleep so I am not sure what is going on.  I have tried writing down what I am doing with the device leading up to the advertising stopping and then repeating the steps and when I do, it doesn't happen again!

                               

                              I programmed the device to go into an error mode after the disconnection event "instant passed".  This seems to give the device enough time to connect without interruption from the user.

                               

                              Thanks!

                              • 12. Re: bluetooth connection stops
                                PY_21

                                Hello,

                                 

                                Can you please check this thread for information on instant passed error instant passed error

                                Can you please share your project so that we can check at our side. Refer this KBA link for archiving a project Archiving a PSoC Creator Design

                                 

                                Thanks,

                                P Yugandhar.

                                • 13. Re: bluetooth connection stops
                                  FaBr_4408376

                                  Hello, here is my project.

                                   

                                  Thank you!

                                  • 14. Re: bluetooth connection stops
                                    PY_21

                                    Hello,

                                     

                                    Please refer to the attached project. I'm not seeing any issue with the project. I'm establishing the connection after device power switching.

                                    1. Could you please let me know why you are disconnecting the device before putting the CPU into Deepsleep mode. When we put the device into Deepsleep during advertising or connection interval, the BLESS interrupt will wakes up the system from DeepSleep before start of every connection or advertisement event. So we can put the device into low power mode during advertising or connected state. Please refer to this Application note AN92584 for more information on low power mode for BLE.

                                    2. Please store the bonding data when the device is paired using CyBle_StoreBondingData() API function.

                                    3. Please restart the advertisement immediately in disconnection event CYBLE_EVT_GAP_DEVICE_DISCONNECTED.

                                    4. Please put the BLESS interrupt to highest priority i.e., the priority should be 0.

                                     

                                    Please let me know if you have any questions.

                                     

                                    Thanks,

                                    P Yugandhar.

                                    1 2 Previous Next