Reedyuk / blue-falcon

A Bluetooth kotlin multiplatform "Cross-Platform" library for iOS and Android
https://bluefalcon.dev
Apache License 2.0
340 stars 45 forks source link

[Android] Exposing autoConnect flag #38

Closed PeterKucera closed 4 years ago

PeterKucera commented 4 years ago

Hi all,

In BlueFalcon Android actual class , method connectGatt is called with flag autoconnect set to false by default.

I understand this is for a reason - in iOS there's no such thing as autoConnect flag (autoConnect on iOS is implicit - correct me if I'm wrong).

But IMO there is still need to expose this autoConnect flag to the developer, so connection initiated by Android stack will be possible, when device comes into range.

So my sugestion would be - add optional parameter to connect method, e.g.

connect(bluetoothPeripheral: BluetoothPeripheral, autoConnect:Boolean = false).

On platforms that do not offer setting explicit autoConnect flag(such as iOS, MacOS), this argument would be ignored.

Any comments / different ideas how to approach this ?

Thanks

Reedyuk commented 4 years ago

Yes sounds like a logical approach. Do you want to put a PR in for it.

felislynx-silae commented 4 years ago

Good point. Worth to remember that there was a bug in autoconnect feature (2-3 years ago). Google is not well known with bugfixing in some Android internals ;). Is it working correctly now?

Reedyuk commented 4 years ago

https://github.com/Reedyuk/blue-falcon/pull/42