1d7108c9d0
- Updated autogenerated files to reflect changes from Pigeon v26.3.4. - Added new classes for UniversalBlePeripheralConfig, UniversalBlePeripheralService, UniversalBlePeripheralCharacteristic, UniversalBlePeripheralDescriptor, and UniversalBlePeripheralWriteEvent to handle peripheral configurations and events. - Modified UniversalBlePlugin to implement methods for peripheral support, including StartPeripheral, StopPeripheral, UpdatePeripheralCharacteristicValue, and NotifyPeripheralCharacteristic, returning appropriate error messages for unsupported features on Windows. - Updated HasPermissions method to include an additional parameter for Bluetooth advertising permissions. - Adjusted method signatures and implementations across the plugin to accommodate new peripheral functionality. Signed-off-by: Tony <tonylu@tony-cloud.com>
1883 lines
57 KiB
Dart
1883 lines
57 KiB
Dart
// Autogenerated from Pigeon (v26.3.4), do not edit directly.
|
|
// See also: https://pub.dev/packages/pigeon
|
|
// ignore_for_file: unused_import, unused_shown_name
|
|
// ignore_for_file: type=lint
|
|
|
|
import 'dart:async';
|
|
import 'dart:typed_data' show Float64List, Int32List, Int64List;
|
|
|
|
import 'package:flutter/services.dart';
|
|
import 'package:meta/meta.dart' show immutable, protected, visibleForTesting;
|
|
|
|
Object? _extractReplyValueOrThrow(
|
|
List<Object?>? replyList,
|
|
String channelName, {
|
|
required bool isNullValid,
|
|
}) {
|
|
if (replyList == null) {
|
|
throw PlatformException(
|
|
code: 'channel-error',
|
|
message: 'Unable to establish connection on channel: "$channelName".',
|
|
);
|
|
} else if (replyList.length > 1) {
|
|
throw PlatformException(
|
|
code: replyList[0]! as String,
|
|
message: replyList[1] as String?,
|
|
details: replyList[2],
|
|
);
|
|
} else if (!isNullValid && (replyList.isNotEmpty && replyList[0] == null)) {
|
|
throw PlatformException(
|
|
code: 'null-error',
|
|
message: 'Host platform returned null value for non-null return value.',
|
|
);
|
|
}
|
|
return replyList.firstOrNull;
|
|
}
|
|
|
|
List<Object?> wrapResponse({
|
|
Object? result,
|
|
PlatformException? error,
|
|
bool empty = false,
|
|
}) {
|
|
if (empty) {
|
|
return <Object?>[];
|
|
}
|
|
if (error == null) {
|
|
return <Object?>[result];
|
|
}
|
|
return <Object?>[error.code, error.message, error.details];
|
|
}
|
|
|
|
bool _deepEquals(Object? a, Object? b) {
|
|
if (identical(a, b)) {
|
|
return true;
|
|
}
|
|
if (a is double && b is double) {
|
|
if (a.isNaN && b.isNaN) {
|
|
return true;
|
|
}
|
|
return a == b;
|
|
}
|
|
if (a is List && b is List) {
|
|
return a.length == b.length &&
|
|
a.indexed.every(
|
|
((int, dynamic) item) => _deepEquals(item.$2, b[item.$1]),
|
|
);
|
|
}
|
|
if (a is Map && b is Map) {
|
|
if (a.length != b.length) {
|
|
return false;
|
|
}
|
|
for (final MapEntry<Object?, Object?> entryA in a.entries) {
|
|
bool found = false;
|
|
for (final MapEntry<Object?, Object?> entryB in b.entries) {
|
|
if (_deepEquals(entryA.key, entryB.key)) {
|
|
if (_deepEquals(entryA.value, entryB.value)) {
|
|
found = true;
|
|
break;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
if (!found) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
return a == b;
|
|
}
|
|
|
|
int _deepHash(Object? value) {
|
|
if (value is List) {
|
|
return Object.hashAll(value.map(_deepHash));
|
|
}
|
|
if (value is Map) {
|
|
int result = 0;
|
|
for (final MapEntry<Object?, Object?> entry in value.entries) {
|
|
result += (_deepHash(entry.key) * 31) ^ _deepHash(entry.value);
|
|
}
|
|
return result;
|
|
}
|
|
if (value is double && value.isNaN) {
|
|
// Normalize NaN to a consistent hash.
|
|
return 0x7FF8000000000000.hashCode;
|
|
}
|
|
if (value is double && value == 0.0) {
|
|
// Normalize -0.0 to 0.0 so they have the same hash code.
|
|
return 0.0.hashCode;
|
|
}
|
|
return value.hashCode;
|
|
}
|
|
|
|
enum UniversalBleLogLevel { none, error, warning, info, debug, verbose }
|
|
|
|
/// Scan config
|
|
enum AndroidScanMode { balanced, lowLatency, lowPower, opportunistic }
|
|
|
|
/// Unified error codes for all platforms
|
|
enum UniversalBleErrorCode {
|
|
unknownError,
|
|
failed,
|
|
notSupported,
|
|
notImplemented,
|
|
channelError,
|
|
bluetoothNotAvailable,
|
|
bluetoothNotEnabled,
|
|
bluetoothNotAllowed,
|
|
bluetoothUnauthorized,
|
|
deviceDisconnected,
|
|
connectionTimeout,
|
|
connectionFailed,
|
|
connectionRejected,
|
|
connectionLimitExceeded,
|
|
connectionAlreadyExists,
|
|
connectionTerminated,
|
|
connectionInProgress,
|
|
illegalArgument,
|
|
deviceNotFound,
|
|
serviceNotFound,
|
|
characteristicNotFound,
|
|
invalidServiceUuid,
|
|
invalidCharacteristicUuid,
|
|
invalidOffset,
|
|
invalidAttributeLength,
|
|
invalidPdu,
|
|
invalidHandle,
|
|
readFailed,
|
|
readNotPermitted,
|
|
writeFailed,
|
|
writeNotPermitted,
|
|
writeRequestBusy,
|
|
invalidAction,
|
|
operationNotSupported,
|
|
operationTimeout,
|
|
operationCancelled,
|
|
operationInProgress,
|
|
characteristicDoesNotSupportRead,
|
|
characteristicDoesNotSupportWrite,
|
|
characteristicDoesNotSupportWriteWithoutResponse,
|
|
characteristicDoesNotSupportNotify,
|
|
characteristicDoesNotSupportIndicate,
|
|
notPaired,
|
|
notPairable,
|
|
alreadyPaired,
|
|
pairingFailed,
|
|
pairingCancelled,
|
|
pairingTimeout,
|
|
pairingNotAllowed,
|
|
authenticationFailure,
|
|
insufficientAuthentication,
|
|
insufficientAuthorization,
|
|
insufficientEncryption,
|
|
insufficientKeySize,
|
|
protectionLevelNotMet,
|
|
accessDenied,
|
|
unpairingFailed,
|
|
alreadyUnpaired,
|
|
scanFailed,
|
|
stoppingScanInProgress,
|
|
webBluetoothGloballyDisabled,
|
|
}
|
|
|
|
class UniversalBleScanResult {
|
|
UniversalBleScanResult({
|
|
required this.deviceId,
|
|
this.name,
|
|
this.isPaired,
|
|
this.rssi,
|
|
this.manufacturerDataList,
|
|
this.serviceData,
|
|
this.services,
|
|
this.timestamp,
|
|
});
|
|
|
|
String deviceId;
|
|
|
|
String? name;
|
|
|
|
bool? isPaired;
|
|
|
|
int? rssi;
|
|
|
|
List<UniversalManufacturerData>? manufacturerDataList;
|
|
|
|
Map<String, Uint8List>? serviceData;
|
|
|
|
List<String>? services;
|
|
|
|
int? timestamp;
|
|
|
|
List<Object?> _toList() {
|
|
return <Object?>[
|
|
deviceId,
|
|
name,
|
|
isPaired,
|
|
rssi,
|
|
manufacturerDataList,
|
|
serviceData,
|
|
services,
|
|
timestamp,
|
|
];
|
|
}
|
|
|
|
Object encode() {
|
|
return _toList();
|
|
}
|
|
|
|
static UniversalBleScanResult decode(Object result) {
|
|
result as List<Object?>;
|
|
return UniversalBleScanResult(
|
|
deviceId: result[0]! as String,
|
|
name: result[1] as String?,
|
|
isPaired: result[2] as bool?,
|
|
rssi: result[3] as int?,
|
|
manufacturerDataList: (result[4] as List<Object?>?)
|
|
?.cast<UniversalManufacturerData>(),
|
|
serviceData: (result[5] as Map<Object?, Object?>?)
|
|
?.cast<String, Uint8List>(),
|
|
services: (result[6] as List<Object?>?)?.cast<String>(),
|
|
timestamp: result[7] as int?,
|
|
);
|
|
}
|
|
|
|
@override
|
|
// ignore: avoid_equals_and_hash_code_on_mutable_classes
|
|
bool operator ==(Object other) {
|
|
if (other is! UniversalBleScanResult || other.runtimeType != runtimeType) {
|
|
return false;
|
|
}
|
|
if (identical(this, other)) {
|
|
return true;
|
|
}
|
|
return _deepEquals(deviceId, other.deviceId) &&
|
|
_deepEquals(name, other.name) &&
|
|
_deepEquals(isPaired, other.isPaired) &&
|
|
_deepEquals(rssi, other.rssi) &&
|
|
_deepEquals(manufacturerDataList, other.manufacturerDataList) &&
|
|
_deepEquals(serviceData, other.serviceData) &&
|
|
_deepEquals(services, other.services) &&
|
|
_deepEquals(timestamp, other.timestamp);
|
|
}
|
|
|
|
@override
|
|
// ignore: avoid_equals_and_hash_code_on_mutable_classes
|
|
int get hashCode => _deepHash(<Object?>[runtimeType, ..._toList()]);
|
|
}
|
|
|
|
class UniversalBleService {
|
|
UniversalBleService({required this.uuid, this.characteristics});
|
|
|
|
String uuid;
|
|
|
|
List<UniversalBleCharacteristic>? characteristics;
|
|
|
|
List<Object?> _toList() {
|
|
return <Object?>[uuid, characteristics];
|
|
}
|
|
|
|
Object encode() {
|
|
return _toList();
|
|
}
|
|
|
|
static UniversalBleService decode(Object result) {
|
|
result as List<Object?>;
|
|
return UniversalBleService(
|
|
uuid: result[0]! as String,
|
|
characteristics: (result[1] as List<Object?>?)
|
|
?.cast<UniversalBleCharacteristic>(),
|
|
);
|
|
}
|
|
|
|
@override
|
|
// ignore: avoid_equals_and_hash_code_on_mutable_classes
|
|
bool operator ==(Object other) {
|
|
if (other is! UniversalBleService || other.runtimeType != runtimeType) {
|
|
return false;
|
|
}
|
|
if (identical(this, other)) {
|
|
return true;
|
|
}
|
|
return _deepEquals(uuid, other.uuid) &&
|
|
_deepEquals(characteristics, other.characteristics);
|
|
}
|
|
|
|
@override
|
|
// ignore: avoid_equals_and_hash_code_on_mutable_classes
|
|
int get hashCode => _deepHash(<Object?>[runtimeType, ..._toList()]);
|
|
}
|
|
|
|
class UniversalBleCharacteristic {
|
|
UniversalBleCharacteristic({
|
|
required this.uuid,
|
|
required this.properties,
|
|
required this.descriptors,
|
|
});
|
|
|
|
String uuid;
|
|
|
|
List<int> properties;
|
|
|
|
List<UniversalBleDescriptor> descriptors;
|
|
|
|
List<Object?> _toList() {
|
|
return <Object?>[uuid, properties, descriptors];
|
|
}
|
|
|
|
Object encode() {
|
|
return _toList();
|
|
}
|
|
|
|
static UniversalBleCharacteristic decode(Object result) {
|
|
result as List<Object?>;
|
|
return UniversalBleCharacteristic(
|
|
uuid: result[0]! as String,
|
|
properties: (result[1]! as List<Object?>).cast<int>(),
|
|
descriptors: (result[2]! as List<Object?>).cast<UniversalBleDescriptor>(),
|
|
);
|
|
}
|
|
|
|
@override
|
|
// ignore: avoid_equals_and_hash_code_on_mutable_classes
|
|
bool operator ==(Object other) {
|
|
if (other is! UniversalBleCharacteristic ||
|
|
other.runtimeType != runtimeType) {
|
|
return false;
|
|
}
|
|
if (identical(this, other)) {
|
|
return true;
|
|
}
|
|
return _deepEquals(uuid, other.uuid) &&
|
|
_deepEquals(properties, other.properties) &&
|
|
_deepEquals(descriptors, other.descriptors);
|
|
}
|
|
|
|
@override
|
|
// ignore: avoid_equals_and_hash_code_on_mutable_classes
|
|
int get hashCode => _deepHash(<Object?>[runtimeType, ..._toList()]);
|
|
}
|
|
|
|
class UniversalBleDescriptor {
|
|
UniversalBleDescriptor({required this.uuid});
|
|
|
|
String uuid;
|
|
|
|
List<Object?> _toList() {
|
|
return <Object?>[uuid];
|
|
}
|
|
|
|
Object encode() {
|
|
return _toList();
|
|
}
|
|
|
|
static UniversalBleDescriptor decode(Object result) {
|
|
result as List<Object?>;
|
|
return UniversalBleDescriptor(uuid: result[0]! as String);
|
|
}
|
|
|
|
@override
|
|
// ignore: avoid_equals_and_hash_code_on_mutable_classes
|
|
bool operator ==(Object other) {
|
|
if (other is! UniversalBleDescriptor || other.runtimeType != runtimeType) {
|
|
return false;
|
|
}
|
|
if (identical(this, other)) {
|
|
return true;
|
|
}
|
|
return _deepEquals(uuid, other.uuid);
|
|
}
|
|
|
|
@override
|
|
// ignore: avoid_equals_and_hash_code_on_mutable_classes
|
|
int get hashCode => _deepHash(<Object?>[runtimeType, ..._toList()]);
|
|
}
|
|
|
|
class UniversalBlePeripheralConfig {
|
|
UniversalBlePeripheralConfig({
|
|
required this.advertisedName,
|
|
required this.services,
|
|
});
|
|
|
|
String advertisedName;
|
|
|
|
List<UniversalBlePeripheralService> services;
|
|
|
|
List<Object?> _toList() {
|
|
return <Object?>[advertisedName, services];
|
|
}
|
|
|
|
Object encode() {
|
|
return _toList();
|
|
}
|
|
|
|
static UniversalBlePeripheralConfig decode(Object result) {
|
|
result as List<Object?>;
|
|
return UniversalBlePeripheralConfig(
|
|
advertisedName: result[0]! as String,
|
|
services: (result[1]! as List<Object?>)
|
|
.cast<UniversalBlePeripheralService>(),
|
|
);
|
|
}
|
|
|
|
@override
|
|
// ignore: avoid_equals_and_hash_code_on_mutable_classes
|
|
bool operator ==(Object other) {
|
|
if (other is! UniversalBlePeripheralConfig ||
|
|
other.runtimeType != runtimeType) {
|
|
return false;
|
|
}
|
|
if (identical(this, other)) {
|
|
return true;
|
|
}
|
|
return _deepEquals(advertisedName, other.advertisedName) &&
|
|
_deepEquals(services, other.services);
|
|
}
|
|
|
|
@override
|
|
// ignore: avoid_equals_and_hash_code_on_mutable_classes
|
|
int get hashCode => _deepHash(<Object?>[runtimeType, ..._toList()]);
|
|
}
|
|
|
|
class UniversalBlePeripheralService {
|
|
UniversalBlePeripheralService({
|
|
required this.uuid,
|
|
required this.characteristics,
|
|
});
|
|
|
|
String uuid;
|
|
|
|
List<UniversalBlePeripheralCharacteristic> characteristics;
|
|
|
|
List<Object?> _toList() {
|
|
return <Object?>[uuid, characteristics];
|
|
}
|
|
|
|
Object encode() {
|
|
return _toList();
|
|
}
|
|
|
|
static UniversalBlePeripheralService decode(Object result) {
|
|
result as List<Object?>;
|
|
return UniversalBlePeripheralService(
|
|
uuid: result[0]! as String,
|
|
characteristics: (result[1]! as List<Object?>)
|
|
.cast<UniversalBlePeripheralCharacteristic>(),
|
|
);
|
|
}
|
|
|
|
@override
|
|
// ignore: avoid_equals_and_hash_code_on_mutable_classes
|
|
bool operator ==(Object other) {
|
|
if (other is! UniversalBlePeripheralService ||
|
|
other.runtimeType != runtimeType) {
|
|
return false;
|
|
}
|
|
if (identical(this, other)) {
|
|
return true;
|
|
}
|
|
return _deepEquals(uuid, other.uuid) &&
|
|
_deepEquals(characteristics, other.characteristics);
|
|
}
|
|
|
|
@override
|
|
// ignore: avoid_equals_and_hash_code_on_mutable_classes
|
|
int get hashCode => _deepHash(<Object?>[runtimeType, ..._toList()]);
|
|
}
|
|
|
|
class UniversalBlePeripheralCharacteristic {
|
|
UniversalBlePeripheralCharacteristic({
|
|
required this.uuid,
|
|
required this.properties,
|
|
required this.permissions,
|
|
required this.descriptors,
|
|
this.initialValue,
|
|
});
|
|
|
|
String uuid;
|
|
|
|
List<int> properties;
|
|
|
|
List<int> permissions;
|
|
|
|
List<UniversalBlePeripheralDescriptor> descriptors;
|
|
|
|
Uint8List? initialValue;
|
|
|
|
List<Object?> _toList() {
|
|
return <Object?>[uuid, properties, permissions, descriptors, initialValue];
|
|
}
|
|
|
|
Object encode() {
|
|
return _toList();
|
|
}
|
|
|
|
static UniversalBlePeripheralCharacteristic decode(Object result) {
|
|
result as List<Object?>;
|
|
return UniversalBlePeripheralCharacteristic(
|
|
uuid: result[0]! as String,
|
|
properties: (result[1]! as List<Object?>).cast<int>(),
|
|
permissions: (result[2]! as List<Object?>).cast<int>(),
|
|
descriptors: (result[3]! as List<Object?>)
|
|
.cast<UniversalBlePeripheralDescriptor>(),
|
|
initialValue: result[4] as Uint8List?,
|
|
);
|
|
}
|
|
|
|
@override
|
|
// ignore: avoid_equals_and_hash_code_on_mutable_classes
|
|
bool operator ==(Object other) {
|
|
if (other is! UniversalBlePeripheralCharacteristic ||
|
|
other.runtimeType != runtimeType) {
|
|
return false;
|
|
}
|
|
if (identical(this, other)) {
|
|
return true;
|
|
}
|
|
return _deepEquals(uuid, other.uuid) &&
|
|
_deepEquals(properties, other.properties) &&
|
|
_deepEquals(permissions, other.permissions) &&
|
|
_deepEquals(descriptors, other.descriptors) &&
|
|
_deepEquals(initialValue, other.initialValue);
|
|
}
|
|
|
|
@override
|
|
// ignore: avoid_equals_and_hash_code_on_mutable_classes
|
|
int get hashCode => _deepHash(<Object?>[runtimeType, ..._toList()]);
|
|
}
|
|
|
|
class UniversalBlePeripheralDescriptor {
|
|
UniversalBlePeripheralDescriptor({
|
|
required this.uuid,
|
|
required this.permissions,
|
|
this.initialValue,
|
|
});
|
|
|
|
String uuid;
|
|
|
|
List<int> permissions;
|
|
|
|
Uint8List? initialValue;
|
|
|
|
List<Object?> _toList() {
|
|
return <Object?>[uuid, permissions, initialValue];
|
|
}
|
|
|
|
Object encode() {
|
|
return _toList();
|
|
}
|
|
|
|
static UniversalBlePeripheralDescriptor decode(Object result) {
|
|
result as List<Object?>;
|
|
return UniversalBlePeripheralDescriptor(
|
|
uuid: result[0]! as String,
|
|
permissions: (result[1]! as List<Object?>).cast<int>(),
|
|
initialValue: result[2] as Uint8List?,
|
|
);
|
|
}
|
|
|
|
@override
|
|
// ignore: avoid_equals_and_hash_code_on_mutable_classes
|
|
bool operator ==(Object other) {
|
|
if (other is! UniversalBlePeripheralDescriptor ||
|
|
other.runtimeType != runtimeType) {
|
|
return false;
|
|
}
|
|
if (identical(this, other)) {
|
|
return true;
|
|
}
|
|
return _deepEquals(uuid, other.uuid) &&
|
|
_deepEquals(permissions, other.permissions) &&
|
|
_deepEquals(initialValue, other.initialValue);
|
|
}
|
|
|
|
@override
|
|
// ignore: avoid_equals_and_hash_code_on_mutable_classes
|
|
int get hashCode => _deepHash(<Object?>[runtimeType, ..._toList()]);
|
|
}
|
|
|
|
class UniversalBlePeripheralWriteEvent {
|
|
UniversalBlePeripheralWriteEvent({
|
|
required this.deviceId,
|
|
required this.service,
|
|
required this.characteristic,
|
|
required this.value,
|
|
});
|
|
|
|
String deviceId;
|
|
|
|
String service;
|
|
|
|
String characteristic;
|
|
|
|
Uint8List value;
|
|
|
|
List<Object?> _toList() {
|
|
return <Object?>[deviceId, service, characteristic, value];
|
|
}
|
|
|
|
Object encode() {
|
|
return _toList();
|
|
}
|
|
|
|
static UniversalBlePeripheralWriteEvent decode(Object result) {
|
|
result as List<Object?>;
|
|
return UniversalBlePeripheralWriteEvent(
|
|
deviceId: result[0]! as String,
|
|
service: result[1]! as String,
|
|
characteristic: result[2]! as String,
|
|
value: result[3]! as Uint8List,
|
|
);
|
|
}
|
|
|
|
@override
|
|
// ignore: avoid_equals_and_hash_code_on_mutable_classes
|
|
bool operator ==(Object other) {
|
|
if (other is! UniversalBlePeripheralWriteEvent ||
|
|
other.runtimeType != runtimeType) {
|
|
return false;
|
|
}
|
|
if (identical(this, other)) {
|
|
return true;
|
|
}
|
|
return _deepEquals(deviceId, other.deviceId) &&
|
|
_deepEquals(service, other.service) &&
|
|
_deepEquals(characteristic, other.characteristic) &&
|
|
_deepEquals(value, other.value);
|
|
}
|
|
|
|
@override
|
|
// ignore: avoid_equals_and_hash_code_on_mutable_classes
|
|
int get hashCode => _deepHash(<Object?>[runtimeType, ..._toList()]);
|
|
}
|
|
|
|
/// Android options to scan devices
|
|
/// [requestLocationPermission] is used to request location permission on Android 12+ (API 31+).
|
|
/// [scanMode] is used to set the scan mode for for Bluetooth LE scan.
|
|
/// Set [reportDelayMillis] timestamp for Bluetooth LE scan. If set to 0, you will be notified of scan results immediately.
|
|
/// If > 0, scan results are queued up and delivered after the requested delay or 5000 milliseconds (whichever is higher).
|
|
/// Note scan results may be delivered sooner if the internal buffers fill up.
|
|
class AndroidOptions {
|
|
AndroidOptions({
|
|
this.requestLocationPermission,
|
|
this.scanMode,
|
|
this.reportDelayMillis,
|
|
});
|
|
|
|
bool? requestLocationPermission;
|
|
|
|
AndroidScanMode? scanMode;
|
|
|
|
int? reportDelayMillis;
|
|
|
|
List<Object?> _toList() {
|
|
return <Object?>[requestLocationPermission, scanMode, reportDelayMillis];
|
|
}
|
|
|
|
Object encode() {
|
|
return _toList();
|
|
}
|
|
|
|
static AndroidOptions decode(Object result) {
|
|
result as List<Object?>;
|
|
return AndroidOptions(
|
|
requestLocationPermission: result[0] as bool?,
|
|
scanMode: result[1] as AndroidScanMode?,
|
|
reportDelayMillis: result[2] as int?,
|
|
);
|
|
}
|
|
|
|
@override
|
|
// ignore: avoid_equals_and_hash_code_on_mutable_classes
|
|
bool operator ==(Object other) {
|
|
if (other is! AndroidOptions || other.runtimeType != runtimeType) {
|
|
return false;
|
|
}
|
|
if (identical(this, other)) {
|
|
return true;
|
|
}
|
|
return _deepEquals(
|
|
requestLocationPermission,
|
|
other.requestLocationPermission,
|
|
) &&
|
|
_deepEquals(scanMode, other.scanMode) &&
|
|
_deepEquals(reportDelayMillis, other.reportDelayMillis);
|
|
}
|
|
|
|
@override
|
|
// ignore: avoid_equals_and_hash_code_on_mutable_classes
|
|
int get hashCode => _deepHash(<Object?>[runtimeType, ..._toList()]);
|
|
}
|
|
|
|
class UniversalScanConfig {
|
|
UniversalScanConfig({this.android});
|
|
|
|
AndroidOptions? android;
|
|
|
|
List<Object?> _toList() {
|
|
return <Object?>[android];
|
|
}
|
|
|
|
Object encode() {
|
|
return _toList();
|
|
}
|
|
|
|
static UniversalScanConfig decode(Object result) {
|
|
result as List<Object?>;
|
|
return UniversalScanConfig(android: result[0] as AndroidOptions?);
|
|
}
|
|
|
|
@override
|
|
// ignore: avoid_equals_and_hash_code_on_mutable_classes
|
|
bool operator ==(Object other) {
|
|
if (other is! UniversalScanConfig || other.runtimeType != runtimeType) {
|
|
return false;
|
|
}
|
|
if (identical(this, other)) {
|
|
return true;
|
|
}
|
|
return _deepEquals(android, other.android);
|
|
}
|
|
|
|
@override
|
|
// ignore: avoid_equals_and_hash_code_on_mutable_classes
|
|
int get hashCode => _deepHash(<Object?>[runtimeType, ..._toList()]);
|
|
}
|
|
|
|
/// Scan Filters
|
|
class UniversalScanFilter {
|
|
UniversalScanFilter({
|
|
required this.withServices,
|
|
required this.withNamePrefix,
|
|
required this.withManufacturerData,
|
|
});
|
|
|
|
List<String> withServices;
|
|
|
|
List<String> withNamePrefix;
|
|
|
|
List<UniversalManufacturerDataFilter> withManufacturerData;
|
|
|
|
List<Object?> _toList() {
|
|
return <Object?>[withServices, withNamePrefix, withManufacturerData];
|
|
}
|
|
|
|
Object encode() {
|
|
return _toList();
|
|
}
|
|
|
|
static UniversalScanFilter decode(Object result) {
|
|
result as List<Object?>;
|
|
return UniversalScanFilter(
|
|
withServices: (result[0]! as List<Object?>).cast<String>(),
|
|
withNamePrefix: (result[1]! as List<Object?>).cast<String>(),
|
|
withManufacturerData: (result[2]! as List<Object?>)
|
|
.cast<UniversalManufacturerDataFilter>(),
|
|
);
|
|
}
|
|
|
|
@override
|
|
// ignore: avoid_equals_and_hash_code_on_mutable_classes
|
|
bool operator ==(Object other) {
|
|
if (other is! UniversalScanFilter || other.runtimeType != runtimeType) {
|
|
return false;
|
|
}
|
|
if (identical(this, other)) {
|
|
return true;
|
|
}
|
|
return _deepEquals(withServices, other.withServices) &&
|
|
_deepEquals(withNamePrefix, other.withNamePrefix) &&
|
|
_deepEquals(withManufacturerData, other.withManufacturerData);
|
|
}
|
|
|
|
@override
|
|
// ignore: avoid_equals_and_hash_code_on_mutable_classes
|
|
int get hashCode => _deepHash(<Object?>[runtimeType, ..._toList()]);
|
|
}
|
|
|
|
class UniversalManufacturerDataFilter {
|
|
UniversalManufacturerDataFilter({
|
|
required this.companyIdentifier,
|
|
this.data,
|
|
this.mask,
|
|
});
|
|
|
|
int companyIdentifier;
|
|
|
|
Uint8List? data;
|
|
|
|
Uint8List? mask;
|
|
|
|
List<Object?> _toList() {
|
|
return <Object?>[companyIdentifier, data, mask];
|
|
}
|
|
|
|
Object encode() {
|
|
return _toList();
|
|
}
|
|
|
|
static UniversalManufacturerDataFilter decode(Object result) {
|
|
result as List<Object?>;
|
|
return UniversalManufacturerDataFilter(
|
|
companyIdentifier: result[0]! as int,
|
|
data: result[1] as Uint8List?,
|
|
mask: result[2] as Uint8List?,
|
|
);
|
|
}
|
|
|
|
@override
|
|
// ignore: avoid_equals_and_hash_code_on_mutable_classes
|
|
bool operator ==(Object other) {
|
|
if (other is! UniversalManufacturerDataFilter ||
|
|
other.runtimeType != runtimeType) {
|
|
return false;
|
|
}
|
|
if (identical(this, other)) {
|
|
return true;
|
|
}
|
|
return _deepEquals(companyIdentifier, other.companyIdentifier) &&
|
|
_deepEquals(data, other.data) &&
|
|
_deepEquals(mask, other.mask);
|
|
}
|
|
|
|
@override
|
|
// ignore: avoid_equals_and_hash_code_on_mutable_classes
|
|
int get hashCode => _deepHash(<Object?>[runtimeType, ..._toList()]);
|
|
}
|
|
|
|
class UniversalManufacturerData {
|
|
UniversalManufacturerData({
|
|
required this.companyIdentifier,
|
|
required this.data,
|
|
});
|
|
|
|
int companyIdentifier;
|
|
|
|
Uint8List data;
|
|
|
|
List<Object?> _toList() {
|
|
return <Object?>[companyIdentifier, data];
|
|
}
|
|
|
|
Object encode() {
|
|
return _toList();
|
|
}
|
|
|
|
static UniversalManufacturerData decode(Object result) {
|
|
result as List<Object?>;
|
|
return UniversalManufacturerData(
|
|
companyIdentifier: result[0]! as int,
|
|
data: result[1]! as Uint8List,
|
|
);
|
|
}
|
|
|
|
@override
|
|
// ignore: avoid_equals_and_hash_code_on_mutable_classes
|
|
bool operator ==(Object other) {
|
|
if (other is! UniversalManufacturerData ||
|
|
other.runtimeType != runtimeType) {
|
|
return false;
|
|
}
|
|
if (identical(this, other)) {
|
|
return true;
|
|
}
|
|
return _deepEquals(companyIdentifier, other.companyIdentifier) &&
|
|
_deepEquals(data, other.data);
|
|
}
|
|
|
|
@override
|
|
// ignore: avoid_equals_and_hash_code_on_mutable_classes
|
|
int get hashCode => _deepHash(<Object?>[runtimeType, ..._toList()]);
|
|
}
|
|
|
|
class _PigeonCodec extends StandardMessageCodec {
|
|
const _PigeonCodec();
|
|
@override
|
|
void writeValue(WriteBuffer buffer, Object? value) {
|
|
if (value is int) {
|
|
buffer.putUint8(4);
|
|
buffer.putInt64(value);
|
|
} else if (value is UniversalBleLogLevel) {
|
|
buffer.putUint8(129);
|
|
writeValue(buffer, value.index);
|
|
} else if (value is AndroidScanMode) {
|
|
buffer.putUint8(130);
|
|
writeValue(buffer, value.index);
|
|
} else if (value is UniversalBleErrorCode) {
|
|
buffer.putUint8(131);
|
|
writeValue(buffer, value.index);
|
|
} else if (value is UniversalBleScanResult) {
|
|
buffer.putUint8(132);
|
|
writeValue(buffer, value.encode());
|
|
} else if (value is UniversalBleService) {
|
|
buffer.putUint8(133);
|
|
writeValue(buffer, value.encode());
|
|
} else if (value is UniversalBleCharacteristic) {
|
|
buffer.putUint8(134);
|
|
writeValue(buffer, value.encode());
|
|
} else if (value is UniversalBleDescriptor) {
|
|
buffer.putUint8(135);
|
|
writeValue(buffer, value.encode());
|
|
} else if (value is UniversalBlePeripheralConfig) {
|
|
buffer.putUint8(136);
|
|
writeValue(buffer, value.encode());
|
|
} else if (value is UniversalBlePeripheralService) {
|
|
buffer.putUint8(137);
|
|
writeValue(buffer, value.encode());
|
|
} else if (value is UniversalBlePeripheralCharacteristic) {
|
|
buffer.putUint8(138);
|
|
writeValue(buffer, value.encode());
|
|
} else if (value is UniversalBlePeripheralDescriptor) {
|
|
buffer.putUint8(139);
|
|
writeValue(buffer, value.encode());
|
|
} else if (value is UniversalBlePeripheralWriteEvent) {
|
|
buffer.putUint8(140);
|
|
writeValue(buffer, value.encode());
|
|
} else if (value is AndroidOptions) {
|
|
buffer.putUint8(141);
|
|
writeValue(buffer, value.encode());
|
|
} else if (value is UniversalScanConfig) {
|
|
buffer.putUint8(142);
|
|
writeValue(buffer, value.encode());
|
|
} else if (value is UniversalScanFilter) {
|
|
buffer.putUint8(143);
|
|
writeValue(buffer, value.encode());
|
|
} else if (value is UniversalManufacturerDataFilter) {
|
|
buffer.putUint8(144);
|
|
writeValue(buffer, value.encode());
|
|
} else if (value is UniversalManufacturerData) {
|
|
buffer.putUint8(145);
|
|
writeValue(buffer, value.encode());
|
|
} else {
|
|
super.writeValue(buffer, value);
|
|
}
|
|
}
|
|
|
|
@override
|
|
Object? readValueOfType(int type, ReadBuffer buffer) {
|
|
switch (type) {
|
|
case 129:
|
|
final value = readValue(buffer) as int?;
|
|
return value == null ? null : UniversalBleLogLevel.values[value];
|
|
case 130:
|
|
final value = readValue(buffer) as int?;
|
|
return value == null ? null : AndroidScanMode.values[value];
|
|
case 131:
|
|
final value = readValue(buffer) as int?;
|
|
return value == null ? null : UniversalBleErrorCode.values[value];
|
|
case 132:
|
|
return UniversalBleScanResult.decode(readValue(buffer)!);
|
|
case 133:
|
|
return UniversalBleService.decode(readValue(buffer)!);
|
|
case 134:
|
|
return UniversalBleCharacteristic.decode(readValue(buffer)!);
|
|
case 135:
|
|
return UniversalBleDescriptor.decode(readValue(buffer)!);
|
|
case 136:
|
|
return UniversalBlePeripheralConfig.decode(readValue(buffer)!);
|
|
case 137:
|
|
return UniversalBlePeripheralService.decode(readValue(buffer)!);
|
|
case 138:
|
|
return UniversalBlePeripheralCharacteristic.decode(readValue(buffer)!);
|
|
case 139:
|
|
return UniversalBlePeripheralDescriptor.decode(readValue(buffer)!);
|
|
case 140:
|
|
return UniversalBlePeripheralWriteEvent.decode(readValue(buffer)!);
|
|
case 141:
|
|
return AndroidOptions.decode(readValue(buffer)!);
|
|
case 142:
|
|
return UniversalScanConfig.decode(readValue(buffer)!);
|
|
case 143:
|
|
return UniversalScanFilter.decode(readValue(buffer)!);
|
|
case 144:
|
|
return UniversalManufacturerDataFilter.decode(readValue(buffer)!);
|
|
case 145:
|
|
return UniversalManufacturerData.decode(readValue(buffer)!);
|
|
default:
|
|
return super.readValueOfType(type, buffer);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// Flutter -> Native
|
|
class UniversalBlePlatformChannel {
|
|
/// Constructor for [UniversalBlePlatformChannel]. The [binaryMessenger] named argument is
|
|
/// available for dependency injection. If it is left null, the default
|
|
/// BinaryMessenger will be used which routes to the host platform.
|
|
UniversalBlePlatformChannel({
|
|
BinaryMessenger? binaryMessenger,
|
|
String messageChannelSuffix = '',
|
|
}) : pigeonVar_binaryMessenger = binaryMessenger,
|
|
pigeonVar_messageChannelSuffix = messageChannelSuffix.isNotEmpty
|
|
? '.$messageChannelSuffix'
|
|
: '';
|
|
final BinaryMessenger? pigeonVar_binaryMessenger;
|
|
|
|
static const MessageCodec<Object?> pigeonChannelCodec = _PigeonCodec();
|
|
|
|
final String pigeonVar_messageChannelSuffix;
|
|
|
|
Future<int> getBluetoothAvailabilityState() async {
|
|
final pigeonVar_channelName =
|
|
'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.getBluetoothAvailabilityState$pigeonVar_messageChannelSuffix';
|
|
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
|
pigeonVar_channelName,
|
|
pigeonChannelCodec,
|
|
binaryMessenger: pigeonVar_binaryMessenger,
|
|
);
|
|
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(null);
|
|
final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;
|
|
|
|
final Object? pigeonVar_replyValue = _extractReplyValueOrThrow(
|
|
pigeonVar_replyList,
|
|
pigeonVar_channelName,
|
|
isNullValid: false,
|
|
);
|
|
return pigeonVar_replyValue! as int;
|
|
}
|
|
|
|
Future<bool> hasPermissions(
|
|
bool withAndroidFineLocation,
|
|
bool withAndroidBluetoothAdvertise,
|
|
) async {
|
|
final pigeonVar_channelName =
|
|
'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.hasPermissions$pigeonVar_messageChannelSuffix';
|
|
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
|
pigeonVar_channelName,
|
|
pigeonChannelCodec,
|
|
binaryMessenger: pigeonVar_binaryMessenger,
|
|
);
|
|
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(
|
|
<Object?>[withAndroidFineLocation, withAndroidBluetoothAdvertise],
|
|
);
|
|
final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;
|
|
|
|
final Object? pigeonVar_replyValue = _extractReplyValueOrThrow(
|
|
pigeonVar_replyList,
|
|
pigeonVar_channelName,
|
|
isNullValid: false,
|
|
);
|
|
return pigeonVar_replyValue! as bool;
|
|
}
|
|
|
|
Future<void> requestPermissions(
|
|
bool withAndroidFineLocation,
|
|
bool withAndroidBluetoothAdvertise,
|
|
) async {
|
|
final pigeonVar_channelName =
|
|
'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.requestPermissions$pigeonVar_messageChannelSuffix';
|
|
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
|
pigeonVar_channelName,
|
|
pigeonChannelCodec,
|
|
binaryMessenger: pigeonVar_binaryMessenger,
|
|
);
|
|
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(
|
|
<Object?>[withAndroidFineLocation, withAndroidBluetoothAdvertise],
|
|
);
|
|
final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;
|
|
|
|
_extractReplyValueOrThrow(
|
|
pigeonVar_replyList,
|
|
pigeonVar_channelName,
|
|
isNullValid: true,
|
|
);
|
|
}
|
|
|
|
Future<bool> enableBluetooth() async {
|
|
final pigeonVar_channelName =
|
|
'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.enableBluetooth$pigeonVar_messageChannelSuffix';
|
|
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
|
pigeonVar_channelName,
|
|
pigeonChannelCodec,
|
|
binaryMessenger: pigeonVar_binaryMessenger,
|
|
);
|
|
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(null);
|
|
final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;
|
|
|
|
final Object? pigeonVar_replyValue = _extractReplyValueOrThrow(
|
|
pigeonVar_replyList,
|
|
pigeonVar_channelName,
|
|
isNullValid: false,
|
|
);
|
|
return pigeonVar_replyValue! as bool;
|
|
}
|
|
|
|
Future<bool> disableBluetooth() async {
|
|
final pigeonVar_channelName =
|
|
'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.disableBluetooth$pigeonVar_messageChannelSuffix';
|
|
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
|
pigeonVar_channelName,
|
|
pigeonChannelCodec,
|
|
binaryMessenger: pigeonVar_binaryMessenger,
|
|
);
|
|
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(null);
|
|
final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;
|
|
|
|
final Object? pigeonVar_replyValue = _extractReplyValueOrThrow(
|
|
pigeonVar_replyList,
|
|
pigeonVar_channelName,
|
|
isNullValid: false,
|
|
);
|
|
return pigeonVar_replyValue! as bool;
|
|
}
|
|
|
|
Future<void> startScan(
|
|
UniversalScanFilter? filter,
|
|
UniversalScanConfig? config,
|
|
) async {
|
|
final pigeonVar_channelName =
|
|
'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.startScan$pigeonVar_messageChannelSuffix';
|
|
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
|
pigeonVar_channelName,
|
|
pigeonChannelCodec,
|
|
binaryMessenger: pigeonVar_binaryMessenger,
|
|
);
|
|
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(
|
|
<Object?>[filter, config],
|
|
);
|
|
final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;
|
|
|
|
_extractReplyValueOrThrow(
|
|
pigeonVar_replyList,
|
|
pigeonVar_channelName,
|
|
isNullValid: true,
|
|
);
|
|
}
|
|
|
|
Future<void> stopScan() async {
|
|
final pigeonVar_channelName =
|
|
'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.stopScan$pigeonVar_messageChannelSuffix';
|
|
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
|
pigeonVar_channelName,
|
|
pigeonChannelCodec,
|
|
binaryMessenger: pigeonVar_binaryMessenger,
|
|
);
|
|
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(null);
|
|
final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;
|
|
|
|
_extractReplyValueOrThrow(
|
|
pigeonVar_replyList,
|
|
pigeonVar_channelName,
|
|
isNullValid: true,
|
|
);
|
|
}
|
|
|
|
Future<bool> isScanning() async {
|
|
final pigeonVar_channelName =
|
|
'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.isScanning$pigeonVar_messageChannelSuffix';
|
|
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
|
pigeonVar_channelName,
|
|
pigeonChannelCodec,
|
|
binaryMessenger: pigeonVar_binaryMessenger,
|
|
);
|
|
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(null);
|
|
final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;
|
|
|
|
final Object? pigeonVar_replyValue = _extractReplyValueOrThrow(
|
|
pigeonVar_replyList,
|
|
pigeonVar_channelName,
|
|
isNullValid: false,
|
|
);
|
|
return pigeonVar_replyValue! as bool;
|
|
}
|
|
|
|
Future<void> connect(String deviceId, {bool? autoConnect}) async {
|
|
final pigeonVar_channelName =
|
|
'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.connect$pigeonVar_messageChannelSuffix';
|
|
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
|
pigeonVar_channelName,
|
|
pigeonChannelCodec,
|
|
binaryMessenger: pigeonVar_binaryMessenger,
|
|
);
|
|
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(
|
|
<Object?>[deviceId, autoConnect],
|
|
);
|
|
final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;
|
|
|
|
_extractReplyValueOrThrow(
|
|
pigeonVar_replyList,
|
|
pigeonVar_channelName,
|
|
isNullValid: true,
|
|
);
|
|
}
|
|
|
|
Future<void> disconnect(String deviceId) async {
|
|
final pigeonVar_channelName =
|
|
'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.disconnect$pigeonVar_messageChannelSuffix';
|
|
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
|
pigeonVar_channelName,
|
|
pigeonChannelCodec,
|
|
binaryMessenger: pigeonVar_binaryMessenger,
|
|
);
|
|
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(
|
|
<Object?>[deviceId],
|
|
);
|
|
final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;
|
|
|
|
_extractReplyValueOrThrow(
|
|
pigeonVar_replyList,
|
|
pigeonVar_channelName,
|
|
isNullValid: true,
|
|
);
|
|
}
|
|
|
|
Future<void> setNotifiable(
|
|
String deviceId,
|
|
String service,
|
|
String characteristic,
|
|
int bleInputProperty,
|
|
) async {
|
|
final pigeonVar_channelName =
|
|
'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.setNotifiable$pigeonVar_messageChannelSuffix';
|
|
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
|
pigeonVar_channelName,
|
|
pigeonChannelCodec,
|
|
binaryMessenger: pigeonVar_binaryMessenger,
|
|
);
|
|
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(
|
|
<Object?>[deviceId, service, characteristic, bleInputProperty],
|
|
);
|
|
final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;
|
|
|
|
_extractReplyValueOrThrow(
|
|
pigeonVar_replyList,
|
|
pigeonVar_channelName,
|
|
isNullValid: true,
|
|
);
|
|
}
|
|
|
|
Future<List<UniversalBleService>> discoverServices(
|
|
String deviceId,
|
|
bool withDescriptors,
|
|
) async {
|
|
final pigeonVar_channelName =
|
|
'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.discoverServices$pigeonVar_messageChannelSuffix';
|
|
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
|
pigeonVar_channelName,
|
|
pigeonChannelCodec,
|
|
binaryMessenger: pigeonVar_binaryMessenger,
|
|
);
|
|
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(
|
|
<Object?>[deviceId, withDescriptors],
|
|
);
|
|
final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;
|
|
|
|
final Object? pigeonVar_replyValue = _extractReplyValueOrThrow(
|
|
pigeonVar_replyList,
|
|
pigeonVar_channelName,
|
|
isNullValid: false,
|
|
);
|
|
return (pigeonVar_replyValue! as List<Object?>).cast<UniversalBleService>();
|
|
}
|
|
|
|
Future<Uint8List> readValue(
|
|
String deviceId,
|
|
String service,
|
|
String characteristic,
|
|
) async {
|
|
final pigeonVar_channelName =
|
|
'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.readValue$pigeonVar_messageChannelSuffix';
|
|
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
|
pigeonVar_channelName,
|
|
pigeonChannelCodec,
|
|
binaryMessenger: pigeonVar_binaryMessenger,
|
|
);
|
|
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(
|
|
<Object?>[deviceId, service, characteristic],
|
|
);
|
|
final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;
|
|
|
|
final Object? pigeonVar_replyValue = _extractReplyValueOrThrow(
|
|
pigeonVar_replyList,
|
|
pigeonVar_channelName,
|
|
isNullValid: false,
|
|
);
|
|
return pigeonVar_replyValue! as Uint8List;
|
|
}
|
|
|
|
Future<int> requestMtu(String deviceId, int expectedMtu) async {
|
|
final pigeonVar_channelName =
|
|
'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.requestMtu$pigeonVar_messageChannelSuffix';
|
|
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
|
pigeonVar_channelName,
|
|
pigeonChannelCodec,
|
|
binaryMessenger: pigeonVar_binaryMessenger,
|
|
);
|
|
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(
|
|
<Object?>[deviceId, expectedMtu],
|
|
);
|
|
final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;
|
|
|
|
final Object? pigeonVar_replyValue = _extractReplyValueOrThrow(
|
|
pigeonVar_replyList,
|
|
pigeonVar_channelName,
|
|
isNullValid: false,
|
|
);
|
|
return pigeonVar_replyValue! as int;
|
|
}
|
|
|
|
Future<void> writeValue(
|
|
String deviceId,
|
|
String service,
|
|
String characteristic,
|
|
Uint8List value,
|
|
int bleOutputProperty,
|
|
) async {
|
|
final pigeonVar_channelName =
|
|
'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.writeValue$pigeonVar_messageChannelSuffix';
|
|
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
|
pigeonVar_channelName,
|
|
pigeonChannelCodec,
|
|
binaryMessenger: pigeonVar_binaryMessenger,
|
|
);
|
|
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(
|
|
<Object?>[deviceId, service, characteristic, value, bleOutputProperty],
|
|
);
|
|
final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;
|
|
|
|
_extractReplyValueOrThrow(
|
|
pigeonVar_replyList,
|
|
pigeonVar_channelName,
|
|
isNullValid: true,
|
|
);
|
|
}
|
|
|
|
Future<bool> isPaired(String deviceId) async {
|
|
final pigeonVar_channelName =
|
|
'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.isPaired$pigeonVar_messageChannelSuffix';
|
|
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
|
pigeonVar_channelName,
|
|
pigeonChannelCodec,
|
|
binaryMessenger: pigeonVar_binaryMessenger,
|
|
);
|
|
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(
|
|
<Object?>[deviceId],
|
|
);
|
|
final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;
|
|
|
|
final Object? pigeonVar_replyValue = _extractReplyValueOrThrow(
|
|
pigeonVar_replyList,
|
|
pigeonVar_channelName,
|
|
isNullValid: false,
|
|
);
|
|
return pigeonVar_replyValue! as bool;
|
|
}
|
|
|
|
Future<bool> pair(String deviceId) async {
|
|
final pigeonVar_channelName =
|
|
'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.pair$pigeonVar_messageChannelSuffix';
|
|
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
|
pigeonVar_channelName,
|
|
pigeonChannelCodec,
|
|
binaryMessenger: pigeonVar_binaryMessenger,
|
|
);
|
|
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(
|
|
<Object?>[deviceId],
|
|
);
|
|
final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;
|
|
|
|
final Object? pigeonVar_replyValue = _extractReplyValueOrThrow(
|
|
pigeonVar_replyList,
|
|
pigeonVar_channelName,
|
|
isNullValid: false,
|
|
);
|
|
return pigeonVar_replyValue! as bool;
|
|
}
|
|
|
|
Future<void> unPair(String deviceId) async {
|
|
final pigeonVar_channelName =
|
|
'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.unPair$pigeonVar_messageChannelSuffix';
|
|
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
|
pigeonVar_channelName,
|
|
pigeonChannelCodec,
|
|
binaryMessenger: pigeonVar_binaryMessenger,
|
|
);
|
|
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(
|
|
<Object?>[deviceId],
|
|
);
|
|
final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;
|
|
|
|
_extractReplyValueOrThrow(
|
|
pigeonVar_replyList,
|
|
pigeonVar_channelName,
|
|
isNullValid: true,
|
|
);
|
|
}
|
|
|
|
Future<List<UniversalBleScanResult>> getSystemDevices(
|
|
List<String> withServices,
|
|
) async {
|
|
final pigeonVar_channelName =
|
|
'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.getSystemDevices$pigeonVar_messageChannelSuffix';
|
|
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
|
pigeonVar_channelName,
|
|
pigeonChannelCodec,
|
|
binaryMessenger: pigeonVar_binaryMessenger,
|
|
);
|
|
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(
|
|
<Object?>[withServices],
|
|
);
|
|
final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;
|
|
|
|
final Object? pigeonVar_replyValue = _extractReplyValueOrThrow(
|
|
pigeonVar_replyList,
|
|
pigeonVar_channelName,
|
|
isNullValid: false,
|
|
);
|
|
return (pigeonVar_replyValue! as List<Object?>)
|
|
.cast<UniversalBleScanResult>();
|
|
}
|
|
|
|
Future<int> getConnectionState(String deviceId) async {
|
|
final pigeonVar_channelName =
|
|
'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.getConnectionState$pigeonVar_messageChannelSuffix';
|
|
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
|
pigeonVar_channelName,
|
|
pigeonChannelCodec,
|
|
binaryMessenger: pigeonVar_binaryMessenger,
|
|
);
|
|
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(
|
|
<Object?>[deviceId],
|
|
);
|
|
final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;
|
|
|
|
final Object? pigeonVar_replyValue = _extractReplyValueOrThrow(
|
|
pigeonVar_replyList,
|
|
pigeonVar_channelName,
|
|
isNullValid: false,
|
|
);
|
|
return pigeonVar_replyValue! as int;
|
|
}
|
|
|
|
Future<int> readRssi(String deviceId) async {
|
|
final pigeonVar_channelName =
|
|
'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.readRssi$pigeonVar_messageChannelSuffix';
|
|
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
|
pigeonVar_channelName,
|
|
pigeonChannelCodec,
|
|
binaryMessenger: pigeonVar_binaryMessenger,
|
|
);
|
|
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(
|
|
<Object?>[deviceId],
|
|
);
|
|
final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;
|
|
|
|
final Object? pigeonVar_replyValue = _extractReplyValueOrThrow(
|
|
pigeonVar_replyList,
|
|
pigeonVar_channelName,
|
|
isNullValid: false,
|
|
);
|
|
return pigeonVar_replyValue! as int;
|
|
}
|
|
|
|
Future<void> requestConnectionPriority(String deviceId, int priority) async {
|
|
final pigeonVar_channelName =
|
|
'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.requestConnectionPriority$pigeonVar_messageChannelSuffix';
|
|
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
|
pigeonVar_channelName,
|
|
pigeonChannelCodec,
|
|
binaryMessenger: pigeonVar_binaryMessenger,
|
|
);
|
|
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(
|
|
<Object?>[deviceId, priority],
|
|
);
|
|
final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;
|
|
|
|
_extractReplyValueOrThrow(
|
|
pigeonVar_replyList,
|
|
pigeonVar_channelName,
|
|
isNullValid: true,
|
|
);
|
|
}
|
|
|
|
Future<bool> isPeripheralSupported() async {
|
|
final pigeonVar_channelName =
|
|
'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.isPeripheralSupported$pigeonVar_messageChannelSuffix';
|
|
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
|
pigeonVar_channelName,
|
|
pigeonChannelCodec,
|
|
binaryMessenger: pigeonVar_binaryMessenger,
|
|
);
|
|
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(null);
|
|
final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;
|
|
|
|
final Object? pigeonVar_replyValue = _extractReplyValueOrThrow(
|
|
pigeonVar_replyList,
|
|
pigeonVar_channelName,
|
|
isNullValid: false,
|
|
);
|
|
return pigeonVar_replyValue! as bool;
|
|
}
|
|
|
|
Future<void> startPeripheral(UniversalBlePeripheralConfig config) async {
|
|
final pigeonVar_channelName =
|
|
'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.startPeripheral$pigeonVar_messageChannelSuffix';
|
|
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
|
pigeonVar_channelName,
|
|
pigeonChannelCodec,
|
|
binaryMessenger: pigeonVar_binaryMessenger,
|
|
);
|
|
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(
|
|
<Object?>[config],
|
|
);
|
|
final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;
|
|
|
|
_extractReplyValueOrThrow(
|
|
pigeonVar_replyList,
|
|
pigeonVar_channelName,
|
|
isNullValid: true,
|
|
);
|
|
}
|
|
|
|
Future<void> stopPeripheral() async {
|
|
final pigeonVar_channelName =
|
|
'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.stopPeripheral$pigeonVar_messageChannelSuffix';
|
|
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
|
pigeonVar_channelName,
|
|
pigeonChannelCodec,
|
|
binaryMessenger: pigeonVar_binaryMessenger,
|
|
);
|
|
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(null);
|
|
final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;
|
|
|
|
_extractReplyValueOrThrow(
|
|
pigeonVar_replyList,
|
|
pigeonVar_channelName,
|
|
isNullValid: true,
|
|
);
|
|
}
|
|
|
|
Future<void> updatePeripheralCharacteristicValue(
|
|
String service,
|
|
String characteristic,
|
|
Uint8List value,
|
|
) async {
|
|
final pigeonVar_channelName =
|
|
'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.updatePeripheralCharacteristicValue$pigeonVar_messageChannelSuffix';
|
|
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
|
pigeonVar_channelName,
|
|
pigeonChannelCodec,
|
|
binaryMessenger: pigeonVar_binaryMessenger,
|
|
);
|
|
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(
|
|
<Object?>[service, characteristic, value],
|
|
);
|
|
final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;
|
|
|
|
_extractReplyValueOrThrow(
|
|
pigeonVar_replyList,
|
|
pigeonVar_channelName,
|
|
isNullValid: true,
|
|
);
|
|
}
|
|
|
|
Future<void> notifyPeripheralCharacteristic(
|
|
String service,
|
|
String characteristic,
|
|
Uint8List value,
|
|
bool indicate,
|
|
) async {
|
|
final pigeonVar_channelName =
|
|
'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.notifyPeripheralCharacteristic$pigeonVar_messageChannelSuffix';
|
|
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
|
pigeonVar_channelName,
|
|
pigeonChannelCodec,
|
|
binaryMessenger: pigeonVar_binaryMessenger,
|
|
);
|
|
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(
|
|
<Object?>[service, characteristic, value, indicate],
|
|
);
|
|
final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;
|
|
|
|
_extractReplyValueOrThrow(
|
|
pigeonVar_replyList,
|
|
pigeonVar_channelName,
|
|
isNullValid: true,
|
|
);
|
|
}
|
|
|
|
Future<void> setLogLevel(UniversalBleLogLevel logLevel) async {
|
|
final pigeonVar_channelName =
|
|
'dev.flutter.pigeon.universal_ble.UniversalBlePlatformChannel.setLogLevel$pigeonVar_messageChannelSuffix';
|
|
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
|
pigeonVar_channelName,
|
|
pigeonChannelCodec,
|
|
binaryMessenger: pigeonVar_binaryMessenger,
|
|
);
|
|
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(
|
|
<Object?>[logLevel],
|
|
);
|
|
final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;
|
|
|
|
_extractReplyValueOrThrow(
|
|
pigeonVar_replyList,
|
|
pigeonVar_channelName,
|
|
isNullValid: true,
|
|
);
|
|
}
|
|
}
|
|
|
|
/// Native -> Flutter
|
|
abstract class UniversalBleCallbackChannel {
|
|
static const MessageCodec<Object?> pigeonChannelCodec = _PigeonCodec();
|
|
|
|
void onAvailabilityChanged(int state);
|
|
|
|
void onPairStateChange(String deviceId, bool isPaired, String? error);
|
|
|
|
void onScanResult(UniversalBleScanResult result);
|
|
|
|
void onValueChanged(
|
|
String deviceId,
|
|
String characteristicId,
|
|
Uint8List value,
|
|
int? timestamp,
|
|
);
|
|
|
|
void onConnectionChanged(String deviceId, bool connected, String? error);
|
|
|
|
void onPeripheralConnectionChanged(String deviceId, bool connected);
|
|
|
|
void onPeripheralWrite(UniversalBlePeripheralWriteEvent event);
|
|
|
|
void onPeripheralSubscriptionChanged(
|
|
String deviceId,
|
|
String service,
|
|
String characteristic,
|
|
bool subscribed,
|
|
);
|
|
|
|
static void setUp(
|
|
UniversalBleCallbackChannel? api, {
|
|
BinaryMessenger? binaryMessenger,
|
|
String messageChannelSuffix = '',
|
|
}) {
|
|
messageChannelSuffix = messageChannelSuffix.isNotEmpty
|
|
? '.$messageChannelSuffix'
|
|
: '';
|
|
{
|
|
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
|
'dev.flutter.pigeon.universal_ble.UniversalBleCallbackChannel.onAvailabilityChanged$messageChannelSuffix',
|
|
pigeonChannelCodec,
|
|
binaryMessenger: binaryMessenger,
|
|
);
|
|
if (api == null) {
|
|
pigeonVar_channel.setMessageHandler(null);
|
|
} else {
|
|
pigeonVar_channel.setMessageHandler((Object? message) async {
|
|
final List<Object?> args = message! as List<Object?>;
|
|
final int arg_state = args[0]! as int;
|
|
try {
|
|
api.onAvailabilityChanged(arg_state);
|
|
return wrapResponse(empty: true);
|
|
} on PlatformException catch (e) {
|
|
return wrapResponse(error: e);
|
|
} catch (e) {
|
|
return wrapResponse(
|
|
error: PlatformException(code: 'error', message: e.toString()),
|
|
);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
{
|
|
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
|
'dev.flutter.pigeon.universal_ble.UniversalBleCallbackChannel.onPairStateChange$messageChannelSuffix',
|
|
pigeonChannelCodec,
|
|
binaryMessenger: binaryMessenger,
|
|
);
|
|
if (api == null) {
|
|
pigeonVar_channel.setMessageHandler(null);
|
|
} else {
|
|
pigeonVar_channel.setMessageHandler((Object? message) async {
|
|
final List<Object?> args = message! as List<Object?>;
|
|
final String arg_deviceId = args[0]! as String;
|
|
final bool arg_isPaired = args[1]! as bool;
|
|
final String? arg_error = args[2] as String?;
|
|
try {
|
|
api.onPairStateChange(arg_deviceId, arg_isPaired, arg_error);
|
|
return wrapResponse(empty: true);
|
|
} on PlatformException catch (e) {
|
|
return wrapResponse(error: e);
|
|
} catch (e) {
|
|
return wrapResponse(
|
|
error: PlatformException(code: 'error', message: e.toString()),
|
|
);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
{
|
|
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
|
'dev.flutter.pigeon.universal_ble.UniversalBleCallbackChannel.onScanResult$messageChannelSuffix',
|
|
pigeonChannelCodec,
|
|
binaryMessenger: binaryMessenger,
|
|
);
|
|
if (api == null) {
|
|
pigeonVar_channel.setMessageHandler(null);
|
|
} else {
|
|
pigeonVar_channel.setMessageHandler((Object? message) async {
|
|
final List<Object?> args = message! as List<Object?>;
|
|
final UniversalBleScanResult arg_result =
|
|
args[0]! as UniversalBleScanResult;
|
|
try {
|
|
api.onScanResult(arg_result);
|
|
return wrapResponse(empty: true);
|
|
} on PlatformException catch (e) {
|
|
return wrapResponse(error: e);
|
|
} catch (e) {
|
|
return wrapResponse(
|
|
error: PlatformException(code: 'error', message: e.toString()),
|
|
);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
{
|
|
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
|
'dev.flutter.pigeon.universal_ble.UniversalBleCallbackChannel.onValueChanged$messageChannelSuffix',
|
|
pigeonChannelCodec,
|
|
binaryMessenger: binaryMessenger,
|
|
);
|
|
if (api == null) {
|
|
pigeonVar_channel.setMessageHandler(null);
|
|
} else {
|
|
pigeonVar_channel.setMessageHandler((Object? message) async {
|
|
final List<Object?> args = message! as List<Object?>;
|
|
final String arg_deviceId = args[0]! as String;
|
|
final String arg_characteristicId = args[1]! as String;
|
|
final Uint8List arg_value = args[2]! as Uint8List;
|
|
final int? arg_timestamp = args[3] as int?;
|
|
try {
|
|
api.onValueChanged(
|
|
arg_deviceId,
|
|
arg_characteristicId,
|
|
arg_value,
|
|
arg_timestamp,
|
|
);
|
|
return wrapResponse(empty: true);
|
|
} on PlatformException catch (e) {
|
|
return wrapResponse(error: e);
|
|
} catch (e) {
|
|
return wrapResponse(
|
|
error: PlatformException(code: 'error', message: e.toString()),
|
|
);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
{
|
|
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
|
'dev.flutter.pigeon.universal_ble.UniversalBleCallbackChannel.onConnectionChanged$messageChannelSuffix',
|
|
pigeonChannelCodec,
|
|
binaryMessenger: binaryMessenger,
|
|
);
|
|
if (api == null) {
|
|
pigeonVar_channel.setMessageHandler(null);
|
|
} else {
|
|
pigeonVar_channel.setMessageHandler((Object? message) async {
|
|
final List<Object?> args = message! as List<Object?>;
|
|
final String arg_deviceId = args[0]! as String;
|
|
final bool arg_connected = args[1]! as bool;
|
|
final String? arg_error = args[2] as String?;
|
|
try {
|
|
api.onConnectionChanged(arg_deviceId, arg_connected, arg_error);
|
|
return wrapResponse(empty: true);
|
|
} on PlatformException catch (e) {
|
|
return wrapResponse(error: e);
|
|
} catch (e) {
|
|
return wrapResponse(
|
|
error: PlatformException(code: 'error', message: e.toString()),
|
|
);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
{
|
|
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
|
'dev.flutter.pigeon.universal_ble.UniversalBleCallbackChannel.onPeripheralConnectionChanged$messageChannelSuffix',
|
|
pigeonChannelCodec,
|
|
binaryMessenger: binaryMessenger,
|
|
);
|
|
if (api == null) {
|
|
pigeonVar_channel.setMessageHandler(null);
|
|
} else {
|
|
pigeonVar_channel.setMessageHandler((Object? message) async {
|
|
final List<Object?> args = message! as List<Object?>;
|
|
final String arg_deviceId = args[0]! as String;
|
|
final bool arg_connected = args[1]! as bool;
|
|
try {
|
|
api.onPeripheralConnectionChanged(arg_deviceId, arg_connected);
|
|
return wrapResponse(empty: true);
|
|
} on PlatformException catch (e) {
|
|
return wrapResponse(error: e);
|
|
} catch (e) {
|
|
return wrapResponse(
|
|
error: PlatformException(code: 'error', message: e.toString()),
|
|
);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
{
|
|
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
|
'dev.flutter.pigeon.universal_ble.UniversalBleCallbackChannel.onPeripheralWrite$messageChannelSuffix',
|
|
pigeonChannelCodec,
|
|
binaryMessenger: binaryMessenger,
|
|
);
|
|
if (api == null) {
|
|
pigeonVar_channel.setMessageHandler(null);
|
|
} else {
|
|
pigeonVar_channel.setMessageHandler((Object? message) async {
|
|
final List<Object?> args = message! as List<Object?>;
|
|
final UniversalBlePeripheralWriteEvent arg_event =
|
|
args[0]! as UniversalBlePeripheralWriteEvent;
|
|
try {
|
|
api.onPeripheralWrite(arg_event);
|
|
return wrapResponse(empty: true);
|
|
} on PlatformException catch (e) {
|
|
return wrapResponse(error: e);
|
|
} catch (e) {
|
|
return wrapResponse(
|
|
error: PlatformException(code: 'error', message: e.toString()),
|
|
);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
{
|
|
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
|
'dev.flutter.pigeon.universal_ble.UniversalBleCallbackChannel.onPeripheralSubscriptionChanged$messageChannelSuffix',
|
|
pigeonChannelCodec,
|
|
binaryMessenger: binaryMessenger,
|
|
);
|
|
if (api == null) {
|
|
pigeonVar_channel.setMessageHandler(null);
|
|
} else {
|
|
pigeonVar_channel.setMessageHandler((Object? message) async {
|
|
final List<Object?> args = message! as List<Object?>;
|
|
final String arg_deviceId = args[0]! as String;
|
|
final String arg_service = args[1]! as String;
|
|
final String arg_characteristic = args[2]! as String;
|
|
final bool arg_subscribed = args[3]! as bool;
|
|
try {
|
|
api.onPeripheralSubscriptionChanged(
|
|
arg_deviceId,
|
|
arg_service,
|
|
arg_characteristic,
|
|
arg_subscribed,
|
|
);
|
|
return wrapResponse(empty: true);
|
|
} on PlatformException catch (e) {
|
|
return wrapResponse(error: e);
|
|
} catch (e) {
|
|
return wrapResponse(
|
|
error: PlatformException(code: 'error', message: e.toString()),
|
|
);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|