4 Replies Latest reply on Sep 7, 2016 12:04 AM by anpm

    Disconnect

    phateee_1677816

      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 

        • 1. Re: Disconnect
          kwagjj_1632506

          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.

          • 2. Re: Disconnect
            phateee_1677816

            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....

            • 3. Re: Disconnect
              kwagjj_1632506

              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..

              • 4. Re: Disconnect
                anpm

                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