* fix: 重构

* fix: 1

* fix: 重构

* fix: 修复 iOS 和 macOS 代码错误

* fix: 优化项目

* fix: 构建项目

* fix: 修复权限问题

* fix: 解决 macOS 沙盒权限问题

* fix: 修复代码问题

* fix: 更新依赖

* fix: 更新依赖项

* fix: 添加缺失的位置权限
This commit is contained in:
Mr剑侠客
2023-08-21 01:06:57 +08:00
committed by GitHub
parent 689b1fb045
commit 0f4fb7f553
127 changed files with 560 additions and 3693 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.vscode/
.DS_Store

View File

@ -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: 682aa387cfe4fbd71ccd5418b2c2a075729a1c66
channel: stable
revision: "efbf63d9c66b9f6ec30e9ad4611189aa80003d31"
channel: "stable"
project_type: plugin
@ -13,23 +13,8 @@ project_type: plugin
migration:
platforms:
- platform: root
create_revision: 682aa387cfe4fbd71ccd5418b2c2a075729a1c66
base_revision: 682aa387cfe4fbd71ccd5418b2c2a075729a1c66
- platform: android
create_revision: 682aa387cfe4fbd71ccd5418b2c2a075729a1c66
base_revision: 682aa387cfe4fbd71ccd5418b2c2a075729a1c66
- platform: ios
create_revision: 682aa387cfe4fbd71ccd5418b2c2a075729a1c66
base_revision: 682aa387cfe4fbd71ccd5418b2c2a075729a1c66
- platform: linux
create_revision: 682aa387cfe4fbd71ccd5418b2c2a075729a1c66
base_revision: 682aa387cfe4fbd71ccd5418b2c2a075729a1c66
- platform: macos
create_revision: 682aa387cfe4fbd71ccd5418b2c2a075729a1c66
base_revision: 682aa387cfe4fbd71ccd5418b2c2a075729a1c66
- platform: windows
create_revision: 682aa387cfe4fbd71ccd5418b2c2a075729a1c66
base_revision: 682aa387cfe4fbd71ccd5418b2c2a075729a1c66
create_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31
base_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31
# User provided section

View File

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

View File

@ -13,8 +13,7 @@ linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at
# https://dart-lang.github.io/linter/lints/index.html.
# and their documentation is published at https://dart.dev/lints.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code

View File

