android没有检测到BLE设备

时间:2015-04-14 01:10:36

标签: android bluetooth bluetooth-lowenergy android-bluetooth

我试图编写一个应用程序来连接到我的团队正在研究的BLE设备(使用赛普拉斯PSoC先锋板)。现在,我已经挂断了让应用程序检测任何设备。

我在HTC Desire 510上测试应用程序,而我试图检测的设备是运行赛普拉斯接近传感器示例的PSoC板。

经过多次挫折之后,我尝试在我的设备上运行整个API-21 BluetoothLEGatt样本,它检测到(并且可以连接到)主板没问题。

然后我尝试将整个DeviceScanActivity复制到我的项目中,只做以下修改:

  • 我将toast留言转为logcat条消息
  • 我删除了onListItemClick的内容,因为它引用了我没有的活动
  • 我将几个标签更改为项目中已有的字符串值

我的AndroidManifest同时拥有BLUETOOTHBLUETOOTH_ADMIN,并设置为直接启动活动。

当我在我的项目中运行时,手机没有检测到任何设备,扫描时我得到以下logcat输出:

04-13 17:51:25.350    3892-3892/com.fredwilby.chipper D/BluetoothAdapter﹕ startLeScan(): null
04-13 17:51:25.350    3892-3903/com.fredwilby.chipper D/BluetoothAdapter﹕ onClientRegistered() - status=0 clientIf=5
04-13 17:51:27.350    3892-3892/com.fredwilby.chipper I/Choreographer﹕ Skipped 120 frames!  The application may be doing too much work on its main thread.
04-13 17:51:31.940    3892-3892/com.fredwilby.chipper D/BluetoothAdapter﹕ stopLeScan()

与我从Sample项目中扫描时的输出相比:

04-13 18:05:36.750    6887-6887/com.example.android.bluetoothlegatt D/BluetoothAdapter﹕ startLeScan(): null
04-13 18:05:36.750    6887-6899/com.example.android.bluetoothlegatt D/BluetoothAdapter﹕ onClientRegistered() - status=0 clientIf=5
04-13 18:05:37.120    6887-6898/com.example.android.bluetoothlegatt D/BluetoothAdapter﹕ onScanResult() - Device=00:A0:50:00:00:69 RSSI=-59
04-13 18:05:37.120    6887-6898/com.example.android.bluetoothlegatt D/BluetoothDevice﹕ getService() entry
04-13 18:05:38.080    6887-6887/com.example.android.bluetoothlegatt D/BluetoothAdapter﹕ stopLeScan()

每次我从我的应用程序扫描时,我都没有收到有关跳过帧的消息,但这种情况非常频繁,当我尝试制作我编写的代码时更是如此。

我尝试重新启动设备无济于事,我真的不知道此时我还能尝试什么。有没有人知道如何让它发挥作用?

我很乐意发布任何其他有用的信息。我在这里省略了代码,因为正如我上面提到的,它与样本相同,只是非常轻微的化妆调整(扫描代码附近没有任何内容)。

1 个答案:

答案 0 :(得分:1)

好吧,我设法通过从<uses-sdk android:minSdkVersion="18" android:targetSdkVersion="21" />删除AndroidManifest来解决此问题。当然,这是一种令人愤怒的解决方案,如果有人对此发生的原因有所了解,我会很感激。

相关问题