sl4a-r6.1.1-arm-debug.apk,
PythonForAndroid-debug.apk,
python_r26.zip,
python_extras_r26.zip,
python_scripts_r26.zip
运行SL4A以及Py4A的apk安装他们
随后运行Py4A(Python for Android)
可以点击Install自动下载Python运行环境,这一步会需要一定时间,并且需要FQ
也可以点击Local Install安装手动下载的数据文件。
如果选择本地安装需要将手动下载的zip包(python, extras, scripts)放在/内部存储/com.googlecode.pythonforandroid(如果有sd卡则是/sdcard/com.googlecode.pythonforandroid)下
打开SL4A界面,点击菜单选择添加一个Python2.7的脚本
起名为喜欢的名字,如blueserial_monitor.py
向脚本中写入如下内容:
1import android 2import time 3 4 droid = android.Android() 5droid.toggleBluetoothState(True) 6 cnRst = droid.bluetoothConnect( 7'00001101-0000-1000-8000-00805F9B34FB') 8 9print(cnRst)1011if cnRst.result: 12while True:13 message = droid.bluetoothReadLine().result14print(message)1516 droid.exit()
当bluetoothConnect执行完成,cnRst会得到成功的返回值,这时候就可以使用bluetoothReadLine等函数读写该串口了