Open GoogleCodeExporter opened 8 years ago
For source, an example which fails is
https://github.com/cefn/blueshrimp/blob/master/Androino/bluezsensordisplay/bluez
sensordisplay.py
...which relies on metaserial to create a consistent wrapper around Bluetooth,
PySerial or SL4ASerial...
https://github.com/cefn/blueshrimp/tree/master/MetaSerial/metaserial
This code works when launched in SL4A, but I just need to know how to package
pybluez and metaserial and configure the APK so it will play ball with
Bluetooth.
Original comment by c...@cefn.com
on 15 Mar 2013 at 6:37
There is no bluetooth module included in the Python build, so you hit an
ImportError which kills the process.
You would need either to add a bluetooth module in the Python build of this
project, or use PY4A Python build in this project as explained here:
https://code.google.com/p/android-python27/wiki/TutorialHowToChangePythonBuilds
Original comment by anthony....@gmail.com
on 18 Mar 2013 at 6:17
NB: you cannot use PyBluez-0.19-py2.6-linux-armv.egg as it's linked against
libpython2.6.so (and this project uses Python 2.7 by default)
Original comment by anthony....@gmail.com
on 18 Mar 2013 at 6:20
That's incredibly useful to learn.
I hadn't recognised the hard dependency on the python version (or figured the
importance of different version numbers between Py4A and the canonical APK
build). That's probably why it was dying all the time. I tried adding the .egg
contents to a variety of locations within the zips representing the python
build in the APK, but it would never work without the right version.
I'm trying to apply your suggestion right now - rolling back the version of the
python builds to 2.6 and then extracting the .egg contents into
python_extras_r14.zip under the path /python. Does anything else need updating
to notify that pybluez support is there?
If this works and I can indeed carry on using Py4A for prototyping and
deployment, it raises a number of questions if anyone has time to help.
Is there any way I could have seen the ImportError as I couldn't figure out
what the failure condition actually was in the python engine. I must have been
looking in the wrong place but don't know where the relevant logging goes to.
There didn't seem to be any error condition as such in the Logcat, which is
emphasised for bug reporting.
Does the fact Google is migrating away from Bluez (announced at
http://developer.android.com/about/versions/jelly-bean.html) mean that PyBluez
is never going to work beyond JellyBean 4.2 so I should immediately be working
out how to phase it out?
=== Separate Bug/Feature ===
I wouldn't need to use PyBluez at all, if it wasn't that the SL4A
BluetoothFacade triggers bugs (possibly mine) but only when I deploy in an APK.
This could potentially be associated with the version too?
From the bug I experience (connid not ready) it could be that the blocking
behaviour promised by bluetoothConnect in newer versions of the SL4A facades
http://www.mithril.com.au/android/doc/BluetoothFacade.html isn't actually
happening in the APKed version, perhaps because I'm not getting the script.jar
from the correct/latest source somehow. If it doesn't block, then I'm going
straight to accessing an unready connection.
Alternatively it's just failing to connect in the APKed version for some
different reason, even whilst the console-run version works fine. Are there
differences between the deployment environments which could explain the same
SL4A code which works on the console failing on the APK version (originally I
wasn't using PyBluez at all).
In any case, this SL4A Bluetooth Facade issue is probably a completely
different bug/feature. Let me know if I should re-file this issue separately.
Original comment by c...@cefn.com
on 18 Mar 2013 at 8:16
>Is there any way I could have seen the ImportError as I couldn't figure
>out what the failure condition actually was in the python engine. I must
>have been looking in the wrong place but don't know where the relevant
>logging goes to. There didn't seem to be any error condition as such in
>the Logcat, which is emphasised for bug reporting.
You should run the script from the command line. Once the apk is installed you
have all the Python file you need for that, just export the env vars as here:
https://code.google.com/p/android-python27/wiki/TutorialHowToRunPythonfromShell
Original comment by anthony....@gmail.com
on 19 Mar 2013 at 9:18
I find that BluetoothDeviceList activity [in script.jar] can not be started
normally, but do't know the reason.
I try to add another BluetoothDeviceList activity [from SL4A source code] to
the project and start this activity from bluetoothConnect() in
BluetoothFacade.java [also from SL4A, compile new ones to replace the old ones
in script.jar] then Bluetooth can work.
Original comment by chunglon...@gmail.com
on 19 Jul 2013 at 6:23
Original issue reported on code.google.com by
c...@cefn.com
on 15 Mar 2013 at 6:29