@ -1,3 +1,9 @@
plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
}
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
@ -6,11 +12,6 @@ if (localPropertiesFile.exists()) {
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
@ -21,10 +22,6 @@ if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
namespace "dev.yanshouwang.bluetooth_low_energy_example"
compileSdkVersion flutter.compileSdkVersion
@ -68,6 +65,4 @@ flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
dependencies {}

View File

@ -1,11 +1,20 @@
include ':app'
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
pluginManagement {
def flutterSdkPath = {
def properties = new Properties()
assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
file("local.properties").withInputStream { properties.load(it) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
return flutterSdkPath
}
settings.ext.flutterSdkPath = flutterSdkPath()
includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle")
plugins {
id "dev.flutter.flutter-gradle-plugin" version "1.0.0" apply false
}
}
include ":app"
apply from: "${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle/app_plugin_loader.gradle"

View File

@ -14,10 +14,11 @@ import 'package:bluetooth_low_energy/bluetooth_low_energy.dart';
void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
testWidgets('getPlatformVersion test', (WidgetTester tester) async {
final centralController = CentralController.instance;
await centralController.setUp();
// The version string depends on the host platform running the test, so
// just assert that some non-empty string is returned.
});
// testWidgets('getPlatformVersion test', (WidgetTester tester) async {
// final BluetoothLowEnergy plugin = BluetoothLowEnergy();
// final String? version = await plugin.getPlatformVersion();
// // The version string depends on the host platform running the test, so
// // just assert that some non-empty string is returned.
// expect(version?.isNotEmpty, true);
// });
}

View File

@ -1,25 +1,26 @@
PODS:
- bluetooth_low_energy_ios (0.0.1):
- bluetooth_low_energy_darwin (2.0.2):
- Flutter
- FlutterMacOS
- Flutter (1.0.0)
- integration_test (0.0.1):
- Flutter
DEPENDENCIES:
- bluetooth_low_energy_ios (from `.symlinks/plugins/bluetooth_low_energy_ios/ios`)
- bluetooth_low_energy_darwin (from `.symlinks/plugins/bluetooth_low_energy_darwin/darwin`)
- Flutter (from `Flutter`)
- integration_test (from `.symlinks/plugins/integration_test/ios`)
EXTERNAL SOURCES:
bluetooth_low_energy_ios:
:path: ".symlinks/plugins/bluetooth_low_energy_ios/ios"
bluetooth_low_energy_darwin:
:path: ".symlinks/plugins/bluetooth_low_energy_darwin/darwin"
Flutter:
:path: Flutter
integration_test:
:path: ".symlinks/plugins/integration_test/ios"
SPEC CHECKSUMS:
bluetooth_low_energy_ios: 91a6dff92249a98d885a4a8b024b80738a3124f2
bluetooth_low_energy_darwin: e37c1af3337ebc99a60807137dc5e47c6195eac7
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
integration_test: 13825b8a9334a850581300559b8839134b124670

View File

@ -9,13 +9,13 @@
/* Begin PBXBuildFile section */
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; };
369342A832F5F7F47DA4170A /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 98646AC7896A9C8175156D38 /* Pods_Runner.framework */; };
34E52FEFFBA34148D7F4058F /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2353C45A2E0DF37667D194A1 /* Pods_Runner.framework */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
A1695FB5D643C19FF42B7D1B /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 439B7B71AF91617DD56EEFF1 /* Pods_RunnerTests.framework */; };
F6040B5AA5E5A63D395CB345 /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 076A35C4833796B0B42E0237 /* Pods_RunnerTests.framework */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@ -42,19 +42,21 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
03284B9B33BEA09EAC1AFD47 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
076A35C4833796B0B42E0237 /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
2353C45A2E0DF37667D194A1 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
331C807B294A618700263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = "<group>"; };
331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
38113858F1AB4328A9E0D621 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
4088D13267D2EE25F7EE3CCF /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = "<group>"; };
439B7B71AF91617DD56EEFF1 /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
67071827BD45B7E898C0774B /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
4BF6EEA10984CDD1A14F950F /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
54C98B3103488CA87E98A6F4 /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = "<group>"; };
710DD54C8BBDEA22C3F7F293 /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = "<group>"; };
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
8F0034913C0134B13451F847 /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = "<group>"; };
93DA77ACC45858A97F558838 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
@ -62,17 +64,15 @@
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
98646AC7896A9C8175156D38 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
A31C0685DD53747D3B81FC1C /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
FAF9D3328591BF2DE56D8B53 /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = "<group>"; };
9C6D6BDEFF4878166372D24A /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
4EEB0BF7ABB9FA0A8A0038DF /* Frameworks */ = {
6B5302E24483403072236BBB /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
A1695FB5D643C19FF42B7D1B /* Pods_RunnerTests.framework in Frameworks */,
F6040B5AA5E5A63D395CB345 /* Pods_RunnerTests.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -80,13 +80,22 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
369342A832F5F7F47DA4170A /* Pods_Runner.framework in Frameworks */,
34E52FEFFBA34148D7F4058F /* Pods_Runner.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
0FAACD3CD9E188E482384358 /* Frameworks */ = {
isa = PBXGroup;
children = (
2353C45A2E0DF37667D194A1 /* Pods_Runner.framework */,
076A35C4833796B0B42E0237 /* Pods_RunnerTests.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
331C8082294A63A400263BE5 /* RunnerTests */ = {
isa = PBXGroup;
children = (
@ -95,15 +104,15 @@
path = RunnerTests;
sourceTree = "<group>";
};
822F134A747E09F3777D7DEA /* Pods */ = {
3C9A3D0714D61C07F02BFBB4 /* Pods */ = {
isa = PBXGroup;
children = (
67071827BD45B7E898C0774B /* Pods-Runner.debug.xcconfig */,
38113858F1AB4328A9E0D621 /* Pods-Runner.release.xcconfig */,
A31C0685DD53747D3B81FC1C /* Pods-Runner.profile.xcconfig */,
4088D13267D2EE25F7EE3CCF /* Pods-RunnerTests.debug.xcconfig */,
8F0034913C0134B13451F847 /* Pods-RunnerTests.release.xcconfig */,
FAF9D3328591BF2DE56D8B53 /* Pods-RunnerTests.profile.xcconfig */,
93DA77ACC45858A97F558838 /* Pods-Runner.debug.xcconfig */,
4BF6EEA10984CDD1A14F950F /* Pods-Runner.release.xcconfig */,
03284B9B33BEA09EAC1AFD47 /* Pods-Runner.profile.xcconfig */,
9C6D6BDEFF4878166372D24A /* Pods-RunnerTests.debug.xcconfig */,
54C98B3103488CA87E98A6F4 /* Pods-RunnerTests.release.xcconfig */,
710DD54C8BBDEA22C3F7F293 /* Pods-RunnerTests.profile.xcconfig */,
);
path = Pods;
sourceTree = "<group>";
@ -126,8 +135,8 @@
97C146F01CF9000F007C117D /* Runner */,
97C146EF1CF9000F007C117D /* Products */,
331C8082294A63A400263BE5 /* RunnerTests */,
822F134A747E09F3777D7DEA /* Pods */,
C80FCE1738A3643721B199AA /* Frameworks */,
3C9A3D0714D61C07F02BFBB4 /* Pods */,
0FAACD3CD9E188E482384358 /* Frameworks */,
);
sourceTree = "<group>";
};
@ -155,15 +164,6 @@
path = Runner;
sourceTree = "<group>";
};
C80FCE1738A3643721B199AA /* Frameworks */ = {
isa = PBXGroup;
children = (
98646AC7896A9C8175156D38 /* Pods_Runner.framework */,
439B7B71AF91617DD56EEFF1 /* Pods_RunnerTests.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
@ -171,10 +171,10 @@
isa = PBXNativeTarget;
buildConfigurationList = 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */;
buildPhases = (
F833496E53FDE3C2844AFA53 /* [CP] Check Pods Manifest.lock */,
A3C3FEADF4EBF04832B143F6 /* [CP] Check Pods Manifest.lock */,
331C807D294A63A400263BE5 /* Sources */,
331C807F294A63A400263BE5 /* Resources */,
4EEB0BF7ABB9FA0A8A0038DF /* Frameworks */,
6B5302E24483403072236BBB /* Frameworks */,
);
buildRules = (
);
@ -190,14 +190,14 @@
isa = PBXNativeTarget;
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
buildPhases = (
1DA3D512A09A37D587233A2B /* [CP] Check Pods Manifest.lock */,
67E1A4356061A10A5EC11286 /* [CP] Check Pods Manifest.lock */,
9740EEB61CF901F6004384FC /* Run Script */,
97C146EA1CF9000F007C117D /* Sources */,
97C146EB1CF9000F007C117D /* Frameworks */,
97C146EC1CF9000F007C117D /* Resources */,
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
6130D1869ECFA87E05987AFE /* [CP] Embed Pods Frameworks */,
066C9063BC370AC8304B71D9 /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
@ -214,7 +214,8 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1300;
BuildIndependentTargetsInParallel = YES;
LastUpgradeCheck = 1430;
ORGANIZATIONNAME = "";
TargetAttributes = {
331C8080294A63A400263BE5 = {
@ -268,7 +269,40 @@
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
1DA3D512A09A37D587233A2B /* [CP] Check Pods Manifest.lock */ = {
066C9063BC370AC8304B71D9 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}",
);
name = "Thin Binary";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
};
67E1A4356061A10A5EC11286 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
@ -290,39 +324,6 @@
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}",
);
name = "Thin Binary";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
};
6130D1869ECFA87E05987AFE /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
@ -338,7 +339,7 @@
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
};
F833496E53FDE3C2844AFA53 /* [CP] Check Pods Manifest.lock */ = {
A3C3FEADF4EBF04832B143F6 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
@ -484,7 +485,7 @@
};
331C8088294A63A400263BE5 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 4088D13267D2EE25F7EE3CCF /* Pods-RunnerTests.debug.xcconfig */;
baseConfigurationReference = 9C6D6BDEFF4878166372D24A /* Pods-RunnerTests.debug.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
@ -502,7 +503,7 @@
};
331C8089294A63A400263BE5 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 8F0034913C0134B13451F847 /* Pods-RunnerTests.release.xcconfig */;
baseConfigurationReference = 54C98B3103488CA87E98A6F4 /* Pods-RunnerTests.release.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
@ -518,7 +519,7 @@
};
331C808A294A63A400263BE5 /* Profile */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = FAF9D3328591BF2DE56D8B53 /* Pods-RunnerTests.profile.xcconfig */;
baseConfigurationReference = 710DD54C8BBDEA22C3F7F293 /* Pods-RunnerTests.profile.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
LastUpgradeVersion = "1430"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

View File

@ -47,7 +47,5 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
</dict>
</plist>

View File

@ -5,8 +5,8 @@
import FlutterMacOS
import Foundation
import bluetooth_low_energy_macos
import bluetooth_low_energy_darwin
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
BluetoothLowEnergymacOS.register(with: registry.registrar(forPlugin: "BluetoothLowEnergymacOS"))
BluetoothLowEnergyDarwin.register(with: registry.registrar(forPlugin: "BluetoothLowEnergyDarwin"))
}

View File

@ -1,20 +1,21 @@
PODS:
- bluetooth_low_energy_macos (0.0.1):
- bluetooth_low_energy_darwin (2.0.2):
- Flutter
- FlutterMacOS
- FlutterMacOS (1.0.0)
DEPENDENCIES:
- bluetooth_low_energy_macos (from `Flutter/ephemeral/.symlinks/plugins/bluetooth_low_energy_macos/macos`)
- bluetooth_low_energy_darwin (from `Flutter/ephemeral/.symlinks/plugins/bluetooth_low_energy_darwin/darwin`)
- FlutterMacOS (from `Flutter/ephemeral`)
EXTERNAL SOURCES:
bluetooth_low_energy_macos:
:path: Flutter/ephemeral/.symlinks/plugins/bluetooth_low_energy_macos/macos
bluetooth_low_energy_darwin:
:path: Flutter/ephemeral/.symlinks/plugins/bluetooth_low_energy_darwin/darwin
FlutterMacOS:
:path: Flutter/ephemeral
SPEC CHECKSUMS:
bluetooth_low_energy_macos: d2722dc64693c937eecccb6bf0e84689b7d13990
bluetooth_low_energy_darwin: e37c1af3337ebc99a60807137dc5e47c6195eac7
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
PODFILE CHECKSUM: 236401fc2c932af29a9fcf0e97baeeb2d750d367

View File

@ -21,14 +21,14 @@
/* End PBXAggregateTarget section */
/* Begin PBXBuildFile section */
11E67697E2DFF348C5E0FBA6 /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 12AE3247A53A0A6C66A10AB1 /* Pods_RunnerTests.framework */; };
331C80D8294CF71000263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C80D7294CF71000263BE5 /* RunnerTests.swift */; };
335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */; };
33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC10F02044A3C60003C045 /* AppDelegate.swift */; };
33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; };
33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; };
33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; };
33CE7B97C678853E09EF58D9 /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5F2A7C4C98AC4208FDDA9ECE /* Pods_RunnerTests.framework */; };
D0655D46C4172378498F27F0 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5CE5350781EEC56C5A7B326E /* Pods_Runner.framework */; };
98831461FCCC0C712B565489 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7618EFBF5D56DEA9B5BC6858 /* Pods_Runner.framework */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@ -62,7 +62,9 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
08818FCFA3AD25DA4826A9B1 /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = "<group>"; };
032DEBF51E6D235331EAFB6D /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
12AE3247A53A0A6C66A10AB1 /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
2C73F6F52B9D612E7A3ED61B /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
331C80D5294CF71000263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
331C80D7294CF71000263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = "<group>"; };
333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = "<group>"; };
@ -79,15 +81,13 @@
33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = "<group>"; };
33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = "<group>"; };
33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = "<group>"; };
4FED463EB6DAAF306AA7409D /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = "<group>"; };
5CE5350781EEC56C5A7B326E /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
5F2A7C4C98AC4208FDDA9ECE /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
76A40A8A945A8E078EAA71A1 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
42843373A331898F762AE9FA /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = "<group>"; };
69A28A72349A6C45CE7FD12D /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
7618EFBF5D56DEA9B5BC6858 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = "<group>"; };
7F585ABB312A56C96CA02B4C /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = "<group>"; };
8406DF2F1C036588A3864C26 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
7F49A581B2FF1737F1557371 /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = "<group>"; };
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = "<group>"; };
9FF50575085F165BF8BD5429 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
BBBF70DBDF6B0B4E82F4E8A2 /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -95,7 +95,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
33CE7B97C678853E09EF58D9 /* Pods_RunnerTests.framework in Frameworks */,
11E67697E2DFF348C5E0FBA6 /* Pods_RunnerTests.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -103,26 +103,13 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
D0655D46C4172378498F27F0 /* Pods_Runner.framework in Frameworks */,
98831461FCCC0C712B565489 /* Pods_Runner.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
0ECA3FC2C896A4C67723C2B3 /* Pods */ = {
isa = PBXGroup;
children = (
76A40A8A945A8E078EAA71A1 /* Pods-Runner.debug.xcconfig */,
8406DF2F1C036588A3864C26 /* Pods-Runner.release.xcconfig */,
9FF50575085F165BF8BD5429 /* Pods-Runner.profile.xcconfig */,
7F585ABB312A56C96CA02B4C /* Pods-RunnerTests.debug.xcconfig */,
4FED463EB6DAAF306AA7409D /* Pods-RunnerTests.release.xcconfig */,
08818FCFA3AD25DA4826A9B1 /* Pods-RunnerTests.profile.xcconfig */,
);
path = Pods;
sourceTree = "<group>";
};
331C80D6294CF71000263BE5 /* RunnerTests */ = {
isa = PBXGroup;
children = (
@ -150,7 +137,7 @@
331C80D6294CF71000263BE5 /* RunnerTests */,
33CC10EE2044A3C60003C045 /* Products */,
D73912EC22F37F3D000D13A0 /* Frameworks */,
0ECA3FC2C896A4C67723C2B3 /* Pods */,
5413C8972DC878C53291A3D1 /* Pods */,
);
sourceTree = "<group>";
};
@ -198,11 +185,24 @@
path = Runner;
sourceTree = "<group>";
};
5413C8972DC878C53291A3D1 /* Pods */ = {
isa = PBXGroup;
children = (
2C73F6F52B9D612E7A3ED61B /* Pods-Runner.debug.xcconfig */,
69A28A72349A6C45CE7FD12D /* Pods-Runner.release.xcconfig */,
032DEBF51E6D235331EAFB6D /* Pods-Runner.profile.xcconfig */,
42843373A331898F762AE9FA /* Pods-RunnerTests.debug.xcconfig */,
7F49A581B2FF1737F1557371 /* Pods-RunnerTests.release.xcconfig */,
BBBF70DBDF6B0B4E82F4E8A2 /* Pods-RunnerTests.profile.xcconfig */,
);
path = Pods;
sourceTree = "<group>";
};
D73912EC22F37F3D000D13A0 /* Frameworks */ = {
isa = PBXGroup;
children = (
5CE5350781EEC56C5A7B326E /* Pods_Runner.framework */,
5F2A7C4C98AC4208FDDA9ECE /* Pods_RunnerTests.framework */,
7618EFBF5D56DEA9B5BC6858 /* Pods_Runner.framework */,
12AE3247A53A0A6C66A10AB1 /* Pods_RunnerTests.framework */,
);
name = Frameworks;
sourceTree = "<group>";
@ -214,7 +214,7 @@
isa = PBXNativeTarget;
buildConfigurationList = 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */;
buildPhases = (
A548F4D04C3E24479BB698BE /* [CP] Check Pods Manifest.lock */,
1AB4F7EB04EA489C9D3447CC /* [CP] Check Pods Manifest.lock */,
331C80D1294CF70F00263BE5 /* Sources */,
331C80D2294CF70F00263BE5 /* Frameworks */,
331C80D3294CF70F00263BE5 /* Resources */,
@ -233,13 +233,13 @@
isa = PBXNativeTarget;
buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */;
buildPhases = (
1574A0DEAF72C4DDCEDE693B /* [CP] Check Pods Manifest.lock */,
B609B32CB0330D926A7BF173 /* [CP] Check Pods Manifest.lock */,
33CC10E92044A3C60003C045 /* Sources */,
33CC10EA2044A3C60003C045 /* Frameworks */,
33CC10EB2044A3C60003C045 /* Resources */,
33CC110E2044A8840003C045 /* Bundle Framework */,
3399D490228B24CF009A79C7 /* ShellScript */,
96E7733803072B7333093533 /* [CP] Embed Pods Frameworks */,
C553F2A78B180316DDD47899 /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
@ -258,7 +258,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0920;
LastUpgradeCheck = 1300;
LastUpgradeCheck = 1430;
ORGANIZATIONNAME = "";
TargetAttributes = {
331C80D4294CF70F00263BE5 = {
@ -321,7 +321,7 @@
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
1574A0DEAF72C4DDCEDE693B /* [CP] Check Pods Manifest.lock */ = {
1AB4F7EB04EA489C9D3447CC /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
@ -336,7 +336,7 @@
outputFileListPaths = (
);
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
"$(DERIVED_FILE_DIR)/Pods-RunnerTests-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
@ -381,24 +381,7 @@
shellPath = /bin/sh;
shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire";
};
96E7733803072B7333093533 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
A548F4D04C3E24479BB698BE /* [CP] Check Pods Manifest.lock */ = {
B609B32CB0330D926A7BF173 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
@ -413,13 +396,30 @@
outputFileListPaths = (
);
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-RunnerTests-checkManifestLockResult.txt",
"$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
C553F2A78B180316DDD47899 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
@ -471,7 +471,7 @@
/* Begin XCBuildConfiguration section */
331C80DB294CF71000263BE5 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 7F585ABB312A56C96CA02B4C /* Pods-RunnerTests.debug.xcconfig */;
baseConfigurationReference = 42843373A331898F762AE9FA /* Pods-RunnerTests.debug.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CURRENT_PROJECT_VERSION = 1;
@ -486,7 +486,7 @@
};
331C80DC294CF71000263BE5 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 4FED463EB6DAAF306AA7409D /* Pods-RunnerTests.release.xcconfig */;
baseConfigurationReference = 7F49A581B2FF1737F1557371 /* Pods-RunnerTests.release.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CURRENT_PROJECT_VERSION = 1;
@ -501,7 +501,7 @@
};
331C80DD294CF71000263BE5 /* Profile */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 08818FCFA3AD25DA4826A9B1 /* Pods-RunnerTests.profile.xcconfig */;
baseConfigurationReference = BBBF70DBDF6B0B4E82F4E8A2 /* Pods-RunnerTests.profile.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CURRENT_PROJECT_VERSION = 1;
@ -569,7 +569,6 @@
CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = JJSB6LL9HD;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
@ -696,7 +695,6 @@
CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = JJSB6LL9HD;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
@ -717,7 +715,6 @@
CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = JJSB6LL9HD;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
LastUpgradeVersion = "1430"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

View File

@ -23,55 +23,47 @@ packages:
path: ".."
relative: true
source: path
version: "2.0.1"
version: "2.0.2"
bluetooth_low_energy_android:
dependency: transitive
description:
name: bluetooth_low_energy_android
sha256: e4a14243be6b4556836a734e53e813a1c5f4f6c8e380ca49ebf8d02e5b3f37dc
sha256: "99cf2d82ea788f9f927513827f33b501a866902bbbdc20031b856fab7bcda61b"
url: "https://pub.dev"
source: hosted
version: "2.0.1"
bluetooth_low_energy_ios:
version: "2.0.2"
bluetooth_low_energy_darwin:
dependency: transitive
description:
name: bluetooth_low_energy_ios
sha256: "38401d8e50d6f96b3e63f2c7e6fc32d6a1ae7d99dc60520fcb4162eb39ba2dd4"
name: bluetooth_low_energy_darwin
sha256: b81cc04e04ad44063a05072ddc748e036a3f269a90af4c86b132689e66df404f
url: "https://pub.dev"
source: hosted
version: "2.0.1"
version: "2.0.2"
bluetooth_low_energy_linux:
dependency: transitive
description:
name: bluetooth_low_energy_linux
sha256: c88363e296ecb3a4b936e6d02f21214cf4e894d694c9996b523811b65e2d0eb0
sha256: "11fc6a5f4c3d9121d2ac9b213a2f587dad2b091b7bfea648a709f0d70a909ca3"
url: "https://pub.dev"
source: hosted
version: "2.0.1"
bluetooth_low_energy_macos:
dependency: transitive
description:
name: bluetooth_low_energy_macos
sha256: b816568cc943d419bb395fbeb4b7aad66295c5e25e2f5b3e06532394dc27522e
url: "https://pub.dev"
source: hosted
version: "2.0.1"
version: "2.0.2"
bluetooth_low_energy_platform_interface:
dependency: transitive
description:
name: bluetooth_low_energy_platform_interface
sha256: "090b642fa738c04e899c4f4a78e88fa43a7dfa7f5b99f1c882cadad10a68e8fb"
sha256: "05ea2e4a802555065bda342099efec006b4d02c51806ee913fb82da90b5da60a"
url: "https://pub.dev"
source: hosted
version: "2.0.1"
version: "2.0.2"
bluetooth_low_energy_windows:
dependency: transitive
description:
name: bluetooth_low_energy_windows
sha256: ddd66c36811ad3fd347efaaba132e7bb27cdc446afc3e8cd3880c5f26a0d3b54
sha256: "404c704b88e516f23b5cd9bc3873f65593e868b8c6398292146ccda6e48fd335"
url: "https://pub.dev"
source: hosted
version: "2.0.1"
version: "2.0.2"
bluez:
dependency: transitive
description:
@ -148,10 +140,10 @@ packages:
dependency: transitive
description:
name: ffi
sha256: ed5337a5660c506388a9f012be0288fb38b49020ce2b45fe1f8b8323fe429f99
sha256: "7bf0adc28a23d395f19f3f1eb21dd7cfd1dd9f8e1c50051c069122e6853bc878"
url: "https://pub.dev"
source: hosted
version: "2.0.2"
version: "2.1.0"
file:
dependency: transitive
description:

View File

@ -5,7 +5,7 @@ description: Demonstrates how to use the bluetooth_low_energy plugin.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
environment:
sdk: '>=3.0.3 <4.0.0'
sdk: '>=3.0.0 <4.0.0'
# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions

View File

@ -8,7 +8,7 @@ set(BINARY_NAME "bluetooth_low_energy_example")
# Explicitly opt in to modern CMake behaviors to avoid warnings with recent
# versions of CMake.
cmake_policy(SET CMP0063 NEW)
cmake_policy(VERSION 3.14...3.25)
# Define build configuration option.
get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)

View File

@ -6,9 +6,6 @@
#include "generated_plugin_registrant.h"
#include <bluetooth_low_energy_windows/bluetooth_low_energy_windows_plugin_c_api.h>
void RegisterPlugins(flutter::PluginRegistry* registry) {
BluetoothLowEnergyWindowsPluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("BluetoothLowEnergyWindowsPluginCApi"));
}

View File

@ -3,7 +3,6 @@
#
list(APPEND FLUTTER_PLUGIN_LIST
bluetooth_low_energy_windows
)
list(APPEND FLUTTER_FFI_PLUGIN_LIST

View File

@ -1,6 +1,6 @@
name: bluetooth_low_energy
description: A Flutter plugin for controlling the bluetooth low energy.
version: 2.0.1
version: 2.0.2
homepage: https://github.com/yanshouwang/bluetooth_low_energy
environment:
@ -10,12 +10,11 @@ environment:
dependencies:
flutter:
sdk: flutter
bluetooth_low_energy_platform_interface: ^2.0.1
bluetooth_low_energy_android: ^2.0.1
bluetooth_low_energy_ios: ^2.0.1
bluetooth_low_energy_macos: ^2.0.1
bluetooth_low_energy_linux: ^2.0.1
bluetooth_low_energy_windows: ^2.0.1
bluetooth_low_energy_platform_interface: ^2.0.2
bluetooth_low_energy_android: ^2.0.2
bluetooth_low_energy_darwin: ^2.0.2
bluetooth_low_energy_linux: ^2.0.2
bluetooth_low_energy_windows: ^2.0.2
dev_dependencies:
flutter_test:
@ -28,9 +27,9 @@ flutter:
android:
default_package: bluetooth_low_energy_android
ios:
default_package: bluetooth_low_energy_ios
default_package: bluetooth_low_energy_darwin
macos:
default_package: bluetooth_low_energy_macos
default_package: bluetooth_low_energy_darwin
linux:
default_package: bluetooth_low_energy_linux
windows:

View File

@ -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,11 +13,11 @@ project_type: plugin
migration:
platforms:
- platform: root
create_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
base_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
create_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31
base_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31
- platform: android
create_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
base_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
create_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31
base_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31
# User provided section

View File

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

View File

@ -1,4 +1,4 @@
group 'dev.yanshouwang.bluetooth_low_energy'
group 'dev.yanshouwang.bluetooth_low_energy_android'
version '1.0-SNAPSHOT'
buildscript {
@ -25,6 +25,10 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
android {
if (project.android.hasProperty("namespace")) {
namespace 'dev.yanshouwang.bluetooth_low_energy_android'
}
compileSdkVersion 31
compileOptions {

View File

@ -1 +1 @@
rootProject.name = 'bluetooth_low_energy'
rootProject.name = 'bluetooth_low_energy_android'

View File

@ -1,6 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="dev.yanshouwang.bluetooth_low_energy">
package="dev.yanshouwang.bluetooth_low_energy_android">
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.BLUETOOTH"

View File

@ -1,4 +1,4 @@
package dev.yanshouwang.bluetooth_low_energy
package dev.yanshouwang.bluetooth_low_energy_android
import io.flutter.embedding.engine.plugins.FlutterPlugin
import io.flutter.embedding.engine.plugins.activity.ActivityAware

View File

@ -1,7 +1,7 @@
// Autogenerated from Pigeon (v10.1.6), do not edit directly.
// See also: https://pub.dev/packages/pigeon
package dev.yanshouwang.bluetooth_low_energy
package dev.yanshouwang.bluetooth_low_energy_android
import android.util.Log
import io.flutter.plugin.common.BasicMessageChannel

View File

@ -1,4 +1,4 @@
package dev.yanshouwang.bluetooth_low_energy
package dev.yanshouwang.bluetooth_low_energy_android
import android.bluetooth.BluetoothGatt
import android.bluetooth.BluetoothGattCallback

View File

@ -1,4 +1,4 @@
package dev.yanshouwang.bluetooth_low_energy
package dev.yanshouwang.bluetooth_low_energy_android
import android.content.BroadcastReceiver
import android.content.Context

View File

@ -1,4 +1,4 @@
package dev.yanshouwang.bluetooth_low_energy
package dev.yanshouwang.bluetooth_low_energy_android
import android.bluetooth.BluetoothAdapter
import android.bluetooth.BluetoothDevice
@ -77,9 +77,9 @@ class MyCentralController(private val context: Context, binaryMessenger: BinaryM
throw IllegalStateException()
}
val permissions = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
arrayOf(android.Manifest.permission.ACCESS_FINE_LOCATION, android.Manifest.permission.BLUETOOTH_SCAN, android.Manifest.permission.BLUETOOTH_CONNECT)
arrayOf(android.Manifest.permission.ACCESS_COARSE_LOCATION, android.Manifest.permission.ACCESS_FINE_LOCATION, android.Manifest.permission.BLUETOOTH_SCAN, android.Manifest.permission.BLUETOOTH_CONNECT)
} else {
arrayOf(android.Manifest.permission.ACCESS_FINE_LOCATION)
arrayOf(android.Manifest.permission.ACCESS_COARSE_LOCATION, android.Manifest.permission.ACCESS_FINE_LOCATION)
}
val activity = binding.activity
ActivityCompat.requestPermissions(activity, permissions, REQUEST_CODE)

View File

@ -1,4 +1,4 @@
package dev.yanshouwang.bluetooth_low_energy
package dev.yanshouwang.bluetooth_low_energy_android
import io.flutter.plugin.common.PluginRegistry.RequestPermissionsResultListener

View File

@ -1,4 +1,4 @@
package dev.yanshouwang.bluetooth_low_energy
package dev.yanshouwang.bluetooth_low_energy_android
import android.bluetooth.le.ScanCallback
import android.bluetooth.le.ScanResult

View File

@ -1,4 +1,4 @@
package dev.yanshouwang.bluetooth_low_energy
package dev.yanshouwang.bluetooth_low_energy_android
import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel
@ -13,10 +13,10 @@ import org.mockito.Mockito
* you can run them directly from IDEs that support JUnit such as Android Studio.
*/
internal class BluetoothLowEnergyPluginTest {
internal class BluetoothLowEnergyAndroidPluginTest {
@Test
fun onMethodCall_getPlatformVersion_returnsExpectedValue() {
val plugin = BluetoothLowEnergyAndroid()
val plugin = BluetoothLowEnergyAndroidPlugin()
val call = MethodCall("getPlatformVersion", null)
val mockResult: MethodChannel.Result = Mockito.mock(MethodChannel.Result::class.java)

View File

@ -5,9 +5,9 @@ import 'package:pigeon/pigeon.dart';
dartOut: 'lib/src/my_api.g.dart',
dartOptions: DartOptions(),
kotlinOut:
'android/src/main/kotlin/dev/yanshouwang/bluetooth_low_energy/MyApi.g.kt',
'android/src/main/kotlin/dev/yanshouwang/bluetooth_low_energy_android/MyApi.g.kt',
kotlinOptions: KotlinOptions(
package: 'dev.yanshouwang.bluetooth_low_energy',
package: 'dev.yanshouwang.bluetooth_low_energy_android',
),
),
)

View File

@ -1,6 +1,6 @@
name: bluetooth_low_energy_android
description: Android implementation of the bluetooth_low_energy plugin.
version: 2.0.1
version: 2.0.2
homepage: https://github.com/yanshouwang/bluetooth_low_energy
environment:
@ -10,7 +10,7 @@ environment:
dependencies:
flutter:
sdk: flutter
bluetooth_low_energy_platform_interface: ^2.0.1
bluetooth_low_energy_platform_interface: ^2.0.2
dev_dependencies:
flutter_test:
@ -23,6 +23,6 @@ flutter:
implements: bluetooth_low_energy
platforms:
android:
package: dev.yanshouwang.bluetooth_low_energy
package: dev.yanshouwang.bluetooth_low_energy_android
pluginClass: BluetoothLowEnergyAndroid
dartPluginClass: BluetoothLowEnergyAndroid

View File

@ -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,11 +13,14 @@ project_type: plugin
migration:
platforms:
- platform: root
create_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
base_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
create_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31
base_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31
- platform: ios
create_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31
base_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31
- platform: macos
create_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
base_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
create_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31
base_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31
# User provided section

View File

@ -0,0 +1,4 @@
## 2.0.2
- Combine iOS and macOS projects.
- Optimize project structure.

View File

@ -1,6 +1,6 @@
# bluetooth_low_energy_ios
# bluetooth_low_energy_darwin
The iOS implementation of [`bluetooth_low_energy`][1].
The iOS and macOS implementation of [`bluetooth_low_energy`][1].
## Usage

View File

@ -1,9 +1,22 @@
#if os(iOS)
import Flutter
import UIKit
#elseif os(macOS)
import Cocoa
import FlutterMacOS
#else
#error("Unsupported platform.")
#endif
public class BluetoothLowEnergymacOS: NSObject, FlutterPlugin {
public class BluetoothLowEnergyDarwin: NSObject, FlutterPlugin {
public static func register(with registrar: FlutterPluginRegistrar) {
#if os(iOS)
let binaryMessenger = registrar.messenger()
#elseif os(macOS)
let binaryMessenger = registrar.messenger
#else
#error("Unsupported platform.")
#endif
let centralController = MyCentralController(binaryMessenger)
MyCentralControllerHostApiSetup.setUp(binaryMessenger: binaryMessenger, api: centralController)
}

View File

@ -271,7 +271,7 @@ class MyCentralControllerHostApiSetup {
static var codec: FlutterStandardMessageCodec { MyCentralControllerHostApiCodec.shared }
/// Sets up an instance of `MyCentralControllerHostApi` to handle messages through the `binaryMessenger`.
static func setUp(binaryMessenger: FlutterBinaryMessenger, api: MyCentralControllerHostApi?) {
let setUpChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerHostApi.setUp", binaryMessenger: binaryMessenger, codec: codec)
let setUpChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerHostApi.setUp", binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
setUpChannel.setMessageHandler { _, reply in
api.setUp() { result in
@ -286,7 +286,7 @@ class MyCentralControllerHostApiSetup {
} else {
setUpChannel.setMessageHandler(nil)
}
let tearDownChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerHostApi.tearDown", binaryMessenger: binaryMessenger, codec: codec)
let tearDownChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerHostApi.tearDown", binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
tearDownChannel.setMessageHandler { _, reply in
do {
@ -299,7 +299,7 @@ class MyCentralControllerHostApiSetup {
} else {
tearDownChannel.setMessageHandler(nil)
}
let startDiscoveryChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerHostApi.startDiscovery", binaryMessenger: binaryMessenger, codec: codec)
let startDiscoveryChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerHostApi.startDiscovery", binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
startDiscoveryChannel.setMessageHandler { _, reply in
do {
@ -312,7 +312,7 @@ class MyCentralControllerHostApiSetup {
} else {
startDiscoveryChannel.setMessageHandler(nil)
}
let stopDiscoveryChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerHostApi.stopDiscovery", binaryMessenger: binaryMessenger, codec: codec)
let stopDiscoveryChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerHostApi.stopDiscovery", binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
stopDiscoveryChannel.setMessageHandler { _, reply in
do {
@ -325,7 +325,7 @@ class MyCentralControllerHostApiSetup {
} else {
stopDiscoveryChannel.setMessageHandler(nil)
}
let connectChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerHostApi.connect", binaryMessenger: binaryMessenger, codec: codec)
let connectChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerHostApi.connect", binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
connectChannel.setMessageHandler { message, reply in
let args = message as! [Any?]
@ -342,7 +342,7 @@ class MyCentralControllerHostApiSetup {
} else {
connectChannel.setMessageHandler(nil)
}
let disconnectChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerHostApi.disconnect", binaryMessenger: binaryMessenger, codec: codec)
let disconnectChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerHostApi.disconnect", binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
disconnectChannel.setMessageHandler { message, reply in
let args = message as! [Any?]
@ -359,7 +359,7 @@ class MyCentralControllerHostApiSetup {
} else {
disconnectChannel.setMessageHandler(nil)
}
let discoverGATTChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerHostApi.discoverGATT", binaryMessenger: binaryMessenger, codec: codec)
let discoverGATTChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerHostApi.discoverGATT", binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
discoverGATTChannel.setMessageHandler { message, reply in
let args = message as! [Any?]
@ -376,7 +376,7 @@ class MyCentralControllerHostApiSetup {
} else {
discoverGATTChannel.setMessageHandler(nil)
}
let getServicesChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerHostApi.getServices", binaryMessenger: binaryMessenger, codec: codec)
let getServicesChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerHostApi.getServices", binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
getServicesChannel.setMessageHandler { message, reply in
let args = message as! [Any?]
@ -391,7 +391,7 @@ class MyCentralControllerHostApiSetup {
} else {
getServicesChannel.setMessageHandler(nil)
}
let getCharacteristicsChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerHostApi.getCharacteristics", binaryMessenger: binaryMessenger, codec: codec)
let getCharacteristicsChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerHostApi.getCharacteristics", binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
getCharacteristicsChannel.setMessageHandler { message, reply in
let args = message as! [Any?]
@ -406,7 +406,7 @@ class MyCentralControllerHostApiSetup {
} else {
getCharacteristicsChannel.setMessageHandler(nil)
}
let getDescriptorsChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerHostApi.getDescriptors", binaryMessenger: binaryMessenger, codec: codec)
let getDescriptorsChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerHostApi.getDescriptors", binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
getDescriptorsChannel.setMessageHandler { message, reply in
let args = message as! [Any?]
@ -421,7 +421,7 @@ class MyCentralControllerHostApiSetup {
} else {
getDescriptorsChannel.setMessageHandler(nil)
}
let readCharacteristicChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerHostApi.readCharacteristic", binaryMessenger: binaryMessenger, codec: codec)
let readCharacteristicChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerHostApi.readCharacteristic", binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
readCharacteristicChannel.setMessageHandler { message, reply in
let args = message as! [Any?]
@ -440,7 +440,7 @@ class MyCentralControllerHostApiSetup {
} else {
readCharacteristicChannel.setMessageHandler(nil)
}
let writeCharacteristicChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerHostApi.writeCharacteristic", binaryMessenger: binaryMessenger, codec: codec)
let writeCharacteristicChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerHostApi.writeCharacteristic", binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
writeCharacteristicChannel.setMessageHandler { message, reply in
let args = message as! [Any?]
@ -461,7 +461,7 @@ class MyCentralControllerHostApiSetup {
} else {
writeCharacteristicChannel.setMessageHandler(nil)
}
let notifyCharacteristicChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerHostApi.notifyCharacteristic", binaryMessenger: binaryMessenger, codec: codec)
let notifyCharacteristicChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerHostApi.notifyCharacteristic", binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
notifyCharacteristicChannel.setMessageHandler { message, reply in
let args = message as! [Any?]
@ -481,7 +481,7 @@ class MyCentralControllerHostApiSetup {
} else {
notifyCharacteristicChannel.setMessageHandler(nil)
}
let readDescriptorChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerHostApi.readDescriptor", binaryMessenger: binaryMessenger, codec: codec)
let readDescriptorChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerHostApi.readDescriptor", binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
readDescriptorChannel.setMessageHandler { message, reply in
let args = message as! [Any?]
@ -500,7 +500,7 @@ class MyCentralControllerHostApiSetup {
} else {
readDescriptorChannel.setMessageHandler(nil)
}
let writeDescriptorChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerHostApi.writeDescriptor", binaryMessenger: binaryMessenger, codec: codec)
let writeDescriptorChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerHostApi.writeDescriptor", binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
writeDescriptorChannel.setMessageHandler { message, reply in
let args = message as! [Any?]
@ -573,25 +573,25 @@ class MyCentralControllerFlutterApi {
return MyCentralControllerFlutterApiCodec.shared
}
func onStateChanged(myStateNumber myStateNumberArg: Int64, completion: @escaping () -> Void) {
let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerFlutterApi.onStateChanged", binaryMessenger: binaryMessenger, codec: codec)
let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerFlutterApi.onStateChanged", binaryMessenger: binaryMessenger, codec: codec)
channel.sendMessage([myStateNumberArg] as [Any?]) { _ in
completion()
}
}
func onDiscovered(myPeripheralArgs myPeripheralArgsArg: MyPeripheralArgs, rssi rssiArg: Int64, myAdvertisementArgs myAdvertisementArgsArg: MyAdvertisementArgs, completion: @escaping () -> Void) {
let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerFlutterApi.onDiscovered", binaryMessenger: binaryMessenger, codec: codec)
let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerFlutterApi.onDiscovered", binaryMessenger: binaryMessenger, codec: codec)
channel.sendMessage([myPeripheralArgsArg, rssiArg, myAdvertisementArgsArg] as [Any?]) { _ in
completion()
}
}
func onPeripheralStateChanged(myPeripheralKey myPeripheralKeyArg: Int64, state stateArg: Bool, completion: @escaping () -> Void) {
let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerFlutterApi.onPeripheralStateChanged", binaryMessenger: binaryMessenger, codec: codec)
let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerFlutterApi.onPeripheralStateChanged", binaryMessenger: binaryMessenger, codec: codec)
channel.sendMessage([myPeripheralKeyArg, stateArg] as [Any?]) { _ in
completion()
}
}
func onCharacteristicValueChanged(myCharacteristicKey myCharacteristicKeyArg: Int64, value valueArg: FlutterStandardTypedData, completion: @escaping () -> Void) {
let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerFlutterApi.onCharacteristicValueChanged", binaryMessenger: binaryMessenger, codec: codec)
let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerFlutterApi.onCharacteristicValueChanged", binaryMessenger: binaryMessenger, codec: codec)
channel.sendMessage([myCharacteristicKeyArg, valueArg] as [Any?]) { _ in
completion()
}

View File

@ -6,8 +6,14 @@
//
import Foundation
import FlutterMacOS
import CoreBluetooth
#if os(iOS)
import Flutter
#elseif os(macOS)
import FlutterMacOS
#else
#error("Unsupported platform.")
#endif
class MyCentralController: MyCentralControllerHostApi {
init(_ binaryMessenger: FlutterBinaryMessenger) {

View File

@ -0,0 +1,27 @@
#
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html.
# Run `pod lib lint bluetooth_low_energy_darwin.podspec` to validate before publishing.
#
Pod::Spec.new do |s|
s.name = 'bluetooth_low_energy_darwin'
s.version = '2.0.2'
s.summary = 'iOS and macOS implementation of the bluetooth_low_energy plugin.'
s.description = <<-DESC
iOS and macOS implementation of the bluetooth_low_energy plugin.
DESC
s.homepage = 'https://github.com/yanshouwang/bluetooth_low_energy'
s.license = { :file => '../LICENSE' }
s.author = { 'yanshouwang' => 'yanshouwang@outlook.com' }
s.source = { :path => '.' }
s.source_files = 'Classes/**/*'
s.ios.dependency 'Flutter'
s.ios.deployment_target = '11.0'
s.osx.dependency 'FlutterMacOS'
s.osx.deployment_target = '10.11'
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
s.swift_version = '5.0'
end

View File

@ -2,7 +2,7 @@ import 'package:bluetooth_low_energy_platform_interface/bluetooth_low_energy_pla
import 'src/my_central_controller.dart';
abstract class BluetoothLowEnergymacOS {
abstract class BluetoothLowEnergyDarwin {
static void registerWith() {
CentralController.instance = MyCentralController();
}

View File

@ -245,7 +245,7 @@ class MyCentralControllerHostApi {
Future<MyCentralControllerArgs> setUp() async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerHostApi.setUp', codec,
'dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerHostApi.setUp', codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(null) as List<Object?>?;
@ -272,7 +272,7 @@ class MyCentralControllerHostApi {
Future<void> tearDown() async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerHostApi.tearDown', codec,
'dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerHostApi.tearDown', codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(null) as List<Object?>?;
@ -294,7 +294,7 @@ class MyCentralControllerHostApi {
Future<void> startDiscovery() async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerHostApi.startDiscovery', codec,
'dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerHostApi.startDiscovery', codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(null) as List<Object?>?;
@ -316,7 +316,7 @@ class MyCentralControllerHostApi {
Future<void> stopDiscovery() async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerHostApi.stopDiscovery', codec,
'dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerHostApi.stopDiscovery', codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(null) as List<Object?>?;
@ -338,7 +338,7 @@ class MyCentralControllerHostApi {
Future<void> connect(int arg_myPeripheralKey) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerHostApi.connect', codec,
'dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerHostApi.connect', codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_myPeripheralKey]) as List<Object?>?;
@ -360,7 +360,7 @@ class MyCentralControllerHostApi {
Future<void> disconnect(int arg_myPeripheralKey) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerHostApi.disconnect', codec,
'dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerHostApi.disconnect', codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_myPeripheralKey]) as List<Object?>?;
@ -382,7 +382,7 @@ class MyCentralControllerHostApi {
Future<void> discoverGATT(int arg_myPeripheralKey) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerHostApi.discoverGATT', codec,
'dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerHostApi.discoverGATT', codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_myPeripheralKey]) as List<Object?>?;
@ -404,7 +404,7 @@ class MyCentralControllerHostApi {
Future<List<MyGattServiceArgs?>> getServices(int arg_myPeripheralKey) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerHostApi.getServices', codec,
'dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerHostApi.getServices', codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_myPeripheralKey]) as List<Object?>?;
@ -431,7 +431,7 @@ class MyCentralControllerHostApi {
Future<List<MyGattCharacteristicArgs?>> getCharacteristics(int arg_myServiceKey) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerHostApi.getCharacteristics', codec,
'dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerHostApi.getCharacteristics', codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_myServiceKey]) as List<Object?>?;
@ -458,7 +458,7 @@ class MyCentralControllerHostApi {
Future<List<MyGattDescriptorArgs?>> getDescriptors(int arg_myCharacteristicKey) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerHostApi.getDescriptors', codec,
'dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerHostApi.getDescriptors', codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_myCharacteristicKey]) as List<Object?>?;
@ -485,7 +485,7 @@ class MyCentralControllerHostApi {
Future<Uint8List> readCharacteristic(int arg_myPeripheralKey, int arg_myServiceKey, int arg_myCharacteristicKey) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerHostApi.readCharacteristic', codec,
'dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerHostApi.readCharacteristic', codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_myPeripheralKey, arg_myServiceKey, arg_myCharacteristicKey]) as List<Object?>?;
@ -512,7 +512,7 @@ class MyCentralControllerHostApi {
Future<void> writeCharacteristic(int arg_myPeripheralKey, int arg_myServiceKey, int arg_myCharacteristicKey, Uint8List arg_value, int arg_myTypeNumber) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerHostApi.writeCharacteristic', codec,
'dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerHostApi.writeCharacteristic', codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_myPeripheralKey, arg_myServiceKey, arg_myCharacteristicKey, arg_value, arg_myTypeNumber]) as List<Object?>?;
@ -534,7 +534,7 @@ class MyCentralControllerHostApi {
Future<void> notifyCharacteristic(int arg_myPeripheralKey, int arg_myServiceKey, int arg_myCharacteristicKey, bool arg_state) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerHostApi.notifyCharacteristic', codec,
'dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerHostApi.notifyCharacteristic', codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_myPeripheralKey, arg_myServiceKey, arg_myCharacteristicKey, arg_state]) as List<Object?>?;
@ -556,7 +556,7 @@ class MyCentralControllerHostApi {
Future<Uint8List> readDescriptor(int arg_myPeripheralKey, int arg_myCharacteristicKey, int arg_myDescriptorKey) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerHostApi.readDescriptor', codec,
'dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerHostApi.readDescriptor', codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_myPeripheralKey, arg_myCharacteristicKey, arg_myDescriptorKey]) as List<Object?>?;
@ -583,7 +583,7 @@ class MyCentralControllerHostApi {
Future<void> writeDescriptor(int arg_myPeripheralKey, int arg_myCharacteristicKey, int arg_myDescriptorKey, Uint8List arg_value) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerHostApi.writeDescriptor', codec,
'dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerHostApi.writeDescriptor', codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_myPeripheralKey, arg_myCharacteristicKey, arg_myDescriptorKey, arg_value]) as List<Object?>?;
@ -646,18 +646,18 @@ abstract class MyCentralControllerFlutterApi {
static void setup(MyCentralControllerFlutterApi? api, {BinaryMessenger? binaryMessenger}) {
{
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerFlutterApi.onStateChanged', codec,
'dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerFlutterApi.onStateChanged', codec,
binaryMessenger: binaryMessenger);
if (api == null) {
channel.setMessageHandler(null);
} else {
channel.setMessageHandler((Object? message) async {
assert(message != null,
'Argument for dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerFlutterApi.onStateChanged was null.');
'Argument for dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerFlutterApi.onStateChanged was null.');
final List<Object?> args = (message as List<Object?>?)!;
final int? arg_myStateNumber = (args[0] as int?);
assert(arg_myStateNumber != null,
'Argument for dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerFlutterApi.onStateChanged was null, expected non-null int.');
'Argument for dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerFlutterApi.onStateChanged was null, expected non-null int.');
api.onStateChanged(arg_myStateNumber!);
return;
});
@ -665,24 +665,24 @@ abstract class MyCentralControllerFlutterApi {
}
{
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerFlutterApi.onDiscovered', codec,
'dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerFlutterApi.onDiscovered', codec,
binaryMessenger: binaryMessenger);
if (api == null) {
channel.setMessageHandler(null);
} else {
channel.setMessageHandler((Object? message) async {
assert(message != null,
'Argument for dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerFlutterApi.onDiscovered was null.');
'Argument for dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerFlutterApi.onDiscovered was null.');
final List<Object?> args = (message as List<Object?>?)!;
final MyPeripheralArgs? arg_myPeripheralArgs = (args[0] as MyPeripheralArgs?);
assert(arg_myPeripheralArgs != null,
'Argument for dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerFlutterApi.onDiscovered was null, expected non-null MyPeripheralArgs.');
'Argument for dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerFlutterApi.onDiscovered was null, expected non-null MyPeripheralArgs.');
final int? arg_rssi = (args[1] as int?);
assert(arg_rssi != null,
'Argument for dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerFlutterApi.onDiscovered was null, expected non-null int.');
'Argument for dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerFlutterApi.onDiscovered was null, expected non-null int.');
final MyAdvertisementArgs? arg_myAdvertisementArgs = (args[2] as MyAdvertisementArgs?);
assert(arg_myAdvertisementArgs != null,
'Argument for dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerFlutterApi.onDiscovered was null, expected non-null MyAdvertisementArgs.');
'Argument for dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerFlutterApi.onDiscovered was null, expected non-null MyAdvertisementArgs.');
api.onDiscovered(arg_myPeripheralArgs!, arg_rssi!, arg_myAdvertisementArgs!);
return;
});
@ -690,21 +690,21 @@ abstract class MyCentralControllerFlutterApi {
}
{
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerFlutterApi.onPeripheralStateChanged', codec,
'dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerFlutterApi.onPeripheralStateChanged', codec,
binaryMessenger: binaryMessenger);
if (api == null) {
channel.setMessageHandler(null);
} else {
channel.setMessageHandler((Object? message) async {
assert(message != null,
'Argument for dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerFlutterApi.onPeripheralStateChanged was null.');
'Argument for dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerFlutterApi.onPeripheralStateChanged was null.');
final List<Object?> args = (message as List<Object?>?)!;
final int? arg_myPeripheralKey = (args[0] as int?);
assert(arg_myPeripheralKey != null,
'Argument for dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerFlutterApi.onPeripheralStateChanged was null, expected non-null int.');
'Argument for dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerFlutterApi.onPeripheralStateChanged was null, expected non-null int.');
final bool? arg_state = (args[1] as bool?);
assert(arg_state != null,
'Argument for dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerFlutterApi.onPeripheralStateChanged was null, expected non-null bool.');
'Argument for dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerFlutterApi.onPeripheralStateChanged was null, expected non-null bool.');
api.onPeripheralStateChanged(arg_myPeripheralKey!, arg_state!);
return;
});
@ -712,21 +712,21 @@ abstract class MyCentralControllerFlutterApi {
}
{
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerFlutterApi.onCharacteristicValueChanged', codec,
'dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerFlutterApi.onCharacteristicValueChanged', codec,
binaryMessenger: binaryMessenger);
if (api == null) {
channel.setMessageHandler(null);
} else {
channel.setMessageHandler((Object? message) async {
assert(message != null,
'Argument for dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerFlutterApi.onCharacteristicValueChanged was null.');
'Argument for dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerFlutterApi.onCharacteristicValueChanged was null.');
final List<Object?> args = (message as List<Object?>?)!;
final int? arg_myCharacteristicKey = (args[0] as int?);
assert(arg_myCharacteristicKey != null,
'Argument for dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerFlutterApi.onCharacteristicValueChanged was null, expected non-null int.');
'Argument for dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerFlutterApi.onCharacteristicValueChanged was null, expected non-null int.');
final Uint8List? arg_value = (args[1] as Uint8List?);
assert(arg_value != null,
'Argument for dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerFlutterApi.onCharacteristicValueChanged was null, expected non-null Uint8List.');
'Argument for dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerFlutterApi.onCharacteristicValueChanged was null, expected non-null Uint8List.');
api.onCharacteristicValueChanged(arg_myCharacteristicKey!, arg_value!);
return;
});

View File

@ -4,7 +4,7 @@ import 'package:pigeon/pigeon.dart';
PigeonOptions(
dartOut: 'lib/src/my_api.g.dart',
dartOptions: DartOptions(),
swiftOut: 'ios/Classes/MyApi.g.swift',
swiftOut: 'darwin/Classes/MyApi.g.swift',
swiftOptions: SwiftOptions(),
),
)

View File

@ -0,0 +1,31 @@
name: bluetooth_low_energy_darwin
description: iOS and macOS implementation of the bluetooth_low_energy plugin.
version: 2.0.2
homepage: https://github.com/yanshouwang/bluetooth_low_energy
environment:
sdk: ">=3.0.0 <4.0.0"
flutter: ">=3.3.0"
dependencies:
flutter:
sdk: flutter
bluetooth_low_energy_platform_interface: ^2.0.2
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^2.0.0
pigeon: ^10.1.6
flutter:
plugin:
platforms:
ios:
pluginClass: BluetoothLowEnergyDarwin
sharedDarwinSource: true
dartPluginClass: BluetoothLowEnergyDarwin
macos:
pluginClass: BluetoothLowEnergyDarwin
sharedDarwinSource: true
dartPluginClass: BluetoothLowEnergyDarwin

View File

@ -1,30 +0,0 @@
# 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.
version:
revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
channel: stable
project_type: plugin
# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
base_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
- platform: ios
create_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
base_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
# User provided section
# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'

View File

@ -1,10 +0,0 @@
## 2.0.1
- Fix the issue that GATTs is cleared after peripheral disconnected on iOS and macOS.
- Fix the issue that create UUID form peripheral's address failed on Linux.
- Fix the issue that instance match failed on Linux.
## 2.0.0
- Rewrite the whole project with federated plugins.
- Support macOS and Linux.

View File

@ -1,38 +0,0 @@
.idea/
.vagrant/
.sconsign.dblite
.svn/
.DS_Store
*.swp
profile
DerivedData/
build/
GeneratedPluginRegistrant.h
GeneratedPluginRegistrant.m
.generated/
*.pbxuser
*.mode1v3
*.mode2v3
*.perspectivev3
!default.pbxuser
!default.mode1v3
!default.mode2v3
!default.perspectivev3
xcuserdata
*.moved-aside
*.pyc
*sync/
Icon?
.tags*
/Flutter/Generated.xcconfig
/Flutter/ephemeral/
/Flutter/flutter_export_environment.sh

View File

@ -1,10 +0,0 @@
import Flutter
import UIKit
public class BluetoothLowEnergyiOS: NSObject, FlutterPlugin {
public static func register(with registrar: FlutterPluginRegistrar) {
let binaryMessenger = registrar.messenger()
let centralController = MyCentralController(binaryMessenger)
MyCentralControllerHostApiSetup.setUp(binaryMessenger: binaryMessenger, api: centralController)
}
}

View File

@ -1,599 +0,0 @@
// Autogenerated from Pigeon (v10.1.6), do not edit directly.
// See also: https://pub.dev/packages/pigeon
import Foundation
#if os(iOS)
import Flutter
#elseif os(macOS)
import FlutterMacOS
#else
#error("Unsupported platform.")
#endif
private func wrapResult(_ result: Any?) -> [Any?] {
return [result]
}
private func wrapError(_ error: Any) -> [Any?] {
if let flutterError = error as? FlutterError {
return [
flutterError.code,
flutterError.message,
flutterError.details
]
}
return [
"\(error)",
"\(type(of: error))",
"Stacktrace: \(Thread.callStackSymbols)"
]
}
private func nilOrValue<T>(_ value: Any?) -> T? {
if value is NSNull { return nil }
return value as! T?
}
enum MyCentralStateArgs: Int {
case unknown = 0
case unsupported = 1
case unauthorized = 2
case poweredOff = 3
case poweredOn = 4
}
enum MyGattCharacteristicPropertyArgs: Int {
case read = 0
case write = 1
case writeWithoutResponse = 2
case notify = 3
case indicate = 4
}
enum MyGattCharacteristicWriteTypeArgs: Int {
case withResponse = 0
case withoutResponse = 1
}
/// Generated class from Pigeon that represents data sent in messages.
struct MyCentralControllerArgs {
var myStateNumber: Int64
static func fromList(_ list: [Any?]) -> MyCentralControllerArgs? {
let myStateNumber = list[0] is Int64 ? list[0] as! Int64 : Int64(list[0] as! Int32)
return MyCentralControllerArgs(
myStateNumber: myStateNumber
)
}
func toList() -> [Any?] {
return [
myStateNumber,
]
}
}
/// Generated class from Pigeon that represents data sent in messages.
struct MyPeripheralArgs {
var key: Int64
var uuid: String
static func fromList(_ list: [Any?]) -> MyPeripheralArgs? {
let key = list[0] is Int64 ? list[0] as! Int64 : Int64(list[0] as! Int32)
let uuid = list[1] as! String
return MyPeripheralArgs(
key: key,
uuid: uuid
)
}
func toList() -> [Any?] {
return [
key,
uuid,
]
}
}
/// Generated class from Pigeon that represents data sent in messages.
struct MyAdvertisementArgs {
var name: String? = nil
var manufacturerSpecificData: [Int64?: FlutterStandardTypedData?]
var serviceUUIDs: [String?]
var serviceData: [String?: FlutterStandardTypedData?]
static func fromList(_ list: [Any?]) -> MyAdvertisementArgs? {
let name: String? = nilOrValue(list[0])
let manufacturerSpecificData = list[1] as! [Int64?: FlutterStandardTypedData?]
let serviceUUIDs = list[2] as! [String?]
let serviceData = list[3] as! [String?: FlutterStandardTypedData?]
return MyAdvertisementArgs(
name: name,
manufacturerSpecificData: manufacturerSpecificData,
serviceUUIDs: serviceUUIDs,
serviceData: serviceData
)
}
func toList() -> [Any?] {
return [
name,
manufacturerSpecificData,
serviceUUIDs,
serviceData,
]
}
}
/// Generated class from Pigeon that represents data sent in messages.
struct MyGattServiceArgs {
var key: Int64
var uuid: String
static func fromList(_ list: [Any?]) -> MyGattServiceArgs? {
let key = list[0] is Int64 ? list[0] as! Int64 : Int64(list[0] as! Int32)
let uuid = list[1] as! String
return MyGattServiceArgs(
key: key,
uuid: uuid
)
}
func toList() -> [Any?] {
return [
key,
uuid,
]
}
}
/// Generated class from Pigeon that represents data sent in messages.
struct MyGattCharacteristicArgs {
var key: Int64
var uuid: String
var myPropertyNumbers: [Int64?]
static func fromList(_ list: [Any?]) -> MyGattCharacteristicArgs? {
let key = list[0] is Int64 ? list[0] as! Int64 : Int64(list[0] as! Int32)
let uuid = list[1] as! String
let myPropertyNumbers = list[2] as! [Int64?]
return MyGattCharacteristicArgs(
key: key,
uuid: uuid,
myPropertyNumbers: myPropertyNumbers
)
}
func toList() -> [Any?] {
return [
key,
uuid,
myPropertyNumbers,
]
}
}
/// Generated class from Pigeon that represents data sent in messages.
struct MyGattDescriptorArgs {
var key: Int64
var uuid: String
static func fromList(_ list: [Any?]) -> MyGattDescriptorArgs? {
let key = list[0] is Int64 ? list[0] as! Int64 : Int64(list[0] as! Int32)
let uuid = list[1] as! String
return MyGattDescriptorArgs(
key: key,
uuid: uuid
)
}
func toList() -> [Any?] {
return [
key,
uuid,
]
}
}
private class MyCentralControllerHostApiCodecReader: FlutterStandardReader {
override func readValue(ofType type: UInt8) -> Any? {
switch type {
case 128:
return MyCentralControllerArgs.fromList(self.readValue() as! [Any?])
case 129:
return MyGattCharacteristicArgs.fromList(self.readValue() as! [Any?])
case 130:
return MyGattDescriptorArgs.fromList(self.readValue() as! [Any?])
case 131:
return MyGattServiceArgs.fromList(self.readValue() as! [Any?])
default:
return super.readValue(ofType: type)
}
}
}
private class MyCentralControllerHostApiCodecWriter: FlutterStandardWriter {
override func writeValue(_ value: Any) {
if let value = value as? MyCentralControllerArgs {
super.writeByte(128)
super.writeValue(value.toList())
} else if let value = value as? MyGattCharacteristicArgs {
super.writeByte(129)
super.writeValue(value.toList())
} else if let value = value as? MyGattDescriptorArgs {
super.writeByte(130)
super.writeValue(value.toList())
} else if let value = value as? MyGattServiceArgs {
super.writeByte(131)
super.writeValue(value.toList())
} else {
super.writeValue(value)
}
}
}
private class MyCentralControllerHostApiCodecReaderWriter: FlutterStandardReaderWriter {
override func reader(with data: Data) -> FlutterStandardReader {
return MyCentralControllerHostApiCodecReader(data: data)
}
override func writer(with data: NSMutableData) -> FlutterStandardWriter {
return MyCentralControllerHostApiCodecWriter(data: data)
}
}
class MyCentralControllerHostApiCodec: FlutterStandardMessageCodec {
static let shared = MyCentralControllerHostApiCodec(readerWriter: MyCentralControllerHostApiCodecReaderWriter())
}
/// Generated protocol from Pigeon that represents a handler of messages from Flutter.
protocol MyCentralControllerHostApi {
func setUp(completion: @escaping (Result<MyCentralControllerArgs, Error>) -> Void)
func tearDown() throws
func startDiscovery() throws
func stopDiscovery() throws
func connect(myPeripheralKey: Int64, completion: @escaping (Result<Void, Error>) -> Void)
func disconnect(myPeripheralKey: Int64, completion: @escaping (Result<Void, Error>) -> Void)
func discoverGATT(myPeripheralKey: Int64, completion: @escaping (Result<Void, Error>) -> Void)
func getServices(myPeripheralKey: Int64) throws -> [MyGattServiceArgs]
func getCharacteristics(myServiceKey: Int64) throws -> [MyGattCharacteristicArgs]
func getDescriptors(myCharacteristicKey: Int64) throws -> [MyGattDescriptorArgs]
func readCharacteristic(myPeripheralKey: Int64, myServiceKey: Int64, myCharacteristicKey: Int64, completion: @escaping (Result<FlutterStandardTypedData, Error>) -> Void)
func writeCharacteristic(myPeripheralKey: Int64, myServiceKey: Int64, myCharacteristicKey: Int64, value: FlutterStandardTypedData, myTypeNumber: Int64, completion: @escaping (Result<Void, Error>) -> Void)
func notifyCharacteristic(myPeripheralKey: Int64, myServiceKey: Int64, myCharacteristicKey: Int64, state: Bool, completion: @escaping (Result<Void, Error>) -> Void)
func readDescriptor(myPeripheralKey: Int64, myCharacteristicKey: Int64, myDescriptorKey: Int64, completion: @escaping (Result<FlutterStandardTypedData, Error>) -> Void)
func writeDescriptor(myPeripheralKey: Int64, myCharacteristicKey: Int64, myDescriptorKey: Int64, value: FlutterStandardTypedData, completion: @escaping (Result<Void, Error>) -> Void)
}
/// Generated setup class from Pigeon to handle messages through the `binaryMessenger`.
class MyCentralControllerHostApiSetup {
/// The codec used by MyCentralControllerHostApi.
static var codec: FlutterStandardMessageCodec { MyCentralControllerHostApiCodec.shared }
/// Sets up an instance of `MyCentralControllerHostApi` to handle messages through the `binaryMessenger`.
static func setUp(binaryMessenger: FlutterBinaryMessenger, api: MyCentralControllerHostApi?) {
let setUpChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerHostApi.setUp", binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
setUpChannel.setMessageHandler { _, reply in
api.setUp() { result in
switch result {
case .success(let res):
reply(wrapResult(res))
case .failure(let error):
reply(wrapError(error))
}
}
}
} else {
setUpChannel.setMessageHandler(nil)
}
let tearDownChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerHostApi.tearDown", binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
tearDownChannel.setMessageHandler { _, reply in
do {
try api.tearDown()
reply(wrapResult(nil))
} catch {
reply(wrapError(error))
}
}
} else {
tearDownChannel.setMessageHandler(nil)
}
let startDiscoveryChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerHostApi.startDiscovery", binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
startDiscoveryChannel.setMessageHandler { _, reply in
do {
try api.startDiscovery()
reply(wrapResult(nil))
} catch {
reply(wrapError(error))
}
}
} else {
startDiscoveryChannel.setMessageHandler(nil)
}
let stopDiscoveryChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerHostApi.stopDiscovery", binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
stopDiscoveryChannel.setMessageHandler { _, reply in
do {
try api.stopDiscovery()
reply(wrapResult(nil))
} catch {
reply(wrapError(error))
}
}
} else {
stopDiscoveryChannel.setMessageHandler(nil)
}
let connectChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerHostApi.connect", binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
connectChannel.setMessageHandler { message, reply in
let args = message as! [Any?]
let myPeripheralKeyArg = args[0] is Int64 ? args[0] as! Int64 : Int64(args[0] as! Int32)
api.connect(myPeripheralKey: myPeripheralKeyArg) { result in
switch result {
case .success:
reply(wrapResult(nil))
case .failure(let error):
reply(wrapError(error))
}
}
}
} else {
connectChannel.setMessageHandler(nil)
}
let disconnectChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerHostApi.disconnect", binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
disconnectChannel.setMessageHandler { message, reply in
let args = message as! [Any?]
let myPeripheralKeyArg = args[0] is Int64 ? args[0] as! Int64 : Int64(args[0] as! Int32)
api.disconnect(myPeripheralKey: myPeripheralKeyArg) { result in
switch result {
case .success:
reply(wrapResult(nil))
case .failure(let error):
reply(wrapError(error))
}
}
}
} else {
disconnectChannel.setMessageHandler(nil)
}
let discoverGATTChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerHostApi.discoverGATT", binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
discoverGATTChannel.setMessageHandler { message, reply in
let args = message as! [Any?]
let myPeripheralKeyArg = args[0] is Int64 ? args[0] as! Int64 : Int64(args[0] as! Int32)
api.discoverGATT(myPeripheralKey: myPeripheralKeyArg) { result in
switch result {
case .success:
reply(wrapResult(nil))
case .failure(let error):
reply(wrapError(error))
}
}
}
} else {
discoverGATTChannel.setMessageHandler(nil)
}
let getServicesChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerHostApi.getServices", binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
getServicesChannel.setMessageHandler { message, reply in
let args = message as! [Any?]
let myPeripheralKeyArg = args[0] is Int64 ? args[0] as! Int64 : Int64(args[0] as! Int32)
do {
let result = try api.getServices(myPeripheralKey: myPeripheralKeyArg)
reply(wrapResult(result))
} catch {
reply(wrapError(error))
}
}
} else {
getServicesChannel.setMessageHandler(nil)
}
let getCharacteristicsChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerHostApi.getCharacteristics", binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
getCharacteristicsChannel.setMessageHandler { message, reply in
let args = message as! [Any?]
let myServiceKeyArg = args[0] is Int64 ? args[0] as! Int64 : Int64(args[0] as! Int32)
do {
let result = try api.getCharacteristics(myServiceKey: myServiceKeyArg)
reply(wrapResult(result))
} catch {
reply(wrapError(error))
}
}
} else {
getCharacteristicsChannel.setMessageHandler(nil)
}
let getDescriptorsChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerHostApi.getDescriptors", binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
getDescriptorsChannel.setMessageHandler { message, reply in
let args = message as! [Any?]
let myCharacteristicKeyArg = args[0] is Int64 ? args[0] as! Int64 : Int64(args[0] as! Int32)
do {
let result = try api.getDescriptors(myCharacteristicKey: myCharacteristicKeyArg)
reply(wrapResult(result))
} catch {
reply(wrapError(error))
}
}
} else {
getDescriptorsChannel.setMessageHandler(nil)
}
let readCharacteristicChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerHostApi.readCharacteristic", binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
readCharacteristicChannel.setMessageHandler { message, reply in
let args = message as! [Any?]
let myPeripheralKeyArg = args[0] is Int64 ? args[0] as! Int64 : Int64(args[0] as! Int32)
let myServiceKeyArg = args[1] is Int64 ? args[1] as! Int64 : Int64(args[1] as! Int32)
let myCharacteristicKeyArg = args[2] is Int64 ? args[2] as! Int64 : Int64(args[2] as! Int32)
api.readCharacteristic(myPeripheralKey: myPeripheralKeyArg, myServiceKey: myServiceKeyArg, myCharacteristicKey: myCharacteristicKeyArg) { result in
switch result {
case .success(let res):
reply(wrapResult(res))
case .failure(let error):
reply(wrapError(error))
}
}
}
} else {
readCharacteristicChannel.setMessageHandler(nil)
}
let writeCharacteristicChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerHostApi.writeCharacteristic", binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
writeCharacteristicChannel.setMessageHandler { message, reply in
let args = message as! [Any?]
let myPeripheralKeyArg = args[0] is Int64 ? args[0] as! Int64 : Int64(args[0] as! Int32)
let myServiceKeyArg = args[1] is Int64 ? args[1] as! Int64 : Int64(args[1] as! Int32)
let myCharacteristicKeyArg = args[2] is Int64 ? args[2] as! Int64 : Int64(args[2] as! Int32)
let valueArg = args[3] as! FlutterStandardTypedData
let myTypeNumberArg = args[4] is Int64 ? args[4] as! Int64 : Int64(args[4] as! Int32)
api.writeCharacteristic(myPeripheralKey: myPeripheralKeyArg, myServiceKey: myServiceKeyArg, myCharacteristicKey: myCharacteristicKeyArg, value: valueArg, myTypeNumber: myTypeNumberArg) { result in
switch result {
case .success:
reply(wrapResult(nil))
case .failure(let error):
reply(wrapError(error))
}
}
}
} else {
writeCharacteristicChannel.setMessageHandler(nil)
}
let notifyCharacteristicChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerHostApi.notifyCharacteristic", binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
notifyCharacteristicChannel.setMessageHandler { message, reply in
let args = message as! [Any?]
let myPeripheralKeyArg = args[0] is Int64 ? args[0] as! Int64 : Int64(args[0] as! Int32)
let myServiceKeyArg = args[1] is Int64 ? args[1] as! Int64 : Int64(args[1] as! Int32)
let myCharacteristicKeyArg = args[2] is Int64 ? args[2] as! Int64 : Int64(args[2] as! Int32)
let stateArg = args[3] as! Bool
api.notifyCharacteristic(myPeripheralKey: myPeripheralKeyArg, myServiceKey: myServiceKeyArg, myCharacteristicKey: myCharacteristicKeyArg, state: stateArg) { result in
switch result {
case .success:
reply(wrapResult(nil))
case .failure(let error):
reply(wrapError(error))
}
}
}
} else {
notifyCharacteristicChannel.setMessageHandler(nil)
}
let readDescriptorChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerHostApi.readDescriptor", binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
readDescriptorChannel.setMessageHandler { message, reply in
let args = message as! [Any?]
let myPeripheralKeyArg = args[0] is Int64 ? args[0] as! Int64 : Int64(args[0] as! Int32)
let myCharacteristicKeyArg = args[1] is Int64 ? args[1] as! Int64 : Int64(args[1] as! Int32)
let myDescriptorKeyArg = args[2] is Int64 ? args[2] as! Int64 : Int64(args[2] as! Int32)
api.readDescriptor(myPeripheralKey: myPeripheralKeyArg, myCharacteristicKey: myCharacteristicKeyArg, myDescriptorKey: myDescriptorKeyArg) { result in
switch result {
case .success(let res):
reply(wrapResult(res))
case .failure(let error):
reply(wrapError(error))
}
}
}
} else {
readDescriptorChannel.setMessageHandler(nil)
}
let writeDescriptorChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerHostApi.writeDescriptor", binaryMessenger: binaryMessenger, codec: codec)
if let api = api {
writeDescriptorChannel.setMessageHandler { message, reply in
let args = message as! [Any?]
let myPeripheralKeyArg = args[0] is Int64 ? args[0] as! Int64 : Int64(args[0] as! Int32)
let myCharacteristicKeyArg = args[1] is Int64 ? args[1] as! Int64 : Int64(args[1] as! Int32)
let myDescriptorKeyArg = args[2] is Int64 ? args[2] as! Int64 : Int64(args[2] as! Int32)
let valueArg = args[3] as! FlutterStandardTypedData
api.writeDescriptor(myPeripheralKey: myPeripheralKeyArg, myCharacteristicKey: myCharacteristicKeyArg, myDescriptorKey: myDescriptorKeyArg, value: valueArg) { result in
switch result {
case .success:
reply(wrapResult(nil))
case .failure(let error):
reply(wrapError(error))
}
}
}
} else {
writeDescriptorChannel.setMessageHandler(nil)
}
}
}
private class MyCentralControllerFlutterApiCodecReader: FlutterStandardReader {
override func readValue(ofType type: UInt8) -> Any? {
switch type {
case 128:
return MyAdvertisementArgs.fromList(self.readValue() as! [Any?])
case 129:
return MyPeripheralArgs.fromList(self.readValue() as! [Any?])
default:
return super.readValue(ofType: type)
}
}
}
private class MyCentralControllerFlutterApiCodecWriter: FlutterStandardWriter {
override func writeValue(_ value: Any) {
if let value = value as? MyAdvertisementArgs {
super.writeByte(128)
super.writeValue(value.toList())
} else if let value = value as? MyPeripheralArgs {
super.writeByte(129)
super.writeValue(value.toList())
} else {
super.writeValue(value)
}
}
}
private class MyCentralControllerFlutterApiCodecReaderWriter: FlutterStandardReaderWriter {
override func reader(with data: Data) -> FlutterStandardReader {
return MyCentralControllerFlutterApiCodecReader(data: data)
}
override func writer(with data: NSMutableData) -> FlutterStandardWriter {
return MyCentralControllerFlutterApiCodecWriter(data: data)
}
}
class MyCentralControllerFlutterApiCodec: FlutterStandardMessageCodec {
static let shared = MyCentralControllerFlutterApiCodec(readerWriter: MyCentralControllerFlutterApiCodecReaderWriter())
}
/// Generated class from Pigeon that represents Flutter messages that can be called from Swift.
class MyCentralControllerFlutterApi {
private let binaryMessenger: FlutterBinaryMessenger
init(binaryMessenger: FlutterBinaryMessenger){
self.binaryMessenger = binaryMessenger
}
var codec: FlutterStandardMessageCodec {
return MyCentralControllerFlutterApiCodec.shared
}
func onStateChanged(myStateNumber myStateNumberArg: Int64, completion: @escaping () -> Void) {
let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerFlutterApi.onStateChanged", binaryMessenger: binaryMessenger, codec: codec)
channel.sendMessage([myStateNumberArg] as [Any?]) { _ in
completion()
}
}
func onDiscovered(myPeripheralArgs myPeripheralArgsArg: MyPeripheralArgs, rssi rssiArg: Int64, myAdvertisementArgs myAdvertisementArgsArg: MyAdvertisementArgs, completion: @escaping () -> Void) {
let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerFlutterApi.onDiscovered", binaryMessenger: binaryMessenger, codec: codec)
channel.sendMessage([myPeripheralArgsArg, rssiArg, myAdvertisementArgsArg] as [Any?]) { _ in
completion()
}
}
func onPeripheralStateChanged(myPeripheralKey myPeripheralKeyArg: Int64, state stateArg: Bool, completion: @escaping () -> Void) {
let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerFlutterApi.onPeripheralStateChanged", binaryMessenger: binaryMessenger, codec: codec)
channel.sendMessage([myPeripheralKeyArg, stateArg] as [Any?]) { _ in
completion()
}
}
func onCharacteristicValueChanged(myCharacteristicKey myCharacteristicKeyArg: Int64, value valueArg: FlutterStandardTypedData, completion: @escaping () -> Void) {
let channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerFlutterApi.onCharacteristicValueChanged", binaryMessenger: binaryMessenger, codec: codec)
channel.sendMessage([myCharacteristicKeyArg, valueArg] as [Any?]) { _ in
completion()
}
}
}

View File

@ -1,716 +0,0 @@
//
// MyCentralController.swift
// bluetooth_low_energy_ios
//
// Created by on 2023/8/13.
//
import Foundation
import Flutter
import CoreBluetooth
class MyCentralController: MyCentralControllerHostApi {
init(_ binaryMessenger: FlutterBinaryMessenger) {
myApi = MyCentralControllerFlutterApi(binaryMessenger: binaryMessenger)
}
private let myApi: MyCentralControllerFlutterApi
private lazy var myCentralManagerDelegate = MyCentralManagerDelegate(self)
private lazy var myPeripheralDelegate = MyPeripheralDelegate(self)
private let centralManager = CBCentralManager()
private var cachedPeripherals = [Int: CBPeripheral]()
private var cachedServices = [Int: [Int: CBService]]()
private var cachedCharacteristics = [Int: [Int: CBCharacteristic]]()
private var cachedDescriptors = [Int: [Int: CBDescriptor]]()
var setUpCompletion: ((Result<MyCentralControllerArgs, Error>) -> Void)?
var connectCompletions = [Int: (Result<Void, Error>) -> Void]()
var disconnectCompletions = [Int: (Result<Void, Error>) -> Void]()
var discoverGattCompletions = [Int: (Result<Void, Error>) -> Void]()
var unfinishedServices = [Int: [CBService]]()
var unfinishedCharacteristics = [Int: [CBCharacteristic]]()
var readCharacteristicCompletions = [Int: (Result<FlutterStandardTypedData, Error>) -> Void]()
var writeCharacteristicCompletions = [Int: (Result<Void, Error>) -> Void]()
var notifyCharacteristicCompletions = [Int: (Result<Void, Error>) -> Void]()
var readDescriptorCompletions = [Int: (Result<FlutterStandardTypedData, Error>) -> Void]()
var writeDescriptorCompletions = [Int: (Result<Void, Error>) -> Void]()
func setUp(completion: @escaping (Result<MyCentralControllerArgs, Error>) -> Void) {
do {
let unfinishedCompletion = setUpCompletion
if unfinishedCompletion != nil {
throw MyError.illegalState
}
centralManager.delegate = myCentralManagerDelegate
if centralManager.state == .unknown {
setUpCompletion = completion
} else {
let myStateArgs = centralManager.state.toMyArgs()
let myStateNumber = Int64(myStateArgs.rawValue)
let myArgs = MyCentralControllerArgs(myStateNumber: myStateNumber)
completion(.success(myArgs))
}
} catch {
completion(.failure(error))
}
}
func tearDown() throws {
centralManager.delegate = nil
if(centralManager.isScanning) {
centralManager.stopScan()
}
for peripheral in cachedPeripherals.values {
peripheral.delegate = nil
if peripheral.state != .disconnected {
centralManager.cancelPeripheralConnection(peripheral)
}
}
cachedPeripherals.removeAll()
cachedServices.removeAll()
cachedCharacteristics.removeAll()
cachedDescriptors.removeAll()
}
func startDiscovery() throws {
let options = [CBCentralManagerScanOptionAllowDuplicatesKey: true]
centralManager.scanForPeripherals(withServices: nil, options: options)
}
func stopDiscovery() throws {
centralManager.stopScan()
}
func connect(myPeripheralKey: Int64, completion: @escaping (Result<Void, Error>) -> Void) {
do {
let peripheralKey = Int(myPeripheralKey)
let unfinishedCompletion = connectCompletions[peripheralKey]
if unfinishedCompletion != nil {
throw MyError.illegalState
}
guard let peripheral = cachedPeripherals[peripheralKey] else {
throw MyError.illegalArgument
}
centralManager.connect(peripheral)
connectCompletions[peripheralKey] = completion
} catch {
completion(.failure(error))
}
}
func disconnect(myPeripheralKey: Int64, completion: @escaping (Result<Void, Error>) -> Void) {
do {
let peripheralKey = Int(myPeripheralKey)
let unfinishedCompletion = disconnectCompletions[peripheralKey]
if unfinishedCompletion != nil {
throw MyError.illegalState
}
guard let peripheral = cachedPeripherals[peripheralKey] else {
throw MyError.illegalArgument
}
centralManager.cancelPeripheralConnection(peripheral)
disconnectCompletions[peripheralKey] = completion
} catch {
completion(.failure(error))
}
}
func discoverGATT(myPeripheralKey: Int64, completion: @escaping (Result<Void, Error>) -> Void) {
do {
let peripheralKey = Int(myPeripheralKey)
let unfinishedCompletion = discoverGattCompletions[peripheralKey]
if unfinishedCompletion != nil {
throw MyError.illegalState
}
guard let peripheral = cachedPeripherals[peripheralKey] else {
throw MyError.illegalArgument
}
peripheral.discoverServices(nil)
discoverGattCompletions[peripheralKey] = completion
} catch {
completion(.failure(error))
}
}
func getServices(myPeripheralKey: Int64) throws -> [MyGattServiceArgs] {
let peripheralKey = Int(myPeripheralKey)
guard let services = cachedServices[peripheralKey] else {
throw MyError.illegalArgument
}
return services.map { (key, service) in
return service.toMyArgs()
}
}
func getCharacteristics(myServiceKey: Int64) throws -> [MyGattCharacteristicArgs] {
let serviceKey = Int(myServiceKey)
guard let characteristics = cachedCharacteristics[serviceKey] else {
throw MyError.illegalArgument
}
return characteristics.map { (key, characteristic) in
return characteristic.toMyArgs()
}
}
func getDescriptors(myCharacteristicKey: Int64) throws -> [MyGattDescriptorArgs] {
let characteristicKey = Int(myCharacteristicKey)
guard let descriptors = cachedDescriptors[characteristicKey] else {
throw MyError.illegalArgument
}
return descriptors.map { (key, descriptor) in
return descriptor.toMyArgs()
}
}
func readCharacteristic(myPeripheralKey: Int64, myServiceKey: Int64, myCharacteristicKey: Int64, completion: @escaping (Result<FlutterStandardTypedData, Error>) -> Void) {
do {
let peripheralKey = Int(myPeripheralKey)
guard let peripheral = cachedPeripherals[peripheralKey] else {
throw MyError.illegalArgument
}
let serviceKey = Int(myServiceKey)
guard let characteristics = cachedCharacteristics[serviceKey] else {
throw MyError.illegalArgument
}
let characteristicKey = Int(myCharacteristicKey)
guard let characteristic = characteristics[characteristicKey] else {
throw MyError.illegalArgument
}
let unfinishedCompletion = readCharacteristicCompletions[characteristicKey]
if unfinishedCompletion != nil {
throw MyError.illegalState
}
peripheral.readValue(for: characteristic)
readCharacteristicCompletions[characteristicKey] = completion
} catch {
completion(.failure(error))
}
}
func writeCharacteristic(myPeripheralKey: Int64, myServiceKey: Int64, myCharacteristicKey: Int64, value: FlutterStandardTypedData, myTypeNumber: Int64, completion: @escaping (Result<Void, Error>) -> Void) {
do {
let peripheralKey = Int(myPeripheralKey)
guard let peripheral = cachedPeripherals[peripheralKey] else {
throw MyError.illegalArgument
}
let serviceKey = Int(myServiceKey)
guard let characteristics = cachedCharacteristics[serviceKey] else {
throw MyError.illegalArgument
}
let characteristicKey = Int(myCharacteristicKey)
guard let characteristic = characteristics[characteristicKey] else {
throw MyError.illegalArgument
}
let data = value.data
let myTypeRawValue = Int(myTypeNumber)
guard let myTypeArgs = MyGattCharacteristicWriteTypeArgs(rawValue: myTypeRawValue) else {
throw MyError.illegalArgument
}
let type = myTypeArgs.toType()
let unfinishedCompletion = writeCharacteristicCompletions[characteristicKey]
if unfinishedCompletion != nil {
throw MyError.illegalState
}
peripheral.writeValue(data, for: characteristic, type: type)
writeCharacteristicCompletions[characteristicKey] = completion
} catch {
completion(.failure(error))
}
}
func notifyCharacteristic(myPeripheralKey: Int64, myServiceKey: Int64, myCharacteristicKey: Int64, state: Bool, completion: @escaping (Result<Void, Error>) -> Void) {
do {
let peripheralKey = Int(myPeripheralKey)
guard let peripheral = cachedPeripherals[peripheralKey] else {
throw MyError.illegalArgument
}
let serviceKey = Int(myServiceKey)
guard let characteristics = cachedCharacteristics[serviceKey] else {
throw MyError.illegalArgument
}
let characteristicKey = Int(myCharacteristicKey)
guard let characteristic = characteristics[characteristicKey] else {
throw MyError.illegalArgument
}
let unfinishedCompletion = notifyCharacteristicCompletions[characteristicKey]
if unfinishedCompletion != nil {
throw MyError.illegalState
}
peripheral.setNotifyValue(state, for: characteristic)
notifyCharacteristicCompletions[characteristicKey] = completion
} catch {
completion(.failure(error))
}
}
func readDescriptor(myPeripheralKey: Int64, myCharacteristicKey: Int64, myDescriptorKey: Int64, completion: @escaping (Result<FlutterStandardTypedData, Error>) -> Void) {
do {
let peripheralKey = Int(myPeripheralKey)
guard let peripheral = cachedPeripherals[peripheralKey] else {
throw MyError.illegalArgument
}
let characteristicKey = Int(myCharacteristicKey)
guard let descriptors = cachedDescriptors[characteristicKey] else {
throw MyError.illegalArgument
}
let descriptorKey = Int(myDescriptorKey)
guard let descriptor = descriptors[descriptorKey] else {
throw MyError.illegalArgument
}
let unfinishedCompletion = readDescriptorCompletions[descriptorKey]
if unfinishedCompletion != nil {
throw MyError.illegalState
}
peripheral.readValue(for: descriptor)
readDescriptorCompletions[descriptorKey] = completion
} catch {
completion(.failure(error))
}
}
func writeDescriptor(myPeripheralKey: Int64, myCharacteristicKey: Int64, myDescriptorKey: Int64, value: FlutterStandardTypedData, completion: @escaping (Result<Void, Error>) -> Void) {
do {
let peripheralKey = Int(myPeripheralKey)
guard let peripheral = cachedPeripherals[peripheralKey] else {
throw MyError.illegalArgument
}
let characteristicKey = Int(myCharacteristicKey)
guard let descriptors = cachedDescriptors[characteristicKey] else {
throw MyError.illegalArgument
}
let descriptorKey = Int(myDescriptorKey)
guard let descriptor = descriptors[descriptorKey] else {
throw MyError.illegalArgument
}
let data = value.data
let unfinishedCompletion = writeDescriptorCompletions[descriptorKey]
if unfinishedCompletion != nil {
throw MyError.illegalState
}
peripheral.writeValue(data, for: descriptor)
writeDescriptorCompletions[descriptorKey] = completion
} catch {
completion(.failure(error))
}
}
func didUpdateState(_ state: CBManagerState) {
let completion = setUpCompletion
if state != .unknown && completion != nil {
let myStateArgs = state.toMyArgs()
let myStateNumber = Int64(myStateArgs.rawValue)
let myArgs = MyCentralControllerArgs(myStateNumber: myStateNumber)
completion!(.success(myArgs))
setUpCompletion = nil
}
let myStateArgs = state.toMyArgs()
let myStateNumber = Int64(myStateArgs.rawValue)
myApi.onStateChanged(myStateNumber: myStateNumber) {}
}
func didDiscover(_ peripheral: CBPeripheral, _ advertisementData: [String : Any], _ rssiNumber: NSNumber) {
let peripheralKey = peripheral.hash
if cachedPeripherals[peripheralKey] == nil {
peripheral.delegate = myPeripheralDelegate
cachedPeripherals[peripheralKey] = peripheral
}
let myPeripheralArgs = peripheral.toMyArgs()
let rssi = rssiNumber.int64Value
let name = advertisementData[CBAdvertisementDataLocalNameKey] as? String
let rawManufacturerSpecificData = advertisementData[CBAdvertisementDataManufacturerDataKey] as? Data
var manufacturerSpecificData = [Int64: FlutterStandardTypedData]()
if rawManufacturerSpecificData != nil {
do {
guard let data = rawManufacturerSpecificData else {
throw MyError.illegalArgument
}
guard data.count >= 2 else {
throw MyError.illegalArgument
}
let key = Int64(data[0]) | (Int64(data[1]) << 8)
let bytes = data.count > 2 ? data[2...data.count-1] : Data()
let value = FlutterStandardTypedData(bytes: bytes)
manufacturerSpecificData[key] = value
} catch {
manufacturerSpecificData = [:]
}
}
let rawServiceUUIDs = advertisementData[CBAdvertisementDataServiceUUIDsKey] as? [CBUUID] ?? []
let serviceUUIDs = rawServiceUUIDs.map { uuid in uuid.uuidString }
let rawServiceData = advertisementData[CBAdvertisementDataServiceDataKey] as? [CBUUID: Data] ?? [:]
let elements = rawServiceData.map { (uuid, data) in
let key = uuid.uuidString
let value = FlutterStandardTypedData(bytes: data)
return (key, value)
}
let serviceData = [String?: FlutterStandardTypedData?](uniqueKeysWithValues: elements)
let myAdvertisementArgs = MyAdvertisementArgs(name: name, manufacturerSpecificData: manufacturerSpecificData, serviceUUIDs: serviceUUIDs, serviceData: serviceData)
myApi.onDiscovered(myPeripheralArgs: myPeripheralArgs, rssi: rssi, myAdvertisementArgs: myAdvertisementArgs) {}
}
func didConnect(_ peripheral: CBPeripheral) {
let peripheralKey = peripheral.hash
let myPeripheralKey = Int64(peripheralKey)
myApi.onPeripheralStateChanged(myPeripheralKey: myPeripheralKey, state: true) {}
guard let completion = connectCompletions.removeValue(forKey: peripheralKey) else {
return
}
completion(.success(()))
}
func didFailToConnect(_ peripheral: CBPeripheral, _ error: Error?) {
let peripheralKey = peripheral.hash
guard let completion = connectCompletions.removeValue(forKey: peripheralKey) else {
return
}
completion(.failure(error ?? MyError.unknown))
}
func didDisconnectPeripheral(_ peripheral: CBPeripheral, _ error: Error?) {
let peripheralKey = peripheral.hash
let myPeripheralKey = Int64(peripheralKey)
let discoverGattCompletion = discoverGattCompletions.removeValue(forKey: peripheralKey)
if discoverGattCompletion != nil {
didDiscoverGATT(peripheral, error ?? MyError.unknown)
}
let services = cachedServices[peripheralKey] ?? [:]
for service in services {
let characteristics = cachedCharacteristics[service.key] ?? [:]
for characteristic in characteristics {
let readCharacteristicCompletion = readCharacteristicCompletions.removeValue(forKey: characteristic.key)
let writeCharacteristicCompletion = writeCharacteristicCompletions.removeValue(forKey: characteristic.key)
if readCharacteristicCompletion != nil {
readCharacteristicCompletion!(.failure(MyError.illegalState))
}
if writeCharacteristicCompletion != nil {
writeCharacteristicCompletion!(.failure(MyError.illegalState))
}
let descriptors = cachedDescriptors[characteristic.key] ?? [:]
for descriptor in descriptors {
let readDescriptorCompletion = readDescriptorCompletions.removeValue(forKey: descriptor.key)
let writeDescriptorCompletion = writeDescriptorCompletions.removeValue(forKey: descriptor.key)
if readDescriptorCompletion != nil {
readDescriptorCompletion!(.failure(MyError.illegalState))
}
if writeDescriptorCompletion != nil {
writeDescriptorCompletion!(.failure(MyError.illegalState))
}
}
}
}
myApi.onPeripheralStateChanged(myPeripheralKey: myPeripheralKey, state: false) {}
guard let completion = disconnectCompletions.removeValue(forKey: peripheralKey) else {
return
}
if error == nil {
completion(.success(()))
} else {
completion(.failure(error!))
}
}
func didDiscoverServices(_ peripheral: CBPeripheral, _ error: Error?) {
let peripheralKey = peripheral.hash
if error == nil {
var services = peripheral.services ?? []
if services.isEmpty {
didDiscoverGATT(peripheral, error)
} else {
let service = services.removeFirst()
unfinishedServices[peripheralKey] = services
peripheral.discoverCharacteristics(nil, for: service)
}
} else {
didDiscoverGATT(peripheral, error)
}
}
func didDiscoverCharacteristics(_ peripheral: CBPeripheral, _ service: CBService, _ error: Error?) {
let peripheralKey = peripheral.hash
if error == nil {
var characteristics = service.characteristics ?? []
if characteristics.isEmpty {
var services = unfinishedServices.removeValue(forKey: peripheralKey) ?? []
if services.isEmpty {
didDiscoverGATT(peripheral, error)
} else {
let service = services.removeFirst()
unfinishedServices[peripheralKey] = services
peripheral.discoverCharacteristics(nil, for: service)
}
} else {
let characteristic = characteristics.removeFirst()
unfinishedCharacteristics[peripheralKey] = characteristics
peripheral.discoverDescriptors(for: characteristic)
}
} else {
didDiscoverGATT(peripheral, error)
}
}
func didDiscoverDescriptors(_ peripheral: CBPeripheral, _ characteristic: CBCharacteristic, _ error: Error?) {
let peripheralKey = peripheral.hash
if error == nil {
var characteristics = unfinishedCharacteristics.removeValue(forKey: peripheralKey) ?? []
if (characteristics.isEmpty) {
var services = unfinishedServices.removeValue(forKey: peripheralKey) ?? []
if services.isEmpty {
didDiscoverGATT(peripheral, error)
} else {
let service = services.removeFirst()
unfinishedServices[peripheralKey] = services
peripheral.discoverCharacteristics(nil, for: service)
}
} else {
let characteristic = characteristics.removeFirst()
unfinishedCharacteristics[peripheralKey] = characteristics
peripheral.discoverDescriptors(for: characteristic)
}
} else {
didDiscoverGATT(peripheral, error)
}
}
private func didDiscoverGATT(_ peripheral: CBPeripheral, _ error: Error?) {
let peripheralKey = peripheral.hash
unfinishedServices.removeValue(forKey: peripheralKey)
unfinishedCharacteristics.removeValue(forKey: peripheralKey)
guard let completion = discoverGattCompletions.removeValue(forKey: peripheralKey) else {
return
}
if error == nil {
let services = peripheral.services ?? []
var cachedServices = [Int: CBService]()
for service in services {
let serviceKey = service.hash
cachedServices[serviceKey] = service
let characteristics = service.characteristics ?? []
var cachedCharacteristics = [Int: CBCharacteristic]()
for characteristic in characteristics {
let characteristicKey = characteristic.hash
cachedCharacteristics[characteristicKey] = characteristic
let descriptors = characteristic.descriptors ?? []
var cachedDescriptors = [Int: CBDescriptor]()
for descriptor in descriptors {
let descriptorKey = descriptor.hash
cachedDescriptors[descriptorKey] = descriptor
}
self.cachedDescriptors[characteristicKey] = cachedDescriptors
}
self.cachedCharacteristics[serviceKey] = cachedCharacteristics
}
self.cachedServices[peripheralKey] = cachedServices
completion(.success(()))
} else {
completion(.failure(error!))
}
}
func didUpdateCharacteristicValue(_ characteristic: CBCharacteristic, _ error: Error?) {
let characteristicKey = characteristic.hash
guard let completion = readCharacteristicCompletions.removeValue(forKey: characteristicKey) else {
let myCharacteristicKey = Int64(characteristicKey)
let rawValue = characteristic.value ?? Data()
let value = FlutterStandardTypedData(bytes: rawValue)
myApi.onCharacteristicValueChanged(myCharacteristicKey: myCharacteristicKey, value: value) {}
return
}
if error == nil {
let rawValue = characteristic.value ?? Data()
let value = FlutterStandardTypedData(bytes: rawValue)
completion(.success(value))
} else {
completion(.failure(error!))
}
}
func didWriteCharacteristicValue(_ characteristic: CBCharacteristic, _ error: Error?) {
let characteristicKey = characteristic.hash
guard let completion = writeCharacteristicCompletions.removeValue(forKey: characteristicKey) else {
return
}
if error == nil {
completion(.success(()))
} else {
completion(.failure(error!))
}
}
func didUpdateNotificationState(_ characteristic: CBCharacteristic, _ error: Error?) {
let characteristicKey = characteristic.hash
guard let completion = notifyCharacteristicCompletions.removeValue(forKey: characteristicKey) else {
return
}
if error == nil {
completion(.success(()))
} else {
completion(.failure(error!))
}
}
func didUpdateDescriptorValue(_ descriptor: CBDescriptor, _ error: Error?) {
let descriptorKey = descriptor.hash
guard let completion = readDescriptorCompletions.removeValue(forKey: descriptorKey) else {
return
}
if error == nil {
// TODO: Need to confirm wheather the corresponding descriptor type and value is correct.
let value: FlutterStandardTypedData
let rawValue = descriptor.value
do {
switch descriptor.uuid.uuidString {
case CBUUIDCharacteristicExtendedPropertiesString:
fallthrough
case CBUUIDClientCharacteristicConfigurationString:
fallthrough
case CBUUIDServerCharacteristicConfigurationString:
guard let rawNumber = rawValue as? NSNumber else {
throw MyError.illegalArgument
}
value = FlutterStandardTypedData(bytes: rawNumber.data)
case CBUUIDCharacteristicUserDescriptionString:
fallthrough
case CBUUIDCharacteristicAggregateFormatString:
guard let rawString = rawValue as? String else {
throw MyError.illegalArgument
}
value = FlutterStandardTypedData(bytes: rawString.data)
case CBUUIDCharacteristicFormatString:
guard let rawData = rawValue as? Data else {
throw MyError.illegalArgument
}
value = FlutterStandardTypedData(bytes: rawData)
case CBUUIDL2CAPPSMCharacteristicString:
guard let rawU16 = rawValue as? UInt16 else {
throw MyError.illegalArgument
}
value = FlutterStandardTypedData(bytes: rawU16.data)
default:
throw MyError.illegalArgument
}
} catch {
value = FlutterStandardTypedData()
}
completion(.success((value)))
} else {
completion(.failure(error!))
}
}
func didWriteDescriptorValue(_ descriptor: CBDescriptor, _ error: Error?) {
let descriptorKey = descriptor.hash
guard let completion = writeDescriptorCompletions.removeValue(forKey: descriptorKey) else {
return
}
if error == nil {
completion(.success(()))
} else {
completion(.failure(error!))
}
}
}
extension CBManagerState {
func toMyArgs() -> MyCentralStateArgs {
switch self {
case .unauthorized:
return .unauthorized
case .poweredOff:
return .poweredOff
case .poweredOn:
return .poweredOn
default:
return .unsupported
}
}
}
extension CBPeripheral {
func toMyArgs() -> MyPeripheralArgs {
let key = Int64(hash)
let uuid = identifier.uuidString
return MyPeripheralArgs(key: key, uuid: uuid)
}
}
extension CBService {
func toMyArgs() -> MyGattServiceArgs {
let key = Int64(hash)
let uuid = uuid.uuidString
return MyGattServiceArgs(key: key, uuid: uuid)
}
}
extension CBCharacteristic {
func toMyArgs() -> MyGattCharacteristicArgs {
let key = Int64(hash)
let uuid = uuid.uuidString
let myPropertyArgses = properties.toMyArgses()
let myPropertyNumbers = myPropertyArgses.map { myPropertyArgs in Int64(myPropertyArgs.rawValue) }
return MyGattCharacteristicArgs(key: key, uuid: uuid, myPropertyNumbers: myPropertyNumbers)
}
}
extension CBDescriptor {
func toMyArgs() -> MyGattDescriptorArgs {
let key = Int64(hash)
let uuid = uuid.uuidString
return MyGattDescriptorArgs(key: key, uuid: uuid)
}
}
extension CBCharacteristicProperties {
func toMyArgses() -> [MyGattCharacteristicPropertyArgs] {
var myPropertyArgs = [MyGattCharacteristicPropertyArgs]()
if contains(.read) {
myPropertyArgs.append(.read)
}
if contains(.write) {
myPropertyArgs.append(.write)
}
if contains(.writeWithoutResponse) {
myPropertyArgs.append(.writeWithoutResponse)
}
if contains(.notify) {
myPropertyArgs.append(.notify)
}
if contains(.indicate) {
myPropertyArgs.append(.indicate)
}
return myPropertyArgs
}
}
extension MyGattCharacteristicWriteTypeArgs {
func toType() -> CBCharacteristicWriteType {
switch self {
case .withResponse:
return .withResponse
case .withoutResponse:
return .withoutResponse
}
}
}
extension NSNumber {
var data: Data {
var source = self
return Data(bytes: &source, count: MemoryLayout<NSNumber>.size)
}
}
extension String {
var data: Data {
return data(using: String.Encoding.utf8)!
}
}
extension UInt16 {
var data: Data {
var source = self
return Data(bytes: &source, count: MemoryLayout<UInt16>.size)
}
}

View File

@ -1,23 +0,0 @@
#
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html.
# Run `pod lib lint bluetooth_low_energy.podspec` to validate before publishing.
#
Pod::Spec.new do |s|
s.name = 'bluetooth_low_energy'
s.version = '0.0.1'
s.summary = 'A new Flutter plugin project.'
s.description = <<-DESC
A new Flutter plugin project.
DESC
s.homepage = 'http://example.com'
s.license = { :file => '../LICENSE' }
s.author = { 'Your Company' => 'email@example.com' }
s.source = { :path => '.' }
s.source_files = 'Classes/**/*'
s.dependency 'Flutter'
s.platform = :ios, '11.0'
# Flutter.framework does not contain a i386 slice.
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
s.swift_version = '5.0'
end

View File

@ -1,9 +0,0 @@
import 'package:bluetooth_low_energy_platform_interface/bluetooth_low_energy_platform_interface.dart';
import 'src/my_central_controller.dart';
abstract class BluetoothLowEnergyiOS {
static void registerWith() {
CentralController.instance = MyCentralController();
}
}

View File

@ -1,26 +0,0 @@
name: bluetooth_low_energy_ios
description: iOS implementation of the bluetooth_low_energy plugin.
version: 2.0.1
homepage: https://github.com/yanshouwang/bluetooth_low_energy
environment:
sdk: ">=3.0.0 <4.0.0"
flutter: ">=3.3.0"
dependencies:
flutter:
sdk: flutter
bluetooth_low_energy_platform_interface: ^2.0.1
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^2.0.0
pigeon: ^10.1.6
flutter:
plugin:
platforms:
ios:
pluginClass: BluetoothLowEnergyiOS
dartPluginClass: BluetoothLowEnergyiOS

View File

@ -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,11 +13,11 @@ project_type: plugin
migration:
platforms:
- platform: root
create_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
base_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
create_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31
base_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31
- platform: linux
create_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
base_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf
create_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31
base_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31
# User provided section

View File

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

View File

@ -1,6 +1,6 @@
name: bluetooth_low_energy_linux
description: Linux implementation of the bluetooth_low_energy plugin.
version: 2.0.1
version: 2.0.2
homepage: https://github.com/yanshouwang/bluetooth_low_energy
environment:
@ -10,7 +10,7 @@ environment:
dependencies:
flutter:
sdk: flutter
bluetooth_low_energy_platform_interface: ^2.0.1
bluetooth_low_energy_platform_interface: ^2.0.2
bluez: ^0.8.1
dev_dependencies:

View File

@ -1,30 +0,0 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/
# IntelliJ related
*.iml
*.ipr
*.iws
.idea/
# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/
# Flutter/Dart/Pub related
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
/pubspec.lock
**/doc/api/
.dart_tool/
.packages
build/

View File

@ -1,10 +0,0 @@
## 2.0.1
- Fix the issue that GATTs is cleared after peripheral disconnected on iOS and macOS.
- Fix the issue that create UUID form peripheral's address failed on Linux.
- Fix the issue that instance match failed on Linux.
## 2.0.0
- Rewrite the whole project with federated plugins.
- Support macOS and Linux.

View File

@ -1,21 +0,0 @@
MIT License
Copyright (c) 2021 yanshouwang
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
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.

View File

@ -1,15 +0,0 @@
# bluetooth_low_energy_macos
The macOS implementation of [`bluetooth_low_energy`][1].
## Usage
This package is [endorsed][2], which means you can simply use `bluetooth_low_energy`
normally. This package will be automatically included in your app when you do,
so you do not need to add it to your `pubspec.yaml`.
However, if you `import` this package to use any of its APIs directly, you
should add it to your `pubspec.yaml` as usual.
[1]: https://pub.dev/packages/bluetooth_low_energy
[2]: https://flutter.dev/docs/development/packages-and-plugins/developing-packages#endorsed-federated-plugin

View File

@ -1,4 +0,0 @@
include: package:flutter_lints/flutter.yaml
# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options

View File

@ -1,736 +0,0 @@
// Autogenerated from Pigeon (v10.1.6), do not edit directly.
// See also: https://pub.dev/packages/pigeon
// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import
import 'dart:async';
import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List;
import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer;
import 'package:flutter/services.dart';
enum MyCentralStateArgs {
unknown,
unsupported,
unauthorized,
poweredOff,
poweredOn,
}
enum MyGattCharacteristicPropertyArgs {
read,
write,
writeWithoutResponse,
notify,
indicate,
}
enum MyGattCharacteristicWriteTypeArgs {
withResponse,
withoutResponse,
}
class MyCentralControllerArgs {
MyCentralControllerArgs({
required this.myStateNumber,
});
int myStateNumber;
Object encode() {
return <Object?>[
myStateNumber,
];
}
static MyCentralControllerArgs decode(Object result) {
result as List<Object?>;
return MyCentralControllerArgs(
myStateNumber: result[0]! as int,
);
}
}
class MyPeripheralArgs {
MyPeripheralArgs({
required this.key,
required this.uuid,
});
int key;
String uuid;
Object encode() {
return <Object?>[
key,
uuid,
];
}
static MyPeripheralArgs decode(Object result) {
result as List<Object?>;
return MyPeripheralArgs(
key: result[0]! as int,
uuid: result[1]! as String,
);
}
}
class MyAdvertisementArgs {
MyAdvertisementArgs({
this.name,
required this.manufacturerSpecificData,
required this.serviceUUIDs,
required this.serviceData,
});
String? name;
Map<int?, Uint8List?> manufacturerSpecificData;
List<String?> serviceUUIDs;
Map<String?, Uint8List?> serviceData;
Object encode() {
return <Object?>[
name,
manufacturerSpecificData,
serviceUUIDs,
serviceData,
];
}
static MyAdvertisementArgs decode(Object result) {
result as List<Object?>;
return MyAdvertisementArgs(
name: result[0] as String?,
manufacturerSpecificData: (result[1] as Map<Object?, Object?>?)!.cast<int?, Uint8List?>(),
serviceUUIDs: (result[2] as List<Object?>?)!.cast<String?>(),
serviceData: (result[3] as Map<Object?, Object?>?)!.cast<String?, Uint8List?>(),
);
}
}
class MyGattServiceArgs {
MyGattServiceArgs({
required this.key,
required this.uuid,
});
int key;
String uuid;
Object encode() {
return <Object?>[
key,
uuid,
];
}
static MyGattServiceArgs decode(Object result) {
result as List<Object?>;
return MyGattServiceArgs(
key: result[0]! as int,
uuid: result[1]! as String,
);
}
}
class MyGattCharacteristicArgs {
MyGattCharacteristicArgs({
required this.key,
required this.uuid,
required this.myPropertyNumbers,
});
int key;
String uuid;
List<int?> myPropertyNumbers;
Object encode() {
return <Object?>[
key,
uuid,
myPropertyNumbers,
];
}
static MyGattCharacteristicArgs decode(Object result) {
result as List<Object?>;
return MyGattCharacteristicArgs(
key: result[0]! as int,
uuid: result[1]! as String,
myPropertyNumbers: (result[2] as List<Object?>?)!.cast<int?>(),
);
}
}
class MyGattDescriptorArgs {
MyGattDescriptorArgs({
required this.key,
required this.uuid,
});
int key;
String uuid;
Object encode() {
return <Object?>[
key,
uuid,
];
}
static MyGattDescriptorArgs decode(Object result) {
result as List<Object?>;
return MyGattDescriptorArgs(
key: result[0]! as int,
uuid: result[1]! as String,
);
}
}
class _MyCentralControllerHostApiCodec extends StandardMessageCodec {
const _MyCentralControllerHostApiCodec();
@override
void writeValue(WriteBuffer buffer, Object? value) {
if (value is MyCentralControllerArgs) {
buffer.putUint8(128);
writeValue(buffer, value.encode());
} else if (value is MyGattCharacteristicArgs) {
buffer.putUint8(129);
writeValue(buffer, value.encode());
} else if (value is MyGattDescriptorArgs) {
buffer.putUint8(130);
writeValue(buffer, value.encode());
} else if (value is MyGattServiceArgs) {
buffer.putUint8(131);
writeValue(buffer, value.encode());
} else {
super.writeValue(buffer, value);
}
}
@override
Object? readValueOfType(int type, ReadBuffer buffer) {
switch (type) {
case 128:
return MyCentralControllerArgs.decode(readValue(buffer)!);
case 129:
return MyGattCharacteristicArgs.decode(readValue(buffer)!);
case 130:
return MyGattDescriptorArgs.decode(readValue(buffer)!);
case 131:
return MyGattServiceArgs.decode(readValue(buffer)!);
default:
return super.readValueOfType(type, buffer);
}
}
}
class MyCentralControllerHostApi {
/// Constructor for [MyCentralControllerHostApi]. 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.
MyCentralControllerHostApi({BinaryMessenger? binaryMessenger})
: _binaryMessenger = binaryMessenger;
final BinaryMessenger? _binaryMessenger;
static const MessageCodec<Object?> codec = _MyCentralControllerHostApiCodec();
Future<MyCentralControllerArgs> setUp() async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerHostApi.setUp', codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(null) as List<Object?>?;
if (replyList == null) {
throw PlatformException(
code: 'channel-error',
message: 'Unable to establish connection on channel.',
);
} else if (replyList.length > 1) {
throw PlatformException(
code: replyList[0]! as String,
message: replyList[1] as String?,
details: replyList[2],
);
} else if (replyList[0] == null) {
throw PlatformException(
code: 'null-error',
message: 'Host platform returned null value for non-null return value.',
);
} else {
return (replyList[0] as MyCentralControllerArgs?)!;
}
}
Future<void> tearDown() async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerHostApi.tearDown', codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(null) as List<Object?>?;
if (replyList == null) {
throw PlatformException(
code: 'channel-error',
message: 'Unable to establish connection on channel.',
);
} else if (replyList.length > 1) {
throw PlatformException(
code: replyList[0]! as String,
message: replyList[1] as String?,
details: replyList[2],
);
} else {
return;
}
}
Future<void> startDiscovery() async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerHostApi.startDiscovery', codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(null) as List<Object?>?;
if (replyList == null) {
throw PlatformException(
code: 'channel-error',
message: 'Unable to establish connection on channel.',
);
} else if (replyList.length > 1) {
throw PlatformException(
code: replyList[0]! as String,
message: replyList[1] as String?,
details: replyList[2],
);
} else {
return;
}
}
Future<void> stopDiscovery() async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerHostApi.stopDiscovery', codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(null) as List<Object?>?;
if (replyList == null) {
throw PlatformException(
code: 'channel-error',
message: 'Unable to establish connection on channel.',
);
} else if (replyList.length > 1) {
throw PlatformException(
code: replyList[0]! as String,
message: replyList[1] as String?,
details: replyList[2],
);
} else {
return;
}
}
Future<void> connect(int arg_myPeripheralKey) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerHostApi.connect', codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_myPeripheralKey]) as List<Object?>?;
if (replyList == null) {
throw PlatformException(
code: 'channel-error',
message: 'Unable to establish connection on channel.',
);
} else if (replyList.length > 1) {
throw PlatformException(
code: replyList[0]! as String,
message: replyList[1] as String?,
details: replyList[2],
);
} else {
return;
}
}
Future<void> disconnect(int arg_myPeripheralKey) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerHostApi.disconnect', codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_myPeripheralKey]) as List<Object?>?;
if (replyList == null) {
throw PlatformException(
code: 'channel-error',
message: 'Unable to establish connection on channel.',
);
} else if (replyList.length > 1) {
throw PlatformException(
code: replyList[0]! as String,
message: replyList[1] as String?,
details: replyList[2],
);
} else {
return;
}
}
Future<void> discoverGATT(int arg_myPeripheralKey) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerHostApi.discoverGATT', codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_myPeripheralKey]) as List<Object?>?;
if (replyList == null) {
throw PlatformException(
code: 'channel-error',
message: 'Unable to establish connection on channel.',
);
} else if (replyList.length > 1) {
throw PlatformException(
code: replyList[0]! as String,
message: replyList[1] as String?,
details: replyList[2],
);
} else {
return;
}
}
Future<List<MyGattServiceArgs?>> getServices(int arg_myPeripheralKey) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerHostApi.getServices', codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_myPeripheralKey]) as List<Object?>?;
if (replyList == null) {
throw PlatformException(
code: 'channel-error',
message: 'Unable to establish connection on channel.',
);
} else if (replyList.length > 1) {
throw PlatformException(
code: replyList[0]! as String,
message: replyList[1] as String?,
details: replyList[2],
);
} else if (replyList[0] == null) {
throw PlatformException(
code: 'null-error',
message: 'Host platform returned null value for non-null return value.',
);
} else {
return (replyList[0] as List<Object?>?)!.cast<MyGattServiceArgs?>();
}
}
Future<List<MyGattCharacteristicArgs?>> getCharacteristics(int arg_myServiceKey) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerHostApi.getCharacteristics', codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_myServiceKey]) as List<Object?>?;
if (replyList == null) {
throw PlatformException(
code: 'channel-error',
message: 'Unable to establish connection on channel.',
);
} else if (replyList.length > 1) {
throw PlatformException(
code: replyList[0]! as String,
message: replyList[1] as String?,
details: replyList[2],
);
} else if (replyList[0] == null) {
throw PlatformException(
code: 'null-error',
message: 'Host platform returned null value for non-null return value.',
);
} else {
return (replyList[0] as List<Object?>?)!.cast<MyGattCharacteristicArgs?>();
}
}
Future<List<MyGattDescriptorArgs?>> getDescriptors(int arg_myCharacteristicKey) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerHostApi.getDescriptors', codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_myCharacteristicKey]) as List<Object?>?;
if (replyList == null) {
throw PlatformException(
code: 'channel-error',
message: 'Unable to establish connection on channel.',
);
} else if (replyList.length > 1) {
throw PlatformException(
code: replyList[0]! as String,
message: replyList[1] as String?,
details: replyList[2],
);
} else if (replyList[0] == null) {
throw PlatformException(
code: 'null-error',
message: 'Host platform returned null value for non-null return value.',
);
} else {
return (replyList[0] as List<Object?>?)!.cast<MyGattDescriptorArgs?>();
}
}
Future<Uint8List> readCharacteristic(int arg_myPeripheralKey, int arg_myServiceKey, int arg_myCharacteristicKey) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerHostApi.readCharacteristic', codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_myPeripheralKey, arg_myServiceKey, arg_myCharacteristicKey]) as List<Object?>?;
if (replyList == null) {
throw PlatformException(
code: 'channel-error',
message: 'Unable to establish connection on channel.',
);
} else if (replyList.length > 1) {
throw PlatformException(
code: replyList[0]! as String,
message: replyList[1] as String?,
details: replyList[2],
);
} else if (replyList[0] == null) {
throw PlatformException(
code: 'null-error',
message: 'Host platform returned null value for non-null return value.',
);
} else {
return (replyList[0] as Uint8List?)!;
}
}
Future<void> writeCharacteristic(int arg_myPeripheralKey, int arg_myServiceKey, int arg_myCharacteristicKey, Uint8List arg_value, int arg_myTypeNumber) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerHostApi.writeCharacteristic', codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_myPeripheralKey, arg_myServiceKey, arg_myCharacteristicKey, arg_value, arg_myTypeNumber]) as List<Object?>?;
if (replyList == null) {
throw PlatformException(
code: 'channel-error',
message: 'Unable to establish connection on channel.',
);
} else if (replyList.length > 1) {
throw PlatformException(
code: replyList[0]! as String,
message: replyList[1] as String?,
details: replyList[2],
);
} else {
return;
}
}
Future<void> notifyCharacteristic(int arg_myPeripheralKey, int arg_myServiceKey, int arg_myCharacteristicKey, bool arg_state) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerHostApi.notifyCharacteristic', codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_myPeripheralKey, arg_myServiceKey, arg_myCharacteristicKey, arg_state]) as List<Object?>?;
if (replyList == null) {
throw PlatformException(
code: 'channel-error',
message: 'Unable to establish connection on channel.',
);
} else if (replyList.length > 1) {
throw PlatformException(
code: replyList[0]! as String,
message: replyList[1] as String?,
details: replyList[2],
);
} else {
return;
}
}
Future<Uint8List> readDescriptor(int arg_myPeripheralKey, int arg_myCharacteristicKey, int arg_myDescriptorKey) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerHostApi.readDescriptor', codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_myPeripheralKey, arg_myCharacteristicKey, arg_myDescriptorKey]) as List<Object?>?;
if (replyList == null) {
throw PlatformException(
code: 'channel-error',
message: 'Unable to establish connection on channel.',
);
} else if (replyList.length > 1) {
throw PlatformException(
code: replyList[0]! as String,
message: replyList[1] as String?,
details: replyList[2],
);
} else if (replyList[0] == null) {
throw PlatformException(
code: 'null-error',
message: 'Host platform returned null value for non-null return value.',
);
} else {
return (replyList[0] as Uint8List?)!;
}
}
Future<void> writeDescriptor(int arg_myPeripheralKey, int arg_myCharacteristicKey, int arg_myDescriptorKey, Uint8List arg_value) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerHostApi.writeDescriptor', codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_myPeripheralKey, arg_myCharacteristicKey, arg_myDescriptorKey, arg_value]) as List<Object?>?;
if (replyList == null) {
throw PlatformException(
code: 'channel-error',
message: 'Unable to establish connection on channel.',
);
} else if (replyList.length > 1) {
throw PlatformException(
code: replyList[0]! as String,
message: replyList[1] as String?,
details: replyList[2],
);
} else {
return;
}
}
}
class _MyCentralControllerFlutterApiCodec extends StandardMessageCodec {
const _MyCentralControllerFlutterApiCodec();
@override
void writeValue(WriteBuffer buffer, Object? value) {
if (value is MyAdvertisementArgs) {
buffer.putUint8(128);
writeValue(buffer, value.encode());
} else if (value is MyPeripheralArgs) {
buffer.putUint8(129);
writeValue(buffer, value.encode());
} else {
super.writeValue(buffer, value);
}
}
@override
Object? readValueOfType(int type, ReadBuffer buffer) {
switch (type) {
case 128:
return MyAdvertisementArgs.decode(readValue(buffer)!);
case 129:
return MyPeripheralArgs.decode(readValue(buffer)!);
default:
return super.readValueOfType(type, buffer);
}
}
}
abstract class MyCentralControllerFlutterApi {
static const MessageCodec<Object?> codec = _MyCentralControllerFlutterApiCodec();
void onStateChanged(int myStateNumber);
void onDiscovered(MyPeripheralArgs myPeripheralArgs, int rssi, MyAdvertisementArgs myAdvertisementArgs);
void onPeripheralStateChanged(int myPeripheralKey, bool state);
void onCharacteristicValueChanged(int myCharacteristicKey, Uint8List value);
static void setup(MyCentralControllerFlutterApi? api, {BinaryMessenger? binaryMessenger}) {
{
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerFlutterApi.onStateChanged', codec,
binaryMessenger: binaryMessenger);
if (api == null) {
channel.setMessageHandler(null);
} else {
channel.setMessageHandler((Object? message) async {
assert(message != null,
'Argument for dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerFlutterApi.onStateChanged was null.');
final List<Object?> args = (message as List<Object?>?)!;
final int? arg_myStateNumber = (args[0] as int?);
assert(arg_myStateNumber != null,
'Argument for dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerFlutterApi.onStateChanged was null, expected non-null int.');
api.onStateChanged(arg_myStateNumber!);
return;
});
}
}
{
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerFlutterApi.onDiscovered', codec,
binaryMessenger: binaryMessenger);
if (api == null) {
channel.setMessageHandler(null);
} else {
channel.setMessageHandler((Object? message) async {
assert(message != null,
'Argument for dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerFlutterApi.onDiscovered was null.');
final List<Object?> args = (message as List<Object?>?)!;
final MyPeripheralArgs? arg_myPeripheralArgs = (args[0] as MyPeripheralArgs?);
assert(arg_myPeripheralArgs != null,
'Argument for dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerFlutterApi.onDiscovered was null, expected non-null MyPeripheralArgs.');
final int? arg_rssi = (args[1] as int?);
assert(arg_rssi != null,
'Argument for dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerFlutterApi.onDiscovered was null, expected non-null int.');
final MyAdvertisementArgs? arg_myAdvertisementArgs = (args[2] as MyAdvertisementArgs?);
assert(arg_myAdvertisementArgs != null,
'Argument for dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerFlutterApi.onDiscovered was null, expected non-null MyAdvertisementArgs.');
api.onDiscovered(arg_myPeripheralArgs!, arg_rssi!, arg_myAdvertisementArgs!);
return;
});
}
}
{
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerFlutterApi.onPeripheralStateChanged', codec,
binaryMessenger: binaryMessenger);
if (api == null) {
channel.setMessageHandler(null);
} else {
channel.setMessageHandler((Object? message) async {
assert(message != null,
'Argument for dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerFlutterApi.onPeripheralStateChanged was null.');
final List<Object?> args = (message as List<Object?>?)!;
final int? arg_myPeripheralKey = (args[0] as int?);
assert(arg_myPeripheralKey != null,
'Argument for dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerFlutterApi.onPeripheralStateChanged was null, expected non-null int.');
final bool? arg_state = (args[1] as bool?);
assert(arg_state != null,
'Argument for dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerFlutterApi.onPeripheralStateChanged was null, expected non-null bool.');
api.onPeripheralStateChanged(arg_myPeripheralKey!, arg_state!);
return;
});
}
}
{
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerFlutterApi.onCharacteristicValueChanged', codec,
binaryMessenger: binaryMessenger);
if (api == null) {
channel.setMessageHandler(null);
} else {
channel.setMessageHandler((Object? message) async {
assert(message != null,
'Argument for dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerFlutterApi.onCharacteristicValueChanged was null.');
final List<Object?> args = (message as List<Object?>?)!;
final int? arg_myCharacteristicKey = (args[0] as int?);
assert(arg_myCharacteristicKey != null,
'Argument for dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerFlutterApi.onCharacteristicValueChanged was null, expected non-null int.');
final Uint8List? arg_value = (args[1] as Uint8List?);
assert(arg_value != null,
'Argument for dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerFlutterApi.onCharacteristicValueChanged was null, expected non-null Uint8List.');
api.onCharacteristicValueChanged(arg_myCharacteristicKey!, arg_value!);
return;
});
}
}
}
}

