2.0.2 (#11)
* fix: 重构 * fix: 1 * fix: 重构 * fix: 修复 iOS 和 macOS 代码错误 * fix: 优化项目 * fix: 构建项目 * fix: 修复权限问题 * fix: 解决 macOS 沙盒权限问题 * fix: 修复代码问题 * fix: 更新依赖 * fix: 更新依赖项 * fix: 添加缺失的位置权限
This commit is contained in:
@ -1,11 +1,11 @@
|
||||
# This file tracks properties of this Flutter project.
|
||||
# Used by Flutter tool to assess capabilities and perform upgrades etc.
|
||||
#
|
||||
# This file should be version controlled.
|
||||
# This file should be version controlled and should not be manually edited.
|
||||
|
||||
version:
|
||||
revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
|
||||
channel: stable
|
||||
revision: "efbf63d9c66b9f6ec30e9ad4611189aa80003d31"
|
||||
channel: "stable"
|
||||
|
||||
project_type: plugin
|
||||
|
||||
@ -13,8 +13,8 @@ project_type: plugin
|
||||
migration:
|
||||
platforms:
|
||||
- platform: root
|
||||
create_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
|
||||
base_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
|
||||
create_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31
|
||||
base_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31
|
||||
|
||||
# User provided section
|
||||
|
||||
|
@ -1,3 +1,8 @@
|
||||
## 2.0.2
|
||||
|
||||
- Combine iOS and macOS projects.
|
||||
- Optimize project structure.
|
||||
|
||||
## 2.0.1
|
||||
|
||||
- Fix the issue that GATTs is cleared after peripheral disconnected on iOS and macOS.
|
||||
|
@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
SOFTWARE.
|
||||
|
@ -2,12 +2,21 @@ import 'dart:typed_data';
|
||||
|
||||
import 'uuid.dart';
|
||||
|
||||
/// The advertisement discovered from a peripheral.
|
||||
class Advertisement {
|
||||
/// The name of the peripheral.
|
||||
final String? name;
|
||||
|
||||
/// The manufacturer specific data of the peripheral.
|
||||
final Map<int, Uint8List> manufacturerSpecificData;
|
||||
|
||||
/// The GATT service uuids of the peripheral.
|
||||
final List<UUID> serviceUUIDs;
|
||||
|
||||
/// The GATT service data of the peripheral.
|
||||
final Map<UUID, Uint8List> serviceData;
|
||||
|
||||
/// Constructs an [Advertisement].
|
||||
Advertisement({
|
||||
this.name,
|
||||
this.manufacturerSpecificData = const {},
|
||||
|
@ -10,6 +10,8 @@ import 'gatt_descriptor.dart';
|
||||
import 'gatt_service.dart';
|
||||
import 'peripheral.dart';
|
||||
|
||||
/// The central controller used to communicate with peripherals.
|
||||
/// Call `setUp` before use any api, and call `tearDown` when it is no longer needed.
|
||||
abstract class CentralController extends PlatformInterface {
|
||||
/// Constructs a [CentralController].
|
||||
CentralController() : super(token: _token);
|
||||
@ -37,36 +39,74 @@ abstract class CentralController extends PlatformInterface {
|
||||
_instance = instance;
|
||||
}
|
||||
|
||||
/// Gets the state of the central.
|
||||
CentralState get state;
|
||||
|
||||
/// Used to listen the central state changed event.
|
||||
Stream<CentralStateChangedEventArgs> get stateChanged;
|
||||
|
||||
/// Used to listen the central discovered event.
|
||||
Stream<CentralDiscoveredEventArgs> get discovered;
|
||||
|
||||
/// Used to listen peripherals state changed event.
|
||||
Stream<PeripheralStateChangedEventArgs> get peripheralStateChanged;
|
||||
|
||||
/// Used to listen GATT characteristics value changed event.
|
||||
Stream<GattCharacteristicValueChangedEventArgs>
|
||||
get characteristicValueChanged;
|
||||
|
||||
/// Sets up the central controller.
|
||||
Future<void> setUp();
|
||||
|
||||
/// Tears down the central controller.
|
||||
Future<void> tearDown();
|
||||
|
||||
/// Starts to discover peripherals.
|
||||
Future<void> startDiscovery();
|
||||
|
||||
/// Stops to discover peripherals.
|
||||
Future<void> stopDiscovery();
|
||||
|
||||
/// Connects to the peripheral.
|
||||
Future<void> connect(Peripheral peripheral);
|
||||
|
||||
/// Disconnects form the peripheral.
|
||||
Future<void> disconnect(Peripheral peripheral);
|
||||
|
||||
/// Discovers GATT of the peripheral.
|
||||
Future<void> discoverGATT(Peripheral peripheral);
|
||||
|
||||
/// Gets GATT services of the peripheral.
|
||||
Future<List<GattService>> getServices(Peripheral peripheral);
|
||||
|
||||
/// Gets GATT characteristics of the GATT service.
|
||||
Future<List<GattCharacteristic>> getCharacteristics(GattService service);
|
||||
|
||||
/// Gets GATT descriptors of the GATT characteristic.
|
||||
Future<List<GattDescriptor>> getDescriptors(
|
||||
GattCharacteristic characteristic,
|
||||
);
|
||||
|
||||
/// Reads value of the GATT characteristic.
|
||||
Future<Uint8List> readCharacteristic(GattCharacteristic characteristic);
|
||||
|
||||
/// Writes value of the GATT characteristic.
|
||||
Future<void> writeCharacteristic(
|
||||
GattCharacteristic characteristic, {
|
||||
required Uint8List value,
|
||||
required GattCharacteristicWriteType type,
|
||||
});
|
||||
|
||||
/// Notifies value of the GATT characteristic.
|
||||
Future<void> notifyCharacteristic(
|
||||
GattCharacteristic characteristic, {
|
||||
required bool state,
|
||||
});
|
||||
|
||||
/// Reads value of the GATT descriptor.
|
||||
Future<Uint8List> readDescriptor(GattDescriptor descriptor);
|
||||
|
||||
/// Writes value of the GATT descriptor.
|
||||
Future<void> writeDescriptor(
|
||||
GattDescriptor descriptor, {
|
||||
required Uint8List value,
|
||||
|
@ -1,7 +1,17 @@
|
||||
/// The state of the central.
|
||||
enum CentralState {
|
||||
/// The central is unknown.
|
||||
unknown,
|
||||
|
||||
/// The central is unsupported.
|
||||
unsupported,
|
||||
|
||||
/// The central is unauthorized.
|
||||
unauthorized,
|
||||
|
||||
/// The central is powered off.
|
||||
poweredOff,
|
||||
|
||||
/// The central is powered on.
|
||||
poweredOn,
|
||||
}
|
||||
|
@ -1,6 +1,9 @@
|
||||
/// The bluetooth low energy error.
|
||||
class BluetoothLowEnergyError extends Error {
|
||||
/// The message of this error.
|
||||
final String message;
|
||||
|
||||
/// Constructs a [BluetoothLowEnergyError].
|
||||
BluetoothLowEnergyError(this.message);
|
||||
|
||||
@override
|
||||
|
@ -5,32 +5,53 @@ import 'central_state.dart';
|
||||
import 'gatt_characteristic.dart';
|
||||
import 'peripheral.dart';
|
||||
|
||||
/// The base event arguments.
|
||||
abstract class EventArgs {}
|
||||
|
||||
/// The central state changed event arguments.
|
||||
class CentralStateChangedEventArgs extends EventArgs {
|
||||
/// The new state of the central.
|
||||
final CentralState state;
|
||||
|
||||
/// Constructs a [CentralStateChangedEventArgs].
|
||||
CentralStateChangedEventArgs(this.state);
|
||||
}
|
||||
|
||||
/// The central discovered event arguments.
|
||||
class CentralDiscoveredEventArgs extends EventArgs {
|
||||
/// The disvered peripheral.
|
||||
final Peripheral peripheral;
|
||||
|
||||
/// The rssi of the peripheral.
|
||||
final int rssi;
|
||||
|
||||
/// The advertisement of the peripheral.
|
||||
final Advertisement advertisement;
|
||||
|
||||
/// Constructs a [CentralDiscoveredEventArgs].
|
||||
CentralDiscoveredEventArgs(this.peripheral, this.rssi, this.advertisement);
|
||||
}
|
||||
|
||||
/// The peripheral state changed event arguments.
|
||||
class PeripheralStateChangedEventArgs extends EventArgs {
|
||||
/// The peripheral which state is changed.
|
||||
final Peripheral peripheral;
|
||||
|
||||
/// The new state of the peripheral.
|
||||
final bool state;
|
||||
|
||||
/// Constructs a [PeripheralStateChangedEventArgs].
|
||||
PeripheralStateChangedEventArgs(this.peripheral, this.state);
|
||||
}
|
||||
|
||||
/// The GATT characteristic value changed event arguments.
|
||||
class GattCharacteristicValueChangedEventArgs extends EventArgs {
|
||||
/// The GATT characteristic which value is changed.
|
||||
final GattCharacteristic characteristic;
|
||||
|
||||
/// The changed value of the characteristic.
|
||||
final Uint8List value;
|
||||
|
||||
/// Constructs a [GattCharacteristicValueChangedEventArgs].
|
||||
GattCharacteristicValueChangedEventArgs(this.characteristic, this.value);
|
||||
}
|
||||
|
@ -1,10 +1,15 @@
|
||||
import 'gatt_characteristic_property.dart';
|
||||
import 'uuid.dart';
|
||||
|
||||
/// The GATT characteristic.
|
||||
class GattCharacteristic {
|
||||
/// The [UUID] of this GATT characteristic.
|
||||
final UUID uuid;
|
||||
|
||||
/// The properties of this GATT characteristic.
|
||||
final List<GattCharacteristicProperty> properties;
|
||||
|
||||
/// Constructs a [GattCharacteristic].
|
||||
GattCharacteristic({
|
||||
required this.uuid,
|
||||
required this.properties,
|
||||
|
@ -1,7 +1,17 @@
|
||||
/// The properity for a GATT characteristic.
|
||||
enum GattCharacteristicProperty {
|
||||
/// The GATT characteristic is able to read.
|
||||
read,
|
||||
|
||||
/// The GATT characteristic is able to write.
|
||||
write,
|
||||
|
||||
/// The GATT characteristic is able to write without response.
|
||||
writeWithoutResponse,
|
||||
|
||||
/// The GATT characteristic is able to notify.
|
||||
notify,
|
||||
|
||||
/// The GATT characteristic is able to indicate.
|
||||
indicate,
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
/// The write type for a GATT characteristic.
|
||||
enum GattCharacteristicWriteType {
|
||||
// Write with response
|
||||
withResponse,
|
||||
|
@ -1,8 +1,11 @@
|
||||
import 'uuid.dart';
|
||||
|
||||
/// The GATT characteristic.
|
||||
class GattDescriptor {
|
||||
/// The [UUID] of this GATT descriptor.
|
||||
final UUID uuid;
|
||||
|
||||
/// Constructs a [GattDescriptor].
|
||||
GattDescriptor({
|
||||
required this.uuid,
|
||||
});
|
||||
|
@ -1,8 +1,11 @@
|
||||
import 'uuid.dart';
|
||||
|
||||
/// The GATT service.
|
||||
class GattService {
|
||||
/// The [UUID] of this GATT service.
|
||||
final UUID uuid;
|
||||
|
||||
/// Constructs a [GattService].
|
||||
GattService({
|
||||
required this.uuid,
|
||||
});
|
||||
|
@ -1,5 +1,7 @@
|
||||
import 'uuid.dart';
|
||||
|
||||
/// The peripheral.
|
||||
abstract class Peripheral {
|
||||
/// The [UUID] of this peripheral.
|
||||
UUID get uuid;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
name: bluetooth_low_energy_platform_interface
|
||||
description: A common platform interface for the bluetooth_low_energy plugin.
|
||||
version: 2.0.1
|
||||
version: 2.0.2
|
||||
homepage: https://github.com/yanshouwang/bluetooth_low_energy
|
||||
|
||||
environment:
|
||||
|
Reference in New Issue
Block a user