Bluetooth Problem with MIT App Inventor 2 on Android Version 5.0.2

1,824 views
Skip to first unread message
Assigned to andrew.f...@gmail.com by halatmi...@gmail.com

Giner Jean-Marc

unread,
Jul 7, 2016, 3:35:10 AM7/7/16
to MIT App Inventor Forum
Hi,
I have developed several android applications with MIT App Inventor 2 (up to version nb149). All these app are working very well on Android Version 4.2.2 (Archos 101 Xenon tablet).

The connect method used is :


The same app binaries don't work on Android Version 5.0.2 (Samsung SM-T555 tablet). All these app have the same problem. The client is already paired before to start the app. The connection to Bluetooth slave devices using the Serial Port Profile (SPP) fail without error on the screen.
The problem is the same with two SPP slave devices: the HC-05 module and GenBlue 19e DCE.

All is fine on Samsung/Android Version 5.0.2, if I modify the connect method like this :


If the app developed with Inventor is replaced by the Bluetooth Terminal app (available on App Store) everything is working fine on Android Version 5.0.2.  So MIT App Inventor 2 seem to work not correctly on Android Version 5.0.2 !

The .aia project using the first method is attached to this message.

Why the first method doesn't work ? The second method isn't a good solution since it need to know the device address (NAP, UAP, LAP) and only one device can be used.

Thanks to help me.
BTS_PIC_01B.aia
Auto Generated Inline Image 1
Auto Generated Inline Image 2

Abraham Getzler

unread,
Jul 7, 2016, 12:23:50 PM7/7/16
to MIT App Inventor Forum
I don't have a BlueTooth test setup, so I can only speculate.

I notice the List Picker is populated from a block named AddressesAndNames.
I have seen in a recent (a day) other post sample output consisting of a MAX ID followed by a space and a name.

The List Picker Selection is fed directly into the connection request block(s), which I presume only need the MAC ID.

Could it be possible that the Android 4 BT software was more forgiving than the Android 5 software, ignoring the trailing blank and name?

If so, a possible workaround would be to take segment(AddressAndName, 1, 18) and use that to connect.

ABG

Giner Jean-Marc

unread,
Jul 8, 2016, 4:00:47 AM7/8/16
to MIT App Inventor Forum
Hi Abraham,

Thanks for your reply and your help.
Can I implement the workaround with App Inventor 2 ?
If yes, how to connect with segment(AddressAndName, 1, 18) ?
Sincerly,

Jean-Marc Giner

Ghica

unread,
Jul 8, 2016, 4:50:02 AM7/8/16
to MIT App Inventor Forum
Hi,
I do have a BT setup (Arduino Leonardo board, JY-MCU BT module). I tried you .aia, but my Android versions available are 5.1.1 and 6.0.1.
Everything works perfectly, I even tried to use AI in French. I remember that there were problems with Android 5.0.2 and there have been problems with French and AI so somewhere there could be a glitch.
However, I have an easy workaround for you, that works in all Android versions. See  below. The trick is to split the address part from a name part, and use only the address part while connecting.
The advantage to keep the address in a global variable is also, that you do not have to close the app to disconnect.
Cheers, Ghica.

Giner Jean-Marc

unread,
Jul 8, 2016, 5:45:13 AM7/8/16
to MIT App Inventor Forum
Hi,
Thanks for your help Ghica.
I try your workaround. It works perfectly on 4.2.2, but it doesn't work on 5.0.2 (in English or in French).

Sincerly,

Jean-Marc Giner
Auto Generated Inline Image 1

Ghica

unread,
Jul 8, 2016, 5:57:24 AM7/8/16
to MIT App Inventor Forum
Are you saying that you can only connect to a BT device during Screen1.Initialize of your app in 5.0.2?
I was assuming that having the names with the address was the problem and my trick would split these up.
Could you try to connect with a fixed address AFTER screen initialize, using a button?
Cheers, Ghica.

Giner Jean-Marc

unread,
Jul 8, 2016, 6:48:54 AM7/8/16
to MIT App Inventor Forum
Hi,
Thanks for your help Ghica.
Yes the problem appears on Android 5.0.2. The same code works perfectly on Android 4.2.2.
Yes, when i try to connect with a fixed address on 5.0.2 (see my first post to see details) it also works fine.  So, it seems the bug is on App Inventor 2.
Sincerly,

Jean-Marc Giner

Ghica

unread,
Jul 8, 2016, 8:12:13 AM7/8/16
to MIT App Inventor Forum
I think you misunderstood my question.
All on Android 5.0.2:
If you connect with a fixed address **during screen1.initialize** then it works.
My question was: if you connect later, after initialize, with a fixed address, for example using a button.click event, does it work then?

Actually, I have a second question for you: what are the symptoms exactly? Do you see the list of devices to choose from if you click the ListPicker, or, is it, that after you choose a device, it does not connect??

A bug in AI for one version of Android only does not seem very likely to me, but of course anything is possible. I have been doing BT for a while now, using AI (and I believe also Android 5.0.2) without problems.
This brings me to a third question: did you try to shut off the problem phone completely and restart it? This helps sometimes.

Anyway, I cannot solve bugs for you, I am just trying to figure out if a workaround is possible.
Cheers, Ghica.
Reply all
Reply to author
Forward
0 new messages