react-native-ble-nitro 1.0.0 → 1.1.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 (40) hide show
  1. package/README.md +19 -15
  2. package/ios/BleNitroBleManager.swift +77 -43
  3. package/lib/commonjs/index.d.ts +15 -13
  4. package/lib/commonjs/index.d.ts.map +1 -1
  5. package/lib/commonjs/index.js +76 -139
  6. package/lib/commonjs/index.js.map +1 -1
  7. package/lib/commonjs/specs/NativeBleNitro.nitro.d.ts +13 -10
  8. package/lib/commonjs/specs/NativeBleNitro.nitro.d.ts.map +1 -1
  9. package/lib/index.d.ts +15 -13
  10. package/lib/index.js +75 -138
  11. package/lib/specs/NativeBleNitro.nitro.d.ts +13 -10
  12. package/nitrogen/generated/android/BleNitroOnLoad.cpp +2 -8
  13. package/nitrogen/generated/android/c++/JHybridNativeBleNitroSpec.cpp +90 -49
  14. package/nitrogen/generated/android/c++/JHybridNativeBleNitroSpec.hpp +9 -10
  15. package/nitrogen/generated/android/c++/JOperationResult.hpp +58 -0
  16. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/HybridNativeBleNitroSpec.kt +11 -60
  17. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/OperationResult.kt +32 -0
  18. package/nitrogen/generated/ios/BleNitro-Swift-Cxx-Bridge.cpp +5 -29
  19. package/nitrogen/generated/ios/BleNitro-Swift-Cxx-Bridge.hpp +69 -78
  20. package/nitrogen/generated/ios/BleNitro-Swift-Cxx-Umbrella.hpp +3 -0
  21. package/nitrogen/generated/ios/c++/HybridNativeBleNitroSpecSwift.hpp +39 -24
  22. package/nitrogen/generated/ios/swift/HybridNativeBleNitroSpec.swift +9 -10
  23. package/nitrogen/generated/ios/swift/HybridNativeBleNitroSpec_cxx.swift +60 -112
  24. package/nitrogen/generated/ios/swift/OperationResult.swift +64 -0
  25. package/nitrogen/generated/shared/c++/HybridNativeBleNitroSpec.cpp +0 -1
  26. package/nitrogen/generated/shared/c++/HybridNativeBleNitroSpec.hpp +13 -11
  27. package/nitrogen/generated/shared/c++/OperationResult.hpp +72 -0
  28. package/package.json +1 -1
  29. package/src/__tests__/index.test.ts +19 -22
  30. package/src/index.ts +100 -156
  31. package/src/specs/NativeBleNitro.nitro.ts +14 -10
  32. package/nitrogen/generated/android/c++/JFunc_void_bool.hpp +0 -74
  33. package/nitrogen/generated/android/c++/JFunc_void_std__vector_BLEDevice_.hpp +0 -99
  34. package/nitrogen/generated/android/c++/JFunc_void_std__vector_std__string_.hpp +0 -93
  35. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/Func_void_bool.kt +0 -81
  36. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/Func_void_std__vector_BLEDevice_.kt +0 -81
  37. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/Func_void_std__vector_std__string_.kt +0 -81
  38. package/nitrogen/generated/ios/swift/Func_void_bool.swift +0 -47
  39. package/nitrogen/generated/ios/swift/Func_void_std__vector_BLEDevice_.swift +0 -47
  40. package/nitrogen/generated/ios/swift/Func_void_std__vector_std__string_.swift +0 -47
@@ -0,0 +1,58 @@
1
+ ///
2
+ /// JOperationResult.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #include <fbjni/fbjni.h>
11
+ #include "OperationResult.hpp"
12
+
13
+ #include <optional>
14
+ #include <string>
15
+
16
+ namespace margelo::nitro::co::zyke::ble {
17
+
18
+ using namespace facebook;
19
+
20
+ /**
21
+ * The C++ JNI bridge between the C++ struct "OperationResult" and the the Kotlin data class "OperationResult".
22
+ */
23
+ struct JOperationResult final: public jni::JavaClass<JOperationResult> {
24
+ public:
25
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/co/zyke/ble/OperationResult;";
26
+
27
+ public:
28
+ /**
29
+ * Convert this Java/Kotlin-based struct to the C++ struct OperationResult by copying all values to C++.
30
+ */
31
+ [[maybe_unused]]
32
+ [[nodiscard]]
33
+ OperationResult toCpp() const {
34
+ static const auto clazz = javaClassStatic();
35
+ static const auto fieldSuccess = clazz->getField<jboolean>("success");
36
+ jboolean success = this->getFieldValue(fieldSuccess);
37
+ static const auto fieldError = clazz->getField<jni::JString>("error");
38
+ jni::local_ref<jni::JString> error = this->getFieldValue(fieldError);
39
+ return OperationResult(
40
+ static_cast<bool>(success),
41
+ error != nullptr ? std::make_optional(error->toStdString()) : std::nullopt
42
+ );
43
+ }
44
+
45
+ public:
46
+ /**
47
+ * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
48
+ */
49
+ [[maybe_unused]]
50
+ static jni::local_ref<JOperationResult::javaobject> fromCpp(const OperationResult& value) {
51
+ return newInstance(
52
+ value.success,
53
+ value.error.has_value() ? jni::make_jstring(value.error.value()) : nullptr
54
+ );
55
+ }
56
+ };
57
+
58
+ } // namespace margelo::nitro::co::zyke::ble
@@ -49,32 +49,17 @@ abstract class HybridNativeBleNitroSpec: HybridObject() {
49
49
  return __result
50
50
  }
