@capacitor-community/bluetooth-le 8.0.1 → 8.0.2
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.
- package/CapacitorCommunityBluetoothLe.podspec +17 -17
- package/LICENSE +21 -21
- package/Package.swift +27 -27
- package/README.md +2 -1
- package/android/build.gradle +73 -73
- package/android/src/main/AndroidManifest.xml +22 -22
- package/android/src/main/java/com/capacitorjs/community/plugins/bluetoothle/BluetoothLe.kt +1094 -1094
- package/android/src/main/java/com/capacitorjs/community/plugins/bluetoothle/Conversion.kt +51 -51
- package/android/src/main/java/com/capacitorjs/community/plugins/bluetoothle/Device.kt +771 -771
- package/android/src/main/java/com/capacitorjs/community/plugins/bluetoothle/DeviceList.kt +28 -28
- package/android/src/main/java/com/capacitorjs/community/plugins/bluetoothle/DeviceScanner.kt +189 -189
- package/dist/docs.json +43 -43
- package/dist/esm/bleClient.d.ts +278 -278
- package/dist/esm/bleClient.js +361 -361
- package/dist/esm/bleClient.js.map +1 -1
- package/dist/esm/config.d.ts +53 -53
- package/dist/esm/config.js +2 -2
- package/dist/esm/conversion.d.ts +56 -56
- package/dist/esm/conversion.js +134 -134
- package/dist/esm/conversion.js.map +1 -1
- package/dist/esm/definitions.d.ts +352 -352
- package/dist/esm/definitions.js +42 -42
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/index.d.ts +5 -5
- package/dist/esm/index.js +5 -5
- package/dist/esm/plugin.d.ts +2 -2
- package/dist/esm/plugin.js +4 -4
- package/dist/esm/queue.d.ts +3 -3
- package/dist/esm/queue.js +17 -17
- package/dist/esm/timeout.d.ts +1 -1
- package/dist/esm/timeout.js +9 -9
- package/dist/esm/validators.d.ts +1 -1
- package/dist/esm/validators.js +11 -11
- package/dist/esm/web.d.ts +57 -57
- package/dist/esm/web.js +403 -403
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +964 -964
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +964 -964
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/BluetoothLe/Conversion.swift +83 -83
- package/ios/Sources/BluetoothLe/Device.swift +422 -423
- package/ios/Sources/BluetoothLe/DeviceListView.swift +121 -121
- package/ios/Sources/BluetoothLe/DeviceManager.swift +409 -415
- package/ios/Sources/BluetoothLe/Logging.swift +8 -8
- package/ios/Sources/BluetoothLe/Plugin.swift +768 -763
- package/ios/Sources/BluetoothLe/ScanFilters.swift +114 -114
- package/ios/Sources/BluetoothLe/ThreadSafeDictionary.swift +61 -15
- package/ios/Tests/BluetoothLeTests/ConversionTests.swift +55 -55
- package/ios/Tests/BluetoothLeTests/PluginTests.swift +27 -27
- package/ios/Tests/BluetoothLeTests/ScanFiltersTests.swift +153 -153
- package/package.json +114 -114
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
package com.capacitorjs.community.plugins.bluetoothle
|
|
2
|
-
|
|
3
|
-
// Create a LUT for high performance ByteArray conversion
|
|
4
|
-
val HEX_LOOKUP_TABLE = IntArray(256) {
|
|
5
|
-
val hexChars = "0123456789ABCDEF"
|
|
6
|
-
val h: Int = (hexChars[(it shr 4)].code shl 8)
|
|
7
|
-
val l: Int = hexChars[(it and 0x0F)].code
|
|
8
|
-
(h or l)
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// Custom implementation of ByteArray.toHexString until stdlib stabilizes
|
|
12
|
-
private fun ByteArray.toHexString(): String {
|
|
13
|
-
val result = CharArray(this.size * 2);
|
|
14
|
-
var i = 0;
|
|
15
|
-
for (byte in this) {
|
|
16
|
-
val hx = HEX_LOOKUP_TABLE[byte.toInt() and 0xFF]
|
|
17
|
-
result[i] = (hx shr 8).toChar()
|
|
18
|
-
result[i+1] = (hx and 0xFF).toChar()
|
|
19
|
-
i+=2
|
|
20
|
-
}
|
|
21
|
-
return result.concatToString()
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
fun bytesToString(bytes: ByteArray): String {
|
|
25
|
-
return bytes.toHexString()
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
fun stringToBytes(value: String): ByteArray {
|
|
29
|
-
if (value == "") {
|
|
30
|
-
return ByteArray(0)
|
|
31
|
-
}
|
|
32
|
-
require(value.length % 2 == 0) { "Input string must have an even length, not ${value.length}" }
|
|
33
|
-
val bytes = ByteArray(value.length / 2)
|
|
34
|
-
for (i in bytes.indices) {
|
|
35
|
-
val hexPair = value.substring(i * 2, i * 2 + 2)
|
|
36
|
-
bytes[i] = hexToByte(hexPair)
|
|
37
|
-
}
|
|
38
|
-
return bytes
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
fun hexToByte(hexString: String): Byte {
|
|
42
|
-
val firstDigit = toDigit(hexString[0])
|
|
43
|
-
val secondDigit = toDigit(hexString[1])
|
|
44
|
-
return ((firstDigit shl 4) + secondDigit).toByte()
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
private fun toDigit(hexChar: Char): Int {
|
|
48
|
-
val digit = Character.digit(hexChar, 16)
|
|
49
|
-
require(digit != -1) { "Invalid Hexadecimal Character: $hexChar" }
|
|
50
|
-
return digit
|
|
51
|
-
}
|
|
1
|
+
package com.capacitorjs.community.plugins.bluetoothle
|
|
2
|
+
|
|
3
|
+
// Create a LUT for high performance ByteArray conversion
|
|
4
|
+
val HEX_LOOKUP_TABLE = IntArray(256) {
|
|
5
|
+
val hexChars = "0123456789ABCDEF"
|
|
6
|
+
val h: Int = (hexChars[(it shr 4)].code shl 8)
|
|
7
|
+
val l: Int = hexChars[(it and 0x0F)].code
|
|
8
|
+
(h or l)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// Custom implementation of ByteArray.toHexString until stdlib stabilizes
|
|
12
|
+
private fun ByteArray.toHexString(): String {
|
|
13
|
+
val result = CharArray(this.size * 2);
|
|
14
|
+
var i = 0;
|
|
15
|
+
for (byte in this) {
|
|
16
|
+
val hx = HEX_LOOKUP_TABLE[byte.toInt() and 0xFF]
|
|
17
|
+
result[i] = (hx shr 8).toChar()
|
|
18
|
+
result[i+1] = (hx and 0xFF).toChar()
|
|
19
|
+
i+=2
|
|
20
|
+
}
|
|
21
|
+
return result.concatToString()
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
fun bytesToString(bytes: ByteArray): String {
|
|
25
|
+
return bytes.toHexString()
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
fun stringToBytes(value: String): ByteArray {
|
|
29
|
+
if (value == "") {
|
|
30
|
+
return ByteArray(0)
|
|
31
|
+
}
|
|
32
|
+
require(value.length % 2 == 0) { "Input string must have an even length, not ${value.length}" }
|
|
33
|
+
val bytes = ByteArray(value.length / 2)
|
|
34
|
+
for (i in bytes.indices) {
|
|
35
|
+
val hexPair = value.substring(i * 2, i * 2 + 2)
|
|
36
|
+
bytes[i] = hexToByte(hexPair)
|
|
37
|
+
}
|
|
38
|
+
return bytes
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
fun hexToByte(hexString: String): Byte {
|
|
42
|
+
val firstDigit = toDigit(hexString[0])
|
|
43
|
+
val secondDigit = toDigit(hexString[1])
|
|
44
|
+
return ((firstDigit shl 4) + secondDigit).toByte()
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
private fun toDigit(hexChar: Char): Int {
|
|
48
|
+
val digit = Character.digit(hexChar, 16)
|
|
49
|
+
require(digit != -1) { "Invalid Hexadecimal Character: $hexChar" }
|
|
50
|
+
return digit
|
|
51
|
+
}
|