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

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 (54) hide show
  1. package/CapacitorCommunityBluetoothLe.podspec +17 -17
  2. package/LICENSE +21 -21
  3. package/Package.swift +27 -27
  4. package/README.md +5 -3
  5. package/android/build.gradle +73 -71
  6. package/android/src/main/AndroidManifest.xml +22 -22
  7. package/android/src/main/java/com/capacitorjs/community/plugins/bluetoothle/BluetoothLe.kt +1094 -1094
  8. package/android/src/main/java/com/capacitorjs/community/plugins/bluetoothle/Conversion.kt +51 -51
  9. package/android/src/main/java/com/capacitorjs/community/plugins/bluetoothle/Device.kt +771 -771
  10. package/android/src/main/java/com/capacitorjs/community/plugins/bluetoothle/DeviceList.kt +28 -28
  11. package/android/src/main/java/com/capacitorjs/community/plugins/bluetoothle/DeviceScanner.kt +189 -189
  12. package/dist/docs.json +43 -43
  13. package/dist/esm/bleClient.d.ts +278 -278
  14. package/dist/esm/bleClient.js +361 -361
  15. package/dist/esm/bleClient.js.map +1 -1
  16. package/dist/esm/config.d.ts +53 -53
  17. package/dist/esm/config.js +2 -2
  18. package/dist/esm/conversion.d.ts +56 -56
  19. package/dist/esm/conversion.js +134 -134
  20. package/dist/esm/conversion.js.map +1 -1
  21. package/dist/esm/definitions.d.ts +352 -352
  22. package/dist/esm/definitions.js +42 -42
  23. package/dist/esm/definitions.js.map +1 -1
  24. package/dist/esm/index.d.ts +5 -5
  25. package/dist/esm/index.js +5 -5
  26. package/dist/esm/plugin.d.ts +2 -2
  27. package/dist/esm/plugin.js +4 -4
  28. package/dist/esm/queue.d.ts +3 -3
  29. package/dist/esm/queue.js +17 -17
  30. package/dist/esm/queue.js.map +1 -1
  31. package/dist/esm/timeout.d.ts +1 -1
  32. package/dist/esm/timeout.js +9 -9
  33. package/dist/esm/validators.d.ts +1 -1
  34. package/dist/esm/validators.js +11 -11
  35. package/dist/esm/validators.js.map +1 -1
  36. package/dist/esm/web.d.ts +57 -57
  37. package/dist/esm/web.js +403 -403
  38. package/dist/esm/web.js.map +1 -1
  39. package/dist/plugin.cjs.js +964 -964
  40. package/dist/plugin.cjs.js.map +1 -1
  41. package/dist/plugin.js +964 -964
  42. package/dist/plugin.js.map +1 -1
  43. package/ios/Sources/BluetoothLe/Conversion.swift +83 -83
  44. package/ios/Sources/BluetoothLe/Device.swift +423 -423
  45. package/ios/Sources/BluetoothLe/DeviceListView.swift +121 -121
  46. package/ios/Sources/BluetoothLe/DeviceManager.swift +415 -503
  47. package/ios/Sources/BluetoothLe/Logging.swift +8 -8
  48. package/ios/Sources/BluetoothLe/Plugin.swift +763 -775
  49. package/ios/Sources/BluetoothLe/ScanFilters.swift +114 -0
  50. package/ios/Sources/BluetoothLe/ThreadSafeDictionary.swift +15 -15
  51. package/ios/Tests/BluetoothLeTests/ConversionTests.swift +55 -55
  52. package/ios/Tests/BluetoothLeTests/PluginTests.swift +27 -27
  53. package/ios/Tests/BluetoothLeTests/ScanFiltersTests.swift +153 -0
  54. package/package.json +114 -115