51
51
 
52
- abstract fun stopScan(callback: (success: Boolean, error: String) -> Unit): Unit
53
-
54
52
  @DoNotStrip
55
53
  @Keep
56
- private fun stopScan_cxx(callback: Func_void_bool_std__string): Unit {
57
- val __result = stopScan(callback)
58
- return __result
59
- }
60
-
61
- abstract fun isScanning(callback: (result: Boolean) -> Unit): Unit
54
+ abstract fun stopScan(): Boolean
62
55
 
63
56
  @DoNotStrip
64
57
  @Keep
65
- private fun isScanning_cxx(callback: Func_void_bool): Unit {
66
- val __result = isScanning(callback)
67
- return __result
68
- }
69
-
70
- abstract fun getConnectedDevices(callback: (devices: Array<BLEDevice>) -> Unit): Unit
58
+ abstract fun isScanning(): Boolean
71
59
 
72
60
  @DoNotStrip
73
61
  @Keep
74
- private fun getConnectedDevices_cxx(callback: Func_void_std__vector_BLEDevice_): Unit {
75
- val __result = getConnectedDevices(callback)
76
- return __result
77
- }
62
+ abstract fun getConnectedDevices(services: Array<String>): Array<BLEDevice>
78
63
 
79
64
  abstract fun connect(deviceId: String, callback: (success: Boolean, deviceId: String, error: String) -> Unit, disconnectCallback: ((deviceId: String, interrupted: Boolean, error: String) -> Unit)?): Unit
80
65
 
@@ -94,14 +79,9 @@ abstract class HybridNativeBleNitroSpec: HybridObject() {
94
79
  return __result
95
80
  }
96
81
 
97
- abstract fun isConnected(deviceId: String, callback: (result: Boolean) -> Unit): Unit
98
-
99
82
  @DoNotStrip
100
83
  @Keep
101
- private fun isConnected_cxx(deviceId: String, callback: Func_void_bool): Unit {
102
- val __result = isConnected(deviceId, callback)
103
- return __result
104
- }
84
+ abstract fun isConnected(deviceId: String): Boolean
105
85
 
106
86
  abstract fun discoverServices(deviceId: String, callback: (success: Boolean, error: String) -> Unit): Unit
107
87
 
@@ -112,23 +92,13 @@ abstract class HybridNativeBleNitroSpec: HybridObject() {
112
92
  return __result
113
93
  }
114
94
 
115
- abstract fun getServices(deviceId: String, callback: (result: Array<String>) -> Unit): Unit
116
-
117
95
  @DoNotStrip
118
96
  @Keep
119
- private fun getServices_cxx(deviceId: String, callback: Func_void_std__vector_std__string_): Unit {
120
- val __result = getServices(deviceId, callback)
121
- return __result
122
- }
123
-
124
- abstract fun getCharacteristics(deviceId: String, serviceId: String, callback: (result: Array<String>) -> Unit): Unit
97
+ abstract fun getServices(deviceId: String): Array<String>
125
98
 
126
99
  @DoNotStrip
127
100
  @Keep
128
- private fun getCharacteristics_cxx(deviceId: String, serviceId: String, callback: Func_void_std__vector_std__string_): Unit {
129
- val __result = getCharacteristics(deviceId, serviceId, callback)
130
- return __result
131
- }
101
+ abstract fun getCharacteristics(deviceId: String, serviceId: String): Array<String>
132
102
 
133
103
  abstract fun readCharacteristic(deviceId: String, serviceId: String, characteristicId: String, callback: (success: Boolean, data: DoubleArray, error: String) -> Unit): Unit
134
104
 
@@ -166,15 +136,6 @@ abstract class HybridNativeBleNitroSpec: HybridObject() {
166
136
  return __result
167
137
  }
168
138
 
169
- abstract fun isBluetoothEnabled(callback: (result: Boolean) -> Unit): Unit
170
-
171
- @DoNotStrip
172
- @Keep
173
- private fun isBluetoothEnabled_cxx(callback: Func_void_bool): Unit {
174
- val __result = isBluetoothEnabled(callback)
175
- return __result
176
- }
177
-
178
139
  abstract fun requestBluetoothEnable(callback: (success: Boolean, error: String) -> Unit): Unit
