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

Changing Connection Priority on Android #134

Closed
kgillespieatmosphere opened this issue Feb 6, 2015 · 13 comments
Closed

Changing Connection Priority on Android #134

kgillespieatmosphere opened this issue Feb 6, 2015 · 13 comments

Comments

@kgillespieatmosphere
Copy link
Contributor

Working on a patch to allow the BluetoothLE plugin to change the Connection Request priority. Apparently you can improve the throughput by request a high priority.

I have created a patch file for the master branch.

http://pastebin.com/mcXbaqpH

Haven't tested this but it's based on some code I was doing for a native android app. This wouldn't be applicable to iOS but it could be useful for Android.

@kgillespieatmosphere
Copy link
Contributor Author

Should not be optInteger not optString

@randdusing
Copy link
Owner

I'm not too familiar with patch files. Can it be turned into a pull request?

@kgillespieatmosphere
Copy link
Contributor Author

I'll let you know when my fork is tested and I can confirm that this patch works.

@randdusing
Copy link
Owner

Thanks, it seems low risk for existing users, so it should be good after your testing.

@kgillespieatmosphere
Copy link
Contributor Author

It will require that users increase their android-minSdkVersion to at least 21.

@kgillespieatmosphere
Copy link
Contributor Author

I was wondering if it would make sense to break out the functions that are specific to each platform into their own javascript object, and then write wrapper handlers that try and make the best decision based on the platform.

So you would have bluetoothle.android.requestConnectionPriority(...)

@kgillespieatmosphere
Copy link
Contributor Author

I added a check so that if the user is not using API 21 or greater the code simply returns. Although now I have a problem with API 21 where I cannot write to characteristics... Oh boy.

@kgillespieatmosphere
Copy link
Contributor Author

Looks like API 21 on Android is causing a lot of regressions in the plugin, also Phonegap doesn't officially support it

Wondering if the new Bluetooth LE stuff has something to do with it,
https://developer.android.com/reference/android/bluetooth/le/package-summary.html

@randdusing
Copy link
Owner

Oh, I wasn't aware of all the new Bluetooth functionality. My app seems to work fine on API 21, but I'm not writing any characteristics. Eventually I'll probably need to completely rewrite it for API 21 and then allow the user to decide which "code path" to use. But I'm not sure if that's easily possible with the cordova plugin system...

I'm not sure if I see the value in making separate handlers for each platform... If the function doesn't apply, it can be ignored or send a method not supported error back.

@kgillespieatmosphere
Copy link
Contributor Author

I figured out the problem, it was my end and Android not handling a message queue well. My own messaging queue tried to double up a message. My code seems to work, though I am not able to claim any changes to performance yet.

@randdusing
Copy link
Owner

Even on API 21, you mean?

@kgillespieatmosphere
Copy link
Contributor Author

Yes on API 21, I need to run my benchmarking on it and haven't had time today. I'll hopefully get an idea soon. I am right now debugging some unrelated bugs that have occured do to the switch to API 21, apparently the Webkit stuff handles cookies and authentication a little differently and this is a bigger issue for me.

@randdusing
Copy link
Owner

This has been added to the master branch. I made a few changes with error handling.

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

No branches or pull requests

2 participants