Simple bluetooth evaluation app does not what its sposed to.

398 views
Skip to first unread message
Assigned to halab...@google.com by taifu...@gmail.com

cmf...@gmail.com

unread,
Feb 5, 2014, 3:39:04 PM2/5/14
to mitappinv...@googlegroups.com
My simple bluetooth app does not what its supposed to. Different behaviour in the AI2Companion than with the real app. On the LG in the AI2Companion, the app closes when I press the address button. In the real app on the LG I am able to select a bluetooth address but it does not show up on the label. On the zopo and on the Onda it does. In addition the bluetooth connection to the foreign BT device results in a crash of the app. When I remove the list picker from the app and provide constants to the app it works properly, but as soon as I add the correct working list picker snippet, if fails with different behaviour like described. Guess there is an issue with the list picker code. Is this due to the beta state of AI2 or do I something wrong ?

The app code is available here:

http://cmfs.de/BluetoothRemote_functional.aia

What it should do:
pressing "bluetooth device" it should list all known BT Devices
pressing Button "connect" it should connect to the selected device
pressing Button "send String" it should send a single Byte with value 157 to the connected remote BT serial adapter (works without ListPicker)



My configuration:
I use AI2 on a Win XP System.
Firefox 26.0
1st Phone: Zopo300+ With Android 4.1
2nd Phone: LG p895 Android 4.04 Kernel 2.6.39.4
Tablet: Onda V973 with Android 4.2

Taifun

unread,
Feb 5, 2014, 4:38:55 PM2/5/14
to mitappinv...@googlegroups.com
you might want to compare your solution with this example 

A simple Bluetooth Chat with App Inventor 2

probably someone else finds some time to debug your code...
alternatively you might want to provide a screenshot of your relevant blocks...
Taifun

Trying to push the limits of App Inventor! Snippets and Tutorials from Pura Vida Apps by Taifun.         

cmf...@gmail.com

unread,
Feb 6, 2014, 7:10:10 AM2/6/14
to mitappinv...@googlegroups.com
Here the screen shots of all blocks:


Am Mittwoch, 5. Februar 2014 21:39:04 UTC+1 schrieb cmf...@gmail.com:

Taifun

unread,
Feb 6, 2014, 7:38:31 AM2/6/14
to mitappinv...@googlegroups.com
see this bluetooth example 
1. use the listpicker.selection as address, you do not have to use a segment block
2. in Button4.Click use an if statement to connect

if connect...
then <connect was successful, do something>
else <connect was not successful, do something else, e.g. display an error message>

Taifun

cmf...@gmail.com

unread,
Feb 6, 2014, 2:43:59 PM2/6/14
to mitappinv...@googlegroups.com

Many thanks for the recommendations I changed my test app according to your suggestions (see above) and reduced it to a minimum, but unfortunately I found the same behaviour on my LG phone like before. Finally I loaded the chat app you wrote and found again the same behaviour on my LG. Means when I start the app in the AI2Companion and press the connect button I can see the bluetooth address list for a half of a second on the screen and then it crashes and vanishes completely. I guess it has to do with my 4.04 Android ?! Do AppInventor2 apps not run on Android 4 or on LG phones ?
By the way thanks for the hint that its not necessary to cut off the text after the MAC address.

cmfsde

Taifun

unread,
Feb 6, 2014, 3:38:55 PM2/6/14
to mitappinv...@googlegroups.com
make sure to use the newest AI 2 Companion app version, which is Version 2.12ai2zx1
Taifun

Taifun

unread,
Feb 7, 2014, 8:39:27 AM2/7/14
to mitappinv...@googlegroups.com
Finally I loaded the chat app you wrote and found again the same behaviour on my LG. Means when I start the app in the AI2Companion and press the connect button I can see the bluetooth address list for a half of a second on the screen and then it crashes and vanishes completely. 
I just tested my chat example on Android 4.2.2 and it works fine 
this sounds like a device specific problem?

I just checked - thats the version I used already with my first attempts.
cmfsde
you might want to provide the aia file of your  reduced project
Taifun
PS: please keep the discussion in the forum. Thank you.
Message has been deleted

cmf...@gmail.com

unread,
Feb 8, 2014, 1:33:01 PM2/8/14
to mitappinv...@googlegroups.com
Meanwhile I testet the minimal app on my zopo phone and there it seems to work in both ways: using the app and using the AI2Companion. But still on the LG the behaviour is weird. In the AICompanion the BT address shows up just for a half of a second. After that the app crashes. As a .apk I can choose the bt device, but it does not connect the remote BT server. Strange: when I remove the ListPicker from the app and use a constant MAC everything works fine - even on the LG. Now I wonder, if this is a problem in general on LG phones or just on mine. Other apps on my LG have no problem with bluetooth.
Here the aia file for the minimum project: http://cmfs.de/BluetoothRemote_minimum.aia
 


cmfsde



Am Mittwoch, 5. Februar 2014 21:39:04 UTC+1 schrieb cmf...@gmail.com:

Hal Abelson

unread,
Feb 9, 2014, 1:43:24 PM2/9/14
to mitappinv...@googlegroups.com
Filed issue 708

cmfsde:

thank you for reporting this and for taking the trouble to create a minimal example.    I'm pretty sure this is an App Inventor bug.  I suspect it has to do with the switch to and from the List Picker activity messing up the Bluetooth component.   I've filed this as an issue, but we can't give an ETA on when this will be fixed.  So in the meantime, I suggest just trying to code around it by not using the list picker.

One thing that would help:  Could you send a note describing exactly how to use this app for testing -- what to do and what the expected behavior should be .Assume the person dong the testing has never  used Bluetooth with App Inventor.

Thanks

== Hal

cmf...@gmail.com

unread,
Feb 10, 2014, 3:30:26 PM2/10/14
to mitappinv...@googlegroups.com
How to handle the minimal app:

Preconditions:
I use a Bluetooth to Serial module which is intended to connect ta an Arduino evaluation board via a virtual serial interface over bluetooth.
The device has been paired using the phone's connection methods. Authentication to the module has been done in the phone's connection dialog prior to the start of the app.

App usage:
1. When the device is paired, start the minimal app.
2. Press the "Bluetooth Device" button, which runs the list picker and results in a list of known devices.
3. Select the device to connect to.
-> -> On a working phone or tablet, the pick result is replacing the string "BT Connection" in the main screen with the bluetooth address and leads to a connection to the BT device. ON a not working phone or Tablet, nothing changes.
5. Pressing BUtton "send String" sends the number "157" to the BT adapter.
6. Pressing the button "Disconnect Bluetooth" disconnects the BT adapter from the transmission

cmfsde

cmf...@gmail.com

unread,
Feb 22, 2014, 12:07:08 PM2/22/14
to mitappinv...@googlegroups.com
After I got the recommendation from Hal Abelson to work around by not using the ListPicker, I made a project just using buttons. During the development of the app I ran into more or less the same problem when I used serveral screens. I tried to use a second screen to gather the bluetooth address, but when I went back from the 2nd screen, the same thing happened like with the list picker. I guess, that the list picker uses also a inherited second screen and the problem arises from switching back from this screen. Now I have my complete app on one screen and I use disabling and enabling of buttons and other user interface elements instead, without any problem. So for me, it is quite obvious, that on (at least my LG 895 with Android 4.04) the problem is caused by the switching in between screens.


Reply all
Reply to author
Forward
0 new messages