blessed-android-coroutines icon indicating copy to clipboard operation
blessed-android-coroutines copied to clipboard

fix: Fixed bluetooth manual disconnection when bluetooth is back in the second

Open kwiky opened this issue 2 years ago • 3 comments

Fix this :

05-25 18:28:58:019 D/BluetoothCentralManager(2) : bluetooth turning off
05-25 18:28:58:029 W/BluetoothPeripheral(1533) : cannot cancel connection because no connection attempt is made yet
05-25 18:28:58:389 D/BluetoothCentralManager(2) : bluetooth turned off
05-25 18:28:58:823 D/BluetoothCentralManager(2) : bluetooth turning on
05-25 18:28:59:121 D/BluetoothCentralManager(2) : bluetooth turned on
05-25 18:28:59:390 E/BluetoothCentralManager(2) : bluetooth turned off but no automatic disconnects happening, so doing it ourselves
05-25 18:28:59:391 D/BluetoothCentralManager(2) : disconnect all peripherals because bluetooth is off

kwiky avatar May 31 '22 08:05 kwiky

Hi, so the issue is that because I use the timer, there is a 1 second window for things to go wrong. However, with your fix, the peripheral might still not be disconnected. I think we should make sure that peripherals always get disconnected when switching off bluetooth.

Doing so experimentation and now I am considering removing the timer completely and simply call cancelAllConnectionsWhenBluetoothOff() when bluetooth is turning off. What do you think?

weliem avatar Jun 01 '22 09:06 weliem

Hi @weliem

If you think that removing the timer will not cause regressions, i vote for it. 👍

kwiky avatar Jun 10 '22 12:06 kwiky

I have removed the timer and made a new release (0.3.1). Please have a look if that causes any regressions. I did some testing on several phones that I have and it seems to work fine.

weliem avatar Jun 28 '22 08:06 weliem