@blueid/access-react-native 1.16.0 → 1.18.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.
- package/frameworks/CBlueIDAccess.xcframework/Info.plist +6 -6
- package/frameworks/CBlueIDAccess.xcframework/ios-arm64/libCBlueIDAccess.a +0 -0
- package/frameworks/CBlueIDAccess.xcframework/ios-arm64_x86_64-simulator/libCBlueIDAccess.a +0 -0
- package/frameworks/CBlueIDAccess.xcframework/macos-arm64_x86_64/libCBlueIDAccess.a +0 -0
- package/ios/BlueIDAccessSDK/BlueDevices.swift +11 -25
- package/ios/BlueIDAccessSDK/BlueDevicesList.swift +89 -0
- package/ios/BlueIDAccessSDK/BlueSPTransponder.swift +1 -3
- package/package.json +1 -1
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
<key>HeadersPath</key>
|
|
11
11
|
<string>Headers</string>
|
|
12
12
|
<key>LibraryIdentifier</key>
|
|
13
|
-
<string>
|
|
13
|
+
<string>macos-arm64_x86_64</string>
|
|
14
14
|
<key>LibraryPath</key>
|
|
15
15
|
<string>libCBlueIDAccess.a</string>
|
|
16
16
|
<key>SupportedArchitectures</key>
|
|
@@ -19,9 +19,7 @@
|
|
|
19
19
|
<string>x86_64</string>
|
|
20
20
|
</array>
|
|
21
21
|
<key>SupportedPlatform</key>
|
|
22
|
-
<string>
|
|
23
|
-
<key>SupportedPlatformVariant</key>
|
|
24
|
-
<string>simulator</string>
|
|
22
|
+
<string>macos</string>
|
|
25
23
|
</dict>
|
|
26
24
|
<dict>
|
|
27
25
|
<key>BinaryPath</key>
|
|
@@ -29,7 +27,7 @@
|
|
|
29
27
|
<key>HeadersPath</key>
|
|
30
28
|
<string>Headers</string>
|
|
31
29
|
<key>LibraryIdentifier</key>
|
|
32
|
-
<string>
|
|
30
|
+
<string>ios-arm64_x86_64-simulator</string>
|
|
33
31
|
<key>LibraryPath</key>
|
|
34
32
|
<string>libCBlueIDAccess.a</string>
|
|
35
33
|
<key>SupportedArchitectures</key>
|
|
@@ -38,7 +36,9 @@
|
|
|
38
36
|
<string>x86_64</string>
|
|
39
37
|
</array>
|
|
40
38
|
<key>SupportedPlatform</key>
|
|
41
|
-
<string>
|
|
39
|
+
<string>ios</string>
|
|
40
|
+
<key>SupportedPlatformVariant</key>
|
|
41
|
+
<string>simulator</string>
|
|
42
42
|
</dict>
|
|
43
43
|
<dict>
|
|
44
44
|
<key>BinaryPath</key>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -2,10 +2,11 @@ import Foundation
|
|
|
2
2
|
|
|
3
3
|
internal var maxDeviceAgeSeconds = 10.0
|
|
4
4
|
|
|
5
|
-
private var blueDevices: [BlueDevice] = []
|
|
6
5
|
private var bluePurgeDevicesTimer: Timer? = nil
|
|
7
6
|
private var blueDeviceScannersCount = 0
|
|
8
7
|
|
|
8
|
+
private let blueDevicesList = BlueDevicesList()
|
|
9
|
+
|
|
9
10
|
internal func blueSetMaxDeviceAgeSeconds(_ newMaxDeviceAgeSeconds: Double) {
|
|
10
11
|
maxDeviceAgeSeconds = max(newMaxDeviceAgeSeconds, 1)
|
|
11
12
|
}
|
|
@@ -35,18 +36,11 @@ internal func waitForDeviceAvailability(_ deviceID: String, timeout: Int = 10, m
|
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
internal func blueGetDevice(_ deviceID: String) -> BlueDevice? {
|
|
38
|
-
|
|
39
|
-
if (device.info.deviceID == deviceID) {
|
|
40
|
-
return device
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return nil
|
|
39
|
+
return blueDevicesList.get(deviceID)
|
|
45
40
|
}
|
|
46
41
|
|
|
47
42
|
internal func blueAddDevice(_ device: BlueDevice) {
|
|
48
|
-
if
|
|
49
|
-
blueDevices.append(device)
|
|
43
|
+
if blueDevicesList.add(device) {
|
|
50
44
|
blueNotifyAddeddDevice(device)
|
|
51
45
|
}
|
|
52
46
|
}
|
|
@@ -54,32 +48,24 @@ internal func blueAddDevice(_ device: BlueDevice) {
|
|
|
54
48
|
internal func bluePurgeOldDevices() {
|
|
55
49
|
let now = Date()
|
|
56
50
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
for device in blueDevices {
|
|
51
|
+
blueDevicesList.remove() { device in
|
|
60
52
|
let shouldPurge = now.timeIntervalSince(device.lastSeenAt) >= maxDeviceAgeSeconds && !isActiveDevice(device)
|
|
61
53
|
if (shouldPurge) {
|
|
62
54
|
blueNotifyRemovedDevice(device)
|
|
63
|
-
} else {
|
|
64
|
-
newDevices.append(device)
|
|
65
55
|
}
|
|
56
|
+
|
|
57
|
+
return shouldPurge
|
|
66
58
|
}
|
|
67
|
-
|
|
68
|
-
blueDevices = newDevices
|
|
69
59
|
}
|
|
70
60
|
|
|
71
61
|
internal func bluePurgeDevicesByType(_ deviceType: BlueDeviceType) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
if (device.info.deviceType == deviceType) {
|
|
62
|
+
blueDevicesList.remove() { device in
|
|
63
|
+
let shouldPurge = device.info.deviceType == deviceType
|
|
64
|
+
if (shouldPurge) {
|
|
76
65
|
blueNotifyRemovedDevice(device)
|
|
77
|
-
} else {
|
|
78
|
-
newDevices.append(device)
|
|
79
66
|
}
|
|
67
|
+
return shouldPurge
|
|
80
68
|
}
|
|
81
|
-
|
|
82
|
-
blueDevices = newDevices
|
|
83
69
|
}
|
|
84
70
|
|
|
85
71
|
internal func blueAddDeviceScanner() {
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @class BlueDevicesList
|
|
5
|
+
* A thread-safe list to manage BlueDevices.
|
|
6
|
+
* This class provides thread-safe operations for adding, retrieving, and removing BlueDevices.
|
|
7
|
+
* It internally uses a DispatchQueue with concurrent attributes to synchronize access to the list.
|
|
8
|
+
*/
|
|
9
|
+
internal class BlueDevicesList {
|
|
10
|
+
private let queue = DispatchQueue(label: "blueid.BlueDevicesList", attributes: .concurrent)
|
|
11
|
+
|
|
12
|
+
private var devices: [BlueDevice] = []
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Adds a BlueDevice to the list.
|
|
16
|
+
*
|
|
17
|
+
* - Parameters:
|
|
18
|
+
* - device: The BlueDevice to add.
|
|
19
|
+
*
|
|
20
|
+
* - Returns: `true` if the device was successfully added, `false` if a device with the same device ID already exists in the list.
|
|
21
|
+
*/
|
|
22
|
+
func add(_ device: BlueDevice) -> Bool {
|
|
23
|
+
var added = false
|
|
24
|
+
|
|
25
|
+
queue.sync(flags: .barrier) {
|
|
26
|
+
if (self.getById(device.info.deviceID) == nil) {
|
|
27
|
+
self.devices.append(device)
|
|
28
|
+
added = true
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return added
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Retrieves a BlueDevice from the list based on its device ID.
|
|
37
|
+
*
|
|
38
|
+
* - Parameters:
|
|
39
|
+
* - deviceID: The ID of the BlueDevice to retrieve.
|
|
40
|
+
*
|
|
41
|
+
* - Returns: The BlueDevice with the specified device ID, or `nil` if no device with that ID exists in the list.
|
|
42
|
+
*/
|
|
43
|
+
func get(_ deviceID: String) -> BlueDevice? {
|
|
44
|
+
var device: BlueDevice?
|
|
45
|
+
queue.sync() {
|
|
46
|
+
device = self.getById(deviceID)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return device
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Removes BlueDevices from the list based on a filter closure.
|
|
54
|
+
*
|
|
55
|
+
* - Parameters:
|
|
56
|
+
* - where: A closure that returns `true` for devices to be removed, `false` otherwise.
|
|
57
|
+
*/
|
|
58
|
+
func remove(where shouldBeRemoved: @escaping (BlueDevice) -> Bool) {
|
|
59
|
+
queue.async(flags: .barrier) {
|
|
60
|
+
var newDevices: [BlueDevice] = []
|
|
61
|
+
|
|
62
|
+
for device in self.devices {
|
|
63
|
+
if (!shouldBeRemoved(device)) {
|
|
64
|
+
newDevices.append(device)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
self.devices.removeAll()
|
|
69
|
+
self.devices.append(contentsOf: newDevices)
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Returns the number of devices currently stored in the `BlueDevicesList`.
|
|
75
|
+
*
|
|
76
|
+
* - Returns: An integer representing the count of devices in the list.
|
|
77
|
+
*/
|
|
78
|
+
func count() -> Int {
|
|
79
|
+
var count = 0
|
|
80
|
+
queue.sync() {
|
|
81
|
+
count = self.devices.count
|
|
82
|
+
}
|
|
83
|
+
return count
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
private func getById(_ deviceID: String) -> BlueDevice? {
|
|
87
|
+
return self.devices.first { $0.info.deviceID == deviceID }
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -61,10 +61,8 @@ internal final class BlueSPTransponder {
|
|
|
61
61
|
|
|
62
62
|
do {
|
|
63
63
|
_ = try blueClibErrorCheck(blueSPTransponder_Release())
|
|
64
|
-
} catch let error as BlueError {
|
|
65
|
-
fatalError(error.errorDescription!)
|
|
66
64
|
} catch {
|
|
67
|
-
|
|
65
|
+
blueLogError(error.localizedDescription)
|
|
68
66
|
}
|
|
69
67
|
}
|
|
70
68
|
|