【发布时间】:2019-12-22 17:24:43
【问题描述】:
我只想读取我的服务特征的值。但我收到了这个错误: [[错误:flutter/lib/ui/ui_dart_state.cc(148)]
未处理的异常:PlatformException(read_characteristic_error, unknown reason, if readCharacteristic is called before last read finished., null)]
我的代码:
discoverServices() async {
List<BluetoothService services = await device.discoverServices();
services.forEach((service) async {
// do something with service
if (service.uuid.toString() == SERVICE_UUID) {
var characteristics = await service.characteristics;
for(BluetoothCharacteristic c in characteristics) {
//if (characteristic.uuid.toString() == CHARACTERISTIC_UUID) {
targetCharacteristic = c;
List<int value = await c.read();
print(value);
//}
};
}
}); }
知道这里发生了什么吗? 谢谢!!
【问题讨论】: