修复读取 CCCD 报错的问题,写入时更新特征值 (#50)
* 修复 CCCD 无法读取的问题 * 优化代码 * 调整部分必需参数为可空参数 * 调整接口 * 写入时更新特征值 * 调整接口 * 适配新接口 * 调整依赖项
This commit is contained in:
@ -19,7 +19,7 @@ abstract class GattCharacteristic extends GattAttribute {
|
||||
factory GattCharacteristic({
|
||||
required UUID uuid,
|
||||
required List<GattCharacteristicProperty> properties,
|
||||
required Uint8List value,
|
||||
Uint8List? value,
|
||||
required List<GattDescriptor> descriptors,
|
||||
}) =>
|
||||
MyGattCharacteristic(
|
||||
|
@ -9,7 +9,7 @@ abstract class GattDescriptor extends GattAttribute {
|
||||
/// Constructs a [GattDescriptor].
|
||||
factory GattDescriptor({
|
||||
required UUID uuid,
|
||||
required Uint8List value,
|
||||
Uint8List? value,
|
||||
}) =>
|
||||
MyGattDescriptor(
|
||||
uuid: uuid,
|
||||
|
@ -7,9 +7,9 @@ import 'my_gatt_descriptor.dart';
|
||||
|
||||
class MyGattCharacteristic extends MyGattAttribute
|
||||
implements GattCharacteristic {
|
||||
Uint8List _value;
|
||||
@override
|
||||
final List<GattCharacteristicProperty> properties;
|
||||
Uint8List? _value;
|
||||
@override
|
||||
final List<MyGattDescriptor> descriptors;
|
||||
|
||||
@ -18,9 +18,9 @@ class MyGattCharacteristic extends MyGattAttribute
|
||||
required this.properties,
|
||||
Uint8List? value,
|
||||
required this.descriptors,
|
||||
}) : _value = value?.trimGATT();
|
||||
}) : _value = value?.trimGATT() ?? Uint8List(0);
|
||||
|
||||
Uint8List get value => _value ?? Uint8List.fromList([]);
|
||||
Uint8List get value => _value;
|
||||
set value(Uint8List value) {
|
||||
_value = value.trimGATT();
|
||||
}
|
||||
|
@ -4,14 +4,14 @@ import 'gatt_descriptor.dart';
|
||||
import 'my_gatt_attribute.dart';
|
||||
|
||||
class MyGattDescriptor extends MyGattAttribute implements GattDescriptor {
|
||||
Uint8List? _value;
|
||||
Uint8List _value;
|
||||
|
||||
MyGattDescriptor({
|
||||
required super.uuid,
|
||||
Uint8List? value,
|
||||
}) : _value = value?.trimGATT();
|
||||
}) : _value = value?.trimGATT() ?? Uint8List(0);
|
||||
|
||||
Uint8List get value => _value ?? Uint8List.fromList([]);
|
||||
Uint8List get value => _value;
|
||||
set value(Uint8List value) {
|
||||
_value = value.trimGATT();
|
||||
}
|
||||
|
Reference in New Issue
Block a user