我正在用BLE开发一个
Android应用程序.该应用的要求是用各种输入更新特定硬件中的电压变化.所以我在这个应用程序中启用了BLE通知API.这将在最近的硬件电压的一段时间内通知应用程序.
履行
mBluetoothGatt.setCharacteristicNotification(characteristic, enabled);
BluetoothGattDescriptor des = characteristic.getDescriptors();
des.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
//Set the value of the descriptor to enable notification
mBluetoothGatt.writeDescriptor(des);
我在Gatt CallBack方法的通知值中收到通知
@Override
public void onCharacteristicChanged(BluetoothGatt Gatt, BluetoothGattCharacteristic characteristic) {
Log.w(TAG, "**ACTION_DATA_AVAILABLE**" + characteristic.getUuid());
//Indication or notification was received
broadcastUpdate(BLEConstants.ACTION_DATA_AVAILABLE, characteristic);
//Go broadcast an intent with the characteristic data
}
但我的问题是,我在相同的Gatt回调方法中也得到了正常的响应.我想在UI中以特定方式更新通知.所以我需要分开正常的响应和通知.有没有办法做同样的事情?或者任何识别特定消息的选项来自通知?