bluetooth connection stops

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
FaBr_4408376
Level 1
Level 1

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.

0 Likes
19 Replies
Yugandhar
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 5 likes given

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.

0 Likes

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!

0 Likes

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

0 Likes

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.

0 Likes

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.

0 Likes

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

0 Likes

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.

0 Likes

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

0 Likes

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.

0 Likes

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!

0 Likes

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!

0 Likes

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.

0 Likes
lock attach
Attachments are accessible only for community members.

Hello, here is my project.

Thank you!

0 Likes
lock attach
Attachments are accessible only for community members.

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.

0 Likes

Hello,

Thank you so much for your help.  I will make those changes and keep the device connected while in deep sleep.

When you are power switching the device do you get the instant passed error code?  I find that the connection does not reestablish if I continue to power switch after getting this error.

0 Likes

Hello,

I didn't get this instant passed error while switching. Could you please let me know when we will get this error?

Could you please check the attached project and check if you get this error code.

Thanks,

P Yugandhar.

0 Likes

Hello,

I do still get the instant passed error with the new changes.  I pair the device with the iphone, then power switch for about 35sec at a rate of about one button press per second.  I don't think this is a common use-case, but I am curious if you're able to replicate the problem.

So far i haven't seen the other error where it stops advertising altogether!

Thanks!

0 Likes
lock attach
Attachments are accessible only for community members.

Hello,

Please refer to the attached project where I'm using the UART component for printing the Instant passed error statement when occurs. I'm not seeing this Instant passed error, please check once and let me know the observations.

Meanwhile, please check the PSoC Creator code example "BLE_HID_Keyboard" and check if you see any Instant passed error code. Also, please check the guidelines from Apple to have a stable connection with an Apple product in the link below.

Link: https://developer.apple.com/library/archive/qa/qa1931/_index.html

Thanks,

P Yugandhar.

0 Likes

Thank you for taking the time to publish this information on Bluetooth connection. Its very useful for me! Since i am a student i always find thesis writing a most difficult task. After reading this article i find it little bit easy for me to write. Thank you for this post. I also find this website  useful. Please have a look.

0 Likes