Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connecting taking long time... #228

Open
nsnnsn opened this issue Aug 29, 2021 · 2 comments
Open

Connecting taking long time... #228

nsnnsn opened this issue Aug 29, 2021 · 2 comments

Comments

@nsnnsn
Copy link

nsnnsn commented Aug 29, 2021

When i use connection = gattlib_connect(NULL, address, GATTLIB_CONNECTION_OPTIONS_LEGACY_DEFAULT); it takes about 4 seconds to connect. When i use the bluetoothctl utility it takes less than 2 seconds.

time bluetoothctl connect XX:XX:XX:XX:XX:XX
Attempting to connect to XX:XX:XX:XX:XX:XX
[CHG] Device DA:DC:22:B3:94:93 Connected: yes
Connection successful
real 0m 1.56s
user 0m 0.07s
sys 0m 0.02s

How can i speed it up ?
Rest is working ok...

@felwiz
Copy link

felwiz commented Nov 5, 2021

I also am having this problem. Have you found a solution?

@SunilKS-nd
Copy link

Try changing the gattlib_connect options.

i.e. GATTLIB_CONNECTION_OPTIONS_LEGACY_DEFAULT expands to

#define GATTLIB_CONNECTION_OPTIONS_LEGACY_DEFAULT \
		GATTLIB_CONNECTION_OPTIONS_LEGACY_BDADDR_LE_PUBLIC | \
		GATTLIB_CONNECTION_OPTIONS_LEGACY_BDADDR_LE_RANDOM | \
		GATTLIB_CONNECTION_OPTIONS_LEGACY_BT_SEC_LOW

Try combinations like :

gattlib_connect(NULL, address,
				GATTLIB_CONNECTION_OPTIONS_LEGACY_BDADDR_LE_RANDOM |
				GATTLIB_CONNECTION_OPTIONS_LEGACY_BT_SEC_LOW);

Let me know if it has improved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants