我必须使用android studio sdk版本3.1.4设计一个android应用程序,并在API 15上开发:android 4.0.3(IceCreamSandwich)能够使用类似于BLE终端应用程序的HM 10 BLE模块从arduino接收CSV数据在Playstore上。 BLE终端应用程序用于扫描附近的BLE设备,也用于串行通信。通过智能手机控制使用任何BLE模块(基于Texas Instruments CC254x)的任何微控制器。该应用程序可以通过BLE发送和接收命令,因此您可以轻松调试硬件问题。监视接收数据为ASCII或HEX。以ASCII或HEX格式发送数据。 目前,我已在Android Studio上导入了BluetoothLEGATT示例代码,并安装了该应用程序,在该应用程序中我正在获取数据,但数据不在流中,因此我希望将其显示在流中。我想以csv格式接收它。数据应采用流格式。在arduino端,我以csv格式发送邮件。
<?xml version="1.0" encoding="UTF-8"?>
<!--Copyright 2013 The Android Open Source ProjectLicensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License. -->
-<manifest android:versionName="1.0" android:versionCode="1" package="com.example.android.bluetoothlegatt" xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Min/target SDK versions (<uses-sdk>) managed by build.gradle -->
<!-- Declare this required feature if you want to make the app available to BLE-capabledevices only. If you want to make your app available to devices that don't support BLE,you should omit this in the manifest. Instead, determine BLE capability by usingPackageManager.hasSystemFeature(FEATURE_BLUETOOTH_LE) -->
<uses-feature android:required="true" android:name="android.hardware.bluetooth_le"/>
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
-<application android:theme="@android:style/Theme.Holo.Light" android:icon="@drawable/ic_launcher" android:label="@string/app_name">
-<activity android:name=".DeviceScanActivity" android:label="@string/app_name">
-<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".DeviceControlActivity"/>
<service android:name=".BluetoothLeService" android:enabled="true"/>
</application>
</manifest>
答案 0 :(得分:0)
蓝牙低功耗(BLE)在4.3版本中引入了Android。因此,您的问题之一可能是API 15:Android 4.0.3(IceCreamSandwich)。尝试将最小API更改为18。直到API级别21,Lollipop android才使用BlueZ软件堆栈。尽管BlueZ可以工作,但Android 4.3上的BLE仍存在一些稳定性问题,特别是在维护连接性方面进行扫描。在Android API 21版本中,使用了Bluedroid软件堆栈,该堆栈更稳定并改进了BLE的API。