View File

@ -1,354 +0,0 @@
import 'dart:async';
import 'dart:typed_data';
import 'package:bluetooth_low_energy_platform_interface/bluetooth_low_energy_platform_interface.dart';
import 'my_api.g.dart';
import 'my_gatt_characteristic.dart';
import 'my_gatt_descriptor.dart';
import 'my_gatt_service.dart';
import 'my_peripheral.dart';
class MyCentralController extends CentralController
implements MyCentralControllerFlutterApi {
MyCentralController()
: _myApi = MyCentralControllerHostApi(),
_stateChangedController = StreamController.broadcast(),
_discoveredController = StreamController.broadcast(),
_peripheralStateChangedController = StreamController.broadcast(),
_characteristicValueChangedController = StreamController.broadcast(),
_myPeripherals = {},
_myServices = {},
_myCharacteristics = {},
_myDescriptors = {},
_state = CentralState.unknown;
final MyCentralControllerHostApi _myApi;
final StreamController<CentralStateChangedEventArgs> _stateChangedController;
final StreamController<CentralDiscoveredEventArgs> _discoveredController;
final StreamController<PeripheralStateChangedEventArgs>
_peripheralStateChangedController;
final StreamController<GattCharacteristicValueChangedEventArgs>
_characteristicValueChangedController;
final Map<int, MyPeripheral> _myPeripherals;
final Map<int, MyGattService> _myServices;
final Map<int, MyGattCharacteristic> _myCharacteristics;
final Map<int, MyGattDescriptor> _myDescriptors;
CentralState _state;
@override
CentralState get state => _state;
@override
Stream<CentralStateChangedEventArgs> get stateChanged =>
_stateChangedController.stream;
@override
Stream<CentralDiscoveredEventArgs> get discovered =>
_discoveredController.stream;
@override
Stream<PeripheralStateChangedEventArgs> get peripheralStateChanged =>
_peripheralStateChangedController.stream;
@override
Stream<GattCharacteristicValueChangedEventArgs>
get characteristicValueChanged =>
_characteristicValueChangedController.stream;
Future<void> _throwWithState(CentralState state) async {
if (this.state == state) {
throw BluetoothLowEnergyError('$state is unexpected.');
}
}
Future<void> _throwWithoutState(CentralState state) async {
if (this.state != state) {
throw BluetoothLowEnergyError(
'$state is expected, but current state is ${this.state}.',
);
}
}
@override
Future<void> setUp() async {
await _throwWithoutState(CentralState.unknown);
final args = await _myApi.setUp();
final myStateArgs = MyCentralStateArgs.values[args.myStateNumber];
_state = myStateArgs.toState();
MyCentralControllerFlutterApi.setup(this);
}
@override
Future<void> tearDown() async {
await _throwWithState(CentralState.unknown);
await _myApi.tearDown();
MyCentralControllerFlutterApi.setup(null);
_myPeripherals.clear();
_myServices.clear();
_myCharacteristics.clear();
_myDescriptors.clear();
_state = CentralState.unknown;
}
@override
Future<void> startDiscovery() async {
await _throwWithoutState(CentralState.poweredOn);
await _myApi.startDiscovery();
}
@override
Future<void> stopDiscovery() async {
await _throwWithoutState(CentralState.poweredOn);
await _myApi.stopDiscovery();
}
@override
Future<void> connect(Peripheral peripheral) async {
await _throwWithoutState(CentralState.poweredOn);
final myPeripheral = peripheral as MyPeripheral;
await _myApi.connect(myPeripheral.hashCode);
}
@override
Future<void> disconnect(Peripheral peripheral) async {
await _throwWithoutState(CentralState.poweredOn);
final myPeripheral = peripheral as MyPeripheral;
await _myApi.disconnect(myPeripheral.hashCode);
}
@override
Future<void> discoverGATT(Peripheral peripheral) async {
await _throwWithoutState(CentralState.poweredOn);
final myPeripheral = peripheral as MyPeripheral;
await _myApi.discoverGATT(myPeripheral.hashCode);
}
@override
Future<List<GattService>> getServices(Peripheral peripheral) async {
await _throwWithoutState(CentralState.poweredOn);
final myPeripheral = peripheral as MyPeripheral;
final myServiceArgses = await _myApi.getServices(myPeripheral.hashCode);
return myServiceArgses.cast<MyGattServiceArgs>().map(
(myServiceArgs) {
final myService = MyGattService.fromMyArgs(
myPeripheral,
myServiceArgs,
);
_myServices[myService.hashCode] = myService;
return myService;
},
).toList();
}
@override
Future<List<GattCharacteristic>> getCharacteristics(
GattService service,
) async {
await _throwWithoutState(CentralState.poweredOn);
final myService = service as MyGattService;
final myCharactersiticArgses = await _myApi.getCharacteristics(
myService.hashCode,
);
return myCharactersiticArgses.cast<MyGattCharacteristicArgs>().map(
(myCharacteristicArgs) {
final myCharacteristic = MyGattCharacteristic.fromMyArgs(
myService,
myCharacteristicArgs,
);
_myCharacteristics[myCharacteristic.hashCode] = myCharacteristic;
return myCharacteristic;
},
).toList();
}
@override
Future<List<GattDescriptor>> getDescriptors(
GattCharacteristic characteristic,
) async {
await _throwWithoutState(CentralState.poweredOn);
final myCharacteristic = characteristic as MyGattCharacteristic;
final myDescriptorArgses = await _myApi.getDescriptors(
myCharacteristic.hashCode,
);
return myDescriptorArgses.cast<MyGattDescriptorArgs>().map(
(myDescriptorArgs) {
final myDescriptor = MyGattDescriptor.fromMyArgs(
myCharacteristic,
myDescriptorArgs,
);
_myDescriptors[myDescriptor.hashCode] = myDescriptor;
return myDescriptor;
},
).toList();
}
@override
Future<Uint8List> readCharacteristic(
GattCharacteristic characteristic,
) async {
await _throwWithoutState(CentralState.poweredOn);
final myCharacteristic = characteristic as MyGattCharacteristic;
final myService = myCharacteristic.myService;
final myPeripheral = myService.myPeripheral;
final value = await _myApi.readCharacteristic(
myPeripheral.hashCode,
myService.hashCode,
myCharacteristic.hashCode,
);
return value;
}
@override
Future<void> writeCharacteristic(
GattCharacteristic characteristic, {
required Uint8List value,
required GattCharacteristicWriteType type,
}) async {
await _throwWithoutState(CentralState.poweredOn);
final myCharacteristic = characteristic as MyGattCharacteristic;
final myService = myCharacteristic.myService;
final myPeripheral = myService.myPeripheral;
final typeArgs = type.toMyArgs();
final typeNumber = typeArgs.index;
await _myApi.writeCharacteristic(
myPeripheral.hashCode,
myService.hashCode,
myCharacteristic.hashCode,
value,
typeNumber,
);
}
@override
Future<void> notifyCharacteristic(
GattCharacteristic characteristic, {
required bool state,
}) async {
await _throwWithoutState(CentralState.poweredOn);
final myCharacteristic = characteristic as MyGattCharacteristic;
final myService = myCharacteristic.myService;
final myPeripheral = myService.myPeripheral;
await _myApi.notifyCharacteristic(
myPeripheral.hashCode,
myService.hashCode,
myCharacteristic.hashCode,
state,
);
}
@override
Future<Uint8List> readDescriptor(GattDescriptor descriptor) async {
await _throwWithoutState(CentralState.poweredOn);
final myDescriptor = descriptor as MyGattDescriptor;
final myCharacteristic = myDescriptor.myCharacteristic;
final myService = myCharacteristic.myService;
final myPeripheral = myService.myPeripheral;
final value = await _myApi.readDescriptor(
myPeripheral.hashCode,
myCharacteristic.hashCode,
myDescriptor.hashCode,
);
return value;
}
@override
Future<void> writeDescriptor(
GattDescriptor descriptor, {
required Uint8List value,
}) async {
await _throwWithoutState(CentralState.poweredOn);
final myDescriptor = descriptor as MyGattDescriptor;
final myCharacteristic = myDescriptor.myCharacteristic;
final myService = myCharacteristic.myService;
final myPeripheral = myService.myPeripheral;
await _myApi.writeDescriptor(
myPeripheral.hashCode,
myCharacteristic.hashCode,
myDescriptor.hashCode,
value,
);
}
@override
void onStateChanged(int myStateNumber) {
final myStateArgs = MyCentralStateArgs.values[myStateNumber];
final state = myStateArgs.toState();
if (_state == state) {
return;
}
_state = state;
final eventArgs = CentralStateChangedEventArgs(state);
_stateChangedController.add(eventArgs);
}
@override
void onDiscovered(
MyPeripheralArgs myPeripheralArgs,
int rssi,
MyAdvertisementArgs myAdvertisementArgs,
) {
final myPeripheral = MyPeripheral.fromMyArgs(myPeripheralArgs);
_myPeripherals[myPeripheral.hashCode] = myPeripheral;
final advertisement = myAdvertisementArgs.toAdvertisement();
final eventArgs = CentralDiscoveredEventArgs(
myPeripheral,
rssi,
advertisement,
);
_discoveredController.add(eventArgs);
}
@override
void onPeripheralStateChanged(int myPeripheralKey, bool state) {
final myPeripheral = _myPeripherals[myPeripheralKey];
if (myPeripheral == null) {
return;
}
final eventArgs = PeripheralStateChangedEventArgs(myPeripheral, state);
_peripheralStateChangedController.add(eventArgs);
}
@override
void onCharacteristicValueChanged(int myCharacteristicKey, Uint8List value) {
final myCharacteristic =
_myCharacteristics[myCharacteristicKey] as MyGattCharacteristic;
final eventArgs = GattCharacteristicValueChangedEventArgs(
myCharacteristic,
value,
);
_characteristicValueChangedController.add(eventArgs);
}
}
extension on MyAdvertisementArgs {
Advertisement toAdvertisement() {
final serviceUUIDs = this
.serviceUUIDs
.cast<String>()
.map((uuid) => UUID.fromString(uuid))
.toList();
final serviceData = this.serviceData.cast<String, Uint8List>().map(
(uuid, data) {
final key = UUID.fromString(uuid);
final value = data;
return MapEntry(key, value);
},
);
return Advertisement(
name: name,
manufacturerSpecificData: manufacturerSpecificData.cast<int, Uint8List>(),
serviceUUIDs: serviceUUIDs,
serviceData: serviceData,
);
}
}
extension on MyCentralStateArgs {
CentralState toState() {
return CentralState.values[index];
}
}
extension on GattCharacteristicWriteType {
MyGattCharacteristicWriteTypeArgs toMyArgs() {
return MyGattCharacteristicWriteTypeArgs.values[index];
}
}

