react-native-ble-nitro 1.0.0 → 1.2.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 (58) hide show
  1. package/README.md +25 -17
  2. package/ios/BleNitroBleManager.swift +126 -57
  3. package/ios/BlePeripheralDelegate.swift +36 -8
  4. package/lib/commonjs/index.d.ts +29 -20
  5. package/lib/commonjs/index.d.ts.map +1 -1
  6. package/lib/commonjs/index.js +113 -143
  7. package/lib/commonjs/index.js.map +1 -1
  8. package/lib/commonjs/specs/NativeBleNitro.nitro.d.ts +19 -14
  9. package/lib/commonjs/specs/NativeBleNitro.nitro.d.ts.map +1 -1
  10. package/lib/commonjs/specs/NativeBleNitro.nitro.js.map +1 -1
  11. package/lib/index.d.ts +29 -20
  12. package/lib/index.js +112 -142
  13. package/lib/specs/NativeBleNitro.nitro.d.ts +19 -14
  14. package/nitrogen/generated/android/BleNitroOnLoad.cpp +6 -12
  15. package/nitrogen/generated/android/c++/JBLEDevice.hpp +3 -0
  16. package/nitrogen/generated/android/c++/JFunc_void_BLEDevice.hpp +3 -0
  17. package/nitrogen/generated/android/c++/JFunc_void_bool_std__shared_ptr_ArrayBuffer__std__string.hpp +78 -0
  18. package/nitrogen/generated/android/c++/JFunc_void_std__string_std__shared_ptr_ArrayBuffer_.hpp +78 -0
  19. package/nitrogen/generated/android/c++/JHybridNativeBleNitroSpec.cpp +111 -65
  20. package/nitrogen/generated/android/c++/JHybridNativeBleNitroSpec.hpp +13 -13
  21. package/nitrogen/generated/android/c++/JManufacturerData.hpp +3 -0
  22. package/nitrogen/generated/android/c++/JManufacturerDataEntry.hpp +7 -15
  23. package/nitrogen/generated/android/c++/JOperationResult.hpp +58 -0
  24. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/{Func_void_bool_std__vector_double__std__string.kt → Func_void_bool_std__shared_ptr_ArrayBuffer__std__string.kt} +12 -12
  25. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/{Func_void_std__string_std__vector_double_.kt → Func_void_std__string_std__shared_ptr_ArrayBuffer_.kt} +12 -12
  26. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/HybridNativeBleNitroSpec.kt +20 -65
  27. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/ManufacturerDataEntry.kt +1 -1
  28. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/OperationResult.kt +32 -0
  29. package/nitrogen/generated/ios/BleNitro-Swift-Cxx-Bridge.cpp +15 -39
  30. package/nitrogen/generated/ios/BleNitro-Swift-Cxx-Bridge.hpp +108 -113
  31. package/nitrogen/generated/ios/BleNitro-Swift-Cxx-Umbrella.hpp +6 -0
  32. package/nitrogen/generated/ios/c++/HybridNativeBleNitroSpecSwift.hpp +57 -28
  33. package/nitrogen/generated/ios/swift/{Func_void_bool_std__vector_double__std__string.swift → Func_void_bool_std__shared_ptr_ArrayBuffer__std__string.swift} +11 -11
  34. package/nitrogen/generated/ios/swift/{Func_void_std__string_std__vector_double_.swift → Func_void_std__string_std__shared_ptr_ArrayBuffer_.swift} +11 -11
  35. package/nitrogen/generated/ios/swift/HybridNativeBleNitroSpec.swift +13 -13
  36. package/nitrogen/generated/ios/swift/HybridNativeBleNitroSpec_cxx.swift +84 -136
  37. package/nitrogen/generated/ios/swift/ManufacturerDataEntry.swift +5 -17
  38. package/nitrogen/generated/ios/swift/OperationResult.swift +64 -0
  39. package/nitrogen/generated/shared/c++/HybridNativeBleNitroSpec.cpp +1 -1
  40. package/nitrogen/generated/shared/c++/HybridNativeBleNitroSpec.hpp +20 -14
  41. package/nitrogen/generated/shared/c++/ManufacturerDataEntry.hpp +8 -7
  42. package/nitrogen/generated/shared/c++/OperationResult.hpp +72 -0
  43. package/package.json +1 -1
  44. package/react-native.config.js +10 -2
  45. package/src/__tests__/index.test.ts +19 -22
  46. package/src/index.ts +147 -164
  47. package/src/specs/NativeBleNitro.nitro.ts +22 -14
  48. package/nitrogen/generated/android/c++/JFunc_void_bool.hpp +0 -74
  49. package/nitrogen/generated/android/c++/JFunc_void_bool_std__vector_double__std__string.hpp +0 -86
  50. package/nitrogen/generated/android/c++/JFunc_void_std__string_std__vector_double_.hpp +0 -86
  51. package/nitrogen/generated/android/c++/JFunc_void_std__vector_BLEDevice_.hpp +0 -99
  52. package/nitrogen/generated/android/c++/JFunc_void_std__vector_std__string_.hpp +0 -93
  53. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/Func_void_bool.kt +0 -81
  54. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/Func_void_std__vector_BLEDevice_.kt +0 -81
  55. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/Func_void_std__vector_std__string_.kt +0 -81
  56. package/nitrogen/generated/ios/swift/Func_void_bool.swift +0 -47
  57. package/nitrogen/generated/ios/swift/Func_void_std__vector_BLEDevice_.swift +0 -47
  58. package/nitrogen/generated/ios/swift/Func_void_std__vector_std__string_.swift +0 -47
