【发布时间】:2014-03-17 15:13:42
【问题描述】:
我正在使用来自官方 android 开发者网站的代码,发现阅读特性有困难
当迭代所有 uuid 时,我使用此代码在 DisplayGattServices 函数的 DeviceControlActivity 类中创建 gatt 特征读取调用:
mBluetoothLeService.readCharacteristic(new BluetoothGattCharacteristic(
UUID.fromString(uuid),
BluetoothGattCharacteristic.PERMISSION_READ,
BluetoothGattCharacteristic.PROPERTY_READ));
readCharacteristic 函数 int BluetoothLeService calss 是:
public void readCharacteristic(BluetoothGattCharacteristic characteristic) {
if (mBluetoothAdapter == null || mBluetoothGatt == null) {
Log.w(TAG, "BluetoothAdapter not initialized");
return;
}
mBluetoothGatt.readCharacteristic(characteristic);
}
BluetoothLeService 类中的回调也是:
@Override
public void onCharacteristicRead(BluetoothGatt gatt,
BluetoothGattCharacteristic characteristic,
int status) {
if (status == BluetoothGatt.GATT_SUCCESS) {
broadcastUpdate(ACTION_DATA_AVAILABLE, characteristic);
}
我在回调处设置了一个断点,但我永远不会停在那里... 可能是许可还是财产?还有什么?... 有人有一个可行的例子吗?
【问题讨论】:
标签: android bluetooth-lowenergy gatt characteristics