@@ -1,121 +1,121 @@
1
- import UIKit
2
-
3
- class DeviceListView: UIViewController, UITableViewDelegate, UITableViewDataSource {
4
-
5
- private let tableView = UITableView()
6
- private let cancelButton = UIButton(type: .system)
7
- private let titleLabel = UILabel()
8
- private let progressIndication = UIActivityIndicatorView()
9
- private var onCancel: (() -> Void)?
10
- private var devices: [(name: String, action: () -> Void)] = []
11
-
12
- override func viewDidLoad() {
13
- super.viewDidLoad()
14
- isModalInPresentation = true // don't allow drag to dismiss
15
- setupUI()
16
- addBlurBackground()
17
- }
18
-
19
- func setTitle(_ title: String?) {
20
- titleLabel.text = title
21
- }
22
-
23
- func setCancelButton(_ title: String?, action: @escaping () -> Void) {
24
- cancelButton.setTitle(title, for: .normal)
25
- self.onCancel = action
26
- }
27
-
28
- func addItem(_ name: String, action: @escaping () -> Void) {
29
- devices.append((name, action))
30
- tableView.reloadData()
31
- }
32
-
33
- private func addBlurBackground() {
34
- let blurEffect = UIBlurEffect(style: .systemChromeMaterial)
35
- let blurView = UIVisualEffectView(effect: blurEffect)
36
- blurView.frame = view.bounds
37
- blurView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
38
- view.insertSubview(blurView, at: 0)
39
- }
40
-
41
- private func setupUI() {
42
- titleLabel.textAlignment = .center
43
- titleLabel.font = UIFont.boldSystemFont(ofSize: 22)
44
-
45
- let titleStack = UIStackView(arrangedSubviews: [titleLabel, progressIndication])
46
- titleStack.axis = .horizontal
47
- titleStack.alignment = .center
48
- titleStack.distribution = .fill
49
- titleStack.spacing = 8
50
- titleStack.translatesAutoresizingMaskIntoConstraints = false
51
- view.addSubview(titleStack)
52
-
53
- progressIndication.translatesAutoresizingMaskIntoConstraints = false
54
- progressIndication.startAnimating()
55
- progressIndication.hidesWhenStopped = true
56
- progressIndication.setContentHuggingPriority(.required, for: .horizontal)
57
- NSLayoutConstraint.activate([
58
- progressIndication.widthAnchor.constraint(equalToConstant: 22),
59
- progressIndication.heightAnchor.constraint(equalToConstant: 22)
60
- ])
61
-
62
- tableView.backgroundColor = .clear
63
- tableView.delegate = self
64
- tableView.dataSource = self
65
- tableView.translatesAutoresizingMaskIntoConstraints = false
66
- tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
67
- view.addSubview(tableView)
68
-
69
- // Cancel Button
70
- cancelButton.setTitleColor(.systemRed, for: .normal)
71
- cancelButton.addTarget(self, action: #selector(dismissPopover), for: .touchUpInside)
72
- cancelButton.translatesAutoresizingMaskIntoConstraints = false
73
- view.addSubview(cancelButton)
74
-
75
- NSLayoutConstraint.activate([
76
- titleStack.topAnchor.constraint(equalTo: view.topAnchor, constant: 10),
77
- titleStack.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 30),
78
- titleStack.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -30),
79
- titleStack.heightAnchor.constraint(equalToConstant: 30),
80
-
81
- // TableView
82
- tableView.topAnchor.constraint(equalTo: titleLabel.bottomAnchor, constant: 10),
83
- tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 10),
84
- tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -10),
85
- tableView.bottomAnchor.constraint(equalTo: cancelButton.topAnchor, constant: -10),
86
-
87
- // Cancel Button at the Bottom
88
- cancelButton.leadingAnchor.constraint(equalTo: view.leadingAnchor),
89
- cancelButton.trailingAnchor.constraint(equalTo: view.trailingAnchor),
90
- cancelButton.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: -10),
91
- cancelButton.heightAnchor.constraint(equalToConstant: 40)
92
- ])
93
- }
94
-
95
- @objc private func dismissPopover() {
96
- onCancel?()
97
- dismiss(animated: true)
98
- }
99
-
100
- func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
101
- return devices.count
102
- }
103
-
104
- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
105
- let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
106
- cell.textLabel?.text = devices[indexPath.row].name
107
- cell.textLabel?.textColor = .systemBlue
108
- cell.textLabel?.backgroundColor = .clear
109
- cell.backgroundColor = .clear
110
- cell.contentView.backgroundColor = .clear
111
- cell.textLabel?.textAlignment = .center
112
- cell.selectionStyle = .default
113
- return cell
114
- }
115
-
116
- func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
117
- tableView.deselectRow(at: indexPath, animated: true)
118
- devices[indexPath.row].action() // Execute closure action
119
- dismiss(animated: true) // Optionally close the popover
120
- }
121
- }
1
+ import UIKit
2
+
3
+ class DeviceListView: UIViewController, UITableViewDelegate, UITableViewDataSource {
4
+
5
+ private let tableView = UITableView()
6
+ private let cancelButton = UIButton(type: .system)
7
+ private let titleLabel = UILabel()
8
+ private let progressIndication = UIActivityIndicatorView()
9
+ private var onCancel: (() -> Void)?
10
+ private var devices: [(name: String, action: () -> Void)] = []
11
+
12
+ override func viewDidLoad() {
13
+ super.viewDidLoad()
14
+ isModalInPresentation = true // don't allow drag to dismiss
15
+ setupUI()
16
+ addBlurBackground()
17
+ }
18
+
19
+ func setTitle(_ title: String?) {
20
+ titleLabel.text = title
21
+ }
22
+
23
+ func setCancelButton(_ title: String?, action: @escaping () -> Void) {
24
+ cancelButton.setTitle(title, for: .normal)
25
+ self.onCancel = action
26
+ }
27
+
28
+ func addItem(_ name: String, action: @escaping () -> Void) {
29
+ devices.append((name, action))
30
+ tableView.reloadData()
31
+ }
32
+
33
+ private func addBlurBackground() {
34
+ let blurEffect = UIBlurEffect(style: .systemChromeMaterial)
35
+ let blurView = UIVisualEffectView(effect: blurEffect)
36
+ blurView.frame = view.bounds
37
+ blurView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
38
+ view.insertSubview(blurView, at: 0)
39
+ }
40
+
41
+ private func setupUI() {
42
+ titleLabel.textAlignment = .center
43
+ titleLabel.font = UIFont.boldSystemFont(ofSize: 22)
44
+
45
+ let titleStack = UIStackView(arrangedSubviews: [titleLabel, progressIndication])
46
+ titleStack.axis = .horizontal
47
+ titleStack.alignment = .center
48
+ titleStack.distribution = .fill
49
+ titleStack.spacing = 8
50
+ titleStack.translatesAutoresizingMaskIntoConstraints = false
51
+ view.addSubview(titleStack)
52
+
53
+ progressIndication.translatesAutoresizingMaskIntoConstraints = false
54
+ progressIndication.startAnimating()
55
+ progressIndication.hidesWhenStopped = true
56
+ progressIndication.setContentHuggingPriority(.required, for: .horizontal)
57
+ NSLayoutConstraint.activate([
58
+ progressIndication.widthAnchor.constraint(equalToConstant: 22),
59
+ progressIndication.heightAnchor.constraint(equalToConstant: 22)
60
+ ])
61
+
62
+ tableView.backgroundColor = .clear
63
+ tableView.delegate = self
64
+ tableView.dataSource = self
65
+ tableView.translatesAutoresizingMaskIntoConstraints = false
66
+ tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
67
+ view.addSubview(tableView)
68
+
69
+ // Cancel Button
70
+ cancelButton.setTitleColor(.systemRed, for: .normal)
71
+ cancelButton.addTarget(self, action: #selector(dismissPopover), for: .touchUpInside)
72
+ cancelButton.translatesAutoresizingMaskIntoConstraints = false
73
+ view.addSubview(cancelButton)
74
+
75
+ NSLayoutConstraint.activate([
76
+ titleStack.topAnchor.constraint(equalTo: view.topAnchor, constant: 10),
77
+ titleStack.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 30),
78
+ titleStack.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -30),
79
+ titleStack.heightAnchor.constraint(equalToConstant: 30),
80
+
81
+ // TableView
82
+ tableView.topAnchor.constraint(equalTo: titleLabel.bottomAnchor, constant: 10),
83
+ tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 10),
84
+ tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -10),
85
+ tableView.bottomAnchor.constraint(equalTo: cancelButton.topAnchor, constant: -10),
86
+
87
+ // Cancel Button at the Bottom
88
+ cancelButton.leadingAnchor.constraint(equalTo: view.leadingAnchor),
89
+ cancelButton.trailingAnchor.constraint(equalTo: view.trailingAnchor),
90
+ cancelButton.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: -10),
91
+ cancelButton.heightAnchor.constraint(equalToConstant: 40)
92
+ ])
93
+ }
94
+
95
+ @objc private func dismissPopover() {
96
+ onCancel?()
97
+ dismiss(animated: true)
98
+ }
99
+
100
+ func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
101
+ return devices.count
102
+ }
103
+
104
+ func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
105
+ let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
106
+ cell.textLabel?.text = devices[indexPath.row].name
107
+ cell.textLabel?.textColor = .systemBlue
108
+ cell.textLabel?.backgroundColor = .clear
109
+ cell.backgroundColor = .clear
110
+ cell.contentView.backgroundColor = .clear
111
+ cell.textLabel?.textAlignment = .center
112
+ cell.selectionStyle = .default
113
+ return cell
114
+ }
115
+
116
+ func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
117
+ tableView.deselectRow(at: indexPath, animated: true)
118
+ devices[indexPath.row].action() // Execute closure action
119
+ dismiss(animated: true) // Optionally close the popover
120
+ }
121
+ }