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

SerialMessageReceived no longer working after Bean firmware update and 2.1.1 SDK update #31

Open
MMIX2009 opened this issue Sep 3, 2016 · 12 comments

Comments

@MMIX2009
Copy link

MMIX2009 commented Sep 3, 2016

Can you help with the following issue?

I am getting the following errors in the Android Monitor:

Unhandled exception in callback
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.bluetooth.BluetoothGattCallback.onConnectionStateChange(android.bluetooth.BluetoothGatt, int, int)' on a null object reference
at android.bluetooth.BluetoothGatt$1.onClientConnectionState(BluetoothGatt.java:181)
at android.bluetooth.IBluetoothGattCallback$Stub.onTransact(IBluetoothGattCallback.java:70)
at android.os.Binder.execTransact(Binder.java:565)

Profile NOT Discovered: GattSerialXportProfile
Profile NOT Discovered: DeviceProfile
Profile NOT Discovered: BatteryProfile
Profile NOT Discovered: ScratchProfile
Profile NOT Discovered: OADProfile

@swstack
Copy link
Contributor

swstack commented Sep 3, 2016

Is this something that is happening repeatedly or just seen once? Either way, could you please make sure to power cycle the Bean and also restart your phones Bluetooth via the settings? After a Bean goes through a firmware update the GATT table handles may have changed and Android often caches these handles which results in errors.

@MMIX2009
Copy link
Author

MMIX2009 commented Sep 3, 2016

Yes, this is happening repeatedly. My app was working fine before the uodates. Now, even going back to SDK 1.0.3, does not work.

I am pretty sure it is not the device because the Bean Loader virtual serial port sends the incoming data to the Arduino serial Monitor as expected. The issue seems to be in Android.

@swstack
Copy link
Contributor

swstack commented Sep 4, 2016

I'd really like to know the firmware version that the Bean reports. Do you have access to an iPhone so you could use LightBlue Explorer app to read the firmware version? Otherwise you could write a very isolated Android test that just reads the firmware version.

Also, another thing to try is download the latest Bean Loader application from the Android store and attempt connecting/uploading a sketch. The app will force your Bean firmware to the latest available.

@MMIX2009
Copy link
Author

MMIX2009 commented Sep 4, 2016

The firmware is 201606030000 img-B

I am using Bean Loader on a Mac and it appears I have the latest available version.

@MMIX2009
Copy link
Author

MMIX2009 commented Sep 7, 2016

@swstack Was the firmware information helpful?

@swstack
Copy link
Contributor

swstack commented Sep 7, 2016

Yes it's helpful, at least we know that it is running the latest firmware. Could you send me the entire android monitor log (from a fresh run) ... it will give me some intuition as to what your code is doing. Also, if you are comfortable sending me your code, i don't mind taking a look.

@MMIX2009
Copy link
Author

MMIX2009 commented Sep 7, 2016

SerialMessageReceived Android Monitor log.txt

Here is the log. Is there an e-mail where I can send you code snippets? Thanks,

@swstack
Copy link
Contributor

swstack commented Sep 7, 2016

sstack@punchthrough.com

@MMIX2009
Copy link
Author

MMIX2009 commented Sep 7, 2016

Ok. I sent you the main activity file with relevant code snippets. Thanks again.

@MMIX2009
Copy link
Author

MMIX2009 commented Sep 9, 2016

@swstack Was the Android code snippet helpful in getting to root cause?

@swstack
Copy link
Contributor

swstack commented Sep 12, 2016

Hello @MMIX2009 ,

After looking at your logs and code snippets, the issue is not abundantly clear. I copied your code snippet into my local environment and was able to run it and connect to beans of my choosing.

However, one thing that I have noticed is that BeanDiscoveryListener.onBeanDiscovered() will be called many times for the same Bean while scanning is enabled. Do not attempt to connect to the same Bean object more than once! Once you find the Bean you are looking for, call .connect() on it and ignore any further discoveries of that Bean.

Let me know if this makes sense, or helps your issue.

@MMIX2009
Copy link
Author

@swstack Thanks for following up. Connecting to the Bean was not an issue for me either. I will make the code change to ensure the device is connected only once. It still looks like there is another issue because that part of the code was the same and worked before upgrading the Bean firmware.

Could it be some changes in Android related on how permission are required? Does the Bean SDK require setting permissions for location in the manifest?

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

2 participants