-1

我正在尝试对 android 应用程序上的微处理器执行 ble 写入,但发生了一些奇怪的事情。

首先,错误日志如下:

Unhandled exception in callback
                                                                                   java.lang.NullPointerException
                                                                                       at android.bluetooth.BluetoothGatt.writeCharacteristic(BluetoothGatt.java:874)
                                                                                       at com.example.tannerhenry.standalone.ConfigurationActivity.setWriteSensor(ConfigurationActivity.java:248)
                                                                                       at com.example.tannerhenry.standalone.ConfigurationActivity.access$100(ConfigurationActivity.java:31)
                                                                                       at com.example.tannerhenry.standalone.ConfigurationActivity$4.onServicesDiscovered(ConfigurationActivity.java:289)
                                                                                       at android.bluetooth.BluetoothGatt$1.onSearchComplete(BluetoothGatt.java:295)
                                                                                       at android.bluetooth.IBluetoothGattCallback$Stub.onTransact(IBluetoothGattCallback.java:215)
                                                                                       at android.os.Binder.execTransact(Binder.java:404)
                                                                                       at dalvik.system.NativeStart.run(Native Method)

经过一段时间的调试后,我注意到我试图写入的特征没有被发现,因此解释了为什么会发生空指针异常。

问题是这个特性肯定是在做广告,因为我在我的 iPhone 上下载了 LightBlue 并且出现了这个特性。这让我相信我在初始化特性时犯了一个错误,但我从应用商店下载了蓝牙 LE 扫描仪后,它的行为仍然与我的应用程序相同。

iOS和android getCharacteristics的方式有区别吗?

注意: 我之前遇到过这个问题,解决方案是重新下载应用程序几次,最终读取了特征。但是我在我的平板电脑上清除了数据,现在它正在做和以前一样的事情,这次重新下载并没有修复它。

任何帮助将不胜感激,如有必要,我可以提供更多代码。

4

1 回答 1

0

通过手动忘记先前配对的设备并进行修复,该问题已得到解决。

于 2017-04-04T22:58:15.107 回答