Cy_BLE_GAP_Disconnect() returns CY_BLE_SUCCESS but doesn't do anything

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

cross mob
JeHu_3414236
Level 5
Level 5
10 likes received First like received

I am using the HID keyboard example and calling Cy_BLE_GAP_Disconnect() but it doesn't send a disconnect command.  I can see on the BLE capture that nothing happens.  I am copying the code from bond.c:

        /* User wants the bond to be removed */

        for(i = 0u; i < CY_BLE_CONN_COUNT; i++)

        {

            if(Cy_BLE_GetConnectionState(cy_ble_connHandle) >= CY_BLE_CONN_STATE_CONNECTED)

            {

                /* Disconnect before delete devices from bond list */

                cy_stc_ble_gap_disconnect_info_t param =

                {

                    .bdHandle = cy_ble_connHandle.bdHandle,

                    .reason = CY_BLE_HCI_ERROR_OTHER_END_TERMINATED_USER                         

                };

                Cy_BLE_GAP_Disconnect(&param);

            }

        }

Does anyone know what is the problem?

0 Likes
1 Solution

Thanks.  I added a call to Cy_BLE_Stop() after calling Cy_BLE_GAP_Disconnect() but I wasn't waiting long enough for the disconnect to be processed on both sides.  It works with a longer delay.

View solution in original post

0 Likes
2 Replies
ArvindK_86
Employee
Employee
10 sign-ins 5 sign-ins 10 solutions authored

Hi,

Are you using the HID keyboard example as it is without any other changes? I tried the project with my kit and an Android phone and I'm not seeing the issue; it disconnects fine.

The code that you are showing here is invoked on pressing SW2 for more than 4 seconds, so check if it's indeed getting executed. I guess it does, as you mentioned that the API returns CY_BLE_SUCCESS, so you are executing it, but I wanted to re-confirm as your code snippet doesn't show this.

Also, ensure that the Central device is not trying to reconnect automatically as we restart advertisement on disconnection.

0 Likes

Thanks.  I added a call to Cy_BLE_Stop() after calling Cy_BLE_GAP_Disconnect() but I wasn't waiting long enough for the disconnect to be processed on both sides.  It works with a longer delay.

0 Likes