View File

@ -1,42 +0,0 @@
import 'package:bluetooth_low_energy_platform_interface/bluetooth_low_energy_platform_interface.dart';
import 'my_api.g.dart';
import 'my_gatt_service.dart';
import 'my_object.dart';
class MyGattCharacteristic extends MyObject implements GattCharacteristic {
final MyGattService myService;
@override
final UUID uuid;
@override
final List<GattCharacteristicProperty> properties;
MyGattCharacteristic(
super.hashCode,
this.myService,
this.uuid,
this.properties,
);
factory MyGattCharacteristic.fromMyArgs(
MyGattService myService,
MyGattCharacteristicArgs myArgs,
) {
final hashCode = myArgs.key;
final uuid = UUID.fromString(myArgs.uuid);
final properties = myArgs.myPropertyNumbers.cast<int>().map(
(myPropertyNumber) {
final myPropertyArgs =
MyGattCharacteristicPropertyArgs.values[myPropertyNumber];
return myPropertyArgs.toProperty();
},
).toList();
return MyGattCharacteristic(hashCode, myService, uuid, properties);
}
}
extension on MyGattCharacteristicPropertyArgs {
GattCharacteristicProperty toProperty() {
return GattCharacteristicProperty.values[index];
}
}

View File

@ -1,22 +0,0 @@
import 'package:bluetooth_low_energy_platform_interface/bluetooth_low_energy_platform_interface.dart';
import 'my_api.g.dart';
import 'my_gatt_characteristic.dart';
import 'my_object.dart';
class MyGattDescriptor extends MyObject implements GattDescriptor {
final MyGattCharacteristic myCharacteristic;
@override
final UUID uuid;
MyGattDescriptor(super.hashCode, this.myCharacteristic, this.uuid);
factory MyGattDescriptor.fromMyArgs(
MyGattCharacteristic myCharacteristic,
MyGattDescriptorArgs myArgs,
) {
final hashCode = myArgs.key;
final uuid = UUID.fromString(myArgs.uuid);
return MyGattDescriptor(hashCode, myCharacteristic, uuid);
}
}

