【发布时间】:2015-07-28 12:43:06
【问题描述】:
我有一项服务可以通过 mac 地址直接连接到蓝牙葡萄糖设备。
if (mBluetoothGatt != null) {
if (mBluetoothGatt.connect()) {
return true;
}
else {
return false;
}
}
mBluetoothGatt = device.connectGatt(this, false, mGattCallback);
配对例程和从设备下载数据在配对后第一次运行完美,但如果我尝试重新连接到设备并注册通知,我会在我的 BluetoothGatt.onDescriptorWrite 方法中收到 GATT_INSUFFICIENT_AUTHENTICATION 错误。
@Override
public void onDescriptorWrite (BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) {
...
if (status == BluetoothGatt.GATT_INSUFFICIENT_AUTHENTICATION) {
...
然后系统会提示用户输入 PIN 码并要求他们重新使用设备进行身份验证,即使 BONDING STATE 显示为 BONDED。
我已经阅读了很多关于 BLE 的 StackOverflow 帖子,其中一些是相互冲突的,或者没有直接解决连接处理的问题。
- 如果我们尝试连接到以前配对的设备,我们是否使用 自动连接与否?
- 我们是否需要重新启用通知 每次我们连接到它的设备?或者只是我们第一次 连接?
我使用的设备是装有 KitKat 4.4 的 Moto G。
【问题讨论】: