【发布时间】:2014-05-01 17:14:32
【问题描述】:
当我的代码不起作用时,我从找到here 的项目开始,并在我的 moto-x 上针对我们的自定义蓝牙设备运行它。针对配置文件的一般属性,我从以下代码中获取数据:
public void readCharacteristic(BluetoothGattCharacteristic characteristic) {
if (mBluetoothAdapter == null || mBluetoothGatt == null) {
Log.w(TAG, "BluetoothAdapter not initialized");
return;
}
mBluetoothGatt.readCharacteristic(characteristic);
}
异步返回数据:
public void onCharacteristicRead(BluetoothGatt gatt,
BluetoothGattCharacteristic characteristic,
int status) {
if (status == BluetoothGatt.GATT_SUCCESS) {
broadcastUpdate(ACTION_DATA_AVAILABLE, characteristic);
}
}
如果我在心率监视器上运行此代码,这也有效。
如果我在没有默认配置文件的情况下针对我们的自定义属性之一运行它,则数据永远不会返回。永远。
谷歌搜索包括:Cannot read characteristic. Android BLE,但设置通知并没有解决我的问题。
有什么建议吗?
【问题讨论】:
标签: java android bluetooth-lowenergy android-4.4-kitkat