View File

@ -1,22 +0,0 @@
import 'package:bluetooth_low_energy_platform_interface/bluetooth_low_energy_platform_interface.dart';
import 'my_api.g.dart';
import 'my_object.dart';
import 'my_peripheral.dart';
class MyGattService extends MyObject implements GattService {
final MyPeripheral myPeripheral;
@override
final UUID uuid;
MyGattService(super.hashCode, this.myPeripheral, this.uuid);
factory MyGattService.fromMyArgs(
MyPeripheral myPeripheral,
MyGattServiceArgs myArgs,
) {
final hashCode = myArgs.key;
final uuid = UUID.fromString(myArgs.uuid);
return MyGattService(hashCode, myPeripheral, uuid);
}
}

View File

@ -1,11 +0,0 @@
abstract class MyObject {
@override
final int hashCode;
MyObject(this.hashCode);
@override
bool operator ==(Object other) {
return other is MyObject && other.hashCode == hashCode;
}
}

View File

@ -1,17 +0,0 @@
import 'package:bluetooth_low_energy_platform_interface/bluetooth_low_energy_platform_interface.dart';
import 'my_api.g.dart';
import 'my_object.dart';
class MyPeripheral extends MyObject implements Peripheral {
@override
final UUID uuid;
MyPeripheral(super.hashCode, this.uuid);
factory MyPeripheral.fromMyArgs(MyPeripheralArgs myArgs) {
final hashCode = myArgs.key;
final uuid = UUID.fromString(myArgs.uuid);
return MyPeripheral(hashCode, uuid);
}
}

