cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 6 MCU

Contributor II

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
Reply
1 Solution
Contributor II

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
Reply
2 Replies
Employee

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
Reply
Contributor II

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
Reply
Top labels