Disconnecting from ble peripheral with more power, or resetting all Bluetooth connections?

Hi,

I use nRF5340 with SDK 2.2.0. as Central and multiple phones as Peripheral.

I have a question about disconnecting from the device.

If ATT timeout is happening I can't disconnect from peripheral immediately. It seems like that disconnect canot be made untill ATT timeout hapen. 

For disconnecting i am using  

"

int err_disc = bt_conn_disconnect(default_conn, BT_HCI_ERR_REMOTE_USER_TERM_CONN);

"

1. is there some other "stronger" way to force disconnect from device?

2. Or some way to reset everything related to Bluetooth communication, some "hard reset" of everything, or similar?

Thanks in advance.

Br,

Stjepan.

Parents
  • Hi Stjepan, 

    Please correct if I'm wrong, what you want to achieve is that when you are involving in a ATT timeout, you don't want to wait all the way until the timeout expired (30seconds) but you want to disconnect right away ? 
    I was not aware that the connection termination has to wait for the ATT timeout before it can send the connection termination. They are on different layer ATT vs Link layer so it's strange that disconnect has to wait, but maybe I'm wrong. 

    I'm not aware of any more "powerful" disconnect way other than calling bt_conn_disconnect(). 


    But you can try bt_disable() and then bt_enable(). I'm not 100% sure it will disconnect right away. And also it's a newly support feature, you may want to update to the latest SDK to be able to use it. 

  • Hi,


    Please correct if I'm wrong, what you want to achieve is that when you are involving in a ATT timeout, you don't want to wait all the way until the timeout expired (30seconds) but you want to disconnect right away ?

            --> Yes, this is correct, for some reasons sometimes I wait too long for the response from the peripheral, so I would like         to disconnect and start scanning for other peripherals, but this doesn't work because disconnection never happens, or         it  takes to long.


    I'm not aware of anymore "powerful" disconnect way other than calling bt_conn_disconnect().
            --> Sometimes when using bt_conn_disconnect() disconnection never happens, maybe at that moment peripheral is                  no longer close enough, but never mind that I wont to start scanning for other nearby peripherals and I can't do that.


    But you can try bt_disable() and then bt_enable(). I'm not 100% sure it will disconnect right away. And also it's a newly support feature, you may want to update to the latest SDK to be able to use it.
            --> I'm using SDK 2.2. and there is bt_disable & bt_enable function but after bt_disable i put sleep 2 second and calling         bt_enable and i get error -120 --> EALREADY (Operation already in progress)
            Upgrade to the newer SDK is not an option for us at this moment.


    For now, I have a workaround, I restart the nRF when I see that disconnection takes too long but this is a dirty solution so is there some better way?

    Br,

    Stjepan Brlečić

Reply
  • Hi,


    Please correct if I'm wrong, what you want to achieve is that when you are involving in a ATT timeout, you don't want to wait all the way until the timeout expired (30seconds) but you want to disconnect right away ?

            --> Yes, this is correct, for some reasons sometimes I wait too long for the response from the peripheral, so I would like         to disconnect and start scanning for other peripherals, but this doesn't work because disconnection never happens, or         it  takes to long.


    I'm not aware of anymore "powerful" disconnect way other than calling bt_conn_disconnect().
            --> Sometimes when using bt_conn_disconnect() disconnection never happens, maybe at that moment peripheral is                  no longer close enough, but never mind that I wont to start scanning for other nearby peripherals and I can't do that.


    But you can try bt_disable() and then bt_enable(). I'm not 100% sure it will disconnect right away. And also it's a newly support feature, you may want to update to the latest SDK to be able to use it.
            --> I'm using SDK 2.2. and there is bt_disable & bt_enable function but after bt_disable i put sleep 2 second and calling         bt_enable and i get error -120 --> EALREADY (Operation already in progress)
            Upgrade to the newer SDK is not an option for us at this moment.


    For now, I have a workaround, I restart the nRF when I see that disconnection takes too long but this is a dirty solution so is there some better way?

    Br,

    Stjepan Brlečić

Children
  • Hi Stjepan, 

    I don't think bt_disable works properly in SDK v2.2.0. You would need to move to at least v2.4.0 to have it works on nRF52 and v2.5.0 for nRF53. 

    Doing a reset when you want to drop the connection and start a new one is not a terrible solution, in my opinion, especially at SDK v2.2 when the disable and enable the stack is not fully supported. I assume you have your data stored and don't have an issue when restarting?

Related