【发布时间】:2017-06-06 06:40:21
【问题描述】:
我需要在 BLE setValue() 中发送 0x0001、0x0002 之类的值,
有人知道怎么传吗?
例如:
private void command () {
ongoing.setValue(0x0001); //error
mBluetoothLeService.writeCharacteristic(ongoing);
BluetoothLeService.setCharacteristicNotification(ongoing, true);
...
...
...
mBluetoothLeService.readCharacteristic(ongoing);
}
Thanks.
在 DeviceControlActivity.java 中:
private void displayGattServices(List<BluetoothGattService> gattServices){
UUID UBI_COMMAND = UUID.fromString(SampleGattAttributes.UBI_ONGOING_INFO_SERVICE_UUID);
...
...
if (uuid.equals(SampleGattAttributes.UBI_ONGOING_INFO_SERVICE_UUID)){
ongoing = gattService.getCharacteristic(UBI_ONGOING);
}
}
【问题讨论】:
-
ongoing的类型是什么? -
它应该是 BluetoothGattCharacteristic,因为它被传递给需要它的方法?
-
我只读过,但看到这里写作:stackoverflow.com/questions/36163998/… ...值得注意的是,你可以使用像@Override public void onCharacteristicWrite(BluetoothGatt gatt, ....写入数据。但您可能没有按照链接正确写入。
标签: android bluetooth-lowenergy setvalue