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

Android: Discover method returning exception. #342

Closed
DaniloCouto opened this issue Sep 5, 2016 · 6 comments
Closed

Android: Discover method returning exception. #342

DaniloCouto opened this issue Sep 5, 2016 · 6 comments
Labels

Comments

@DaniloCouto
Copy link

DaniloCouto commented Sep 5, 2016

After a succeeded connection with an Bluetoothle device, I tried to discover his services and characteristics.
But, sometimes , the method returns an Java Exception :
Attempt to invoke virtual method 'java.lang.String java.lang.Object.toString()' on a null object reference

It seems that the wasNeverConnected Native Java method is returning Null without throwing an callback. and during the discoverAction Method it's impossible to convert a null object to string.

Edit:

I just found this error on android 5.1 and 6.0.
So it seems an general error, i'll look foward to test this error on iOS too.

@DaniloCouto DaniloCouto changed the title Android 5.1: Discover method returning exception. Android: Discover method returning exception. Sep 5, 2016
@randdusing
Copy link
Owner

Do you know what line it's throwing the error?

@DaniloCouto
Copy link
Author

DaniloCouto commented Sep 6, 2016

On 1615 line of BluetoothLePlugin.java
int discoveredState = Integer.valueOf(connection.get(keyDiscoveredState).toString());
I've even put a log to see if the connection.get(keyDiscoveredState) was really null on .toString.
Log.v("MyBlueTest", "connection = " + connection.get(keyDiscoveredState));
And yes, the log returned null.

But this error is odd and happen hardly ever.
And after that error if I try to restart the bluetooth by turning on and off, the bluetooth just... dies, and I need to restart the phone.

@hannibaldinski
Copy link

hannibaldinski commented Sep 8, 2016

Not sure but this might be related.

When I try connecting and it fails. The second time I try to connect and it succeeds, the discover function will return NULL in its error callback. I can fix it by calling close() and then connect() again.

error

Able to reproduce this on Android 4.4.2 and 6

@randdusing
Copy link
Owner

You shouldn't be able to call connect back to back. Are you calling close in between? Or are some of those actually reconnect calls? If that's reconnect, I think I know the issue and will fix it this evening!

@randdusing
Copy link
Owner

Actually just committed the change with master, I'm curious if you can still recreate.

@randdusing randdusing added the bug label Sep 10, 2016
@randdusing
Copy link
Owner

Please re-open if that doesn't fix it

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

No branches or pull requests

3 participants