@@ -8,6 +8,10 @@
8
8
  #pragma once
9
9
 
10
10
  // Forward declarations of C++ defined types
11
+ // Forward declaration of `ArrayBufferHolder` to properly resolve imports.
12
+ namespace NitroModules { class ArrayBufferHolder; }
13
+ // Forward declaration of `ArrayBuffer` to properly resolve imports.
14
+ namespace NitroModules { class ArrayBuffer; }
11
15
  // Forward declaration of `BLEDevice` to properly resolve imports.
12
16
  namespace margelo::nitro::co::zyke::ble { struct BLEDevice; }
13
17
  // Forward declaration of `BLEState` to properly resolve imports.
@@ -18,6 +22,8 @@ namespace margelo::nitro::co::zyke::ble { class HybridNativeBleNitroSpec; }
18
22
  namespace margelo::nitro::co::zyke::ble { struct ManufacturerDataEntry; }
19
23
  // Forward declaration of `ManufacturerData` to properly resolve imports.
20
24
  namespace margelo::nitro::co::zyke::ble { struct ManufacturerData; }
25
+ // Forward declaration of `OperationResult` to properly resolve imports.
26
+ namespace margelo::nitro::co::zyke::ble { struct OperationResult; }
21
27
 
22
28
  // Forward declarations of Swift defined types
23
29
  // Forward declaration of `HybridNativeBleNitroSpec_cxx` to properly resolve imports.
@@ -29,6 +35,9 @@ namespace BleNitro { class HybridNativeBleNitroSpec_cxx; }
29
35
  #include "HybridNativeBleNitroSpec.hpp"
30
36
  #include "ManufacturerData.hpp"
31
37
  #include "ManufacturerDataEntry.hpp"
38
+ #include "OperationResult.hpp"
39
+ #include <NitroModules/ArrayBuffer.hpp>
40
+ #include <NitroModules/ArrayBufferHolder.hpp>
32
41
  #include <NitroModules/Promise.hpp>
33
42
  #include <NitroModules/PromiseHolder.hpp>
34
43
  #include <NitroModules/Result.hpp>
@@ -56,17 +65,6 @@ namespace margelo::nitro::co::zyke::ble::bridge::swift {
56
65
  return vector;
57
66
  }
58
67
 
59
- // pragma MARK: std::vector<double>
60
- /**
61
- * Specialized version of `std::vector<double>`.
62
- */
63
- using std__vector_double_ = std::vector<double>;
64
- inline std::vector<double> create_std__vector_double_(size_t size) {
65
- std::vector<double> vector;
66
- vector.reserve(size);
67
- return vector;
68
- }
69
-
70
68
  // pragma MARK: std::vector<ManufacturerDataEntry>
71
69
  /**
72
70
  * Specialized version of `std::vector<ManufacturerDataEntry>`.
@@ -100,50 +98,6 @@ namespace margelo::nitro::co::zyke::ble::bridge::swift {
100
98
  return Func_void_BLEDevice_Wrapper(std::move(value));
101
99
  }
102
100
 
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
101
  // pragma MARK: std::vector<BLEDevice>
148
102
  /**
149
103
  * Specialized version of `std::vector<BLEDevice>`.
@@ -155,28 +109,6 @@ namespace margelo::nitro::co::zyke::ble::bridge::swift {
155
109
  return vector;
156
110
  }
157
111
 
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
112
  // pragma MARK: std::function<void(bool /* success */, const std::string& /* deviceId */, const std::string& /* error */)>
181
113
  /**
182
114
  * Specialized version of `std::function<void(bool, const std::string&, const std::string&)>`.
@@ -230,70 +162,79 @@ namespace margelo::nitro::co::zyke::ble::bridge::swift {
230
162
  return std::optional<std::function<void(const std::string& /* deviceId */, bool /* interrupted */, const std::string& /* error */)>>(value);
231
163
  }
232
164
 
233
- // pragma MARK: std::function<void(const std::vector<std::string>& /* result */)>
165
+ // pragma MARK: std::function<void(bool /* success */, const std::string& /* error */)>
234
166
  /**
235
- * Specialized version of `std::function<void(const std::vector<std::string>&)>`.
167
+ * Specialized version of `std::function<void(bool, const std::string&)>`.
236
168
  */
237
- using Func_void_std__vector_std__string_ = std::function<void(const std::vector<std::string>& /* result */)>;
169
+ using Func_void_bool_std__string = std::function<void(bool /* success */, const std::string& /* error */)>;
238
170
  /**
239
- * Wrapper class for a `std::function<void(const std::vector<std::string>& / * result * /)>`, this can be used from Swift.
171
+ * Wrapper class for a `std::function<void(bool / * success * /, const std::string& / * error * /)>`, this can be used from Swift.
240
172
  */
