Disconnect

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

cross mob
Anonymous
Not applicable

Hello,

   

can me somebody help?

   

I have problem with disconnecting:

   

I call the function: CyBle_GapDisconnect(connHandle_Server01.bdHandle);

   

and then I look at: CyBle_GetState() ,  the device is still CYBLE_STATE_CONNECTED.

   

When I recieve new data,  I want to terminate the connection....but this function doesnt work....

   

 

   

Thak you 

0 Likes
1 Solution
AnjanaM_61
Moderator
Moderator
Moderator
5 comments on KBA First comment on KBA 5 questions asked

Hi,

   

Please use the below code for sending disconnect request:

   

if(CyBle_GetState() == CYBLE_STATE_CONNECTED)
                            {
                            CyBle_GapDisconnect(cyBle_connHandle.bdHandle);
                            }

   

 

   

If you are still the issue is persisting, please share the project.

   

Thanks,
Anjana

View solution in original post

0 Likes
4 Replies
Anonymous
Not applicable

From BLE4.2 component datasheet this is what I get:

   
    

CYBLE_API_RESULT_TCyBle_GapDisconnect (uint8 bdHandle)
This function disconnects the peer device. It is to be used by the device in GAP Central mode and may be used
by a GAP Peripheral device to send a disconnect request. This is a non-blocking function. On disconnection, the
following events are generated, in order.
- CYBLE_EVT_GATT_DISCONNECT_IND
- CYBLE_EVT_GAP_DEVICE_DISCONNECTED

   
   

 

   

if your device is the peripheral, then maybe the problem could be the central which do not process the disconnect request sent from your device(the peripheral)?

   

If so, some suggestion would be to change the central device which you are testing with. For example, in my case I usually download the cysmart app in my android phone to act as the central. I think these apps would properly process any disconnect request.

   

 

   

 

   

Just guessing here.

0 Likes
Anonymous
Not applicable

I try catch these events and these events arent start. I read the return value of  CyBle_GapDisconnect() and it is  CYBLE_ERROR_INVALID_PARAMETER....

0 Likes
Anonymous
Not applicable

again, the BLE component datasheet says that return value means

   
    

No device to be disconnected. The specified
device handle does not map to any device
entry in the BLE Stack.

   
   

I guess your input(peer device handle) is somehow corrupt or wrong. You'll have to dig in deeper..

0 Likes
AnjanaM_61
Moderator
Moderator
Moderator
5 comments on KBA First comment on KBA 5 questions asked

Hi,

   

Please use the below code for sending disconnect request:

   

if(CyBle_GetState() == CYBLE_STATE_CONNECTED)
                            {
                            CyBle_GapDisconnect(cyBle_connHandle.bdHandle);
                            }

   

 

   

If you are still the issue is persisting, please share the project.

   

Thanks,
Anjana

0 Likes