You are here

PRoC BLE Disconnect Error | Cypress Semiconductor

PRoC BLE Disconnect Error

Summary: 7 Replies, Latest post by david.taylor2_2102186 on 13 Jan 2017 10:09 AM PST
Verified Answers: 0
Last post
Log in to post new comments.
Simon Wimbles's picture
User
8 posts

I'm having some trouble at the moment with a design I'm working on. I have one central device and two peripherals which take it in turn to connect to the central. The problem I'm having is that one of the peripherals is not disconnecting when a disconnection request is sent from the central. When the central then tries to reconnect to this peripheral it can't as the peripheral still believes it is connected and is therefore not advertising. I have debugged the peripheral in question and when the central calls CyBle_GapDisconnect the peripheral does not jump in to the stack handler; it's as though it never received the request. This is only intermittent, however, and it does work 90% of the time. 
This is the code which calls the disconnection api at the central end:

                    apiResult = CyBle_GapDisconnect(connectionHandle.bdHandle);
                    while (bleConnected == TRUE)
                    {
                        ServiceWDT ();
                        CyBle_ProcessEvents();
                    }
                    if (apiResult != CYBLE_ERROR_OK)
                    {
#                       ifdef SERIALDEBUG
                            UART_UartPutString("+Disconnection error");
                            UART_UartPutString("\r\n");
#                       endif
                    }
                    else if (apiResult == CYBLE_ERROR_OK)
                    {
#                       ifdef SERIALDEBUG
                            UART_UartPutString("Disconnected from device with handle: ");
                            sprintf (valueString, "%i", connectionHandle.bdHandle);
                            UART_UartPutString(valueString);
                            UART_UartPutString("\r\n");
#                       endif
                    }

The disconnection api never returns an error when this fault occurs so I'm at a bit of a loss as to what the issue is. Plus, the connection handle is always correct/same value. Also, the fact the peripheral connection does not time out is just as curious. 
Has anyone come across this, or a similar problem before?

 

lizhaodongli_1448826's picture
User
13 posts

If you intend to disconnect from an existing connection, the function
    CyBle_GapDisconnect() should be used.

what do you do after calling the CyBle_GapDisconnect()? Start scanning? Or ,if it is reconnecting automaticlly?

Simon Wimbles's picture
User
8 posts

Hi. Yes, that is the function I am calling to disconnect. After the central calls CyBle_GapDisconnect the central starts scanning, looking for the second peripheral. The first peripheral starts advertising, once disconnected. The problem is that the first peripheral doesn't always get the disconnect command, and carries on as if still connected. 

Simon Wimbles's picture
User
8 posts

In case anyone is interested/has the same issue it was caused by the stack. I was using an old BLE stack version (V2) and updating to the latest full release (V2.3) solved the problem. There is a note in the errata section of the datasheet regarding this issue.

n.congvu_1902076's picture
User
18 posts

Hi Simon,

Can you let me know how to check the BLE stack version and how to update it. I have encountered same issue.

Thanks 

Matt Eng.WI's picture
User
17 posts

Hello n.congvu,

The BLE version can be determined by opening the TopDesign.cysch of your project and opening up the BLE component.  Click the Click the Built-In tab on the BLE configuration dialog.  The CY_MAJOR_VERSION and CY_MINOR_VERSION values listed on that tab specify the stack version.

david.taylor2_2102186's picture
User
2 posts

I'm seeing the same problem with BLE v3.1 & v3.2. Usually works, but maybe once in thirty connections, CyBle_GapDisconnect returns CYBLE_ERROR_OK, but the CYBLE_EVT_GAP_DEVICE_DISCONNECTED event is not called for 5-10 seconds. Further calls to CyBle_GapDisconnect  return CYBLE_ERROR_INVALID_PARAMETER.  CyBle_GetState() == CYBLE_STATE_CONNECTED remains true until CYBLE_EVT_GAP_DEVICE_DISCONNECTED event eventually arrives.

david.taylor2_2102186's picture
User
2 posts

Appears the issue may be endemic to BLE. If the connection termination packets are lost, the recovery is by "Connection supervision timeout".

Reduced the magnitude of the problem on the peripheral by reducing the central "Connection supervision timeout".

 

Log in to post new comments.