241
- class Func_void_std__vector_std__string__Wrapper final {
173
+ class Func_void_bool_std__string_Wrapper final {
242
174
  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);
175
+ 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))) {}
176
+ inline void call(bool success, std::string error) const {
177
+ _function->operator()(success, error);
246
178
  }
247
179
  private:
248
- std::unique_ptr<std::function<void(const std::vector<std::string>& /* result */)>> _function;
180
+ std::unique_ptr<std::function<void(bool /* success */, const std::string& /* error */)>> _function;
249
181
  } 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));
182
+ Func_void_bool_std__string create_Func_void_bool_std__string(void* _Nonnull swiftClosureWrapper);
183
+ inline Func_void_bool_std__string_Wrapper wrap_Func_void_bool_std__string(Func_void_bool_std__string value) {
184
+ return Func_void_bool_std__string_Wrapper(std::move(value));
253
185
  }
254
186
 
255
- // pragma MARK: std::function<void(bool /* success */, const std::vector<double>& /* data */, const std::string& /* error */)>
187
+ // pragma MARK: std::function<void(bool /* success */, const std::shared_ptr<ArrayBuffer>& /* data */, const std::string& /* error */)>
256
188
  /**
257
- * Specialized version of `std::function<void(bool, const std::vector<double>&, const std::string&)>`.
189
+ * Specialized version of `std::function<void(bool, const std::shared_ptr<ArrayBuffer>&, const std::string&)>`.
258
190
  */
259
- using Func_void_bool_std__vector_double__std__string = std::function<void(bool /* success */, const std::vector<double>& /* data */, const std::string& /* error */)>;
191
+ using Func_void_bool_std__shared_ptr_ArrayBuffer__std__string = std::function<void(bool /* success */, const std::shared_ptr<ArrayBuffer>& /* data */, const std::string& /* error */)>;
260
192
  /**
261
- * Wrapper class for a `std::function<void(bool / * success * /, const std::vector<double>& / * data * /, const std::string& / * error * /)>`, this can be used from Swift.
193
+ * Wrapper class for a `std::function<void(bool / * success * /, const std::shared_ptr<ArrayBuffer>& / * data * /, const std::string& / * error * /)>`, this can be used from Swift.
262
194
  */
