【发布时间】:2021-01-29 11:43:22
【问题描述】:
使用蓝牙 SIG 应用加速器代码,它很好地展示了蓝牙低功耗的不同概念。但是,它没有提到与通知相反的指示。我知道与通知不同,需要确认指示,并且在代码中我会使用byte[] val = enabled ? BluetoothGattDescriptor.ENABLE_INDICATION_VALUE : BluetoothGattDescriptor.DISABLE_INDICATION_VALUE; 而不是byte[] val = enabled ? BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE : BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE;。还有什么我需要做的吗?我究竟如何让服务器知道我收到了所需的指示?有什么需要补充的吗?
@Override
public void onCharacteristicChanged(BluetoothGatt gatt,
BluetoothGattCharacteristic characteristic)
{
notification_id++;
Log.d("BleWrapper","notification count = " + notification_id);
// characteristic's value was updated due to enabled notification, lets get this value
// the value itself will be reported to the UI inside getCharacteristicValue
getCharacteristicValue(characteristic);
// also, notify UI that notification are enabled for particular characteristic
mUiCallback.uiGotNotification(mBluetoothGatt, mBluetoothDevice, mBluetoothSelectedService, characteristic);
}
【问题讨论】:
标签: android bluetooth-lowenergy