修复 CoW 导致 discoverGATT 失败的问题 (#38)
* 修复 CoW 导致 discoverGATT 失败的问题 * 修复 CoW 导致 discoverGATT 失败的问题
This commit is contained in:
@ -1,3 +1,7 @@
|
||||
## 5.0.2
|
||||
|
||||
* Fix the issue that [discoverGATT failed caused by CoW](https://github.com/yanshouwang/bluetooth_low_energy/issues/36).
|
||||
|
||||
## 5.0.1
|
||||
|
||||
* Fix the issue that [completion was called duplicately caused by CoW](https://github.com/yanshouwang/bluetooth_low_energy/issues/36).
|
||||
|
@ -1029,6 +1029,18 @@ class _AdvertiserViewState extends State<AdvertiserView>
|
||||
],
|
||||
);
|
||||
await PeripheralManager.instance.addService(service);
|
||||
final batteryService = GattService(
|
||||
uuid: UUID.short(0x180f),
|
||||
characteristics: [
|
||||
GattCharacteristic(
|
||||
uuid: UUID.short(0x2A19),
|
||||
properties: [GattCharacteristicProperty.read],
|
||||
value: Uint8List.fromList([75]),
|
||||
descriptors: [],
|
||||
),
|
||||
],
|
||||
);
|
||||
await PeripheralManager.instance.addService(batteryService);
|
||||
final advertisement = Advertisement(
|
||||
name: 'le12138',
|
||||
manufacturerSpecificData: ManufacturerSpecificData(
|
||||
|
@ -23,7 +23,7 @@ packages:
|
||||
path: ".."
|
||||
relative: true
|
||||
source: path
|
||||
version: "5.0.1"
|
||||
version: "5.0.2"
|
||||
bluetooth_low_energy_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -36,10 +36,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: bluetooth_low_energy_darwin
|
||||
sha256: "8cbb1a9ac97a217f6f45dca58510df457e8b70f861c36d3bf8cf2640c669e1cd"
|
||||
sha256: "876fd1c7eadd5e4eea92257dd3d2ec31f3c0bb68f8e96c564ed28ecde7382bd1"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "5.0.1"
|
||||
version: "5.0.2"
|
||||
bluetooth_low_energy_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -1,6 +1,6 @@
|
||||
name: bluetooth_low_energy
|
||||
description: A Flutter plugin for controlling the bluetooth low energy, supports central and peripheral apis.
|
||||
version: 5.0.1
|
||||
version: 5.0.2
|
||||
homepage: https://github.com/yanshouwang/bluetooth_low_energy
|
||||
|
||||
environment:
|
||||
@ -12,7 +12,7 @@ dependencies:
|
||||
sdk: flutter
|
||||
bluetooth_low_energy_platform_interface: ^5.0.0
|
||||
bluetooth_low_energy_android: ^5.0.0
|
||||
bluetooth_low_energy_darwin: ^5.0.1
|
||||
bluetooth_low_energy_darwin: ^5.0.2
|
||||
bluetooth_low_energy_windows: ^5.0.0
|
||||
bluetooth_low_energy_linux: ^5.0.0
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
## 5.0.2
|
||||
|
||||
* Fix the issue that [discoverGATT failed caused by CoW](https://github.com/yanshouwang/bluetooth_low_energy/issues/36).
|
||||
|
||||
## 5.0.1
|
||||
|
||||
* Fix the issue that [completion was called duplicately caused by CoW](https://github.com/yanshouwang/bluetooth_low_energy/issues/36).
|
||||
|
@ -384,16 +384,11 @@ class MyCentralManager: MyCentralManagerHostApi {
|
||||
if error == nil {
|
||||
let services = peripheral.services ?? []
|
||||
let servicesArgs = services.map { service in service.toArgs() }
|
||||
let elements = services.flatMap { service in
|
||||
let values = services.flatMap { service in
|
||||
let hashCodeArgs = service.hash.toInt64()
|
||||
return [hashCodeArgs: service]
|
||||
}
|
||||
var items = _services[uuidArgs]
|
||||
if items == nil {
|
||||
_services[uuidArgs] = Dictionary(uniqueKeysWithValues: elements)
|
||||
} else {
|
||||
items!.merge(elements) { service1, service2 in service2 }
|
||||
}
|
||||
_services[uuidArgs] = Dictionary(uniqueKeysWithValues: values)
|
||||
completion(.success(servicesArgs))
|
||||
} else {
|
||||
completion(.failure(error!))
|
||||
@ -409,16 +404,11 @@ class MyCentralManager: MyCentralManagerHostApi {
|
||||
if error == nil {
|
||||
let characteristics = service.characteristics ?? []
|
||||
let characteristicsArgs = characteristics.map { characteristic in characteristic.toArgs() }
|
||||
let elements = characteristics.flatMap { characteristic in
|
||||
let values = characteristics.flatMap { characteristic in
|
||||
let hashCodeArgs = characteristic.hash.toInt64()
|
||||
return [hashCodeArgs: characteristic]
|
||||
}
|
||||
var items = _characteristics[uuidArgs]
|
||||
if items == nil {
|
||||
_characteristics[uuidArgs] = Dictionary(uniqueKeysWithValues: elements)
|
||||
} else {
|
||||
items!.merge(elements) { characteristic1, characteristic2 in characteristic2 }
|
||||
}
|
||||
_characteristics[uuidArgs, default: [:]].merge(values) { value1, value2 in value2 }
|
||||
completion(.success(characteristicsArgs))
|
||||
} else {
|
||||
completion(.failure(error!))
|
||||
@ -434,16 +424,11 @@ class MyCentralManager: MyCentralManagerHostApi {
|
||||
if error == nil {
|
||||
let descriptors = characteristic.descriptors ?? []
|
||||
let descriptorsArgs = descriptors.map { descriptor in descriptor.toArgs() }
|
||||
let elements = descriptors.flatMap { descriptor in
|
||||
let values = descriptors.flatMap { descriptor in
|
||||
let hashCodeArgs = descriptor.hash.toInt64()
|
||||
return [hashCodeArgs: descriptor]
|
||||
}
|
||||
var items = _descriptors[uuidArgs]
|
||||
if items == nil {
|
||||
_descriptors[uuidArgs] = Dictionary(uniqueKeysWithValues: elements)
|
||||
} else {
|
||||
items!.merge(elements) { descriptor1, descriptor2 in descriptor2 }
|
||||
}
|
||||
_descriptors[uuidArgs, default: [:]].merge(values) { value1, value2 in value2 }
|
||||
completion(.success(descriptorsArgs))
|
||||
} else {
|
||||
completion(.failure(error!))
|
||||
|
@ -15,7 +15,7 @@ packages:
|
||||
path: ".."
|
||||
relative: true
|
||||
source: path
|
||||
version: "5.0.1"
|
||||
version: "5.0.2"
|
||||
bluetooth_low_energy_platform_interface:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -1,6 +1,6 @@
|
||||
name: bluetooth_low_energy_darwin
|
||||
description: iOS and macOS implementation of the bluetooth_low_energy plugin.
|
||||
version: 5.0.1
|
||||
version: 5.0.2
|
||||
homepage: https://github.com/yanshouwang/bluetooth_low_energy
|
||||
|
||||
environment:
|
||||
|
Reference in New Issue
Block a user