View File

@ -1,38 +0,0 @@
//
// MyCentralManagerDelegate.swift
// bluetooth_low_energy_ios
//
// Created by on 2023/8/13.
//
import Foundation
import CoreBluetooth
class MyCentralManagerDelegate: NSObject, CBCentralManagerDelegate {
private let myCentralController: MyCentralController
init(_ myCentralController: MyCentralController) {
self.myCentralController = myCentralController
}
func centralManagerDidUpdateState(_ central: CBCentralManager) {
let state = central.state
myCentralController.didUpdateState(state)
}
func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) {
myCentralController.didDiscover(peripheral, advertisementData, RSSI)
}
func centralManager(_ central: CBCentralManager, didConnect peripheral: CBPeripheral) {
myCentralController.didConnect(peripheral)
}
func centralManager(_ central: CBCentralManager, didFailToConnect peripheral: CBPeripheral, error: Error?) {
myCentralController.didFailToConnect(peripheral, error)
}
func centralManager(_ central: CBCentralManager, didDisconnectPeripheral peripheral: CBPeripheral, error: Error?) {
myCentralController.didDisconnectPeripheral(peripheral, error)
}
}

View File

@ -1,14 +0,0 @@
//
// MyError.swift
// bluetooth_low_energy_ios
//
// Created by on 2023/8/13.
//
import Foundation
enum MyError: Error {
case illegalArgument
case illegalState
case unknown
}