179
140
 
180
141
  @DoNotStrip
@@ -184,32 +145,22 @@ abstract class HybridNativeBleNitroSpec: HybridObject() {
184
145
  return __result
185
146
  }
186
147
 
187
- abstract fun state(callback: (state: BLEState) -> Unit): Unit
188
-
189
148
  @DoNotStrip
190
149
  @Keep
191
- private fun state_cxx(callback: Func_void_BLEState): Unit {
192
- val __result = state(callback)
193
- return __result
194
- }
150
+ abstract fun state(): BLEState
195
151
 
196
- abstract fun subscribeToStateChange(stateCallback: (state: BLEState) -> Unit, resultCallback: (success: Boolean, error: String) -> Unit): Unit
152
+ abstract fun subscribeToStateChange(stateCallback: (state: BLEState) -> Unit): OperationResult
197
153
 
198
154
  @DoNotStrip
199
155
  @Keep
200
- private fun subscribeToStateChange_cxx(stateCallback: Func_void_BLEState, resultCallback: Func_void_bool_std__string): Unit {
201
- val __result = subscribeToStateChange(stateCallback, resultCallback)
156
+ private fun subscribeToStateChange_cxx(stateCallback: Func_void_BLEState): OperationResult {
157
+ val __result = subscribeToStateChange(stateCallback)
202
158
  return __result
203
159
  }
204
160
 
205
- abstract fun unsubscribeFromStateChange(resultCallback: (success: Boolean, error: String) -> Unit): Unit
206
-
207
161
  @DoNotStrip
208
162
  @Keep
209
- private fun unsubscribeFromStateChange_cxx(resultCallback: Func_void_bool_std__string): Unit {
210
- val __result = unsubscribeFromStateChange(resultCallback)
211
- return __result
212
- }
163
+ abstract fun unsubscribeFromStateChange(): OperationResult
213
164
 
214
165
  @DoNotStrip
215
166
  @Keep
@@ -0,0 +1,32 @@
1
+ ///
2
+ /// OperationResult.kt
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ package com.margelo.nitro.co.zyke.ble
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.proguard.annotations.DoNotStrip
12
+ import com.margelo.nitro.core.*
13
+
14
+
15
+ /**
16
+ * Represents the JavaScript object/struct "OperationResult".
17
+ */
18
+ @DoNotStrip
19
+ @Keep
20
+ data class OperationResult
21
+ @DoNotStrip
22
+ @Keep
23
+ constructor(
24
+ @DoNotStrip
25
+ @Keep
26
+ val success: Boolean,
27
+ @DoNotStrip
28
+ @Keep
29
+ val error: String?
30
+ ) {
31
+ /* main constructor */
32
+ }
@@ -21,30 +21,6 @@ namespace margelo::nitro::co::zyke::ble::bridge::swift {
21
21
  };
22
22
  }
23
23
 
24
- // pragma MARK: std::function<void(bool /* success */, const std::string& /* error */)>
25
- Func_void_bool_std__string create_Func_void_bool_std__string(void* _Nonnull swiftClosureWrapper) {
26
- auto swiftClosure = BleNitro::Func_void_bool_std__string::fromUnsafe(swiftClosureWrapper);
27
- return [swiftClosure = std::move(swiftClosure)](bool success, const std::string& error) mutable -> void {
28
- swiftClosure.call(success, error);
29
- };
30
- }
31
-
32
- // pragma MARK: std::function<void(bool /* result */)>
33
- Func_void_bool create_Func_void_bool(void* _Nonnull swiftClosureWrapper) {
34
- auto swiftClosure = BleNitro::Func_void_bool::fromUnsafe(swiftClosureWrapper);
35
- return [swiftClosure = std::move(swiftClosure)](bool result) mutable -> void {
36
- swiftClosure.call(result);
37
- };
38
- }
39
-
40
- // pragma MARK: std::function<void(const std::vector<BLEDevice>& /* devices */)>
41
- Func_void_std__vector_BLEDevice_ create_Func_void_std__vector_BLEDevice_(void* _Nonnull swiftClosureWrapper) {
42
- auto swiftClosure = BleNitro::Func_void_std__vector_BLEDevice_::fromUnsafe(swiftClosureWrapper);
43
- return [swiftClosure = std::move(swiftClosure)](const std::vector<BLEDevice>& devices) mutable -> void {
44
- swiftClosure.call(devices);
45
- };
46
- }
47
-
48
24
  // pragma MARK: std::function<void(bool /* success */, const std::string& /* deviceId */, const std::string& /* error */)>
49
25
  Func_void_bool_std__string_std__string create_Func_void_bool_std__string_std__string(void* _Nonnull swiftClosureWrapper) {
50
26
  auto swiftClosure = BleNitro::Func_void_bool_std__string_std__string::fromUnsafe(swiftClosureWrapper);
@@ -61,11 +37,11 @@ namespace margelo::nitro::co::zyke::ble::bridge::swift {
61
37
  };
62
38
  }
