From 0f4fb7f553cdc0c19916b99ecd1b6e413289a956 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=E5=89=91=E4=BE=A0=E5=AE=A2?= Date: Mon, 21 Aug 2023 01:06:57 +0800 Subject: [PATCH] 2.0.2 (#11) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 重构 * fix: 1 * fix: 重构 * fix: 修复 iOS 和 macOS 代码错误 * fix: 优化项目 * fix: 构建项目 * fix: 修复权限问题 * fix: 解决 macOS 沙盒权限问题 * fix: 修复代码问题 * fix: 更新依赖 * fix: 更新依赖项 * fix: 添加缺失的位置权限 --- .gitignore | 2 + LICENSE | 2 +- README.md | 2 +- bluetooth_low_energy/.metadata | 25 +- bluetooth_low_energy/CHANGELOG.md | 7 +- bluetooth_low_energy/LICENSE | 2 +- bluetooth_low_energy/README.md | 2 +- .../example/analysis_options.yaml | 3 +- .../example/android/app/build.gradle | 19 +- .../example/android/settings.gradle | 25 +- .../plugin_integration_test.dart | 13 +- bluetooth_low_energy/example/ios/Podfile.lock | 11 +- .../ios/Runner.xcodeproj/project.pbxproj | 149 ++-- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- .../example/ios/Runner/Info.plist | 2 - .../Flutter/GeneratedPluginRegistrant.swift | 4 +- .../example/macos/Podfile.lock | 11 +- .../macos/Runner.xcodeproj/project.pbxproj | 115 ++- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- .../example/macos/Runner/Info.plist | 2 +- bluetooth_low_energy/example/pubspec.lock | 38 +- bluetooth_low_energy/example/pubspec.yaml | 2 +- .../example/windows/CMakeLists.txt | 2 +- .../flutter/generated_plugin_registrant.cc | 3 - .../windows/flutter/generated_plugins.cmake | 1 - bluetooth_low_energy/pubspec.yaml | 17 +- .../test/bluetooth_low_energy_test.dart | 1 - bluetooth_low_energy_android/.metadata | 14 +- bluetooth_low_energy_android/CHANGELOG.md | 5 + bluetooth_low_energy_android/LICENSE | 2 +- bluetooth_low_energy_android/README.md | 2 +- .../android/build.gradle | 6 +- .../android/settings.gradle | 2 +- .../android/src/main/AndroidManifest.xml | 5 +- .../BluetoothLowEnergyAndroid.kt | 2 +- .../MyApi.g.kt | 2 +- .../MyBluetoothGattCallback.kt | 2 +- .../MyBroadcastReceiver.kt | 2 +- .../MyCentralController.kt | 6 +- .../MyRequestPermissionResultListener.kt | 2 +- .../MyScanCallback.kt | 2 +- .../BluetoothLowEnergyAndroidPluginTest.kt} | 6 +- bluetooth_low_energy_android/my_api.dart | 4 +- bluetooth_low_energy_android/pubspec.yaml | 6 +- .../.gitignore | 0 .../.metadata | 17 +- bluetooth_low_energy_darwin/CHANGELOG.md | 4 + .../LICENSE | 2 +- .../README.md | 4 +- .../analysis_options.yaml | 0 .../Classes/BluetoothLowEnergyDarwin.swift | 15 +- .../darwin}/Classes/MyApi.g.swift | 38 +- .../darwin}/Classes/MyCentralController.swift | 8 +- .../Classes/MyCentralManagerDelegate.swift | 0 .../darwin}/Classes/MyError.swift | 0 .../Classes/MyPeripheralDelegate.swift | 0 .../bluetooth_low_energy_darwin.podspec | 27 + .../lib/bluetooth_low_energy_darwin.dart | 2 +- .../lib/src/my_api.g.dart | 62 +- .../lib/src/my_central_controller.dart | 0 .../lib/src/my_gatt_characteristic.dart | 0 .../lib/src/my_gatt_descriptor.dart | 0 .../lib/src/my_gatt_service.dart | 0 .../lib/src/my_object.dart | 0 .../lib/src/my_peripheral.dart | 0 .../my_api.dart | 2 +- bluetooth_low_energy_darwin/pubspec.yaml | 31 + bluetooth_low_energy_ios/.metadata | 30 - bluetooth_low_energy_ios/CHANGELOG.md | 10 - bluetooth_low_energy_ios/ios/.gitignore | 38 - bluetooth_low_energy_ios/ios/Assets/.gitkeep | 0 .../ios/Classes/BluetoothLowEnergyiOS.swift | 10 - .../ios/Classes/MyApi.g.swift | 599 -------------- .../ios/Classes/MyCentralController.swift | 716 ----------------- .../ios/bluetooth_low_energy.podspec | 23 - .../lib/bluetooth_low_energy_ios.dart | 9 - bluetooth_low_energy_ios/pubspec.yaml | 26 - bluetooth_low_energy_linux/.metadata | 14 +- bluetooth_low_energy_linux/CHANGELOG.md | 5 + bluetooth_low_energy_linux/LICENSE | 2 +- bluetooth_low_energy_linux/pubspec.yaml | 4 +- bluetooth_low_energy_macos/.gitignore | 30 - bluetooth_low_energy_macos/CHANGELOG.md | 10 - bluetooth_low_energy_macos/LICENSE | 21 - bluetooth_low_energy_macos/README.md | 15 - .../analysis_options.yaml | 4 - .../lib/src/my_api.g.dart | 736 ------------------ .../lib/src/my_central_controller.dart | 354 --------- .../lib/src/my_gatt_characteristic.dart | 42 - .../lib/src/my_gatt_descriptor.dart | 22 - .../lib/src/my_gatt_service.dart | 22 - .../lib/src/my_object.dart | 11 - .../lib/src/my_peripheral.dart | 17 - .../Classes/MyCentralManagerDelegate.swift | 38 - .../macos/Classes/MyError.swift | 14 - .../macos/Classes/MyPeripheralDelegate.swift | 49 -- .../macos/bluetooth_low_energy.podspec | 23 - bluetooth_low_energy_macos/my_api.dart | 151 ---- bluetooth_low_energy_macos/pubspec.yaml | 26 - .../.metadata | 10 +- .../CHANGELOG.md | 5 + .../LICENSE | 2 +- .../lib/src/advertisement.dart | 9 + .../lib/src/central_controller.dart | 40 + .../lib/src/central_state.dart | 10 + .../lib/src/errors.dart | 3 + .../lib/src/event_args.dart | 21 + .../lib/src/gatt_characteristic.dart | 5 + .../lib/src/gatt_characteristic_property.dart | 10 + .../src/gatt_characteristic_write_type.dart | 1 + .../lib/src/gatt_descriptor.dart | 3 + .../lib/src/gatt_service.dart | 3 + .../lib/src/peripheral.dart | 2 + .../pubspec.yaml | 2 +- ...th_low_energy_platform_interface_test.dart | 1 - bluetooth_low_energy_windows/.metadata | 14 +- bluetooth_low_energy_windows/CHANGELOG.md | 5 + bluetooth_low_energy_windows/LICENSE | 2 +- bluetooth_low_energy_windows/pubspec.yaml | 5 +- .../windows/.gitignore | 17 - .../windows/CMakeLists.txt | 96 --- .../windows/bluetooth_low_energy_plugin.cpp | 59 -- .../windows/bluetooth_low_energy_plugin.h | 31 - .../bluetooth_low_energy_plugin_c_api.cpp | 12 - .../bluetooth_low_energy_plugin_c_api.h | 23 - .../test/bluetooth_low_energy_plugin_test.cpp | 43 - scripts/run_pigeon.sh | 2 +- 127 files changed, 560 insertions(+), 3693 deletions(-) create mode 100644 .gitignore delete mode 100644 bluetooth_low_energy/test/bluetooth_low_energy_test.dart rename bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/{bluetooth_low_energy => bluetooth_low_energy_android}/BluetoothLowEnergyAndroid.kt (96%) rename bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/{bluetooth_low_energy => bluetooth_low_energy_android}/MyApi.g.kt (99%) rename bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/{bluetooth_low_energy => bluetooth_low_energy_android}/MyBluetoothGattCallback.kt (97%) rename bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/{bluetooth_low_energy => bluetooth_low_energy_android}/MyBroadcastReceiver.kt (85%) rename bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/{bluetooth_low_energy => bluetooth_low_energy_android}/MyCentralController.kt (98%) rename bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/{bluetooth_low_energy => bluetooth_low_energy_android}/MyRequestPermissionResultListener.kt (88%) rename bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/{bluetooth_low_energy => bluetooth_low_energy_android}/MyScanCallback.kt (88%) rename bluetooth_low_energy_android/android/src/test/kotlin/dev/yanshouwang/{bluetooth_low_energy/BluetoothLowEnergyPluginTest.kt => bluetooth_low_energy_android/BluetoothLowEnergyAndroidPluginTest.kt} (84%) rename {bluetooth_low_energy_ios => bluetooth_low_energy_darwin}/.gitignore (100%) rename {bluetooth_low_energy_macos => bluetooth_low_energy_darwin}/.metadata (50%) create mode 100644 bluetooth_low_energy_darwin/CHANGELOG.md rename {bluetooth_low_energy_ios => bluetooth_low_energy_darwin}/LICENSE (99%) rename {bluetooth_low_energy_ios => bluetooth_low_energy_darwin}/README.md (84%) rename {bluetooth_low_energy_ios => bluetooth_low_energy_darwin}/analysis_options.yaml (100%) rename bluetooth_low_energy_macos/macos/Classes/BluetoothLowEnergymacOS.swift => bluetooth_low_energy_darwin/darwin/Classes/BluetoothLowEnergyDarwin.swift (53%) rename {bluetooth_low_energy_macos/macos => bluetooth_low_energy_darwin/darwin}/Classes/MyApi.g.swift (89%) rename {bluetooth_low_energy_macos/macos => bluetooth_low_energy_darwin/darwin}/Classes/MyCentralController.swift (99%) rename {bluetooth_low_energy_ios/ios => bluetooth_low_energy_darwin/darwin}/Classes/MyCentralManagerDelegate.swift (100%) rename {bluetooth_low_energy_ios/ios => bluetooth_low_energy_darwin/darwin}/Classes/MyError.swift (100%) rename {bluetooth_low_energy_ios/ios => bluetooth_low_energy_darwin/darwin}/Classes/MyPeripheralDelegate.swift (100%) create mode 100644 bluetooth_low_energy_darwin/darwin/bluetooth_low_energy_darwin.podspec rename bluetooth_low_energy_macos/lib/bluetooth_low_energy_macos.dart => bluetooth_low_energy_darwin/lib/bluetooth_low_energy_darwin.dart (85%) rename {bluetooth_low_energy_ios => bluetooth_low_energy_darwin}/lib/src/my_api.g.dart (88%) rename {bluetooth_low_energy_ios => bluetooth_low_energy_darwin}/lib/src/my_central_controller.dart (100%) rename {bluetooth_low_energy_ios => bluetooth_low_energy_darwin}/lib/src/my_gatt_characteristic.dart (100%) rename {bluetooth_low_energy_ios => bluetooth_low_energy_darwin}/lib/src/my_gatt_descriptor.dart (100%) rename {bluetooth_low_energy_ios => bluetooth_low_energy_darwin}/lib/src/my_gatt_service.dart (100%) rename {bluetooth_low_energy_ios => bluetooth_low_energy_darwin}/lib/src/my_object.dart (100%) rename {bluetooth_low_energy_ios => bluetooth_low_energy_darwin}/lib/src/my_peripheral.dart (100%) rename {bluetooth_low_energy_ios => bluetooth_low_energy_darwin}/my_api.dart (98%) create mode 100644 bluetooth_low_energy_darwin/pubspec.yaml delete mode 100644 bluetooth_low_energy_ios/.metadata delete mode 100644 bluetooth_low_energy_ios/CHANGELOG.md delete mode 100644 bluetooth_low_energy_ios/ios/.gitignore delete mode 100644 bluetooth_low_energy_ios/ios/Assets/.gitkeep delete mode 100644 bluetooth_low_energy_ios/ios/Classes/BluetoothLowEnergyiOS.swift delete mode 100644 bluetooth_low_energy_ios/ios/Classes/MyApi.g.swift delete mode 100644 bluetooth_low_energy_ios/ios/Classes/MyCentralController.swift delete mode 100644 bluetooth_low_energy_ios/ios/bluetooth_low_energy.podspec delete mode 100644 bluetooth_low_energy_ios/lib/bluetooth_low_energy_ios.dart delete mode 100644 bluetooth_low_energy_ios/pubspec.yaml delete mode 100644 bluetooth_low_energy_macos/.gitignore delete mode 100644 bluetooth_low_energy_macos/CHANGELOG.md delete mode 100644 bluetooth_low_energy_macos/LICENSE delete mode 100644 bluetooth_low_energy_macos/README.md delete mode 100644 bluetooth_low_energy_macos/analysis_options.yaml delete mode 100644 bluetooth_low_energy_macos/lib/src/my_api.g.dart delete mode 100644 bluetooth_low_energy_macos/lib/src/my_central_controller.dart delete mode 100644 bluetooth_low_energy_macos/lib/src/my_gatt_characteristic.dart delete mode 100644 bluetooth_low_energy_macos/lib/src/my_gatt_descriptor.dart delete mode 100644 bluetooth_low_energy_macos/lib/src/my_gatt_service.dart delete mode 100644 bluetooth_low_energy_macos/lib/src/my_object.dart delete mode 100644 bluetooth_low_energy_macos/lib/src/my_peripheral.dart delete mode 100644 bluetooth_low_energy_macos/macos/Classes/MyCentralManagerDelegate.swift delete mode 100644 bluetooth_low_energy_macos/macos/Classes/MyError.swift delete mode 100644 bluetooth_low_energy_macos/macos/Classes/MyPeripheralDelegate.swift delete mode 100644 bluetooth_low_energy_macos/macos/bluetooth_low_energy.podspec delete mode 100644 bluetooth_low_energy_macos/my_api.dart delete mode 100644 bluetooth_low_energy_macos/pubspec.yaml delete mode 100644 bluetooth_low_energy_platform_interface/test/bluetooth_low_energy_platform_interface_test.dart delete mode 100644 bluetooth_low_energy_windows/windows/.gitignore delete mode 100644 bluetooth_low_energy_windows/windows/CMakeLists.txt delete mode 100644 bluetooth_low_energy_windows/windows/bluetooth_low_energy_plugin.cpp delete mode 100644 bluetooth_low_energy_windows/windows/bluetooth_low_energy_plugin.h delete mode 100644 bluetooth_low_energy_windows/windows/bluetooth_low_energy_plugin_c_api.cpp delete mode 100644 bluetooth_low_energy_windows/windows/include/bluetooth_low_energy/bluetooth_low_energy_plugin_c_api.h delete mode 100644 bluetooth_low_energy_windows/windows/test/bluetooth_low_energy_plugin_test.cpp diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5185860 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.vscode/ +.DS_Store \ No newline at end of file diff --git a/LICENSE b/LICENSE index 515ed4b..752d28b 100644 --- a/LICENSE +++ b/LICENSE @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +SOFTWARE. diff --git a/README.md b/README.md index 897ff13..aa7eedb 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,4 @@ This repo contains the source code for the [`bluetooth_low_energy`][1] federated plugins. -[1]: https://pub.dev/packages/bluetooth_low_energy \ No newline at end of file +[1]: https://pub.dev/packages/bluetooth_low_energy diff --git a/bluetooth_low_energy/.metadata b/bluetooth_low_energy/.metadata index 226b72c..0885ce9 100644 --- a/bluetooth_low_energy/.metadata +++ b/bluetooth_low_energy/.metadata @@ -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 diff --git a/bluetooth_low_energy/CHANGELOG.md b/bluetooth_low_energy/CHANGELOG.md index f461cce..4edec1f 100644 --- a/bluetooth_low_energy/CHANGELOG.md +++ b/bluetooth_low_energy/CHANGELOG.md @@ -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. @@ -38,4 +43,4 @@ - Add central APIs. - Add implementations on Android. - Add example. -- Add test. \ No newline at end of file +- Add test. diff --git a/bluetooth_low_energy/LICENSE b/bluetooth_low_energy/LICENSE index 515ed4b..752d28b 100644 --- a/bluetooth_low_energy/LICENSE +++ b/bluetooth_low_energy/LICENSE @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +SOFTWARE. diff --git a/bluetooth_low_energy/README.md b/bluetooth_low_energy/README.md index 16dc072..c401d9c 100644 --- a/bluetooth_low_energy/README.md +++ b/bluetooth_low_energy/README.md @@ -44,4 +44,4 @@ Not tested enough, if you occured any problems, file an issue to let me know abo ### Windows -Not implemented yet but maybe someday or someone can use the `win32` api to implement this plugin_interface or someday the flutter team support C# on windows platform or someday I am familiar with C++ language... \ No newline at end of file +Not implemented yet but maybe someday or someone can use the `win32` api to implement this plugin_interface or someday the flutter team support C# on windows platform or someday I am familiar with C++ language... diff --git a/bluetooth_low_energy/example/analysis_options.yaml b/bluetooth_low_energy/example/analysis_options.yaml index 61b6c4d..0d29021 100644 --- a/bluetooth_low_energy/example/analysis_options.yaml +++ b/bluetooth_low_energy/example/analysis_options.yaml @@ -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 diff --git a/bluetooth_low_energy/example/android/app/build.gradle b/bluetooth_low_energy/example/android/app/build.gradle index 0a7b461..c5ff818 100644 --- a/bluetooth_low_energy/example/android/app/build.gradle +++ b/bluetooth_low_energy/example/android/app/build.gradle @@ -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 {} diff --git a/bluetooth_low_energy/example/android/settings.gradle b/bluetooth_low_energy/example/android/settings.gradle index 44e62bc..55c4ca8 100644 --- a/bluetooth_low_energy/example/android/settings.gradle +++ b/bluetooth_low_energy/example/android/settings.gradle @@ -1,11 +1,20 @@ -include ':app' +pluginManagement { + def flutterSdkPath = { + def properties = new Properties() + file("local.properties").withInputStream { properties.load(it) } + def flutterSdkPath = properties.getProperty("flutter.sdk") + assert flutterSdkPath != null, "flutter.sdk not set in local.properties" + return flutterSdkPath + } + settings.ext.flutterSdkPath = flutterSdkPath() -def localPropertiesFile = new File(rootProject.projectDir, "local.properties") -def properties = new Properties() + includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle") -assert localPropertiesFile.exists() -localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } + plugins { + id "dev.flutter.flutter-gradle-plugin" version "1.0.0" apply false + } +} -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" +include ":app" + +apply from: "${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle/app_plugin_loader.gradle" diff --git a/bluetooth_low_energy/example/integration_test/plugin_integration_test.dart b/bluetooth_low_energy/example/integration_test/plugin_integration_test.dart index 2eeb89b..1d27379 100644 --- a/bluetooth_low_energy/example/integration_test/plugin_integration_test.dart +++ b/bluetooth_low_energy/example/integration_test/plugin_integration_test.dart @@ -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); + // }); } diff --git a/bluetooth_low_energy/example/ios/Podfile.lock b/bluetooth_low_energy/example/ios/Podfile.lock index f2680d1..01f97ed 100644 --- a/bluetooth_low_energy/example/ios/Podfile.lock +++ b/bluetooth_low_energy/example/ios/Podfile.lock @@ -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 diff --git a/bluetooth_low_energy/example/ios/Runner.xcodeproj/project.pbxproj b/bluetooth_low_energy/example/ios/Runner.xcodeproj/project.pbxproj index 4614611..138e46c 100644 --- a/bluetooth_low_energy/example/ios/Runner.xcodeproj/project.pbxproj +++ b/bluetooth_low_energy/example/ios/Runner.xcodeproj/project.pbxproj @@ -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 = ""; }; + 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 = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; + 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 = ""; }; 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 = ""; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; - 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 = ""; }; - 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 = ""; }; + 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 = ""; }; + 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 = ""; }; + 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 = ""; }; 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; - 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 = ""; }; + 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 = ""; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 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 = ""; }; 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 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 = ""; }; - 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 = ""; }; + 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 = ""; }; /* 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 = ""; + }; 331C8082294A63A400263BE5 /* RunnerTests */ = { isa = PBXGroup; children = ( @@ -95,15 +104,15 @@ path = RunnerTests; sourceTree = ""; }; - 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 = ""; @@ -126,8 +135,8 @@ 97C146F01CF9000F007C117D /* Runner */, 97C146EF1CF9000F007C117D /* Products */, 331C8082294A63A400263BE5 /* RunnerTests */, - 822F134A747E09F3777D7DEA /* Pods */, - C80FCE1738A3643721B199AA /* Frameworks */, + 3C9A3D0714D61C07F02BFBB4 /* Pods */, + 0FAACD3CD9E188E482384358 /* Frameworks */, ); sourceTree = ""; }; @@ -155,15 +164,6 @@ path = Runner; sourceTree = ""; }; - C80FCE1738A3643721B199AA /* Frameworks */ = { - isa = PBXGroup; - children = ( - 98646AC7896A9C8175156D38 /* Pods_Runner.framework */, - 439B7B71AF91617DD56EEFF1 /* Pods_RunnerTests.framework */, - ); - name = Frameworks; - sourceTree = ""; - }; /* 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; diff --git a/bluetooth_low_energy/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/bluetooth_low_energy/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index e42adcb..87131a0 100644 --- a/bluetooth_low_energy/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/bluetooth_low_energy/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight - UIViewControllerBasedStatusBarAppearance - diff --git a/bluetooth_low_energy/example/macos/Flutter/GeneratedPluginRegistrant.swift b/bluetooth_low_energy/example/macos/Flutter/GeneratedPluginRegistrant.swift index 2a16fdc..0e96062 100644 --- a/bluetooth_low_energy/example/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/bluetooth_low_energy/example/macos/Flutter/GeneratedPluginRegistrant.swift @@ -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")) } diff --git a/bluetooth_low_energy/example/macos/Podfile.lock b/bluetooth_low_energy/example/macos/Podfile.lock index 39669f2..6e81df1 100644 --- a/bluetooth_low_energy/example/macos/Podfile.lock +++ b/bluetooth_low_energy/example/macos/Podfile.lock @@ -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 diff --git a/bluetooth_low_energy/example/macos/Runner.xcodeproj/project.pbxproj b/bluetooth_low_energy/example/macos/Runner.xcodeproj/project.pbxproj index 3a39f82..fe555c3 100644 --- a/bluetooth_low_energy/example/macos/Runner.xcodeproj/project.pbxproj +++ b/bluetooth_low_energy/example/macos/Runner.xcodeproj/project.pbxproj @@ -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 = ""; }; + 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 = ""; }; + 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 = ""; }; 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 = ""; }; 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; @@ -79,15 +81,13 @@ 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; - 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 = ""; }; - 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 = ""; }; + 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 = ""; }; + 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 = ""; }; + 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 = ""; }; - 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 = ""; }; - 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 = ""; }; + 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 = ""; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; - 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 = ""; }; + 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 = ""; }; /* 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 = ""; - }; 331C80D6294CF71000263BE5 /* RunnerTests */ = { isa = PBXGroup; children = ( @@ -150,7 +137,7 @@ 331C80D6294CF71000263BE5 /* RunnerTests */, 33CC10EE2044A3C60003C045 /* Products */, D73912EC22F37F3D000D13A0 /* Frameworks */, - 0ECA3FC2C896A4C67723C2B3 /* Pods */, + 5413C8972DC878C53291A3D1 /* Pods */, ); sourceTree = ""; }; @@ -198,11 +185,24 @@ path = Runner; sourceTree = ""; }; + 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 = ""; + }; D73912EC22F37F3D000D13A0 /* Frameworks */ = { isa = PBXGroup; children = ( - 5CE5350781EEC56C5A7B326E /* Pods_Runner.framework */, - 5F2A7C4C98AC4208FDDA9ECE /* Pods_RunnerTests.framework */, + 7618EFBF5D56DEA9B5BC6858 /* Pods_Runner.framework */, + 12AE3247A53A0A6C66A10AB1 /* Pods_RunnerTests.framework */, ); name = Frameworks; sourceTree = ""; @@ -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)", diff --git a/bluetooth_low_energy/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/bluetooth_low_energy/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index 1e2ea76..29ceb04 100644 --- a/bluetooth_low_energy/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/bluetooth_low_energy/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ LSMinimumSystemVersion $(MACOSX_DEPLOYMENT_TARGET) NSBluetoothAlwaysUsageDescription - Hello Bluetooth Low Energy! + Hello Bluetooth LowEnergy! NSHumanReadableCopyright $(PRODUCT_COPYRIGHT) NSMainNibFile diff --git a/bluetooth_low_energy/example/pubspec.lock b/bluetooth_low_energy/example/pubspec.lock index 0cc4c43..2ec3966 100644 --- a/bluetooth_low_energy/example/pubspec.lock +++ b/bluetooth_low_energy/example/pubspec.lock @@ -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: diff --git a/bluetooth_low_energy/example/pubspec.yaml b/bluetooth_low_energy/example/pubspec.yaml index 4d7d94e..58da87f 100644 --- a/bluetooth_low_energy/example/pubspec.yaml +++ b/bluetooth_low_energy/example/pubspec.yaml @@ -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 diff --git a/bluetooth_low_energy/example/windows/CMakeLists.txt b/bluetooth_low_energy/example/windows/CMakeLists.txt index b2da711..231ec05 100644 --- a/bluetooth_low_energy/example/windows/CMakeLists.txt +++ b/bluetooth_low_energy/example/windows/CMakeLists.txt @@ -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) diff --git a/bluetooth_low_energy/example/windows/flutter/generated_plugin_registrant.cc b/bluetooth_low_energy/example/windows/flutter/generated_plugin_registrant.cc index 37c2554..8b6d468 100644 --- a/bluetooth_low_energy/example/windows/flutter/generated_plugin_registrant.cc +++ b/bluetooth_low_energy/example/windows/flutter/generated_plugin_registrant.cc @@ -6,9 +6,6 @@ #include "generated_plugin_registrant.h" -#include void RegisterPlugins(flutter::PluginRegistry* registry) { - BluetoothLowEnergyWindowsPluginCApiRegisterWithRegistrar( - registry->GetRegistrarForPlugin("BluetoothLowEnergyWindowsPluginCApi")); } diff --git a/bluetooth_low_energy/example/windows/flutter/generated_plugins.cmake b/bluetooth_low_energy/example/windows/flutter/generated_plugins.cmake index 4b19aa9..b93c4c3 100644 --- a/bluetooth_low_energy/example/windows/flutter/generated_plugins.cmake +++ b/bluetooth_low_energy/example/windows/flutter/generated_plugins.cmake @@ -3,7 +3,6 @@ # list(APPEND FLUTTER_PLUGIN_LIST - bluetooth_low_energy_windows ) list(APPEND FLUTTER_FFI_PLUGIN_LIST diff --git a/bluetooth_low_energy/pubspec.yaml b/bluetooth_low_energy/pubspec.yaml index 96354dd..a049876 100644 --- a/bluetooth_low_energy/pubspec.yaml +++ b/bluetooth_low_energy/pubspec.yaml @@ -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: diff --git a/bluetooth_low_energy/test/bluetooth_low_energy_test.dart b/bluetooth_low_energy/test/bluetooth_low_energy_test.dart deleted file mode 100644 index 8b13789..0000000 --- a/bluetooth_low_energy/test/bluetooth_low_energy_test.dart +++ /dev/null @@ -1 +0,0 @@ - diff --git a/bluetooth_low_energy_android/.metadata b/bluetooth_low_energy_android/.metadata index b0ed2b5..f43a237 100644 --- a/bluetooth_low_energy_android/.metadata +++ b/bluetooth_low_energy_android/.metadata @@ -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 diff --git a/bluetooth_low_energy_android/CHANGELOG.md b/bluetooth_low_energy_android/CHANGELOG.md index 367297e..dac61dd 100644 --- a/bluetooth_low_energy_android/CHANGELOG.md +++ b/bluetooth_low_energy_android/CHANGELOG.md @@ -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. diff --git a/bluetooth_low_energy_android/LICENSE b/bluetooth_low_energy_android/LICENSE index 515ed4b..752d28b 100644 --- a/bluetooth_low_energy_android/LICENSE +++ b/bluetooth_low_energy_android/LICENSE @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +SOFTWARE. diff --git a/bluetooth_low_energy_android/README.md b/bluetooth_low_energy_android/README.md index feecc7c..c205688 100644 --- a/bluetooth_low_energy_android/README.md +++ b/bluetooth_low_energy_android/README.md @@ -12,4 +12,4 @@ 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 \ No newline at end of file +[2]: https://flutter.dev/docs/development/packages-and-plugins/developing-packages#endorsed-federated-plugin diff --git a/bluetooth_low_energy_android/android/build.gradle b/bluetooth_low_energy_android/android/build.gradle index 597dd27..e8eb4df 100644 --- a/bluetooth_low_energy_android/android/build.gradle +++ b/bluetooth_low_energy_android/android/build.gradle @@ -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 { diff --git a/bluetooth_low_energy_android/android/settings.gradle b/bluetooth_low_energy_android/android/settings.gradle index e9fed43..b62e9e8 100644 --- a/bluetooth_low_energy_android/android/settings.gradle +++ b/bluetooth_low_energy_android/android/settings.gradle @@ -1 +1 @@ -rootProject.name = 'bluetooth_low_energy' +rootProject.name = 'bluetooth_low_energy_android' diff --git a/bluetooth_low_energy_android/android/src/main/AndroidManifest.xml b/bluetooth_low_energy_android/android/src/main/AndroidManifest.xml index e469528..0f9ea98 100644 --- a/bluetooth_low_energy_android/android/src/main/AndroidManifest.xml +++ b/bluetooth_low_energy_android/android/src/main/AndroidManifest.xml @@ -1,6 +1,7 @@ + package="dev.yanshouwang.bluetooth_low_energy_android"> + - + \ No newline at end of file diff --git a/bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/bluetooth_low_energy/BluetoothLowEnergyAndroid.kt b/bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/bluetooth_low_energy_android/BluetoothLowEnergyAndroid.kt similarity index 96% rename from bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/bluetooth_low_energy/BluetoothLowEnergyAndroid.kt rename to bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/bluetooth_low_energy_android/BluetoothLowEnergyAndroid.kt index caeacc9..974347b 100644 --- a/bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/bluetooth_low_energy/BluetoothLowEnergyAndroid.kt +++ b/bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/bluetooth_low_energy_android/BluetoothLowEnergyAndroid.kt @@ -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 diff --git a/bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/bluetooth_low_energy/MyApi.g.kt b/bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/bluetooth_low_energy_android/MyApi.g.kt similarity index 99% rename from bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/bluetooth_low_energy/MyApi.g.kt rename to bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/bluetooth_low_energy_android/MyApi.g.kt index 3e9a484..68180d8 100644 --- a/bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/bluetooth_low_energy/MyApi.g.kt +++ b/bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/bluetooth_low_energy_android/MyApi.g.kt @@ -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 diff --git a/bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/bluetooth_low_energy/MyBluetoothGattCallback.kt b/bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/bluetooth_low_energy_android/MyBluetoothGattCallback.kt similarity index 97% rename from bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/bluetooth_low_energy/MyBluetoothGattCallback.kt rename to bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/bluetooth_low_energy_android/MyBluetoothGattCallback.kt index a416fb2..61194f6 100644 --- a/bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/bluetooth_low_energy/MyBluetoothGattCallback.kt +++ b/bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/bluetooth_low_energy_android/MyBluetoothGattCallback.kt @@ -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 diff --git a/bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/bluetooth_low_energy/MyBroadcastReceiver.kt b/bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/bluetooth_low_energy_android/MyBroadcastReceiver.kt similarity index 85% rename from bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/bluetooth_low_energy/MyBroadcastReceiver.kt rename to bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/bluetooth_low_energy_android/MyBroadcastReceiver.kt index c2ddded..ae85a8c 100644 --- a/bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/bluetooth_low_energy/MyBroadcastReceiver.kt +++ b/bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/bluetooth_low_energy_android/MyBroadcastReceiver.kt @@ -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 diff --git a/bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/bluetooth_low_energy/MyCentralController.kt b/bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/bluetooth_low_energy_android/MyCentralController.kt similarity index 98% rename from bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/bluetooth_low_energy/MyCentralController.kt rename to bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/bluetooth_low_energy_android/MyCentralController.kt index 0f9129f..b1ccbf7 100644 --- a/bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/bluetooth_low_energy/MyCentralController.kt +++ b/bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/bluetooth_low_energy_android/MyCentralController.kt @@ -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) diff --git a/bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/bluetooth_low_energy/MyRequestPermissionResultListener.kt b/bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/bluetooth_low_energy_android/MyRequestPermissionResultListener.kt similarity index 88% rename from bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/bluetooth_low_energy/MyRequestPermissionResultListener.kt rename to bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/bluetooth_low_energy_android/MyRequestPermissionResultListener.kt index d3c0e99..90c285e 100644 --- a/bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/bluetooth_low_energy/MyRequestPermissionResultListener.kt +++ b/bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/bluetooth_low_energy_android/MyRequestPermissionResultListener.kt @@ -1,4 +1,4 @@ -package dev.yanshouwang.bluetooth_low_energy +package dev.yanshouwang.bluetooth_low_energy_android import io.flutter.plugin.common.PluginRegistry.RequestPermissionsResultListener diff --git a/bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/bluetooth_low_energy/MyScanCallback.kt b/bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/bluetooth_low_energy_android/MyScanCallback.kt similarity index 88% rename from bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/bluetooth_low_energy/MyScanCallback.kt rename to bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/bluetooth_low_energy_android/MyScanCallback.kt index 0a0e8bd..43f0ca2 100644 --- a/bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/bluetooth_low_energy/MyScanCallback.kt +++ b/bluetooth_low_energy_android/android/src/main/kotlin/dev/yanshouwang/bluetooth_low_energy_android/MyScanCallback.kt @@ -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 diff --git a/bluetooth_low_energy_android/android/src/test/kotlin/dev/yanshouwang/bluetooth_low_energy/BluetoothLowEnergyPluginTest.kt b/bluetooth_low_energy_android/android/src/test/kotlin/dev/yanshouwang/bluetooth_low_energy_android/BluetoothLowEnergyAndroidPluginTest.kt similarity index 84% rename from bluetooth_low_energy_android/android/src/test/kotlin/dev/yanshouwang/bluetooth_low_energy/BluetoothLowEnergyPluginTest.kt rename to bluetooth_low_energy_android/android/src/test/kotlin/dev/yanshouwang/bluetooth_low_energy_android/BluetoothLowEnergyAndroidPluginTest.kt index f41b4be..131f8ca 100644 --- a/bluetooth_low_energy_android/android/src/test/kotlin/dev/yanshouwang/bluetooth_low_energy/BluetoothLowEnergyPluginTest.kt +++ b/bluetooth_low_energy_android/android/src/test/kotlin/dev/yanshouwang/bluetooth_low_energy_android/BluetoothLowEnergyAndroidPluginTest.kt @@ -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) diff --git a/bluetooth_low_energy_android/my_api.dart b/bluetooth_low_energy_android/my_api.dart index be0c80e..89766b5 100644 --- a/bluetooth_low_energy_android/my_api.dart +++ b/bluetooth_low_energy_android/my_api.dart @@ -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', ), ), ) diff --git a/bluetooth_low_energy_android/pubspec.yaml b/bluetooth_low_energy_android/pubspec.yaml index 40d1a75..83f6f4e 100644 --- a/bluetooth_low_energy_android/pubspec.yaml +++ b/bluetooth_low_energy_android/pubspec.yaml @@ -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 diff --git a/bluetooth_low_energy_ios/.gitignore b/bluetooth_low_energy_darwin/.gitignore similarity index 100% rename from bluetooth_low_energy_ios/.gitignore rename to bluetooth_low_energy_darwin/.gitignore diff --git a/bluetooth_low_energy_macos/.metadata b/bluetooth_low_energy_darwin/.metadata similarity index 50% rename from bluetooth_low_energy_macos/.metadata rename to bluetooth_low_energy_darwin/.metadata index cbd8a9c..fe217dd 100644 --- a/bluetooth_low_energy_macos/.metadata +++ b/bluetooth_low_energy_darwin/.metadata @@ -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 diff --git a/bluetooth_low_energy_darwin/CHANGELOG.md b/bluetooth_low_energy_darwin/CHANGELOG.md new file mode 100644 index 0000000..8c3740f --- /dev/null +++ b/bluetooth_low_energy_darwin/CHANGELOG.md @@ -0,0 +1,4 @@ +## 2.0.2 + +- Combine iOS and macOS projects. +- Optimize project structure. diff --git a/bluetooth_low_energy_ios/LICENSE b/bluetooth_low_energy_darwin/LICENSE similarity index 99% rename from bluetooth_low_energy_ios/LICENSE rename to bluetooth_low_energy_darwin/LICENSE index 515ed4b..752d28b 100644 --- a/bluetooth_low_energy_ios/LICENSE +++ b/bluetooth_low_energy_darwin/LICENSE @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +SOFTWARE. diff --git a/bluetooth_low_energy_ios/README.md b/bluetooth_low_energy_darwin/README.md similarity index 84% rename from bluetooth_low_energy_ios/README.md rename to bluetooth_low_energy_darwin/README.md index 9b7853e..6d1bd0d 100644 --- a/bluetooth_low_energy_ios/README.md +++ b/bluetooth_low_energy_darwin/README.md @@ -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 diff --git a/bluetooth_low_energy_ios/analysis_options.yaml b/bluetooth_low_energy_darwin/analysis_options.yaml similarity index 100% rename from bluetooth_low_energy_ios/analysis_options.yaml rename to bluetooth_low_energy_darwin/analysis_options.yaml diff --git a/bluetooth_low_energy_macos/macos/Classes/BluetoothLowEnergymacOS.swift b/bluetooth_low_energy_darwin/darwin/Classes/BluetoothLowEnergyDarwin.swift similarity index 53% rename from bluetooth_low_energy_macos/macos/Classes/BluetoothLowEnergymacOS.swift rename to bluetooth_low_energy_darwin/darwin/Classes/BluetoothLowEnergyDarwin.swift index 25ac7fc..9ab8c9d 100644 --- a/bluetooth_low_energy_macos/macos/Classes/BluetoothLowEnergymacOS.swift +++ b/bluetooth_low_energy_darwin/darwin/Classes/BluetoothLowEnergyDarwin.swift @@ -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) } diff --git a/bluetooth_low_energy_macos/macos/Classes/MyApi.g.swift b/bluetooth_low_energy_darwin/darwin/Classes/MyApi.g.swift similarity index 89% rename from bluetooth_low_energy_macos/macos/Classes/MyApi.g.swift rename to bluetooth_low_energy_darwin/darwin/Classes/MyApi.g.swift index 439dd78..31f02f0 100644 --- a/bluetooth_low_energy_macos/macos/Classes/MyApi.g.swift +++ b/bluetooth_low_energy_darwin/darwin/Classes/MyApi.g.swift @@ -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() } diff --git a/bluetooth_low_energy_macos/macos/Classes/MyCentralController.swift b/bluetooth_low_energy_darwin/darwin/Classes/MyCentralController.swift similarity index 99% rename from bluetooth_low_energy_macos/macos/Classes/MyCentralController.swift rename to bluetooth_low_energy_darwin/darwin/Classes/MyCentralController.swift index 699ee68..c9f57b9 100644 --- a/bluetooth_low_energy_macos/macos/Classes/MyCentralController.swift +++ b/bluetooth_low_energy_darwin/darwin/Classes/MyCentralController.swift @@ -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) { diff --git a/bluetooth_low_energy_ios/ios/Classes/MyCentralManagerDelegate.swift b/bluetooth_low_energy_darwin/darwin/Classes/MyCentralManagerDelegate.swift similarity index 100% rename from bluetooth_low_energy_ios/ios/Classes/MyCentralManagerDelegate.swift rename to bluetooth_low_energy_darwin/darwin/Classes/MyCentralManagerDelegate.swift diff --git a/bluetooth_low_energy_ios/ios/Classes/MyError.swift b/bluetooth_low_energy_darwin/darwin/Classes/MyError.swift similarity index 100% rename from bluetooth_low_energy_ios/ios/Classes/MyError.swift rename to bluetooth_low_energy_darwin/darwin/Classes/MyError.swift diff --git a/bluetooth_low_energy_ios/ios/Classes/MyPeripheralDelegate.swift b/bluetooth_low_energy_darwin/darwin/Classes/MyPeripheralDelegate.swift similarity index 100% rename from bluetooth_low_energy_ios/ios/Classes/MyPeripheralDelegate.swift rename to bluetooth_low_energy_darwin/darwin/Classes/MyPeripheralDelegate.swift diff --git a/bluetooth_low_energy_darwin/darwin/bluetooth_low_energy_darwin.podspec b/bluetooth_low_energy_darwin/darwin/bluetooth_low_energy_darwin.podspec new file mode 100644 index 0000000..04b8bdb --- /dev/null +++ b/bluetooth_low_energy_darwin/darwin/bluetooth_low_energy_darwin.podspec @@ -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 diff --git a/bluetooth_low_energy_macos/lib/bluetooth_low_energy_macos.dart b/bluetooth_low_energy_darwin/lib/bluetooth_low_energy_darwin.dart similarity index 85% rename from bluetooth_low_energy_macos/lib/bluetooth_low_energy_macos.dart rename to bluetooth_low_energy_darwin/lib/bluetooth_low_energy_darwin.dart index 24dc29e..9dd5f3d 100644 --- a/bluetooth_low_energy_macos/lib/bluetooth_low_energy_macos.dart +++ b/bluetooth_low_energy_darwin/lib/bluetooth_low_energy_darwin.dart @@ -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(); } diff --git a/bluetooth_low_energy_ios/lib/src/my_api.g.dart b/bluetooth_low_energy_darwin/lib/src/my_api.g.dart similarity index 88% rename from bluetooth_low_energy_ios/lib/src/my_api.g.dart rename to bluetooth_low_energy_darwin/lib/src/my_api.g.dart index 0603491..c68462f 100644 --- a/bluetooth_low_energy_ios/lib/src/my_api.g.dart +++ b/bluetooth_low_energy_darwin/lib/src/my_api.g.dart @@ -245,7 +245,7 @@ class MyCentralControllerHostApi { Future setUp() async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerHostApi.setUp', codec, + 'dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerHostApi.setUp', codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send(null) as List?; @@ -272,7 +272,7 @@ class MyCentralControllerHostApi { Future tearDown() async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerHostApi.tearDown', codec, + 'dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerHostApi.tearDown', codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send(null) as List?; @@ -294,7 +294,7 @@ class MyCentralControllerHostApi { Future startDiscovery() async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerHostApi.startDiscovery', codec, + 'dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerHostApi.startDiscovery', codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send(null) as List?; @@ -316,7 +316,7 @@ class MyCentralControllerHostApi { Future stopDiscovery() async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerHostApi.stopDiscovery', codec, + 'dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerHostApi.stopDiscovery', codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send(null) as List?; @@ -338,7 +338,7 @@ class MyCentralControllerHostApi { Future connect(int arg_myPeripheralKey) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerHostApi.connect', codec, + 'dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerHostApi.connect', codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_myPeripheralKey]) as List?; @@ -360,7 +360,7 @@ class MyCentralControllerHostApi { Future disconnect(int arg_myPeripheralKey) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerHostApi.disconnect', codec, + 'dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerHostApi.disconnect', codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_myPeripheralKey]) as List?; @@ -382,7 +382,7 @@ class MyCentralControllerHostApi { Future discoverGATT(int arg_myPeripheralKey) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerHostApi.discoverGATT', codec, + 'dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerHostApi.discoverGATT', codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_myPeripheralKey]) as List?; @@ -404,7 +404,7 @@ class MyCentralControllerHostApi { Future> getServices(int arg_myPeripheralKey) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerHostApi.getServices', codec, + 'dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerHostApi.getServices', codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_myPeripheralKey]) as List?; @@ -431,7 +431,7 @@ class MyCentralControllerHostApi { Future> getCharacteristics(int arg_myServiceKey) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerHostApi.getCharacteristics', codec, + 'dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerHostApi.getCharacteristics', codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_myServiceKey]) as List?; @@ -458,7 +458,7 @@ class MyCentralControllerHostApi { Future> getDescriptors(int arg_myCharacteristicKey) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerHostApi.getDescriptors', codec, + 'dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerHostApi.getDescriptors', codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_myCharacteristicKey]) as List?; @@ -485,7 +485,7 @@ class MyCentralControllerHostApi { Future readCharacteristic(int arg_myPeripheralKey, int arg_myServiceKey, int arg_myCharacteristicKey) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerHostApi.readCharacteristic', codec, + 'dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerHostApi.readCharacteristic', codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_myPeripheralKey, arg_myServiceKey, arg_myCharacteristicKey]) as List?; @@ -512,7 +512,7 @@ class MyCentralControllerHostApi { Future writeCharacteristic(int arg_myPeripheralKey, int arg_myServiceKey, int arg_myCharacteristicKey, Uint8List arg_value, int arg_myTypeNumber) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerHostApi.writeCharacteristic', codec, + 'dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerHostApi.writeCharacteristic', codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_myPeripheralKey, arg_myServiceKey, arg_myCharacteristicKey, arg_value, arg_myTypeNumber]) as List?; @@ -534,7 +534,7 @@ class MyCentralControllerHostApi { Future notifyCharacteristic(int arg_myPeripheralKey, int arg_myServiceKey, int arg_myCharacteristicKey, bool arg_state) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerHostApi.notifyCharacteristic', codec, + 'dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerHostApi.notifyCharacteristic', codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_myPeripheralKey, arg_myServiceKey, arg_myCharacteristicKey, arg_state]) as List?; @@ -556,7 +556,7 @@ class MyCentralControllerHostApi { Future readDescriptor(int arg_myPeripheralKey, int arg_myCharacteristicKey, int arg_myDescriptorKey) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerHostApi.readDescriptor', codec, + 'dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerHostApi.readDescriptor', codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_myPeripheralKey, arg_myCharacteristicKey, arg_myDescriptorKey]) as List?; @@ -583,7 +583,7 @@ class MyCentralControllerHostApi { Future writeDescriptor(int arg_myPeripheralKey, int arg_myCharacteristicKey, int arg_myDescriptorKey, Uint8List arg_value) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.bluetooth_low_energy_ios.MyCentralControllerHostApi.writeDescriptor', codec, + 'dev.flutter.pigeon.bluetooth_low_energy_darwin.MyCentralControllerHostApi.writeDescriptor', codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_myPeripheralKey, arg_myCharacteristicKey, arg_myDescriptorKey, arg_value]) as List?; @@ -646,18 +646,18 @@ abstract class MyCentralControllerFlutterApi { static void setup(MyCentralControllerFlutterApi? api, {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - '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 args = (message as List?)!; 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 channel = BasicMessageChannel( - '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 args = (message as List?)!; 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 channel = BasicMessageChannel( - '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 args = (message as List?)!; 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 channel = BasicMessageChannel( - '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 args = (message as List?)!; 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; }); diff --git a/bluetooth_low_energy_ios/lib/src/my_central_controller.dart b/bluetooth_low_energy_darwin/lib/src/my_central_controller.dart similarity index 100% rename from bluetooth_low_energy_ios/lib/src/my_central_controller.dart rename to bluetooth_low_energy_darwin/lib/src/my_central_controller.dart diff --git a/bluetooth_low_energy_ios/lib/src/my_gatt_characteristic.dart b/bluetooth_low_energy_darwin/lib/src/my_gatt_characteristic.dart similarity index 100% rename from bluetooth_low_energy_ios/lib/src/my_gatt_characteristic.dart rename to bluetooth_low_energy_darwin/lib/src/my_gatt_characteristic.dart diff --git a/bluetooth_low_energy_ios/lib/src/my_gatt_descriptor.dart b/bluetooth_low_energy_darwin/lib/src/my_gatt_descriptor.dart similarity index 100% rename from bluetooth_low_energy_ios/lib/src/my_gatt_descriptor.dart rename to bluetooth_low_energy_darwin/lib/src/my_gatt_descriptor.dart diff --git a/bluetooth_low_energy_ios/lib/src/my_gatt_service.dart b/bluetooth_low_energy_darwin/lib/src/my_gatt_service.dart similarity index 100% rename from bluetooth_low_energy_ios/lib/src/my_gatt_service.dart rename to bluetooth_low_energy_darwin/lib/src/my_gatt_service.dart diff --git a/bluetooth_low_energy_ios/lib/src/my_object.dart b/bluetooth_low_energy_darwin/lib/src/my_object.dart similarity index 100% rename from bluetooth_low_energy_ios/lib/src/my_object.dart rename to bluetooth_low_energy_darwin/lib/src/my_object.dart diff --git a/bluetooth_low_energy_ios/lib/src/my_peripheral.dart b/bluetooth_low_energy_darwin/lib/src/my_peripheral.dart similarity index 100% rename from bluetooth_low_energy_ios/lib/src/my_peripheral.dart rename to bluetooth_low_energy_darwin/lib/src/my_peripheral.dart diff --git a/bluetooth_low_energy_ios/my_api.dart b/bluetooth_low_energy_darwin/my_api.dart similarity index 98% rename from bluetooth_low_energy_ios/my_api.dart rename to bluetooth_low_energy_darwin/my_api.dart index b54cbb1..cf9f76b 100644 --- a/bluetooth_low_energy_ios/my_api.dart +++ b/bluetooth_low_energy_darwin/my_api.dart @@ -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(), ), ) diff --git a/bluetooth_low_energy_darwin/pubspec.yaml b/bluetooth_low_energy_darwin/pubspec.yaml new file mode 100644 index 0000000..3f4f2a6 --- /dev/null +++ b/bluetooth_low_energy_darwin/pubspec.yaml @@ -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 diff --git a/bluetooth_low_energy_ios/.metadata b/bluetooth_low_energy_ios/.metadata deleted file mode 100644 index b3231e1..0000000 --- a/bluetooth_low_energy_ios/.metadata +++ /dev/null @@ -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' diff --git a/bluetooth_low_energy_ios/CHANGELOG.md b/bluetooth_low_energy_ios/CHANGELOG.md deleted file mode 100644 index 367297e..0000000 --- a/bluetooth_low_energy_ios/CHANGELOG.md +++ /dev/null @@ -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. diff --git a/bluetooth_low_energy_ios/ios/.gitignore b/bluetooth_low_energy_ios/ios/.gitignore deleted file mode 100644 index 0c88507..0000000 --- a/bluetooth_low_energy_ios/ios/.gitignore +++ /dev/null @@ -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 \ No newline at end of file diff --git a/bluetooth_low_energy_ios/ios/Assets/.gitkeep b/bluetooth_low_energy_ios/ios/Assets/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/bluetooth_low_energy_ios/ios/Classes/BluetoothLowEnergyiOS.swift b/bluetooth_low_energy_ios/ios/Classes/BluetoothLowEnergyiOS.swift deleted file mode 100644 index a80f325..0000000 --- a/bluetooth_low_energy_ios/ios/Classes/BluetoothLowEnergyiOS.swift +++ /dev/null @@ -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) - } -} diff --git a/bluetooth_low_energy_ios/ios/Classes/MyApi.g.swift b/bluetooth_low_energy_ios/ios/Classes/MyApi.g.swift deleted file mode 100644 index f3b4093..0000000 --- a/bluetooth_low_energy_ios/ios/Classes/MyApi.g.swift +++ /dev/null @@ -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(_ 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) -> Void) - func tearDown() throws - func startDiscovery() throws - func stopDiscovery() throws - func connect(myPeripheralKey: Int64, completion: @escaping (Result) -> Void) - func disconnect(myPeripheralKey: Int64, completion: @escaping (Result) -> Void) - func discoverGATT(myPeripheralKey: Int64, completion: @escaping (Result) -> 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) -> Void) - func writeCharacteristic(myPeripheralKey: Int64, myServiceKey: Int64, myCharacteristicKey: Int64, value: FlutterStandardTypedData, myTypeNumber: Int64, completion: @escaping (Result) -> Void) - func notifyCharacteristic(myPeripheralKey: Int64, myServiceKey: Int64, myCharacteristicKey: Int64, state: Bool, completion: @escaping (Result) -> Void) - func readDescriptor(myPeripheralKey: Int64, myCharacteristicKey: Int64, myDescriptorKey: Int64, completion: @escaping (Result) -> Void) - func writeDescriptor(myPeripheralKey: Int64, myCharacteristicKey: Int64, myDescriptorKey: Int64, value: FlutterStandardTypedData, completion: @escaping (Result) -> 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() - } - } -} diff --git a/bluetooth_low_energy_ios/ios/Classes/MyCentralController.swift b/bluetooth_low_energy_ios/ios/Classes/MyCentralController.swift deleted file mode 100644 index 13533ee..0000000 --- a/bluetooth_low_energy_ios/ios/Classes/MyCentralController.swift +++ /dev/null @@ -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) -> Void)? - var connectCompletions = [Int: (Result) -> Void]() - var disconnectCompletions = [Int: (Result) -> Void]() - var discoverGattCompletions = [Int: (Result) -> Void]() - var unfinishedServices = [Int: [CBService]]() - var unfinishedCharacteristics = [Int: [CBCharacteristic]]() - var readCharacteristicCompletions = [Int: (Result) -> Void]() - var writeCharacteristicCompletions = [Int: (Result) -> Void]() - var notifyCharacteristicCompletions = [Int: (Result) -> Void]() - var readDescriptorCompletions = [Int: (Result) -> Void]() - var writeDescriptorCompletions = [Int: (Result) -> Void]() - - func setUp(completion: @escaping (Result) -> 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) { - 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) { - 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) { - 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) -> 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) { - 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) { - 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) -> 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) { - 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.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.size) - } -} diff --git a/bluetooth_low_energy_ios/ios/bluetooth_low_energy.podspec b/bluetooth_low_energy_ios/ios/bluetooth_low_energy.podspec deleted file mode 100644 index c812080..0000000 --- a/bluetooth_low_energy_ios/ios/bluetooth_low_energy.podspec +++ /dev/null @@ -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 diff --git a/bluetooth_low_energy_ios/lib/bluetooth_low_energy_ios.dart b/bluetooth_low_energy_ios/lib/bluetooth_low_energy_ios.dart deleted file mode 100644 index f7244f1..0000000 --- a/bluetooth_low_energy_ios/lib/bluetooth_low_energy_ios.dart +++ /dev/null @@ -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(); - } -} diff --git a/bluetooth_low_energy_ios/pubspec.yaml b/bluetooth_low_energy_ios/pubspec.yaml deleted file mode 100644 index 11c4e22..0000000 --- a/bluetooth_low_energy_ios/pubspec.yaml +++ /dev/null @@ -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 diff --git a/bluetooth_low_energy_linux/.metadata b/bluetooth_low_energy_linux/.metadata index 7df7b20..3c75153 100644 --- a/bluetooth_low_energy_linux/.metadata +++ b/bluetooth_low_energy_linux/.metadata @@ -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 diff --git a/bluetooth_low_energy_linux/CHANGELOG.md b/bluetooth_low_energy_linux/CHANGELOG.md index 367297e..dac61dd 100644 --- a/bluetooth_low_energy_linux/CHANGELOG.md +++ b/bluetooth_low_energy_linux/CHANGELOG.md @@ -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. diff --git a/bluetooth_low_energy_linux/LICENSE b/bluetooth_low_energy_linux/LICENSE index 515ed4b..752d28b 100644 --- a/bluetooth_low_energy_linux/LICENSE +++ b/bluetooth_low_energy_linux/LICENSE @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +SOFTWARE. diff --git a/bluetooth_low_energy_linux/pubspec.yaml b/bluetooth_low_energy_linux/pubspec.yaml index 21cf8f2..17e7fdf 100644 --- a/bluetooth_low_energy_linux/pubspec.yaml +++ b/bluetooth_low_energy_linux/pubspec.yaml @@ -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: diff --git a/bluetooth_low_energy_macos/.gitignore b/bluetooth_low_energy_macos/.gitignore deleted file mode 100644 index 96486fd..0000000 --- a/bluetooth_low_energy_macos/.gitignore +++ /dev/null @@ -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/ diff --git a/bluetooth_low_energy_macos/CHANGELOG.md b/bluetooth_low_energy_macos/CHANGELOG.md deleted file mode 100644 index 367297e..0000000 --- a/bluetooth_low_energy_macos/CHANGELOG.md +++ /dev/null @@ -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. diff --git a/bluetooth_low_energy_macos/LICENSE b/bluetooth_low_energy_macos/LICENSE deleted file mode 100644 index 515ed4b..0000000 --- a/bluetooth_low_energy_macos/LICENSE +++ /dev/null @@ -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. \ No newline at end of file diff --git a/bluetooth_low_energy_macos/README.md b/bluetooth_low_energy_macos/README.md deleted file mode 100644 index 7836cda..0000000 --- a/bluetooth_low_energy_macos/README.md +++ /dev/null @@ -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 diff --git a/bluetooth_low_energy_macos/analysis_options.yaml b/bluetooth_low_energy_macos/analysis_options.yaml deleted file mode 100644 index a5744c1..0000000 --- a/bluetooth_low_energy_macos/analysis_options.yaml +++ /dev/null @@ -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 diff --git a/bluetooth_low_energy_macos/lib/src/my_api.g.dart b/bluetooth_low_energy_macos/lib/src/my_api.g.dart deleted file mode 100644 index e4eaa84..0000000 --- a/bluetooth_low_energy_macos/lib/src/my_api.g.dart +++ /dev/null @@ -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 [ - myStateNumber, - ]; - } - - static MyCentralControllerArgs decode(Object result) { - result as List; - return MyCentralControllerArgs( - myStateNumber: result[0]! as int, - ); - } -} - -class MyPeripheralArgs { - MyPeripheralArgs({ - required this.key, - required this.uuid, - }); - - int key; - - String uuid; - - Object encode() { - return [ - key, - uuid, - ]; - } - - static MyPeripheralArgs decode(Object result) { - result as List; - 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 manufacturerSpecificData; - - List serviceUUIDs; - - Map serviceData; - - Object encode() { - return [ - name, - manufacturerSpecificData, - serviceUUIDs, - serviceData, - ]; - } - - static MyAdvertisementArgs decode(Object result) { - result as List; - return MyAdvertisementArgs( - name: result[0] as String?, - manufacturerSpecificData: (result[1] as Map?)!.cast(), - serviceUUIDs: (result[2] as List?)!.cast(), - serviceData: (result[3] as Map?)!.cast(), - ); - } -} - -class MyGattServiceArgs { - MyGattServiceArgs({ - required this.key, - required this.uuid, - }); - - int key; - - String uuid; - - Object encode() { - return [ - key, - uuid, - ]; - } - - static MyGattServiceArgs decode(Object result) { - result as List; - 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 myPropertyNumbers; - - Object encode() { - return [ - key, - uuid, - myPropertyNumbers, - ]; - } - - static MyGattCharacteristicArgs decode(Object result) { - result as List; - return MyGattCharacteristicArgs( - key: result[0]! as int, - uuid: result[1]! as String, - myPropertyNumbers: (result[2] as List?)!.cast(), - ); - } -} - -class MyGattDescriptorArgs { - MyGattDescriptorArgs({ - required this.key, - required this.uuid, - }); - - int key; - - String uuid; - - Object encode() { - return [ - key, - uuid, - ]; - } - - static MyGattDescriptorArgs decode(Object result) { - result as List; - 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 codec = _MyCentralControllerHostApiCodec(); - - Future setUp() async { - final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerHostApi.setUp', codec, - binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send(null) as List?; - 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 tearDown() async { - final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerHostApi.tearDown', codec, - binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send(null) as List?; - 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 startDiscovery() async { - final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerHostApi.startDiscovery', codec, - binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send(null) as List?; - 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 stopDiscovery() async { - final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerHostApi.stopDiscovery', codec, - binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send(null) as List?; - 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 connect(int arg_myPeripheralKey) async { - final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerHostApi.connect', codec, - binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send([arg_myPeripheralKey]) as List?; - 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 disconnect(int arg_myPeripheralKey) async { - final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerHostApi.disconnect', codec, - binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send([arg_myPeripheralKey]) as List?; - 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 discoverGATT(int arg_myPeripheralKey) async { - final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerHostApi.discoverGATT', codec, - binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send([arg_myPeripheralKey]) as List?; - 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> getServices(int arg_myPeripheralKey) async { - final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerHostApi.getServices', codec, - binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send([arg_myPeripheralKey]) as List?; - 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?)!.cast(); - } - } - - Future> getCharacteristics(int arg_myServiceKey) async { - final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerHostApi.getCharacteristics', codec, - binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send([arg_myServiceKey]) as List?; - 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?)!.cast(); - } - } - - Future> getDescriptors(int arg_myCharacteristicKey) async { - final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerHostApi.getDescriptors', codec, - binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send([arg_myCharacteristicKey]) as List?; - 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?)!.cast(); - } - } - - Future readCharacteristic(int arg_myPeripheralKey, int arg_myServiceKey, int arg_myCharacteristicKey) async { - final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerHostApi.readCharacteristic', codec, - binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send([arg_myPeripheralKey, arg_myServiceKey, arg_myCharacteristicKey]) as List?; - 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 writeCharacteristic(int arg_myPeripheralKey, int arg_myServiceKey, int arg_myCharacteristicKey, Uint8List arg_value, int arg_myTypeNumber) async { - final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerHostApi.writeCharacteristic', codec, - binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send([arg_myPeripheralKey, arg_myServiceKey, arg_myCharacteristicKey, arg_value, arg_myTypeNumber]) as List?; - 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 notifyCharacteristic(int arg_myPeripheralKey, int arg_myServiceKey, int arg_myCharacteristicKey, bool arg_state) async { - final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerHostApi.notifyCharacteristic', codec, - binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send([arg_myPeripheralKey, arg_myServiceKey, arg_myCharacteristicKey, arg_state]) as List?; - 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 readDescriptor(int arg_myPeripheralKey, int arg_myCharacteristicKey, int arg_myDescriptorKey) async { - final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerHostApi.readDescriptor', codec, - binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send([arg_myPeripheralKey, arg_myCharacteristicKey, arg_myDescriptorKey]) as List?; - 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 writeDescriptor(int arg_myPeripheralKey, int arg_myCharacteristicKey, int arg_myDescriptorKey, Uint8List arg_value) async { - final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.bluetooth_low_energy_macos.MyCentralControllerHostApi.writeDescriptor', codec, - binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send([arg_myPeripheralKey, arg_myCharacteristicKey, arg_myDescriptorKey, arg_value]) as List?; - 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 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 channel = BasicMessageChannel( - '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 args = (message as List?)!; - 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 channel = BasicMessageChannel( - '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 args = (message as List?)!; - 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 channel = BasicMessageChannel( - '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 args = (message as List?)!; - 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 channel = BasicMessageChannel( - '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 args = (message as List?)!; - 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; - }); - } - } - } -} diff --git a/bluetooth_low_energy_macos/lib/src/my_central_controller.dart b/bluetooth_low_energy_macos/lib/src/my_central_controller.dart deleted file mode 100644 index b717308..0000000 --- a/bluetooth_low_energy_macos/lib/src/my_central_controller.dart +++ /dev/null @@ -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 _stateChangedController; - final StreamController _discoveredController; - final StreamController - _peripheralStateChangedController; - final StreamController - _characteristicValueChangedController; - final Map _myPeripherals; - final Map _myServices; - final Map _myCharacteristics; - final Map _myDescriptors; - - CentralState _state; - @override - CentralState get state => _state; - - @override - Stream get stateChanged => - _stateChangedController.stream; - @override - Stream get discovered => - _discoveredController.stream; - @override - Stream get peripheralStateChanged => - _peripheralStateChangedController.stream; - @override - Stream - get characteristicValueChanged => - _characteristicValueChangedController.stream; - - Future _throwWithState(CentralState state) async { - if (this.state == state) { - throw BluetoothLowEnergyError('$state is unexpected.'); - } - } - - Future _throwWithoutState(CentralState state) async { - if (this.state != state) { - throw BluetoothLowEnergyError( - '$state is expected, but current state is ${this.state}.', - ); - } - } - - @override - Future 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 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 startDiscovery() async { - await _throwWithoutState(CentralState.poweredOn); - await _myApi.startDiscovery(); - } - - @override - Future stopDiscovery() async { - await _throwWithoutState(CentralState.poweredOn); - await _myApi.stopDiscovery(); - } - - @override - Future connect(Peripheral peripheral) async { - await _throwWithoutState(CentralState.poweredOn); - final myPeripheral = peripheral as MyPeripheral; - await _myApi.connect(myPeripheral.hashCode); - } - - @override - Future disconnect(Peripheral peripheral) async { - await _throwWithoutState(CentralState.poweredOn); - final myPeripheral = peripheral as MyPeripheral; - await _myApi.disconnect(myPeripheral.hashCode); - } - - @override - Future discoverGATT(Peripheral peripheral) async { - await _throwWithoutState(CentralState.poweredOn); - final myPeripheral = peripheral as MyPeripheral; - await _myApi.discoverGATT(myPeripheral.hashCode); - } - - @override - Future> getServices(Peripheral peripheral) async { - await _throwWithoutState(CentralState.poweredOn); - final myPeripheral = peripheral as MyPeripheral; - final myServiceArgses = await _myApi.getServices(myPeripheral.hashCode); - return myServiceArgses.cast().map( - (myServiceArgs) { - final myService = MyGattService.fromMyArgs( - myPeripheral, - myServiceArgs, - ); - _myServices[myService.hashCode] = myService; - return myService; - }, - ).toList(); - } - - @override - Future> getCharacteristics( - GattService service, - ) async { - await _throwWithoutState(CentralState.poweredOn); - final myService = service as MyGattService; - final myCharactersiticArgses = await _myApi.getCharacteristics( - myService.hashCode, - ); - return myCharactersiticArgses.cast().map( - (myCharacteristicArgs) { - final myCharacteristic = MyGattCharacteristic.fromMyArgs( - myService, - myCharacteristicArgs, - ); - _myCharacteristics[myCharacteristic.hashCode] = myCharacteristic; - return myCharacteristic; - }, - ).toList(); - } - - @override - Future> getDescriptors( - GattCharacteristic characteristic, - ) async { - await _throwWithoutState(CentralState.poweredOn); - final myCharacteristic = characteristic as MyGattCharacteristic; - final myDescriptorArgses = await _myApi.getDescriptors( - myCharacteristic.hashCode, - ); - return myDescriptorArgses.cast().map( - (myDescriptorArgs) { - final myDescriptor = MyGattDescriptor.fromMyArgs( - myCharacteristic, - myDescriptorArgs, - ); - _myDescriptors[myDescriptor.hashCode] = myDescriptor; - return myDescriptor; - }, - ).toList(); - } - - @override - Future 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 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 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 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 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() - .map((uuid) => UUID.fromString(uuid)) - .toList(); - final serviceData = this.serviceData.cast().map( - (uuid, data) { - final key = UUID.fromString(uuid); - final value = data; - return MapEntry(key, value); - }, - ); - return Advertisement( - name: name, - manufacturerSpecificData: manufacturerSpecificData.cast(), - serviceUUIDs: serviceUUIDs, - serviceData: serviceData, - ); - } -} - -extension on MyCentralStateArgs { - CentralState toState() { - return CentralState.values[index]; - } -} - -extension on GattCharacteristicWriteType { - MyGattCharacteristicWriteTypeArgs toMyArgs() { - return MyGattCharacteristicWriteTypeArgs.values[index]; - } -} diff --git a/bluetooth_low_energy_macos/lib/src/my_gatt_characteristic.dart b/bluetooth_low_energy_macos/lib/src/my_gatt_characteristic.dart deleted file mode 100644 index 811fb23..0000000 --- a/bluetooth_low_energy_macos/lib/src/my_gatt_characteristic.dart +++ /dev/null @@ -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 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().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]; - } -} diff --git a/bluetooth_low_energy_macos/lib/src/my_gatt_descriptor.dart b/bluetooth_low_energy_macos/lib/src/my_gatt_descriptor.dart deleted file mode 100644 index 6798f4a..0000000 --- a/bluetooth_low_energy_macos/lib/src/my_gatt_descriptor.dart +++ /dev/null @@ -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); - } -} diff --git a/bluetooth_low_energy_macos/lib/src/my_gatt_service.dart b/bluetooth_low_energy_macos/lib/src/my_gatt_service.dart deleted file mode 100644 index 37babdb..0000000 --- a/bluetooth_low_energy_macos/lib/src/my_gatt_service.dart +++ /dev/null @@ -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); - } -} diff --git a/bluetooth_low_energy_macos/lib/src/my_object.dart b/bluetooth_low_energy_macos/lib/src/my_object.dart deleted file mode 100644 index 2b33805..0000000 --- a/bluetooth_low_energy_macos/lib/src/my_object.dart +++ /dev/null @@ -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; - } -} diff --git a/bluetooth_low_energy_macos/lib/src/my_peripheral.dart b/bluetooth_low_energy_macos/lib/src/my_peripheral.dart deleted file mode 100644 index 7be1bd3..0000000 --- a/bluetooth_low_energy_macos/lib/src/my_peripheral.dart +++ /dev/null @@ -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); - } -} diff --git a/bluetooth_low_energy_macos/macos/Classes/MyCentralManagerDelegate.swift b/bluetooth_low_energy_macos/macos/Classes/MyCentralManagerDelegate.swift deleted file mode 100644 index 4a85ff8..0000000 --- a/bluetooth_low_energy_macos/macos/Classes/MyCentralManagerDelegate.swift +++ /dev/null @@ -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) - } -} diff --git a/bluetooth_low_energy_macos/macos/Classes/MyError.swift b/bluetooth_low_energy_macos/macos/Classes/MyError.swift deleted file mode 100644 index 12068c0..0000000 --- a/bluetooth_low_energy_macos/macos/Classes/MyError.swift +++ /dev/null @@ -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 -} diff --git a/bluetooth_low_energy_macos/macos/Classes/MyPeripheralDelegate.swift b/bluetooth_low_energy_macos/macos/Classes/MyPeripheralDelegate.swift deleted file mode 100644 index 5915d9b..0000000 --- a/bluetooth_low_energy_macos/macos/Classes/MyPeripheralDelegate.swift +++ /dev/null @@ -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) - } -} diff --git a/bluetooth_low_energy_macos/macos/bluetooth_low_energy.podspec b/bluetooth_low_energy_macos/macos/bluetooth_low_energy.podspec deleted file mode 100644 index 6ae5f75..0000000 --- a/bluetooth_low_energy_macos/macos/bluetooth_low_energy.podspec +++ /dev/null @@ -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 diff --git a/bluetooth_low_energy_macos/my_api.dart b/bluetooth_low_energy_macos/my_api.dart deleted file mode 100644 index 44d0c24..0000000 --- a/bluetooth_low_energy_macos/my_api.dart +++ /dev/null @@ -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 getServices(int myPeripheralKey); - List getCharacteristics(int myServiceKey); - List 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 manufacturerSpecificData; - final List serviceUUIDs; - final Map 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 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, -} diff --git a/bluetooth_low_energy_macos/pubspec.yaml b/bluetooth_low_energy_macos/pubspec.yaml deleted file mode 100644 index 1ff01d9..0000000 --- a/bluetooth_low_energy_macos/pubspec.yaml +++ /dev/null @@ -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 diff --git a/bluetooth_low_energy_platform_interface/.metadata b/bluetooth_low_energy_platform_interface/.metadata index cedd661..0885ce9 100644 --- a/bluetooth_low_energy_platform_interface/.metadata +++ b/bluetooth_low_energy_platform_interface/.metadata @@ -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 diff --git a/bluetooth_low_energy_platform_interface/CHANGELOG.md b/bluetooth_low_energy_platform_interface/CHANGELOG.md index 367297e..dac61dd 100644 --- a/bluetooth_low_energy_platform_interface/CHANGELOG.md +++ b/bluetooth_low_energy_platform_interface/CHANGELOG.md @@ -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. diff --git a/bluetooth_low_energy_platform_interface/LICENSE b/bluetooth_low_energy_platform_interface/LICENSE index 515ed4b..752d28b 100644 --- a/bluetooth_low_energy_platform_interface/LICENSE +++ b/bluetooth_low_energy_platform_interface/LICENSE @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +SOFTWARE. diff --git a/bluetooth_low_energy_platform_interface/lib/src/advertisement.dart b/bluetooth_low_energy_platform_interface/lib/src/advertisement.dart index 2be8b0e..eabdf0b 100644 --- a/bluetooth_low_energy_platform_interface/lib/src/advertisement.dart +++ b/bluetooth_low_energy_platform_interface/lib/src/advertisement.dart @@ -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 manufacturerSpecificData; + + /// The GATT service uuids of the peripheral. final List serviceUUIDs; + + /// The GATT service data of the peripheral. final Map serviceData; + /// Constructs an [Advertisement]. Advertisement({ this.name, this.manufacturerSpecificData = const {}, diff --git a/bluetooth_low_energy_platform_interface/lib/src/central_controller.dart b/bluetooth_low_energy_platform_interface/lib/src/central_controller.dart index b736d5b..11a0be5 100644 --- a/bluetooth_low_energy_platform_interface/lib/src/central_controller.dart +++ b/bluetooth_low_energy_platform_interface/lib/src/central_controller.dart @@ -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 get stateChanged; + + /// Used to listen the central discovered event. Stream get discovered; + + /// Used to listen peripherals state changed event. Stream get peripheralStateChanged; + + /// Used to listen GATT characteristics value changed event. Stream get characteristicValueChanged; + /// Sets up the central controller. Future setUp(); + + /// Tears down the central controller. Future tearDown(); + + /// Starts to discover peripherals. Future startDiscovery(); + + /// Stops to discover peripherals. Future stopDiscovery(); + + /// Connects to the peripheral. Future connect(Peripheral peripheral); + + /// Disconnects form the peripheral. Future disconnect(Peripheral peripheral); + + /// Discovers GATT of the peripheral. Future discoverGATT(Peripheral peripheral); + + /// Gets GATT services of the peripheral. Future> getServices(Peripheral peripheral); + + /// Gets GATT characteristics of the GATT service. Future> getCharacteristics(GattService service); + + /// Gets GATT descriptors of the GATT characteristic. Future> getDescriptors( GattCharacteristic characteristic, ); + + /// Reads value of the GATT characteristic. Future readCharacteristic(GattCharacteristic characteristic); + + /// Writes value of the GATT characteristic. Future writeCharacteristic( GattCharacteristic characteristic, { required Uint8List value, required GattCharacteristicWriteType type, }); + + /// Notifies value of the GATT characteristic. Future notifyCharacteristic( GattCharacteristic characteristic, { required bool state, }); + + /// Reads value of the GATT descriptor. Future readDescriptor(GattDescriptor descriptor); + + /// Writes value of the GATT descriptor. Future writeDescriptor( GattDescriptor descriptor, { required Uint8List value, diff --git a/bluetooth_low_energy_platform_interface/lib/src/central_state.dart b/bluetooth_low_energy_platform_interface/lib/src/central_state.dart index da785e2..206d55f 100644 --- a/bluetooth_low_energy_platform_interface/lib/src/central_state.dart +++ b/bluetooth_low_energy_platform_interface/lib/src/central_state.dart @@ -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, } diff --git a/bluetooth_low_energy_platform_interface/lib/src/errors.dart b/bluetooth_low_energy_platform_interface/lib/src/errors.dart index 63e1c23..6c4b83e 100644 --- a/bluetooth_low_energy_platform_interface/lib/src/errors.dart +++ b/bluetooth_low_energy_platform_interface/lib/src/errors.dart @@ -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 diff --git a/bluetooth_low_energy_platform_interface/lib/src/event_args.dart b/bluetooth_low_energy_platform_interface/lib/src/event_args.dart index fbd6135..d00002b 100644 --- a/bluetooth_low_energy_platform_interface/lib/src/event_args.dart +++ b/bluetooth_low_energy_platform_interface/lib/src/event_args.dart @@ -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); } diff --git a/bluetooth_low_energy_platform_interface/lib/src/gatt_characteristic.dart b/bluetooth_low_energy_platform_interface/lib/src/gatt_characteristic.dart index 56b7d9c..0f3cee4 100644 --- a/bluetooth_low_energy_platform_interface/lib/src/gatt_characteristic.dart +++ b/bluetooth_low_energy_platform_interface/lib/src/gatt_characteristic.dart @@ -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 properties; + /// Constructs a [GattCharacteristic]. GattCharacteristic({ required this.uuid, required this.properties, diff --git a/bluetooth_low_energy_platform_interface/lib/src/gatt_characteristic_property.dart b/bluetooth_low_energy_platform_interface/lib/src/gatt_characteristic_property.dart index d92d32e..b4d7ab8 100644 --- a/bluetooth_low_energy_platform_interface/lib/src/gatt_characteristic_property.dart +++ b/bluetooth_low_energy_platform_interface/lib/src/gatt_characteristic_property.dart @@ -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, } diff --git a/bluetooth_low_energy_platform_interface/lib/src/gatt_characteristic_write_type.dart b/bluetooth_low_energy_platform_interface/lib/src/gatt_characteristic_write_type.dart index 2d98c0b..8362537 100644 --- a/bluetooth_low_energy_platform_interface/lib/src/gatt_characteristic_write_type.dart +++ b/bluetooth_low_energy_platform_interface/lib/src/gatt_characteristic_write_type.dart @@ -1,3 +1,4 @@ +/// The write type for a GATT characteristic. enum GattCharacteristicWriteType { // Write with response withResponse, diff --git a/bluetooth_low_energy_platform_interface/lib/src/gatt_descriptor.dart b/bluetooth_low_energy_platform_interface/lib/src/gatt_descriptor.dart index cabf602..b60e2c7 100644 --- a/bluetooth_low_energy_platform_interface/lib/src/gatt_descriptor.dart +++ b/bluetooth_low_energy_platform_interface/lib/src/gatt_descriptor.dart @@ -1,8 +1,11 @@ import 'uuid.dart'; +/// The GATT characteristic. class GattDescriptor { + /// The [UUID] of this GATT descriptor. final UUID uuid; + /// Constructs a [GattDescriptor]. GattDescriptor({ required this.uuid, }); diff --git a/bluetooth_low_energy_platform_interface/lib/src/gatt_service.dart b/bluetooth_low_energy_platform_interface/lib/src/gatt_service.dart index 10c2d40..ce5200a 100644 --- a/bluetooth_low_energy_platform_interface/lib/src/gatt_service.dart +++ b/bluetooth_low_energy_platform_interface/lib/src/gatt_service.dart @@ -1,8 +1,11 @@ import 'uuid.dart'; +/// The GATT service. class GattService { + /// The [UUID] of this GATT service. final UUID uuid; + /// Constructs a [GattService]. GattService({ required this.uuid, }); diff --git a/bluetooth_low_energy_platform_interface/lib/src/peripheral.dart b/bluetooth_low_energy_platform_interface/lib/src/peripheral.dart index 07ae1f5..e72ab89 100644 --- a/bluetooth_low_energy_platform_interface/lib/src/peripheral.dart +++ b/bluetooth_low_energy_platform_interface/lib/src/peripheral.dart @@ -1,5 +1,7 @@ import 'uuid.dart'; +/// The peripheral. abstract class Peripheral { + /// The [UUID] of this peripheral. UUID get uuid; } diff --git a/bluetooth_low_energy_platform_interface/pubspec.yaml b/bluetooth_low_energy_platform_interface/pubspec.yaml index fc8fea8..d26a4b1 100644 --- a/bluetooth_low_energy_platform_interface/pubspec.yaml +++ b/bluetooth_low_energy_platform_interface/pubspec.yaml @@ -1,6 +1,6 @@ name: bluetooth_low_energy_platform_interface description: A common platform interface for the bluetooth_low_energy plugin. -version: 2.0.1 +version: 2.0.2 homepage: https://github.com/yanshouwang/bluetooth_low_energy environment: diff --git a/bluetooth_low_energy_platform_interface/test/bluetooth_low_energy_platform_interface_test.dart b/bluetooth_low_energy_platform_interface/test/bluetooth_low_energy_platform_interface_test.dart deleted file mode 100644 index 8b13789..0000000 --- a/bluetooth_low_energy_platform_interface/test/bluetooth_low_energy_platform_interface_test.dart +++ /dev/null @@ -1 +0,0 @@ - diff --git a/bluetooth_low_energy_windows/.metadata b/bluetooth_low_energy_windows/.metadata index a0dc8d7..48fd03f 100644 --- a/bluetooth_low_energy_windows/.metadata +++ b/bluetooth_low_energy_windows/.metadata @@ -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: windows - create_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf - base_revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf + create_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31 + base_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31 # User provided section diff --git a/bluetooth_low_energy_windows/CHANGELOG.md b/bluetooth_low_energy_windows/CHANGELOG.md index 367297e..dac61dd 100644 --- a/bluetooth_low_energy_windows/CHANGELOG.md +++ b/bluetooth_low_energy_windows/CHANGELOG.md @@ -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. diff --git a/bluetooth_low_energy_windows/LICENSE b/bluetooth_low_energy_windows/LICENSE index 515ed4b..752d28b 100644 --- a/bluetooth_low_energy_windows/LICENSE +++ b/bluetooth_low_energy_windows/LICENSE @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +SOFTWARE. diff --git a/bluetooth_low_energy_windows/pubspec.yaml b/bluetooth_low_energy_windows/pubspec.yaml index f11afa6..3efc16e 100644 --- a/bluetooth_low_energy_windows/pubspec.yaml +++ b/bluetooth_low_energy_windows/pubspec.yaml @@ -1,6 +1,6 @@ name: bluetooth_low_energy_windows description: Windows 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 win32: ^5.0.6 dev_dependencies: @@ -23,5 +23,4 @@ flutter: implements: bluetooth_low_energy platforms: windows: - pluginClass: BluetoothLowEnergyPluginCApi dartPluginClass: BluetoothLowEnergyWindows diff --git a/bluetooth_low_energy_windows/windows/.gitignore b/bluetooth_low_energy_windows/windows/.gitignore deleted file mode 100644 index b3eb2be..0000000 --- a/bluetooth_low_energy_windows/windows/.gitignore +++ /dev/null @@ -1,17 +0,0 @@ -flutter/ - -# Visual Studio user-specific files. -*.suo -*.user -*.userosscache -*.sln.docstates - -# Visual Studio build-related files. -x64/ -x86/ - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!*.[Cc]ache/ diff --git a/bluetooth_low_energy_windows/windows/CMakeLists.txt b/bluetooth_low_energy_windows/windows/CMakeLists.txt deleted file mode 100644 index 13df83f..0000000 --- a/bluetooth_low_energy_windows/windows/CMakeLists.txt +++ /dev/null @@ -1,96 +0,0 @@ -# The Flutter tooling requires that developers have a version of Visual Studio -# installed that includes CMake 3.14 or later. You should not increase this -# version, as doing so will cause the plugin to fail to compile for some -# customers of the plugin. -cmake_minimum_required(VERSION 3.14) - -# Project-level configuration. -set(PROJECT_NAME "bluetooth_low_energy") -project(${PROJECT_NAME} LANGUAGES CXX) - -# This value is used when generating builds using this plugin, so it must -# not be changed -set(PLUGIN_NAME "bluetooth_low_energy_plugin") - -# Any new source files that you add to the plugin should be added here. -list(APPEND PLUGIN_SOURCES - "bluetooth_low_energy_plugin.cpp" - "bluetooth_low_energy_plugin.h" -) - -# Define the plugin library target. Its name must not be changed (see comment -# on PLUGIN_NAME above). -add_library(${PLUGIN_NAME} SHARED - "include/bluetooth_low_energy/bluetooth_low_energy_plugin_c_api.h" - "bluetooth_low_energy_plugin_c_api.cpp" - ${PLUGIN_SOURCES} -) - -# Apply a standard set of build settings that are configured in the -# application-level CMakeLists.txt. This can be removed for plugins that want -# full control over build settings. -apply_standard_settings(${PLUGIN_NAME}) - -# Symbols are hidden by default to reduce the chance of accidental conflicts -# between plugins. This should not be removed; any symbols that should be -# exported should be explicitly exported with the FLUTTER_PLUGIN_EXPORT macro. -set_target_properties(${PLUGIN_NAME} PROPERTIES - CXX_VISIBILITY_PRESET hidden) -target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL) - -# Source include directories and library dependencies. Add any plugin-specific -# dependencies here. -target_include_directories(${PLUGIN_NAME} INTERFACE - "${CMAKE_CURRENT_SOURCE_DIR}/include") -target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin) - -# List of absolute paths to libraries that should be bundled with the plugin. -# This list could contain prebuilt libraries, or libraries created by an -# external build triggered from this build file. -set(bluetooth_low_energy_bundled_libraries - "" - PARENT_SCOPE -) - -# === Tests === -# These unit tests can be run from a terminal after building the example, or -# from Visual Studio after opening the generated solution file. - -# Only enable test builds when building the example (which sets this variable) -# so that plugin clients aren't building the tests. -if (${include_${PROJECT_NAME}_tests}) -set(TEST_RUNNER "${PROJECT_NAME}_test") -enable_testing() - -# Add the Google Test dependency. -include(FetchContent) -FetchContent_Declare( - googletest - URL https://github.com/google/googletest/archive/release-1.11.0.zip -) -# Prevent overriding the parent project's compiler/linker settings -set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) -# Disable install commands for gtest so it doesn't end up in the bundle. -set(INSTALL_GTEST OFF CACHE BOOL "Disable installation of googletest" FORCE) -FetchContent_MakeAvailable(googletest) - -# The plugin's C API is not very useful for unit testing, so build the sources -# directly into the test binary rather than using the DLL. -add_executable(${TEST_RUNNER} - test/bluetooth_low_energy_plugin_test.cpp - ${PLUGIN_SOURCES} -) -apply_standard_settings(${TEST_RUNNER}) -target_include_directories(${TEST_RUNNER} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") -target_link_libraries(${TEST_RUNNER} PRIVATE flutter_wrapper_plugin) -target_link_libraries(${TEST_RUNNER} PRIVATE gtest_main gmock) -# flutter_wrapper_plugin has link dependencies on the Flutter DLL. -add_custom_command(TARGET ${TEST_RUNNER} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different - "${FLUTTER_LIBRARY}" $ -) - -# Enable automatic test discovery. -include(GoogleTest) -gtest_discover_tests(${TEST_RUNNER}) -endif() diff --git a/bluetooth_low_energy_windows/windows/bluetooth_low_energy_plugin.cpp b/bluetooth_low_energy_windows/windows/bluetooth_low_energy_plugin.cpp deleted file mode 100644 index 230438b..0000000 --- a/bluetooth_low_energy_windows/windows/bluetooth_low_energy_plugin.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include "bluetooth_low_energy_plugin.h" - -// This must be included before many other Windows headers. -#include - -// For getPlatformVersion; remove unless needed for your plugin implementation. -#include - -#include -#include -#include - -#include -#include - -namespace bluetooth_low_energy { - -// static -void BluetoothLowEnergyPlugin::RegisterWithRegistrar( - flutter::PluginRegistrarWindows *registrar) { - auto channel = - std::make_unique>( - registrar->messenger(), "bluetooth_low_energy", - &flutter::StandardMethodCodec::GetInstance()); - - auto plugin = std::make_unique(); - - channel->SetMethodCallHandler( - [plugin_pointer = plugin.get()](const auto &call, auto result) { - plugin_pointer->HandleMethodCall(call, std::move(result)); - }); - - registrar->AddPlugin(std::move(plugin)); -} - -BluetoothLowEnergyPlugin::BluetoothLowEnergyPlugin() {} - -BluetoothLowEnergyPlugin::~BluetoothLowEnergyPlugin() {} - -void BluetoothLowEnergyPlugin::HandleMethodCall( - const flutter::MethodCall &method_call, - std::unique_ptr> result) { - if (method_call.method_name().compare("getPlatformVersion") == 0) { - std::ostringstream version_stream; - version_stream << "Windows "; - if (IsWindows10OrGreater()) { - version_stream << "10+"; - } else if (IsWindows8OrGreater()) { - version_stream << "8"; - } else if (IsWindows7OrGreater()) { - version_stream << "7"; - } - result->Success(flutter::EncodableValue(version_stream.str())); - } else { - result->NotImplemented(); - } -} - -} // namespace bluetooth_low_energy diff --git a/bluetooth_low_energy_windows/windows/bluetooth_low_energy_plugin.h b/bluetooth_low_energy_windows/windows/bluetooth_low_energy_plugin.h deleted file mode 100644 index e12faa6..0000000 --- a/bluetooth_low_energy_windows/windows/bluetooth_low_energy_plugin.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef FLUTTER_PLUGIN_BLUETOOTH_LOW_ENERGY_PLUGIN_H_ -#define FLUTTER_PLUGIN_BLUETOOTH_LOW_ENERGY_PLUGIN_H_ - -#include -#include - -#include - -namespace bluetooth_low_energy { - -class BluetoothLowEnergyPlugin : public flutter::Plugin { - public: - static void RegisterWithRegistrar(flutter::PluginRegistrarWindows *registrar); - - BluetoothLowEnergyPlugin(); - - virtual ~BluetoothLowEnergyPlugin(); - - // Disallow copy and assign. - BluetoothLowEnergyPlugin(const BluetoothLowEnergyPlugin&) = delete; - BluetoothLowEnergyPlugin& operator=(const BluetoothLowEnergyPlugin&) = delete; - - // Called when a method is called on this plugin's channel from Dart. - void HandleMethodCall( - const flutter::MethodCall &method_call, - std::unique_ptr> result); -}; - -} // namespace bluetooth_low_energy - -#endif // FLUTTER_PLUGIN_BLUETOOTH_LOW_ENERGY_PLUGIN_H_ diff --git a/bluetooth_low_energy_windows/windows/bluetooth_low_energy_plugin_c_api.cpp b/bluetooth_low_energy_windows/windows/bluetooth_low_energy_plugin_c_api.cpp deleted file mode 100644 index ef486c1..0000000 --- a/bluetooth_low_energy_windows/windows/bluetooth_low_energy_plugin_c_api.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "include/bluetooth_low_energy/bluetooth_low_energy_plugin_c_api.h" - -#include - -#include "bluetooth_low_energy_plugin.h" - -void BluetoothLowEnergyPluginCApiRegisterWithRegistrar( - FlutterDesktopPluginRegistrarRef registrar) { - bluetooth_low_energy::BluetoothLowEnergyPlugin::RegisterWithRegistrar( - flutter::PluginRegistrarManager::GetInstance() - ->GetRegistrar(registrar)); -} diff --git a/bluetooth_low_energy_windows/windows/include/bluetooth_low_energy/bluetooth_low_energy_plugin_c_api.h b/bluetooth_low_energy_windows/windows/include/bluetooth_low_energy/bluetooth_low_energy_plugin_c_api.h deleted file mode 100644 index a85ebae..0000000 --- a/bluetooth_low_energy_windows/windows/include/bluetooth_low_energy/bluetooth_low_energy_plugin_c_api.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef FLUTTER_PLUGIN_BLUETOOTH_LOW_ENERGY_PLUGIN_C_API_H_ -#define FLUTTER_PLUGIN_BLUETOOTH_LOW_ENERGY_PLUGIN_C_API_H_ - -#include - -#ifdef FLUTTER_PLUGIN_IMPL -#define FLUTTER_PLUGIN_EXPORT __declspec(dllexport) -#else -#define FLUTTER_PLUGIN_EXPORT __declspec(dllimport) -#endif - -#if defined(__cplusplus) -extern "C" { -#endif - -FLUTTER_PLUGIN_EXPORT void BluetoothLowEnergyPluginCApiRegisterWithRegistrar( - FlutterDesktopPluginRegistrarRef registrar); - -#if defined(__cplusplus) -} // extern "C" -#endif - -#endif // FLUTTER_PLUGIN_BLUETOOTH_LOW_ENERGY_PLUGIN_C_API_H_ diff --git a/bluetooth_low_energy_windows/windows/test/bluetooth_low_energy_plugin_test.cpp b/bluetooth_low_energy_windows/windows/test/bluetooth_low_energy_plugin_test.cpp deleted file mode 100644 index 72c8764..0000000 --- a/bluetooth_low_energy_windows/windows/test/bluetooth_low_energy_plugin_test.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "bluetooth_low_energy_plugin.h" - -namespace bluetooth_low_energy { -namespace test { - -namespace { - -using flutter::EncodableMap; -using flutter::EncodableValue; -using flutter::MethodCall; -using flutter::MethodResultFunctions; - -} // namespace - -TEST(BluetoothLowEnergyPlugin, GetPlatformVersion) { - BluetoothLowEnergyPlugin plugin; - // Save the reply value from the success callback. - std::string result_string; - plugin.HandleMethodCall( - MethodCall("getPlatformVersion", std::make_unique()), - std::make_unique>( - [&result_string](const EncodableValue* result) { - result_string = std::get(*result); - }, - nullptr, nullptr)); - - // Since the exact string varies by host, just ensure that it's a string - // with the expected format. - EXPECT_TRUE(result_string.rfind("Windows ", 0) == 0); -} - -} // namespace test -} // namespace bluetooth_low_energy diff --git a/scripts/run_pigeon.sh b/scripts/run_pigeon.sh index 715890e..a374e85 100644 --- a/scripts/run_pigeon.sh +++ b/scripts/run_pigeon.sh @@ -1 +1 @@ -dart run pigeon --input my_api.dart \ No newline at end of file +dart run pigeon --input my_api.dart