View File

@ -1,49 +0,0 @@
//
// MyPeripheralDelegate.swift
// bluetooth_low_energy_ios
//
// Created by on 2023/8/13.
//
import Foundation
import CoreBluetooth
class MyPeripheralDelegate: NSObject, CBPeripheralDelegate {
private let myCentralController: MyCentralController
init(_ myCentralController: MyCentralController) {
self.myCentralController = myCentralController
}
func peripheral(_ peripheral: CBPeripheral, didDiscoverServices error: Error?) {
myCentralController.didDiscoverServices(peripheral, error)
}
func peripheral(_ peripheral: CBPeripheral, didDiscoverCharacteristicsFor service: CBService, error: Error?) {
myCentralController.didDiscoverCharacteristics(peripheral, service, error)
}
func peripheral(_ peripheral: CBPeripheral, didDiscoverDescriptorsFor characteristic: CBCharacteristic, error: Error?) {
myCentralController.didDiscoverDescriptors(peripheral, characteristic, error)
}
func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?) {
myCentralController.didUpdateCharacteristicValue(characteristic, error)
}
func peripheral(_ peripheral: CBPeripheral, didWriteValueFor characteristic: CBCharacteristic, error: Error?) {
myCentralController.didWriteCharacteristicValue(characteristic, error)
}
func peripheral(_ peripheral: CBPeripheral, didUpdateNotificationStateFor characteristic: CBCharacteristic, error: Error?) {
myCentralController.didUpdateNotificationState(characteristic, error)
}
func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor descriptor: CBDescriptor, error: Error?) {
myCentralController.didUpdateDescriptorValue(descriptor, error)
}
func peripheral(_ peripheral: CBPeripheral, didWriteValueFor descriptor: CBDescriptor, error: Error?) {
myCentralController.didWriteDescriptorValue(descriptor, error)
}
}

View File

@ -1,23 +0,0 @@
#
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html.
# Run `pod lib lint bluetooth_low_energy.podspec` to validate before publishing.
#
Pod::Spec.new do |s|
s.name = 'bluetooth_low_energy'
s.version = '0.0.1'
s.summary = 'A new Flutter plugin project.'
s.description = <<-DESC
A new Flutter plugin project.
DESC
s.homepage = 'http://example.com'
s.license = { :file => '../LICENSE' }
s.author = { 'Your Company' => 'email@example.com' }
s.source = { :path => '.' }
s.source_files = 'Classes/**/*'
s.dependency 'FlutterMacOS'
s.platform = :osx, '10.11'
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
s.swift_version = '5.0'
end

View File

@ -1,151 +0,0 @@
import 'package:pigeon/pigeon.dart';
@ConfigurePigeon(
PigeonOptions(
dartOut: 'lib/src/my_api.g.dart',
dartOptions: DartOptions(),
swiftOut: 'macos/Classes/MyApi.g.swift',
swiftOptions: SwiftOptions(),
),
)
@HostApi()
abstract class MyCentralControllerHostApi {
@async
MyCentralControllerArgs setUp();
void tearDown();
void startDiscovery();
void stopDiscovery();
@async
void connect(int myPeripheralKey);
@async
void disconnect(int myPeripheralKey);
@async
void discoverGATT(int myPeripheralKey);
List<MyGattServiceArgs> getServices(int myPeripheralKey);
List<MyGattCharacteristicArgs> getCharacteristics(int myServiceKey);
List<MyGattDescriptorArgs> getDescriptors(int myCharacteristicKey);
@async
Uint8List readCharacteristic(
int myPeripheralKey,
int myServiceKey,
int myCharacteristicKey,
);
@async
void writeCharacteristic(
int myPeripheralKey,
int myServiceKey,
int myCharacteristicKey,
Uint8List value,
int myTypeNumber,
);
@async
void notifyCharacteristic(
int myPeripheralKey,
int myServiceKey,
int myCharacteristicKey,
bool state,
);
@async
Uint8List readDescriptor(
int myPeripheralKey,
int myCharacteristicKey,
int myDescriptorKey,
);
@async
void writeDescriptor(
int myPeripheralKey,
int myCharacteristicKey,
int myDescriptorKey,
Uint8List value,
);
}
@FlutterApi()
abstract class MyCentralControllerFlutterApi {
void onStateChanged(int myStateNumber);
void onDiscovered(
MyPeripheralArgs myPeripheralArgs,
int rssi,
MyAdvertisementArgs myAdvertisementArgs,
);
void onPeripheralStateChanged(int myPeripheralKey, bool state);
void onCharacteristicValueChanged(int myCharacteristicKey, Uint8List value);
}
class MyCentralControllerArgs {
final int myStateNumber;
MyCentralControllerArgs(this.myStateNumber);
}
class MyPeripheralArgs {
final int key;
final String uuid;
MyPeripheralArgs(this.key, this.uuid);
}
class MyAdvertisementArgs {
final String? name;
final Map<int?, Uint8List?> manufacturerSpecificData;
final List<String?> serviceUUIDs;
final Map<String?, Uint8List?> serviceData;
MyAdvertisementArgs(
this.name,
this.manufacturerSpecificData,
this.serviceUUIDs,
this.serviceData,
);
}
class MyGattServiceArgs {
final int key;
final String uuid;
MyGattServiceArgs(this.key, this.uuid);
}
class MyGattCharacteristicArgs {
final int key;
final String uuid;
final List<int?> myPropertyNumbers;
MyGattCharacteristicArgs(
this.key,
this.uuid,
this.myPropertyNumbers,
);
}
class MyGattDescriptorArgs {
final int key;
final String uuid;
MyGattDescriptorArgs(this.key, this.uuid);
}
enum MyCentralStateArgs {
unknown,
unsupported,
unauthorized,
poweredOff,
poweredOn,
}
enum MyGattCharacteristicPropertyArgs {
read,
write,
writeWithoutResponse,
notify,
indicate,
}
enum MyGattCharacteristicWriteTypeArgs {
// Write with response
withResponse,
// Write without response
withoutResponse,
// Write with response and waiting for confirmation
// reliable,
}

View File

@ -1,26 +0,0 @@
name: bluetooth_low_energy_macos
description: macOS implementation of the bluetooth_low_energy plugin.
version: 2.0.1
homepage: https://github.com/yanshouwang/bluetooth_low_energy
environment:
sdk: ">=3.0.0 <4.0.0"
flutter: ">=3.3.0"
dependencies:
flutter:
sdk: flutter
bluetooth_low_energy_platform_interface: ^2.0.1
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^2.0.0
pigeon: ^10.1.6
flutter:
plugin:
platforms:
macos:
pluginClass: BluetoothLowEnergymacOS
dartPluginClass: BluetoothLowEnergymacOS

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

Some files were not shown because too many files have changed in this diff Show More