63
39
 
64
- // pragma MARK: std::function<void(const std::vector<std::string>& /* result */)>
65
- Func_void_std__vector_std__string_ create_Func_void_std__vector_std__string_(void* _Nonnull swiftClosureWrapper) {
66
- auto swiftClosure = BleNitro::Func_void_std__vector_std__string_::fromUnsafe(swiftClosureWrapper);
67
- return [swiftClosure = std::move(swiftClosure)](const std::vector<std::string>& result) mutable -> void {
68
- swiftClosure.call(result);
40
+ // pragma MARK: std::function<void(bool /* success */, const std::string& /* error */)>
41
+ Func_void_bool_std__string create_Func_void_bool_std__string(void* _Nonnull swiftClosureWrapper) {
42
+ auto swiftClosure = BleNitro::Func_void_bool_std__string::fromUnsafe(swiftClosureWrapper);
43
+ return [swiftClosure = std::move(swiftClosure)](bool success, const std::string& error) mutable -> void {
44
+ swiftClosure.call(success, error);
69
45
  };
70
46
  }
71
47
 
@@ -18,6 +18,8 @@ namespace margelo::nitro::co::zyke::ble { class HybridNativeBleNitroSpec; }
18
18
  namespace margelo::nitro::co::zyke::ble { struct ManufacturerDataEntry; }
19
19
  // Forward declaration of `ManufacturerData` to properly resolve imports.
20
20
  namespace margelo::nitro::co::zyke::ble { struct ManufacturerData; }
21
+ // Forward declaration of `OperationResult` to properly resolve imports.
22
+ namespace margelo::nitro::co::zyke::ble { struct OperationResult; }
21
23
 
22
24
  // Forward declarations of Swift defined types
23
25
  // Forward declaration of `HybridNativeBleNitroSpec_cxx` to properly resolve imports.
@@ -29,6 +31,7 @@ namespace BleNitro { class HybridNativeBleNitroSpec_cxx; }
29
31
  #include "HybridNativeBleNitroSpec.hpp"
30
32
  #include "ManufacturerData.hpp"
31
33
  #include "ManufacturerDataEntry.hpp"
34
+ #include "OperationResult.hpp"
32
35
  #include <NitroModules/Promise.hpp>
33
36
  #include <NitroModules/PromiseHolder.hpp>
34
37
  #include <NitroModules/Result.hpp>
@@ -100,50 +103,6 @@ namespace margelo::nitro::co::zyke::ble::bridge::swift {
100
103
  return Func_void_BLEDevice_Wrapper(std::move(value));
101
104
  }
102
105
 
103
- // pragma MARK: std::function<void(bool /* success */, const std::string& /* error */)>
104
- /**
105
- * Specialized version of `std::function<void(bool, const std::string&)>`.
106
- */
107
- using Func_void_bool_std__string = std::function<void(bool /* success */, const std::string& /* error */)>;
108
- /**
109
- * Wrapper class for a `std::function<void(bool / * success * /, const std::string& / * error * /)>`, this can be used from Swift.
110
- */
111
- class Func_void_bool_std__string_Wrapper final {
112
- public:
113
- explicit Func_void_bool_std__string_Wrapper(std::function<void(bool /* success */, const std::string& /* error */)>&& func): _function(std::make_unique<std::function<void(bool /* success */, const std::string& /* error */)>>(std::move(func))) {}
114
- inline void call(bool success, std::string error) const {
115
- _function->operator()(success, error);
116
- }
117
- private:
118
- std::unique_ptr<std::function<void(bool /* success */, const std::string& /* error */)>> _function;
119
- } SWIFT_NONCOPYABLE;
120
- Func_void_bool_std__string create_Func_void_bool_std__string(void* _Nonnull swiftClosureWrapper);
121
- inline Func_void_bool_std__string_Wrapper wrap_Func_void_bool_std__string(Func_void_bool_std__string value) {
122
- return Func_void_bool_std__string_Wrapper(std::move(value));
123
- }
124
-
125
- // pragma MARK: std::function<void(bool /* result */)>
126
- /**
127
- * Specialized version of `std::function<void(bool)>`.
128
- */
129
- using Func_void_bool = std::function<void(bool /* result */)>;
130
- /**
131
- * Wrapper class for a `std::function<void(bool / * result * /)>`, this can be used from Swift.
132
- */
133
- class Func_void_bool_Wrapper final {
134
- public:
135
- explicit Func_void_bool_Wrapper(std::function<void(bool /* result */)>&& func): _function(std::make_unique<std::function<void(bool /* result */)>>(std::move(func))) {}
136
- inline void call(bool result) const {
137
- _function->operator()(result);
138
- }
139
- private:
140
- std::unique_ptr<std::function<void(bool /* result */)>> _function;
141
- } SWIFT_NONCOPYABLE;
142
- Func_void_bool create_Func_void_bool(void* _Nonnull swiftClosureWrapper);
143
- inline Func_void_bool_Wrapper wrap_Func_void_bool(Func_void_bool value) {
144
- return Func_void_bool_Wrapper(std::move(value));
145
- }
146
-
147
106
  // pragma MARK: std::vector<BLEDevice>
148
107
  /**
149
108
  * Specialized version of `std::vector<BLEDevice>`.
@@ -155,28 +114,6 @@ namespace margelo::nitro::co::zyke::ble::bridge::swift {
155
114
  return vector;
156
115
  }
157
116
 
158
- // pragma MARK: std::function<void(const std::vector<BLEDevice>& /* devices */)>
159
- /**
160
- * Specialized version of `std::function<void(const std::vector<BLEDevice>&)>`.
161
- */
162
- using Func_void_std__vector_BLEDevice_ = std::function<void(const std::vector<BLEDevice>& /* devices */)>;
163
- /**
164
- * Wrapper class for a `std::function<void(const std::vector<BLEDevice>& / * devices * /)>`, this can be used from Swift.
165
- */
166
- class Func_void_std__vector_BLEDevice__Wrapper final {
167
- public:
168
- explicit Func_void_std__vector_BLEDevice__Wrapper(std::function<void(const std::vector<BLEDevice>& /* devices */)>&& func): _function(std::make_unique<std::function<void(const std::vector<BLEDevice>& /* devices */)>>(std::move(func))) {}
169
- inline void call(std::vector<BLEDevice> devices) const {
170
- _function->operator()(devices);
171
- }
172
- private:
173
- std::unique_ptr<std::function<void(const std::vector<BLEDevice>& /* devices */)>> _function;
174
- } SWIFT_NONCOPYABLE;
175
- Func_void_std__vector_BLEDevice_ create_Func_void_std__vector_BLEDevice_(void* _Nonnull swiftClosureWrapper);
176
- inline Func_void_std__vector_BLEDevice__Wrapper wrap_Func_void_std__vector_BLEDevice_(Func_void_std__vector_BLEDevice_ value) {
177
- return Func_void_std__vector_BLEDevice__Wrapper(std::move(value));
178
- }
179
-
180
117
  // pragma MARK: std::function<void(bool /* success */, const std::string& /* deviceId */, const std::string& /* error */)>
181
118
  /**
182
119
  * Specialized version of `std::function<void(bool, const std::string&, const std::string&)>`.
@@ -230,26 +167,26 @@ namespace margelo::nitro::co::zyke::ble::bridge::swift {
230
167
  return std::optional<std::function<void(const std::string& /* deviceId */, bool /* interrupted */, const std::string& /* error */)>>(value);
