修复读取 CCCD 报错的问题,写入时更新特征值 (#50)

* 修复 CCCD 无法读取的问题

* 优化代码

* 调整部分必需参数为可空参数

* 调整接口

* 写入时更新特征值

* 调整接口

* 适配新接口

* 调整依赖项
This commit is contained in:
iAMD
2024-02-01 19:16:42 +08:00
committed by GitHub
parent 63bbc1a732
commit 44efce78df
32 changed files with 521 additions and 231 deletions

View File

@ -1,3 +1,12 @@
## 5.0.2
* Revert GATT characteristic's `descriptors` arguments to required.
## 5.0.1
* Change GATT characteristic and descriptor's `value` arguments to optional.
* Change GATT characteristic's `descriptors` arguments to optional.
## 5.0.0
* Now `CentralManager#writeCharacteristic` and `PeripheralManager#writeCharacteristic` will fragment the value automatically, the maximum write length is 512 bytes.

View File

@ -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(

View File

@ -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,

View File

@ -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();
}

View File

@ -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();
}

View File

@ -1,11 +1,11 @@
name: bluetooth_low_energy_platform_interface
description: A common platform interface for the bluetooth_low_energy plugin.
version: 5.0.0
version: 5.0.2
homepage: https://github.com/yanshouwang/bluetooth_low_energy
environment:
sdk: '>=3.0.0 <4.0.0'
flutter: ">=3.3.0"
flutter: ">=3.0.0"
dependencies:
flutter: