@capacitor-community/bluetooth-le 7.3.0 → 8.0.0-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/CapacitorCommunityBluetoothLe.podspec +17 -17
  2. package/LICENSE +21 -21
  3. package/Package.swift +28 -0
  4. package/android/build.gradle +71 -68
  5. package/android/src/main/AndroidManifest.xml +22 -22
  6. package/android/src/main/java/com/capacitorjs/community/plugins/bluetoothle/BluetoothLe.kt +1094 -1094
  7. package/android/src/main/java/com/capacitorjs/community/plugins/bluetoothle/Conversion.kt +51 -51
  8. package/android/src/main/java/com/capacitorjs/community/plugins/bluetoothle/Device.kt +771 -771
  9. package/android/src/main/java/com/capacitorjs/community/plugins/bluetoothle/DeviceList.kt +28 -28
  10. package/android/src/main/java/com/capacitorjs/community/plugins/bluetoothle/DeviceScanner.kt +189 -189
  11. package/dist/esm/bleClient.d.ts +278 -278
  12. package/dist/esm/bleClient.js +361 -361
  13. package/dist/esm/bleClient.js.map +1 -1
  14. package/dist/esm/config.d.ts +53 -53
  15. package/dist/esm/config.js +2 -2
  16. package/dist/esm/conversion.d.ts +56 -46
  17. package/dist/esm/conversion.js +134 -117
  18. package/dist/esm/conversion.js.map +1 -1
  19. package/dist/esm/definitions.d.ts +352 -352
  20. package/dist/esm/definitions.js +42 -42
  21. package/dist/esm/index.d.ts +5 -5
  22. package/dist/esm/index.js +5 -5
  23. package/dist/esm/plugin.d.ts +2 -2
  24. package/dist/esm/plugin.js +4 -4
  25. package/dist/esm/queue.d.ts +3 -3
  26. package/dist/esm/queue.js +17 -17
  27. package/dist/esm/queue.js.map +1 -1
  28. package/dist/esm/timeout.d.ts +1 -1
  29. package/dist/esm/timeout.js +9 -9
  30. package/dist/esm/validators.d.ts +1 -1
  31. package/dist/esm/validators.js +11 -11
  32. package/dist/esm/validators.js.map +1 -1
  33. package/dist/esm/web.d.ts +57 -57
  34. package/dist/esm/web.js +403 -403
  35. package/dist/esm/web.js.map +1 -1
  36. package/dist/plugin.cjs.js +965 -947
  37. package/dist/plugin.cjs.js.map +1 -1
  38. package/dist/plugin.js +965 -947
  39. package/dist/plugin.js.map +1 -1
  40. package/ios/{Plugin → Sources/BluetoothLe}/Conversion.swift +83 -83
  41. package/ios/{Plugin → Sources/BluetoothLe}/Device.swift +423 -423
  42. package/ios/{Plugin → Sources/BluetoothLe}/DeviceListView.swift +121 -121
  43. package/ios/{Plugin → Sources/BluetoothLe}/DeviceManager.swift +503 -502
  44. package/ios/{Plugin → Sources/BluetoothLe}/Logging.swift +8 -8
  45. package/ios/{Plugin → Sources/BluetoothLe}/Plugin.swift +775 -737
  46. package/ios/{Plugin → Sources/BluetoothLe}/ThreadSafeDictionary.swift +15 -13
  47. package/ios/Tests/BluetoothLeTests/ConversionTests.swift +55 -0
  48. package/ios/Tests/BluetoothLeTests/PluginTests.swift +27 -0
  49. package/package.json +115 -111
  50. package/ios/Plugin/Info.plist +0 -24
  51. package/ios/Plugin/Plugin.h +0 -10
  52. package/ios/Plugin/Plugin.m +0 -41
@@ -1,13 +1,15 @@
1
- class ThreadSafeDictionary<K: Hashable, T> {
2
- private var dictionary: [K: T] = [:]
3
- private let queue = DispatchQueue(label: "threadSafeDictionaryQueue", attributes: .concurrent)
4
-
5
- subscript(key: K) -> T? {
6
- get {
7
- return queue.sync { dictionary[key] }
8
- }
9
- set {
10
- queue.async(flags: .barrier) { self.dictionary[key] = newValue }
11
- }
12
- }
13
- }
1
+ import Foundation
2
+
3
+ class ThreadSafeDictionary<K: Hashable, T> {
4
+ private var dictionary: [K: T] = [:]
5
+ private let queue = DispatchQueue(label: "threadSafeDictionaryQueue", attributes: .concurrent)
6
+
7
+ subscript(key: K) -> T? {
8
+ get {
9
+ return queue.sync { dictionary[key] }
10
+ }
11
+ set {
12
+ queue.async(flags: .barrier) { self.dictionary[key] = newValue }
13
+ }
14
+ }
15
+ }
@@ -0,0 +1,55 @@
1
+ import Foundation
2
+ import CoreBluetooth
3
+ import XCTest
4
+ @testable import BluetoothLe
5
+
6
+ class ConversionTests: XCTestCase {
7
+
8
+ func testDataToString() throws {
9
+ let input = Data([0xA1, 0x2E, 0x38, 0xD4, 0x89, 0xC3])
10
+ let output = dataToString(input)
11
+ XCTAssertEqual(output, "a12e38d489c3")
12
+ }
13
+
14
+ func testStringToData() throws {
15
+ let input = "a12e38d489c3"
16
+ let output = stringToData(input)
17
+ let expected = Data([0xA1, 0x2E, 0x38, 0xD4, 0x89, 0xC3])
18
+ for (index, byte) in output.enumerated() {
19
+ XCTAssertEqual(byte, expected[index])
20
+ }
21
+ }
22
+
23
+ func testEmptyStringToData() throws {
24
+ let input = ""
25
+ let output = stringToData(input)
26
+ XCTAssertEqual(output, Data([]))
27
+ }
28
+
29
+ func testCbuuidToString() throws {
30
+ XCTAssertEqual(cbuuidToString(CBUUID(string: "180D")), "0000180d-0000-1000-8000-00805f9b34fb")
31
+ XCTAssertEqual(cbuuidToString(CBUUID(string: "AAAA180D")), "aaaa180d-0000-1000-8000-00805f9b34fb")
32
+ XCTAssertEqual(cbuuidToString(CBUUID(string: "fb005c80-02e7-f387-1cad-8acd2d8df0c8")), "fb005c80-02e7-f387-1cad-8acd2d8df0c8")
33
+ }
34
+
35
+ func testCbuuidToStringUppercase() throws {
36
+ XCTAssertEqual(cbuuidToStringUppercase(CBUUID(string: "180D")), "0000180D-0000-1000-8000-00805F9B34FB")
37
+ XCTAssertEqual(cbuuidToStringUppercase(CBUUID(string: "fb005c80-02e7-f387-1cad-8acd2d8df0c8")), "FB005C80-02E7-F387-1CAD-8ACD2D8DF0C8")
38
+ }
39
+
40
+ func testOptionalStringConversion() throws {
41
+ let str: String? = "180D"
42
+ XCTAssertEqual("\(str)", "Optional(\"180D\")")
43
+ XCTAssertEqual("\(str!)", "180D")
44
+ }
45
+
46
+ func testDescriptorValueToString() throws {
47
+ XCTAssertEqual(descriptorValueToString("Hello"), "48656c6c6f")
48
+ XCTAssertEqual(descriptorValueToString(Data([0, 5, 255])), "0005ff")
49
+ XCTAssertEqual(descriptorValueToString(UInt16(258)), "0201")
50
+ XCTAssertEqual(descriptorValueToString(UInt16(1)), "0100")
51
+ XCTAssertEqual(descriptorValueToString(NSNumber(1)), "0100")
52
+ XCTAssertEqual(descriptorValueToString(0), "")
53
+ }
54
+
55
+ }
@@ -0,0 +1,27 @@
1
+ import XCTest
2
+ import Capacitor
3
+ @testable import BluetoothLe
4
+
5
+ class PluginTests: XCTestCase {
6
+
7
+ func testEcho() {
8
+ // This is an example of a functional test case for a plugin.
9
+ // Use XCTAssert and related functions to verify your tests produce the correct results.
10
+
11
+ let value = "Hello, World!"
12
+ XCTAssertEqual(1, 1)
13
+
14
+ // let plugin = MyPlugin()
15
+ //
16
+ // let call = CAPPluginCall(callbackId: "test", options: [
17
+ // "value": value
18
+ // ], success: { (result, _) in
19
+ // let resultValue = result!.data["value"] as? String
20
+ // XCTAssertEqual(value, resultValue)
21
+ // }, error: { (_) in
22
+ // XCTFail("Error shouldn't have been called")
23
+ // })
24
+ //
25
+ // plugin.echo(call!)
26
+ }
27
+ }
package/package.json CHANGED
@@ -1,111 +1,115 @@
1
- {
2
- "name": "@capacitor-community/bluetooth-le",
3
- "version": "7.3.0",
4
- "description": "Capacitor plugin for Bluetooth Low Energy ",
5
- "main": "dist/plugin.cjs.js",
6
- "module": "dist/esm/index.js",
7
- "types": "dist/esm/index.d.ts",
8
- "unpkg": "dist/plugin.js",
9
- "scripts": {
10
- "verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
11
- "verify:ios": "set -o pipefail && cd ios && pod install && xcodebuild clean build test -workspace Plugin.xcworkspace -scheme Plugin -destination \"platform=iOS Simulator,name=iPhone 16\" | xcpretty && cd ..",
12
- "verify:android": "cd android && ./gradlew clean build test && cd ..",
13
- "verify:web": "npm run test:coverage && npm run build",
14
- "lint": "npm run eslint && npm run prettier -- --check && npm run lint:ios",
15
- "lint:ios": "npm run swiftlint -- lint ios",
16
- "lint:android": "cd android && ./gradlew clean lint && cd ..",
17
- "fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- lint --fix --format ios",
18
- "eslint": "eslint . --ext ts",
19
- "prettier": "prettier \"**/*.{css,html,ts,js}\"",
20
- "swiftlint": "node-swiftlint",
21
- "docgen": "docgen --api BleClientInterface --output-readme README.md --output-json dist/docs.json",
22
- "postdocgen": "node scripts/fix-docgen-types.js && prettier README.md --write",
23
- "build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.mjs",
24
- "clean": "rimraf ./dist",
25
- "watch": "tsc --watch",
26
- "prepublishOnly": "npm run build",
27
- "test": "jest",
28
- "test:coverage": "jest --coverage",
29
- "test:watch": "jest --watch",
30
- "version:dev": "npm version --no-git-tag-version $(git describe)",
31
- "release": "standard-version",
32
- "release:minor": "standard-version -r minor",
33
- "release:major": "standard-version -r major"
34
- },
35
- "author": "pwespi",
36
- "license": "MIT",
37
- "dependencies": {
38
- "@types/web-bluetooth": "^0.0.20"
39
- },
40
- "devDependencies": {
41
- "@capacitor/android": "^7.0.0",
42
- "@capacitor/cli": "^7.0.0",
43
- "@capacitor/core": "^7.0.0",
44
- "@capacitor/docgen": "^0.3.0",
45
- "@capacitor/ios": "^7.0.0",
46
- "@ionic/eslint-config": "^0.4.0",
47
- "@ionic/prettier-config": "^4.0.0",
48
- "@ionic/swiftlint-config": "^2.0.0",
49
- "@types/jest": "^29.2.5",
50
- "eslint": "^8.57.0",
51
- "jest": "^29.3.1",
52
- "jest-environment-jsdom": "^29.3.1",
53
- "prettier": "^3.4.2",
54
- "rimraf": "^6.0.1",
55
- "rollup": "^4.30.1",
56
- "standard-version": "^9.5.0",
57
- "swiftlint": "^2.0.0",
58
- "ts-jest": "^29.0.3",
59
- "typescript": "~4.9.4"
60
- },
61
- "peerDependencies": {
62
- "@capacitor/core": ">=7.0.0"
63
- },
64
- "files": [
65
- "android/src/main/",
66
- "android/build.gradle",
67
- "dist/",
68
- "ios/Plugin/",
69
- "CapacitorCommunityBluetoothLe.podspec"
70
- ],
71
- "keywords": [
72
- "capacitor",
73
- "plugin",
74
- "native",
75
- "bluetooth"
76
- ],
77
- "capacitor": {
78
- "ios": {
79
- "src": "ios"
80
- },
81
- "android": {
82
- "src": "android"
83
- }
84
- },
85
- "prettier": "@ionic/prettier-config",
86
- "swiftlint": "@ionic/swiftlint-config",
87
- "eslintConfig": {
88
- "extends": "@ionic/eslint-config/recommended",
89
- "rules": {
90
- "@typescript-eslint/no-unused-vars": [
91
- "error",
92
- {
93
- "argsIgnorePattern": "^_",
94
- "varsIgnorePattern": "^_",
95
- "caughtErrorsIgnorePattern": "^_"
96
- }
97
- ]
98
- }
99
- },
100
- "repository": {
101
- "type": "git",
102
- "url": "https://github.com/capacitor-community/bluetooth-le"
103
- },
104
- "bugs": {
105
- "url": "https://github.com/capacitor-community/bluetooth-le/issues"
106
- },
107
- "volta": {
108
- "node": "22.13.1",
109
- "npm": "11.0.0"
110
- }
111
- }
1
+ {
2
+ "name": "@capacitor-community/bluetooth-le",
3
+ "version": "8.0.0-0",
4
+ "description": "Capacitor plugin for Bluetooth Low Energy ",
5
+ "main": "dist/plugin.cjs.js",
6
+ "module": "dist/esm/index.js",
7
+ "types": "dist/esm/index.d.ts",
8
+ "unpkg": "dist/plugin.js",
9
+ "scripts": {
10
+ "verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
11
+ "verify:ios": "xcodebuild -scheme CapacitorCommunityBluetoothLe -destination generic/platform=iOS",
12
+ "verify:android": "cd android && ./gradlew clean build test && cd ..",
13
+ "verify:web": "npm run test:coverage && npm run build",
14
+ "lint": "npm run eslint && npm run prettier -- --check && npm run lint:ios",
15
+ "lint:ios": "npm run swiftlint -- lint ios",
16
+ "lint:android": "cd android && ./gradlew clean lint && cd ..",
17
+ "fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- lint --fix --format ios",
18
+ "eslint": "eslint . --ext ts",
19
+ "prettier": "prettier \"**/*.{css,html,ts,js}\"",
20
+ "swiftlint": "node-swiftlint",
21
+ "docgen": "docgen --api BleClientInterface --output-readme README.md --output-json dist/docs.json",
22
+ "postdocgen": "node scripts/fix-docgen-types.js && prettier README.md --write",
23
+ "build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.mjs",
24
+ "clean": "rimraf ./dist",
25
+ "watch": "tsc --watch",
26
+ "prepublishOnly": "npm run build",
27
+ "test": "jest",
28
+ "test:coverage": "jest --coverage",
29
+ "test:watch": "jest --watch",
30
+ "test:ios": "xcodebuild test -scheme CapacitorCommunityBluetoothLe -destination 'platform=iOS Simulator,name=iPhone 15,OS=17.5'",
31
+ "version:dev": "npm version --no-git-tag-version $(git describe)",
32
+ "release": "standard-version",
33
+ "release:minor": "standard-version -r minor",
34
+ "release:major": "standard-version -r major"
35
+ },
36
+ "author": "pwespi",
37
+ "license": "MIT",
38
+ "dependencies": {
39
+ "@types/web-bluetooth": "^0.0.20"
40
+ },
41
+ "devDependencies": {
42
+ "@capacitor/android": "^8.0.0",
43
+ "@capacitor/cli": "^8.0.0",
44
+ "@capacitor/core": "^8.0.0",
45
+ "@capacitor/docgen": "^0.3.1",
46
+ "@capacitor/ios": "^8.0.0",
47
+ "@ionic/eslint-config": "^0.4.0",
48
+ "@ionic/prettier-config": "^4.0.0",
49
+ "@ionic/swiftlint-config": "^2.0.0",
50
+ "@types/jest": "^29.2.5",
51
+ "eslint": "^8.57.1",
52
+ "jest": "^29.3.1",
53
+ "jest-environment-jsdom": "^29.3.1",
54
+ "prettier": "^3.6.2",
55
+ "rimraf": "^6.1.0",
56
+ "rollup": "^4.53.2",
57
+ "standard-version": "^9.5.0",
58
+ "swiftlint": "^2.0.0",
59
+ "ts-jest": "^29.0.3",
60
+ "typescript": "^5.9.3",
61
+ "prettier-plugin-java": "^2.7.7"
62
+ },
63
+ "peerDependencies": {
64
+ "@capacitor/core": ">=8.0.0"
65
+ },
66
+ "files": [
67
+ "android/src/main/",
68
+ "android/build.gradle",
69
+ "dist/",
70
+ "ios/Sources",
71
+ "ios/Tests",
72
+ "Package.swift",
73
+ "CapacitorCommunityBluetoothLe.podspec"
74
+ ],
75
+ "keywords": [
76
+ "capacitor",
77
+ "plugin",
78
+ "native",
79
+ "bluetooth"
80
+ ],
81
+ "capacitor": {
82
+ "ios": {
83
+ "src": "ios"
84
+ },
85
+ "android": {
86
+ "src": "android"
87
+ }
88
+ },
89
+ "prettier": "@ionic/prettier-config",
90
+ "swiftlint": "@ionic/swiftlint-config",
91
+ "eslintConfig": {
92
+ "extends": "@ionic/eslint-config/recommended",
93
+ "rules": {
94
+ "@typescript-eslint/no-unused-vars": [
95
+ "error",
96
+ {
97
+ "argsIgnorePattern": "^_",
98
+ "varsIgnorePattern": "^_",
99
+ "caughtErrorsIgnorePattern": "^_"
100
+ }
101
+ ]
102
+ }
103
+ },
104
+ "repository": {
105
+ "type": "git",
106
+ "url": "https://github.com/capacitor-community/bluetooth-le"
107
+ },
108
+ "bugs": {
109
+ "url": "https://github.com/capacitor-community/bluetooth-le/issues"
110
+ },
111
+ "volta": {
112
+ "node": "22.13.1",
113
+ "npm": "11.0.0"
114
+ }
115
+ }
@@ -1,24 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
- <plist version="1.0">
4
- <dict>
5
- <key>CFBundleDevelopmentRegion</key>
6
- <string>$(DEVELOPMENT_LANGUAGE)</string>
7
- <key>CFBundleExecutable</key>
8
- <string>$(EXECUTABLE_NAME)</string>
9
- <key>CFBundleIdentifier</key>
10
- <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11
- <key>CFBundleInfoDictionaryVersion</key>
12
- <string>6.0</string>
13
- <key>CFBundleName</key>
14
- <string>$(PRODUCT_NAME)</string>
15
- <key>CFBundlePackageType</key>
16
- <string>FMWK</string>
17
- <key>CFBundleShortVersionString</key>
18
- <string>1.0</string>
19
- <key>CFBundleVersion</key>
20
- <string>$(CURRENT_PROJECT_VERSION)</string>
21
- <key>NSPrincipalClass</key>
22
- <string></string>
23
- </dict>
24
- </plist>
@@ -1,10 +0,0 @@
1
- #import <UIKit/UIKit.h>
2
-
3
- //! Project version number for Plugin.
4
- FOUNDATION_EXPORT double PluginVersionNumber;
5
-
6
- //! Project version string for Plugin.
7
- FOUNDATION_EXPORT const unsigned char PluginVersionString[];
8
-
9
- // In this header, you should import all the public headers of your framework using statements like #import <Plugin/PublicHeader.h>
10
-
@@ -1,41 +0,0 @@
1
- #import <Foundation/Foundation.h>
2
- #import <Capacitor/Capacitor.h>
3
-
4
- // Define the plugin using the CAP_PLUGIN Macro, and
5
- // each method the plugin supports using the CAP_PLUGIN_METHOD macro.
6
- CAP_PLUGIN(BluetoothLe, "BluetoothLe",
7
- CAP_PLUGIN_METHOD(initialize, CAPPluginReturnPromise);
8
- CAP_PLUGIN_METHOD(isEnabled, CAPPluginReturnPromise);
9
- CAP_PLUGIN_METHOD(requestEnable, CAPPluginReturnPromise);
10
- CAP_PLUGIN_METHOD(enable, CAPPluginReturnPromise);
11
- CAP_PLUGIN_METHOD(disable, CAPPluginReturnPromise);
12
- CAP_PLUGIN_METHOD(startEnabledNotifications, CAPPluginReturnPromise);
13
- CAP_PLUGIN_METHOD(stopEnabledNotifications, CAPPluginReturnPromise);
14
- CAP_PLUGIN_METHOD(isLocationEnabled, CAPPluginReturnPromise);
15
- CAP_PLUGIN_METHOD(openLocationSettings, CAPPluginReturnPromise);
16
- CAP_PLUGIN_METHOD(openBluetoothSettings, CAPPluginReturnPromise);
17
- CAP_PLUGIN_METHOD(openAppSettings, CAPPluginReturnPromise);
18
- CAP_PLUGIN_METHOD(setDisplayStrings, CAPPluginReturnPromise);
19
- CAP_PLUGIN_METHOD(requestDevice, CAPPluginReturnPromise);
20
- CAP_PLUGIN_METHOD(requestLEScan, CAPPluginReturnPromise);
21
- CAP_PLUGIN_METHOD(stopLEScan, CAPPluginReturnPromise);
22
- CAP_PLUGIN_METHOD(getDevices, CAPPluginReturnPromise);
23
- CAP_PLUGIN_METHOD(discoverServices, CAPPluginReturnPromise);
24
- CAP_PLUGIN_METHOD(getConnectedDevices, CAPPluginReturnPromise);
25
- CAP_PLUGIN_METHOD(connect, CAPPluginReturnPromise);
26
- CAP_PLUGIN_METHOD(createBond, CAPPluginReturnPromise);
27
- CAP_PLUGIN_METHOD(isBonded, CAPPluginReturnPromise);
28
- CAP_PLUGIN_METHOD(getBondedDevices, CAPPluginReturnPromise);
29
- CAP_PLUGIN_METHOD(disconnect, CAPPluginReturnPromise);
30
- CAP_PLUGIN_METHOD(getServices, CAPPluginReturnPromise);
31
- CAP_PLUGIN_METHOD(getMtu, CAPPluginReturnPromise);
32
- CAP_PLUGIN_METHOD(requestConnectionPriority, CAPPluginReturnPromise);
33
- CAP_PLUGIN_METHOD(readRssi, CAPPluginReturnPromise);
34
- CAP_PLUGIN_METHOD(read, CAPPluginReturnPromise);
35
- CAP_PLUGIN_METHOD(write, CAPPluginReturnPromise);
36
- CAP_PLUGIN_METHOD(writeWithoutResponse, CAPPluginReturnPromise);
37
- CAP_PLUGIN_METHOD(readDescriptor, CAPPluginReturnPromise);
38
- CAP_PLUGIN_METHOD(writeDescriptor, CAPPluginReturnPromise);
39
- CAP_PLUGIN_METHOD(startNotifications, CAPPluginReturnPromise);
40
- CAP_PLUGIN_METHOD(stopNotifications, CAPPluginReturnPromise);
41
- )