231
168
  }
232
169
 
233
- // pragma MARK: std::function<void(const std::vector<std::string>& /* result */)>
170
+ // pragma MARK: std::function<void(bool /* success */, const std::string& /* error */)>
234
171
  /**
235
- * Specialized version of `std::function<void(const std::vector<std::string>&)>`.
172
+ * Specialized version of `std::function<void(bool, const std::string&)>`.
236
173
  */
237
- using Func_void_std__vector_std__string_ = std::function<void(const std::vector<std::string>& /* result */)>;
174
+ using Func_void_bool_std__string = std::function<void(bool /* success */, const std::string& /* error */)>;
238
175
  /**
239
- * Wrapper class for a `std::function<void(const std::vector<std::string>& / * result * /)>`, this can be used from Swift.
176
+ * Wrapper class for a `std::function<void(bool / * success * /, const std::string& / * error * /)>`, this can be used from Swift.
240
177
  */
241
- class Func_void_std__vector_std__string__Wrapper final {
178
+ class Func_void_bool_std__string_Wrapper final {
242
179
  public:
243
- explicit Func_void_std__vector_std__string__Wrapper(std::function<void(const std::vector<std::string>& /* result */)>&& func): _function(std::make_unique<std::function<void(const std::vector<std::string>& /* result */)>>(std::move(func))) {}
244
- inline void call(std::vector<std::string> result) const {
245
- _function->operator()(result);
180
+ explicit Func_void_bool_std__string_Wrapper(std::function<void(bool /* success */, const std::string& /* error */)>&& func): _function(std::make_unique<std::function<void(bool /* success */, const std::string& /* error */)>>(std::move(func))) {}
181
+ inline void call(bool success, std::string error) const {
182
+ _function->operator()(success, error);
246
183
  }
247
184
  private:
248
- std::unique_ptr<std::function<void(const std::vector<std::string>& /* result */)>> _function;
185
+ std::unique_ptr<std::function<void(bool /* success */, const std::string& /* error */)>> _function;
249
186
  } SWIFT_NONCOPYABLE;
250
- Func_void_std__vector_std__string_ create_Func_void_std__vector_std__string_(void* _Nonnull swiftClosureWrapper);
251
- inline Func_void_std__vector_std__string__Wrapper wrap_Func_void_std__vector_std__string_(Func_void_std__vector_std__string_ value) {
252
- return Func_void_std__vector_std__string__Wrapper(std::move(value));
187
+ Func_void_bool_std__string create_Func_void_bool_std__string(void* _Nonnull swiftClosureWrapper);
188
+ inline Func_void_bool_std__string_Wrapper wrap_Func_void_bool_std__string(Func_void_bool_std__string value) {
189
+ return Func_void_bool_std__string_Wrapper(std::move(value));
253
190
  }
254
191
 
255
192
  // pragma MARK: std::function<void(bool /* success */, const std::vector<double>& /* data */, const std::string& /* error */)>
@@ -296,6 +233,15 @@ namespace margelo::nitro::co::zyke::ble::bridge::swift {
296
233
  return Func_void_std__string_std__vector_double__Wrapper(std::move(value));
297
234
  }
298
235
 
236
+ // pragma MARK: std::optional<std::string>
237
+ /**
238
+ * Specialized version of `std::optional<std::string>`.
239
+ */
240
+ using std__optional_std__string_ = std::optional<std::string>;
241
+ inline std::optional<std::string> create_std__optional_std__string_(const std::string& value) {
242
+ return std::optional<std::string>(value);
243
+ }
244
+
299
245
  // pragma MARK: std::function<void(BLEState /* state */)>
300
246
  /**
301
247
  * Specialized version of `std::function<void(BLEState)>`.
@@ -395,6 +341,51 @@ namespace margelo::nitro::co::zyke::ble::bridge::swift {
395
341
  return Result<void>::withError(error);
396
342
  }
397
343
 
344
+ // pragma MARK: Result<bool>
345
+ using Result_bool_ = Result<bool>;
346
+ inline Result_bool_ create_Result_bool_(bool value) {
347
+ return Result<bool>::withValue(std::move(value));
348
+ }
349
+ inline Result_bool_ create_Result_bool_(const std::exception_ptr& error) {
350
+ return Result<bool>::withError(error);
351
+ }
352
+
353
+ // pragma MARK: Result<std::vector<BLEDevice>>
354
+ using Result_std__vector_BLEDevice__ = Result<std::vector<BLEDevice>>;
355
+ inline Result_std__vector_BLEDevice__ create_Result_std__vector_BLEDevice__(const std::vector<BLEDevice>& value) {
356
+ return Result<std::vector<BLEDevice>>::withValue(value);
357
+ }
358
+ inline Result_std__vector_BLEDevice__ create_Result_std__vector_BLEDevice__(const std::exception_ptr& error) {
359
+ return Result<std::vector<BLEDevice>>::withError(error);
360
+ }
361
+
362
+ // pragma MARK: Result<std::vector<std::string>>
363
+ using Result_std__vector_std__string__ = Result<std::vector<std::string>>;
364
+ inline Result_std__vector_std__string__ create_Result_std__vector_std__string__(const std::vector<std::string>& value) {
365
+ return Result<std::vector<std::string>>::withValue(value);
366
+ }
367
+ inline Result_std__vector_std__string__ create_Result_std__vector_std__string__(const std::exception_ptr& error) {
368
+ return Result<std::vector<std::string>>::withError(error);
369
+ }
370
+
371
+ // pragma MARK: Result<BLEState>
372
+ using Result_BLEState_ = Result<BLEState>;
373
+ inline Result_BLEState_ create_Result_BLEState_(BLEState value) {
374
+ return Result<BLEState>::withValue(std::move(value));
375
+ }
376
+ inline Result_BLEState_ create_Result_BLEState_(const std::exception_ptr& error) {
377
+ return Result<BLEState>::withError(error);
378
+ }
379
+
380
+ // pragma MARK: Result<OperationResult>
381
+ using Result_OperationResult_ = Result<OperationResult>;
382
+ inline Result_OperationResult_ create_Result_OperationResult_(const OperationResult& value) {
383
+ return Result<OperationResult>::withValue(value);
384
+ }
385
+ inline Result_OperationResult_ create_Result_OperationResult_(const std::exception_ptr& error) {
386
+ return Result<OperationResult>::withError(error);
387
+ }
388
+
398
389
  // pragma MARK: Result<std::shared_ptr<Promise<void>>>
399
390
  using Result_std__shared_ptr_Promise_void___ = Result<std::shared_ptr<Promise<void>>>;
400
391
  inline Result_std__shared_ptr_Promise_void___ create_Result_std__shared_ptr_Promise_void___(const std::shared_ptr<Promise<void>>& value) {
@@ -18,6 +18,8 @@ namespace margelo::nitro::co::zyke::ble { class HybridNativeBleNitroSpec; }
18
18
  namespace margelo::nitro::co::zyke::ble { struct ManufacturerDataEntry; }
19
19
  // Forward declaration of `ManufacturerData` to properly resolve imports.
20
20
  namespace margelo::nitro::co::zyke::ble { struct ManufacturerData; }
21
+ // Forward declaration of `OperationResult` to properly resolve imports.
22
+ namespace margelo::nitro::co::zyke::ble { struct OperationResult; }
21
23
  // Forward declaration of `ScanFilter` to properly resolve imports.
22
24
  namespace margelo::nitro::co::zyke::ble { struct ScanFilter; }
23
25
 
@@ -27,6 +29,7 @@ namespace margelo::nitro::co::zyke::ble { struct ScanFilter; }
27
29
  #include "HybridNativeBleNitroSpec.hpp"
28
30
  #include "ManufacturerData.hpp"
29
31
  #include "ManufacturerDataEntry.hpp"
32
+ #include "OperationResult.hpp"
30
33
  #include "ScanFilter.hpp"
31
34
  #include <NitroModules/Promise.hpp>
32
35
  #include <NitroModules/Result.hpp>
@@ -22,6 +22,8 @@ namespace margelo::nitro::co::zyke::ble { struct ManufacturerData; }
22
22
  namespace margelo::nitro::co::zyke::ble { struct ManufacturerDataEntry; }
23
23
  // Forward declaration of `BLEState` to properly resolve imports.
24
24
  namespace margelo::nitro::co::zyke::ble { enum class BLEState; }
25
+ // Forward declaration of `OperationResult` to properly resolve imports.
26
+ namespace margelo::nitro::co::zyke::ble { struct OperationResult; }
25
27
 
26
28
  #include "ScanFilter.hpp"
27
29
  #include <string>
@@ -32,6 +34,7 @@ namespace margelo::nitro::co::zyke::ble { enum class BLEState; }
32
34
  #include "ManufacturerDataEntry.hpp"
33
35
  #include <optional>
34
36
  #include "BLEState.hpp"
37
+ #include "OperationResult.hpp"
35
38
  #include <NitroModules/Promise.hpp>
36
39
 
37
40
  #include "BleNitro-Swift-Cxx-Umbrella.hpp"
@@ -81,23 +84,29 @@ namespace margelo::nitro::co::zyke::ble {
81
84
  std::rethrow_exception(__result.error());
82
85
  }
83
86
  }
84
- inline void stopScan(const std::function<void(bool /* success */, const std::string& /* error */)>& callback) override {
85
- auto __result = _swiftPart.stopScan(callback);
87
+ inline bool stopScan() override {
88
+ auto __result = _swiftPart.stopScan();
86
89
  if (__result.hasError()) [[unlikely]] {
87
90
  std::rethrow_exception(__result.error());
88
91
  }
92
+ auto __value = std::move(__result.value());
93
+ return __value;
89
94
  }
90
- inline void isScanning(const std::function<void(bool /* result */)>& callback) override {
91
- auto __result = _swiftPart.isScanning(callback);
95
+ inline bool isScanning() override {
96
+ auto __result = _swiftPart.isScanning();
92
97
  if (__result.hasError()) [[unlikely]] {
93
98
  std::rethrow_exception(__result.error());
94
99
  }
100
+ auto __value = std::move(__result.value());
101
+ return __value;
95
102
  }
96
- inline void getConnectedDevices(const std::function<void(const std::vector<BLEDevice>& /* devices */)>& callback) override {
97
- auto __result = _swiftPart.getConnectedDevices(callback);
103
+ inline std::vector<BLEDevice> getConnectedDevices(const std::vector<std::string>& services) override {
104
+ auto __result = _swiftPart.getConnectedDevices(services);
98
105
  if (__result.hasError()) [[unlikely]] {
99
106
  std::rethrow_exception(__result.error());
100
107
  }
108
+ auto __value = std::move(__result.value());
109
+ return __value;
101
110
  }
102
111
  inline void connect(const std::string& deviceId, const std::function<void(bool /* success */, const std::string& /* deviceId */, const std::string& /* error */)>& callback, const std::optional<std::function<void(const std::string& /* deviceId */, bool /* interrupted */, const std::string& /* error */)>>& disconnectCallback) override {
103
112
  auto __result = _swiftPart.connect(deviceId, callback, disconnectCallback);
@@ -111,11 +120,13 @@ namespace margelo::nitro::co::zyke::ble {
111
120
  std::rethrow_exception(__result.error());
112
121
  }
113
122
  }
114
- inline void isConnected(const std::string& deviceId, const std::function<void(bool /* result */)>& callback) override {
115
- auto __result = _swiftPart.isConnected(deviceId, callback);
123
+ inline bool isConnected(const std::string& deviceId) override {
124
+ auto __result = _swiftPart.isConnected(deviceId);
116
125
  if (__result.hasError()) [[unlikely]] {
117
126
  std::rethrow_exception(__result.error());
118
127
  }
128
+ auto __value = std::move(__result.value());
129
+ return __value;
119
130
  }
120
131
  inline void discoverServices(const std::string& deviceId, const std::function<void(bool /* success */, const std::string& /* error */)>& callback) override {
121
132
  auto __result = _swiftPart.discoverServices(deviceId, callback);
@@ -123,17 +134,21 @@ namespace margelo::nitro::co::zyke::ble {
123
134
  std::rethrow_exception(__result.error());
124
135
  }
125
136
  }
126
- inline void getServices(const std::string& deviceId, const std::function<void(const std::vector<std::string>& /* result */)>& callback) override {
127
- auto __result = _swiftPart.getServices(deviceId, callback);
137
+ inline std::vector<std::string> getServices(const std::string& deviceId) override {
138
+ auto __result = _swiftPart.getServices(deviceId);
128
139
  if (__result.hasError()) [[unlikely]] {
129
140
  std::rethrow_exception(__result.error());
130
141
  }
142
+ auto __value = std::move(__result.value());
143
+ return __value;
131
144
  }
132
- inline void getCharacteristics(const std::string& deviceId, const std::string& serviceId, const std::function<void(const std::vector<std::string>& /* result */)>& callback) override {
133
- auto __result = _swiftPart.getCharacteristics(deviceId, serviceId, callback);
145
+ inline std::vector<std::string> getCharacteristics(const std::string& deviceId, const std::string& serviceId) override {
146
+ auto __result = _swiftPart.getCharacteristics(deviceId, serviceId);
134
147
  if (__result.hasError()) [[unlikely]] {
135
148
  std::rethrow_exception(__result.error());
136
149
  }
150
+ auto __value = std::move(__result.value());
151
+ return __value;
137
152
  }
138
153
  inline void readCharacteristic(const std::string& deviceId, const std::string& serviceId, const std::string& characteristicId, const std::function<void(bool /* success */, const std::vector<double>& /* data */, const std::string& /* error */)>& callback) override {
139
154
  auto __result = _swiftPart.readCharacteristic(deviceId, serviceId, characteristicId, callback);
@@ -159,35 +174,35 @@ namespace margelo::nitro::co::zyke::ble {
159
174
  std::rethrow_exception(__result.error());
160
175
  }
161
176
  }
162
- inline void isBluetoothEnabled(const std::function<void(bool /* result */)>& callback) override {
163
- auto __result = _swiftPart.isBluetoothEnabled(callback);
164
- if (__result.hasError()) [[unlikely]] {
165
- std::rethrow_exception(__result.error());
166
- }
167
- }
168
177
  inline void requestBluetoothEnable(const std::function<void(bool /* success */, const std::string& /* error */)>& callback) override {
169
178
  auto __result = _swiftPart.requestBluetoothEnable(callback);
170
179
  if (__result.hasError()) [[unlikely]] {
171
180
  std::rethrow_exception(__result.error());
172
181
  }
173
182
  }
174
- inline void state(const std::function<void(BLEState /* state */)>& callback) override {
175
- auto __result = _swiftPart.state(callback);
183
+ inline BLEState state() override {
184
+ auto __result = _swiftPart.state();
176
185
  if (__result.hasError()) [[unlikely]] {
177
186
  std::rethrow_exception(__result.error());
178
187
  }
188
+ auto __value = std::move(__result.value());
189
+ return __value;
179
190
  }
180
- inline void subscribeToStateChange(const std::function<void(BLEState /* state */)>& stateCallback, const std::function<void(bool /* success */, const std::string& /* error */)>& resultCallback) override {
181
- auto __result = _swiftPart.subscribeToStateChange(stateCallback, resultCallback);
191
+ inline OperationResult subscribeToStateChange(const std::function<void(BLEState /* state */)>& stateCallback) override {
192
+ auto __result = _swiftPart.subscribeToStateChange(stateCallback);
182
193
  if (__result.hasError()) [[unlikely]] {
183
194
  std::rethrow_exception(__result.error());
184
195
  }
196
+ auto __value = std::move(__result.value());
197
+ return __value;
185
198
  }
186
- inline void unsubscribeFromStateChange(const std::function<void(bool /* success */, const std::string& /* error */)>& resultCallback) override {
187
- auto __result = _swiftPart.unsubscribeFromStateChange(resultCallback);
199
+ inline OperationResult unsubscribeFromStateChange() override {
200
+ auto __result = _swiftPart.unsubscribeFromStateChange();
188
201
  if (__result.hasError()) [[unlikely]] {
189
202
  std::rethrow_exception(__result.error());
190
203
  }
204
+ auto __value = std::move(__result.value());
205
+ return __value;
191
206
  }
192
207
  inline std::shared_ptr<Promise<void>> openSettings() override {
193
208
  auto __result = _swiftPart.openSettings();