【发布时间】:2016-09-23 12:58:46
【问题描述】:
我正在开发一个 Android 应用程序,它在 Android 设备和 BLE 外围设备(一个简单的发射器)之间打开一个 BLE 连接。
外围设备被编程为具有我发现的多个阅读特性。 当我尝试启用通知时,问题就出现了。
第一个总是返回true,然后它开始触发我的通知回调,其他的总是返回一个false值。
List<BluetoothGattDescriptor> descrittoriDellaChar = getListaDescrittoriDaCharact(charact);
Boolean status = null;
for (int i = 0; i < descrittoriDellaChar.size(); i++) {
BluetoothGattDescriptor TargetDescriptor = descrittoriDellaChar.get(i);
byte[] valore = TargetDescriptor.getValue();
if (valore != BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE) {
getCharDiLettura().add(charact);
TargetDescriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
//TargetDescriptor.setValue(BluetoothGattDescriptor.ENABLE_INDICATION_VALUE);
boolean success=false;
while(success==false) {
success = gattGlobale.writeDescriptor(TargetDescriptor);
}
status = gattGlobale.setCharacteristicNotification(charact, true);
}
}
boolean prio= gattGlobale.requestConnectionPriority(gattGlobale.CONNECTION_PRIORITY_HIGH);
我使用相同的方法,因为我只有 1 个要读取的特征,现在它不再起作用了。
【问题讨论】:
标签: android bluetooth-lowenergy