263
- class Func_void_bool_std__vector_double__std__string_Wrapper final {
195
+ class Func_void_bool_std__shared_ptr_ArrayBuffer__std__string_Wrapper final {
264
196
  public:
265
- explicit Func_void_bool_std__vector_double__std__string_Wrapper(std::function<void(bool /* success */, const std::vector<double>& /* data */, const std::string& /* error */)>&& func): _function(std::make_unique<std::function<void(bool /* success */, const std::vector<double>& /* data */, const std::string& /* error */)>>(std::move(func))) {}
266
- inline void call(bool success, std::vector<double> data, std::string error) const {
267
- _function->operator()(success, data, error);
197
+ explicit Func_void_bool_std__shared_ptr_ArrayBuffer__std__string_Wrapper(std::function<void(bool /* success */, const std::shared_ptr<ArrayBuffer>& /* data */, const std::string& /* error */)>&& func): _function(std::make_unique<std::function<void(bool /* success */, const std::shared_ptr<ArrayBuffer>& /* data */, const std::string& /* error */)>>(std::move(func))) {}
198
+ inline void call(bool success, ArrayBufferHolder data, std::string error) const {
199
+ _function->operator()(success, data.getArrayBuffer(), error);
268
200
  }
269
201
  private:
270
- std::unique_ptr<std::function<void(bool /* success */, const std::vector<double>& /* data */, const std::string& /* error */)>> _function;
202
+ std::unique_ptr<std::function<void(bool /* success */, const std::shared_ptr<ArrayBuffer>& /* data */, const std::string& /* error */)>> _function;
271
203
  } SWIFT_NONCOPYABLE;
272
- Func_void_bool_std__vector_double__std__string create_Func_void_bool_std__vector_double__std__string(void* _Nonnull swiftClosureWrapper);
273
- inline Func_void_bool_std__vector_double__std__string_Wrapper wrap_Func_void_bool_std__vector_double__std__string(Func_void_bool_std__vector_double__std__string value) {
274
- return Func_void_bool_std__vector_double__std__string_Wrapper(std::move(value));
204
+ Func_void_bool_std__shared_ptr_ArrayBuffer__std__string create_Func_void_bool_std__shared_ptr_ArrayBuffer__std__string(void* _Nonnull swiftClosureWrapper);
205
+ inline Func_void_bool_std__shared_ptr_ArrayBuffer__std__string_Wrapper wrap_Func_void_bool_std__shared_ptr_ArrayBuffer__std__string(Func_void_bool_std__shared_ptr_ArrayBuffer__std__string value) {
206
+ return Func_void_bool_std__shared_ptr_ArrayBuffer__std__string_Wrapper(std::move(value));
275
207
  }
276
208
 
277
- // pragma MARK: std::function<void(const std::string& /* characteristicId */, const std::vector<double>& /* data */)>
209
+ // pragma MARK: std::function<void(const std::string& /* characteristicId */, const std::shared_ptr<ArrayBuffer>& /* data */)>
278
210
  /**
279
- * Specialized version of `std::function<void(const std::string&, const std::vector<double>&)>`.
211
+ * Specialized version of `std::function<void(const std::string&, const std::shared_ptr<ArrayBuffer>&)>`.
280
212
  */
281
- using Func_void_std__string_std__vector_double_ = std::function<void(const std::string& /* characteristicId */, const std::vector<double>& /* data */)>;
213
+ using Func_void_std__string_std__shared_ptr_ArrayBuffer_ = std::function<void(const std::string& /* characteristicId */, const std::shared_ptr<ArrayBuffer>& /* data */)>;
282
214
  /**
283
- * Wrapper class for a `std::function<void(const std::string& / * characteristicId * /, const std::vector<double>& / * data * /)>`, this can be used from Swift.
215
+ * Wrapper class for a `std::function<void(const std::string& / * characteristicId * /, const std::shared_ptr<ArrayBuffer>& / * data * /)>`, this can be used from Swift.
284
216
  */
285
- class Func_void_std__string_std__vector_double__Wrapper final {
217
+ class Func_void_std__string_std__shared_ptr_ArrayBuffer__Wrapper final {
286
218
  public:
287
- explicit Func_void_std__string_std__vector_double__Wrapper(std::function<void(const std::string& /* characteristicId */, const std::vector<double>& /* data */)>&& func): _function(std::make_unique<std::function<void(const std::string& /* characteristicId */, const std::vector<double>& /* data */)>>(std::move(func))) {}
288
- inline void call(std::string characteristicId, std::vector<double> data) const {
289
- _function->operator()(characteristicId, data);
219
+ explicit Func_void_std__string_std__shared_ptr_ArrayBuffer__Wrapper(std::function<void(const std::string& /* characteristicId */, const std::shared_ptr<ArrayBuffer>& /* data */)>&& func): _function(std::make_unique<std::function<void(const std::string& /* characteristicId */, const std::shared_ptr<ArrayBuffer>& /* data */)>>(std::move(func))) {}
220
+ inline void call(std::string characteristicId, ArrayBufferHolder data) const {
221
+ _function->operator()(characteristicId, data.getArrayBuffer());
290
222
  }
291
223
  private:
292
- std::unique_ptr<std::function<void(const std::string& /* characteristicId */, const std::vector<double>& /* data */)>> _function;
224
+ std::unique_ptr<std::function<void(const std::string& /* characteristicId */, const std::shared_ptr<ArrayBuffer>& /* data */)>> _function;
293
225
  } SWIFT_NONCOPYABLE;
294
- Func_void_std__string_std__vector_double_ create_Func_void_std__string_std__vector_double_(void* _Nonnull swiftClosureWrapper);
295
- inline Func_void_std__string_std__vector_double__Wrapper wrap_Func_void_std__string_std__vector_double_(Func_void_std__string_std__vector_double_ value) {
296
- return Func_void_std__string_std__vector_double__Wrapper(std::move(value));
226
+ Func_void_std__string_std__shared_ptr_ArrayBuffer_ create_Func_void_std__string_std__shared_ptr_ArrayBuffer_(void* _Nonnull swiftClosureWrapper);
227
+ inline Func_void_std__string_std__shared_ptr_ArrayBuffer__Wrapper wrap_Func_void_std__string_std__shared_ptr_ArrayBuffer_(Func_void_std__string_std__shared_ptr_ArrayBuffer_ value) {
228
+ return Func_void_std__string_std__shared_ptr_ArrayBuffer__Wrapper(std::move(value));
229
+ }
230
+
231
+ // pragma MARK: std::optional<std::string>
232
+ /**
233
+ * Specialized version of `std::optional<std::string>`.
234
+ */
235
+ using std__optional_std__string_ = std::optional<std::string>;
236
+ inline std::optional<std::string> create_std__optional_std__string_(const std::string& value) {
237
+ return std::optional<std::string>(value);
297
238
  }
298
239
 
299
240
  // pragma MARK: std::function<void(BLEState /* state */)>
@@ -395,6 +336,60 @@ namespace margelo::nitro::co::zyke::ble::bridge::swift {
395
336
  return Result<void>::withError(error);
396
337
  }
397
338
 
339
+ // pragma MARK: Result<bool>
340
+ using Result_bool_ = Result<bool>;
341
+ inline Result_bool_ create_Result_bool_(bool value) {
342
+ return Result<bool>::withValue(std::move(value));
343
+ }
344
+ inline Result_bool_ create_Result_bool_(const std::exception_ptr& error) {
345
+ return Result<bool>::withError(error);
346
+ }
347
+
348
+ // pragma MARK: Result<std::vector<BLEDevice>>
349
+ using Result_std__vector_BLEDevice__ = Result<std::vector<BLEDevice>>;
350
+ inline Result_std__vector_BLEDevice__ create_Result_std__vector_BLEDevice__(const std::vector<BLEDevice>& value) {
351
+ return Result<std::vector<BLEDevice>>::withValue(value);
352
+ }
353
+ inline Result_std__vector_BLEDevice__ create_Result_std__vector_BLEDevice__(const std::exception_ptr& error) {
354
+ return Result<std::vector<BLEDevice>>::withError(error);
355
+ }
356
+
357
+ // pragma MARK: Result<double>
358
+ using Result_double_ = Result<double>;
359
+ inline Result_double_ create_Result_double_(double value) {
360
+ return Result<double>::withValue(std::move(value));
361
+ }
362
+ inline Result_double_ create_Result_double_(const std::exception_ptr& error) {
363
+ return Result<double>::withError(error);
364
+ }
365
+
366
+ // pragma MARK: Result<std::vector<std::string>>
367
+ using Result_std__vector_std__string__ = Result<std::vector<std::string>>;
368
+ inline Result_std__vector_std__string__ create_Result_std__vector_std__string__(const std::vector<std::string>& value) {
369
+ return Result<std::vector<std::string>>::withValue(value);
370
+ }
371
+ inline Result_std__vector_std__string__ create_Result_std__vector_std__string__(const std::exception_ptr& error) {
372
+ return Result<std::vector<std::string>>::withError(error);
373
+ }
374
+
375
+ // pragma MARK: Result<BLEState>
376
+ using Result_BLEState_ = Result<BLEState>;
377
+ inline Result_BLEState_ create_Result_BLEState_(BLEState value) {
378
+ return Result<BLEState>::withValue(std::move(value));
379
+ }
380
+ inline Result_BLEState_ create_Result_BLEState_(const std::exception_ptr& error) {
381
+ return Result<BLEState>::withError(error);
382
+ }
383
+
384
+ // pragma MARK: Result<OperationResult>
385
+ using Result_OperationResult_ = Result<OperationResult>;
386
+ inline Result_OperationResult_ create_Result_OperationResult_(const OperationResult& value) {
387
+ return Result<OperationResult>::withValue(value);
388
+ }
389
+ inline Result_OperationResult_ create_Result_OperationResult_(const std::exception_ptr& error) {
390
+ return Result<OperationResult>::withError(error);
391
+ }
392
+
398
393
  // pragma MARK: Result<std::shared_ptr<Promise<void>>>
399
394
  using Result_std__shared_ptr_Promise_void___ = Result<std::shared_ptr<Promise<void>>>;
400
395
  inline Result_std__shared_ptr_Promise_void___ create_Result_std__shared_ptr_Promise_void___(const std::shared_ptr<Promise<void>>& value) {
@@ -8,6 +8,8 @@
8
8
  #pragma once
9
9
 
10
10
  // Forward declarations of C++ defined types
11
+ // Forward declaration of `ArrayBuffer` to properly resolve imports.
12
+ namespace NitroModules { class ArrayBuffer; }
11
13
  // Forward declaration of `BLEDevice` to properly resolve imports.
12
14
  namespace margelo::nitro::co::zyke::ble { struct BLEDevice; }
13
15
  // Forward declaration of `BLEState` to properly resolve imports.
@@ -18,6 +20,8 @@ namespace margelo::nitro::co::zyke::ble { class HybridNativeBleNitroSpec; }
18
20
  namespace margelo::nitro::co::zyke::ble { struct ManufacturerDataEntry; }
19
21
  // Forward declaration of `ManufacturerData` to properly resolve imports.
20
22
  namespace margelo::nitro::co::zyke::ble { struct ManufacturerData; }
23
+ // Forward declaration of `OperationResult` to properly resolve imports.
24
+ namespace margelo::nitro::co::zyke::ble { struct OperationResult; }
21
25
  // Forward declaration of `ScanFilter` to properly resolve imports.
22
26
  namespace margelo::nitro::co::zyke::ble { struct ScanFilter; }
23
27
 
@@ -27,7 +31,9 @@ namespace margelo::nitro::co::zyke::ble { struct ScanFilter; }
27
31
  #include "HybridNativeBleNitroSpec.hpp"
28
32
  #include "ManufacturerData.hpp"
29
33
  #include "ManufacturerDataEntry.hpp"
34
+ #include "OperationResult.hpp"
30
35
  #include "ScanFilter.hpp"
36
+ #include <NitroModules/ArrayBuffer.hpp>
31
37
  #include <NitroModules/Promise.hpp>
32
38
  #include <NitroModules/Result.hpp>
33
39
  #include <exception>
@@ -20,8 +20,14 @@ namespace margelo::nitro::co::zyke::ble { struct BLEDevice; }
20
20
  namespace margelo::nitro::co::zyke::ble { struct ManufacturerData; }
21
21
  // Forward declaration of `ManufacturerDataEntry` to properly resolve imports.
22
22
  namespace margelo::nitro::co::zyke::ble { struct ManufacturerDataEntry; }
23
+ // Forward declaration of `ArrayBuffer` to properly resolve imports.
24
+ namespace NitroModules { class ArrayBuffer; }
25
+ // Forward declaration of `ArrayBufferHolder` to properly resolve imports.
26
+ namespace NitroModules { class ArrayBufferHolder; }
23
27
  // Forward declaration of `BLEState` to properly resolve imports.
24
28
  namespace margelo::nitro::co::zyke::ble { enum class BLEState; }
29
+ // Forward declaration of `OperationResult` to properly resolve imports.
30
+ namespace margelo::nitro::co::zyke::ble { struct OperationResult; }
25
31
 
26
32
  #include "ScanFilter.hpp"
27
33
  #include <string>
@@ -30,8 +36,11 @@ namespace margelo::nitro::co::zyke::ble { enum class BLEState; }
30
36
  #include <functional>
31
37
  #include "ManufacturerData.hpp"
32
38
  #include "ManufacturerDataEntry.hpp"
39
+ #include <NitroModules/ArrayBuffer.hpp>
40
+ #include <NitroModules/ArrayBufferHolder.hpp>
33
41
  #include <optional>
34
42
  #include "BLEState.hpp"
43
+ #include "OperationResult.hpp"
35
44
  #include <NitroModules/Promise.hpp>
36
45
 
37
46
  #include "BleNitro-Swift-Cxx-Umbrella.hpp"
@@ -81,23 +90,29 @@ namespace margelo::nitro::co::zyke::ble {
81
90
  std::rethrow_exception(__result.error());
82
91
  }
83
92
  }
84
- inline void stopScan(const std::function<void(bool /* success */, const std::string& /* error */)>& callback) override {
85
- auto __result = _swiftPart.stopScan(callback);
93
+ inline bool stopScan() override {
94
+ auto __result = _swiftPart.stopScan();
86
95
  if (__result.hasError()) [[unlikely]] {
87
96
  std::rethrow_exception(__result.error());
88
97
  }
98
+ auto __value = std::move(__result.value());
99
+ return __value;
89
100
  }
90
- inline void isScanning(const std::function<void(bool /* result */)>& callback) override {
91
- auto __result = _swiftPart.isScanning(callback);
101
+ inline bool isScanning() override {
102
+ auto __result = _swiftPart.isScanning();
92
103
  if (__result.hasError()) [[unlikely]] {
93
104
  std::rethrow_exception(__result.error());
94
105
  }
106
+ auto __value = std::move(__result.value());
107
+ return __value;
95
108
  }
96
- inline void getConnectedDevices(const std::function<void(const std::vector<BLEDevice>& /* devices */)>& callback) override {
97
- auto __result = _swiftPart.getConnectedDevices(callback);
109
+ inline std::vector<BLEDevice> getConnectedDevices(const std::vector<std::string>& services) override {
110
+ auto __result = _swiftPart.getConnectedDevices(services);
98
111
  if (__result.hasError()) [[unlikely]] {
99
112
  std::rethrow_exception(__result.error());
100
113
  }
114
+ auto __value = std::move(__result.value());
115
+ return __value;
101
116
  }
102
117
  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
118
  auto __result = _swiftPart.connect(deviceId, callback, disconnectCallback);
@@ -111,11 +126,21 @@ namespace margelo::nitro::co::zyke::ble {
111
126
  std::rethrow_exception(__result.error());
112
127
  }
113
128
  }
114
- inline void isConnected(const std::string& deviceId, const std::function<void(bool /* result */)>& callback) override {
115
- auto __result = _swiftPart.isConnected(deviceId, callback);
129
+ inline bool isConnected(const std::string& deviceId) override {
130
+ auto __result = _swiftPart.isConnected(deviceId);
131
+ if (__result.hasError()) [[unlikely]] {
132
+ std::rethrow_exception(__result.error());
133
+ }
134
+ auto __value = std::move(__result.value());
135
+ return __value;
136
+ }
137
+ inline double requestMTU(const std::string& deviceId, double mtu) override {
138
+ auto __result = _swiftPart.requestMTU(deviceId, std::forward<decltype(mtu)>(mtu));
116
139
  if (__result.hasError()) [[unlikely]] {
117
140
  std::rethrow_exception(__result.error());
118
141
  }
142
+ auto __value = std::move(__result.value());
143
+ return __value;
119
144
  }
120
145
  inline void discoverServices(const std::string& deviceId, const std::function<void(bool /* success */, const std::string& /* error */)>& callback) override {
121
146
  auto __result = _swiftPart.discoverServices(deviceId, callback);
@@ -123,31 +148,35 @@ namespace margelo::nitro::co::zyke::ble {
123
148
  std::rethrow_exception(__result.error());
124
149
  }
125
150
  }
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);
151
+ inline std::vector<std::string> getServices(const std::string& deviceId) override {
152
+ auto __result = _swiftPart.getServices(deviceId);
128
153
  if (__result.hasError()) [[unlikely]] {
129
154
  std::rethrow_exception(__result.error());
130
155
  }
156
+ auto __value = std::move(__result.value());
157
+ return __value;
131
158
  }
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);
159
+ inline std::vector<std::string> getCharacteristics(const std::string& deviceId, const std::string& serviceId) override {
160
+ auto __result = _swiftPart.getCharacteristics(deviceId, serviceId);
134
161
  if (__result.hasError()) [[unlikely]] {
135
162
  std::rethrow_exception(__result.error());
136
163
  }
164
+ auto __value = std::move(__result.value());
165
+ return __value;
137
166
  }
138
- 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 {
167
+ inline void readCharacteristic(const std::string& deviceId, const std::string& serviceId, const std::string& characteristicId, const std::function<void(bool /* success */, const std::shared_ptr<ArrayBuffer>& /* data */, const std::string& /* error */)>& callback) override {
139
168
  auto __result = _swiftPart.readCharacteristic(deviceId, serviceId, characteristicId, callback);
140
169
  if (__result.hasError()) [[unlikely]] {
141
170
  std::rethrow_exception(__result.error());
142
171
  }
143
172
  }
144
- inline void writeCharacteristic(const std::string& deviceId, const std::string& serviceId, const std::string& characteristicId, const std::vector<double>& data, bool withResponse, const std::function<void(bool /* success */, const std::string& /* error */)>& callback) override {
145
- auto __result = _swiftPart.writeCharacteristic(deviceId, serviceId, characteristicId, data, std::forward<decltype(withResponse)>(withResponse), callback);
173
+ inline void writeCharacteristic(const std::string& deviceId, const std::string& serviceId, const std::string& characteristicId, const std::shared_ptr<ArrayBuffer>& data, bool withResponse, const std::function<void(bool /* success */, const std::string& /* error */)>& callback) override {
174
+ auto __result = _swiftPart.writeCharacteristic(deviceId, serviceId, characteristicId, ArrayBufferHolder(data), std::forward<decltype(withResponse)>(withResponse), callback);
146
175
  if (__result.hasError()) [[unlikely]] {
147
176
  std::rethrow_exception(__result.error());
148
177
  }
149
178
  }
150
- inline void subscribeToCharacteristic(const std::string& deviceId, const std::string& serviceId, const std::string& characteristicId, const std::function<void(const std::string& /* characteristicId */, const std::vector<double>& /* data */)>& updateCallback, const std::function<void(bool /* success */, const std::string& /* error */)>& resultCallback) override {
179
+ inline void subscribeToCharacteristic(const std::string& deviceId, const std::string& serviceId, const std::string& characteristicId, const std::function<void(const std::string& /* characteristicId */, const std::shared_ptr<ArrayBuffer>& /* data */)>& updateCallback, const std::function<void(bool /* success */, const std::string& /* error */)>& resultCallback) override {
151
180
  auto __result = _swiftPart.subscribeToCharacteristic(deviceId, serviceId, characteristicId, updateCallback, resultCallback);
152
181
  if (__result.hasError()) [[unlikely]] {
153
182
  std::rethrow_exception(__result.error());
@@ -159,35 +188,35 @@ namespace margelo::nitro::co::zyke::ble {
159
188
  std::rethrow_exception(__result.error());
160
189
  }
161
190
  }
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
191
  inline void requestBluetoothEnable(const std::function<void(bool /* success */, const std::string& /* error */)>& callback) override {
169
192
  auto __result = _swiftPart.requestBluetoothEnable(callback);
170
193
  if (__result.hasError()) [[unlikely]] {
171
194
  std::rethrow_exception(__result.error());
172
195
  }
173
196
  }
174
- inline void state(const std::function<void(BLEState /* state */)>& callback) override {
175
- auto __result = _swiftPart.state(callback);
197
+ inline BLEState state() override {
198
+ auto __result = _swiftPart.state();
176
199
  if (__result.hasError()) [[unlikely]] {
177
200
  std::rethrow_exception(__result.error());
178
201
  }
202
+ auto __value = std::move(__result.value());
203
+ return __value;
179
204
  }
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);
205
+ inline OperationResult subscribeToStateChange(const std::function<void(BLEState /* state */)>& stateCallback) override {
206
+ auto __result = _swiftPart.subscribeToStateChange(stateCallback);
182
207
  if (__result.hasError()) [[unlikely]] {
183
208
  std::rethrow_exception(__result.error());
184
209
  }
210
+ auto __value = std::move(__result.value());
211
+ return __value;
185
212
  }
186
- inline void unsubscribeFromStateChange(const std::function<void(bool /* success */, const std::string& /* error */)>& resultCallback) override {
187
- auto __result = _swiftPart.unsubscribeFromStateChange(resultCallback);
213
+ inline OperationResult unsubscribeFromStateChange() override {
214
+ auto __result = _swiftPart.unsubscribeFromStateChange();
188
215
  if (__result.hasError()) [[unlikely]] {
189
216
  std::rethrow_exception(__result.error());
190
217
  }
218
+ auto __value = std::move(__result.value());
219
+ return __value;
191
220
  }
192
221
  inline std::shared_ptr<Promise<void>> openSettings() override {
193
222
  auto __result = _swiftPart.openSettings();
@@ -1,5 +1,5 @@
1
1
  ///
2
- /// Func_void_bool_std__vector_double__std__string.swift
2
+ /// Func_void_bool_std__shared_ptr_ArrayBuffer__std__string.swift
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
4
  /// https://github.com/mrousavy/nitro
5
5
  /// Copyright © 2025 Marc Rousavy @ Margelo
@@ -9,21 +9,21 @@ import NitroModules
9
9
 
10
10
 
11
11
  /**
12
- * Wraps a Swift `(_ success: Bool, _ data: [Double], _ error: String) -> Void` as a class.
12
+ * Wraps a Swift `(_ success: Bool, _ data: ArrayBuffer, _ error: String) -> Void` as a class.
13
13
  * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
14
14
  */
15
- public final class Func_void_bool_std__vector_double__std__string {
15
+ public final class Func_void_bool_std__shared_ptr_ArrayBuffer__std__string {
16
16
  public typealias bridge = margelo.nitro.co.zyke.ble.bridge.swift
17
17
 
18
- private let closure: (_ success: Bool, _ data: [Double], _ error: String) -> Void
18
+ private let closure: (_ success: Bool, _ data: ArrayBuffer, _ error: String) -> Void
19
19
 
20
- public init(_ closure: @escaping (_ success: Bool, _ data: [Double], _ error: String) -> Void) {
20
+ public init(_ closure: @escaping (_ success: Bool, _ data: ArrayBuffer, _ error: String) -> Void) {
21
21
  self.closure = closure
22
22
  }
23
23
 
24
24
  @inline(__always)
25
- public func call(success: Bool, data: bridge.std__vector_double_, error: std.string) -> Void {
26
- self.closure(success, data.map({ __item in __item }), String(error))
25
+ public func call(success: Bool, data: ArrayBuffer, error: std.string) -> Void {
26
+ self.closure(success, data, String(error))
27
27
  }
28
28
 
29
29
  /**
@@ -36,12 +36,12 @@ public final class Func_void_bool_std__vector_double__std__string {
36
36
  }
37
37
 
38
38
  /**
39
- * Casts an unsafe pointer to a `Func_void_bool_std__vector_double__std__string`.
40
- * The pointer has to be a retained opaque `Unmanaged<Func_void_bool_std__vector_double__std__string>`.
39
+ * Casts an unsafe pointer to a `Func_void_bool_std__shared_ptr_ArrayBuffer__std__string`.
40
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_bool_std__shared_ptr_ArrayBuffer__std__string>`.
41
41
  * This removes one strong reference from the object!
42
42
  */
43
43
  @inline(__always)
44
- public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_bool_std__vector_double__std__string {
45
- return Unmanaged<Func_void_bool_std__vector_double__std__string>.fromOpaque(pointer).takeRetainedValue()
44
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_bool_std__shared_ptr_ArrayBuffer__std__string {
45
+ return Unmanaged<Func_void_bool_std__shared_ptr_ArrayBuffer__std__string>.fromOpaque(pointer).takeRetainedValue()
46
46
  }
47
47
  }
@@ -1,5 +1,5 @@
1
1
  ///
2
- /// Func_void_std__string_std__vector_double_.swift
2
+ /// Func_void_std__string_std__shared_ptr_ArrayBuffer_.swift
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
4
  /// https://github.com/mrousavy/nitro
5
5
  /// Copyright © 2025 Marc Rousavy @ Margelo
@@ -9,21 +9,21 @@ import NitroModules
9
9
 
10
10
 
11
11
  /**
12
- * Wraps a Swift `(_ characteristicId: String, _ data: [Double]) -> Void` as a class.
12
+ * Wraps a Swift `(_ characteristicId: String, _ data: ArrayBuffer) -> Void` as a class.
13
13
  * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
14
14
  */
15
- public final class Func_void_std__string_std__vector_double_ {
15
+ public final class Func_void_std__string_std__shared_ptr_ArrayBuffer_ {
16
16
  public typealias bridge = margelo.nitro.co.zyke.ble.bridge.swift
17
17
 
18
- private let closure: (_ characteristicId: String, _ data: [Double]) -> Void
18
+ private let closure: (_ characteristicId: String, _ data: ArrayBuffer) -> Void
19
19
 
20
- public init(_ closure: @escaping (_ characteristicId: String, _ data: [Double]) -> Void) {
20
+ public init(_ closure: @escaping (_ characteristicId: String, _ data: ArrayBuffer) -> Void) {
21
21
  self.closure = closure
22
22
  }
23
23
 
24
24
  @inline(__always)
25
- public func call(characteristicId: std.string, data: bridge.std__vector_double_) -> Void {
26
- self.closure(String(characteristicId), data.map({ __item in __item }))
25
+ public func call(characteristicId: std.string, data: ArrayBuffer) -> Void {
26
+ self.closure(String(characteristicId), data)
27
27
  }
28
28
 
29
29
  /**
@@ -36,12 +36,12 @@ public final class Func_void_std__string_std__vector_double_ {
36
36
  }
37
37
 
38
38
  /**
39
- * Casts an unsafe pointer to a `Func_void_std__string_std__vector_double_`.
40
- * The pointer has to be a retained opaque `Unmanaged<Func_void_std__string_std__vector_double_>`.
39
+ * Casts an unsafe pointer to a `Func_void_std__string_std__shared_ptr_ArrayBuffer_`.
40
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_std__string_std__shared_ptr_ArrayBuffer_>`.
41
41
  * This removes one strong reference from the object!
42
42
  */
43
43
  @inline(__always)
44
- public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__string_std__vector_double_ {
45
- return Unmanaged<Func_void_std__string_std__vector_double_>.fromOpaque(pointer).takeRetainedValue()
44
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__string_std__shared_ptr_ArrayBuffer_ {
45
+ return Unmanaged<Func_void_std__string_std__shared_ptr_ArrayBuffer_>.fromOpaque(pointer).takeRetainedValue()
46
46
  }
47
47
  }