react-native-ble-nitro 1.1.0 → 1.3.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 (71) hide show
  1. package/README.md +87 -20
  2. package/android/CMakeLists.txt +32 -0
  3. package/android/build.gradle +140 -0
  4. package/android/fix-prefab.gradle +51 -0
  5. package/android/gradle.properties +5 -0
  6. package/android/src/main/AndroidManifest.xml +2 -0
  7. package/android/src/main/cpp/cpp-adapter.cpp +6 -0
  8. package/android/src/main/java/com/margelo/nitro/co/zyke/ble/BleNitroBleManager.kt +899 -0
  9. package/android/src/main/java/com/margelo/nitro/co/zyke/ble/BleNitroPackage.kt +38 -0
  10. package/ios/BleNitroBleManager.swift +56 -17
  11. package/ios/BlePeripheralDelegate.swift +36 -8
  12. package/lib/commonjs/index.d.ts +22 -9
  13. package/lib/commonjs/index.d.ts.map +1 -1
  14. package/lib/commonjs/index.js +63 -12
  15. package/lib/commonjs/index.js.map +1 -1
  16. package/lib/commonjs/specs/NativeBleNitro.nitro.d.ts +14 -5
  17. package/lib/commonjs/specs/NativeBleNitro.nitro.d.ts.map +1 -1
  18. package/lib/commonjs/specs/NativeBleNitro.nitro.js +8 -1
  19. package/lib/commonjs/specs/NativeBleNitro.nitro.js.map +1 -1
  20. package/lib/index.d.ts +22 -9
  21. package/lib/index.js +61 -10
  22. package/lib/specs/NativeBleNitro.nitro.d.ts +14 -5
  23. package/lib/specs/NativeBleNitro.nitro.js +7 -0
  24. package/nitrogen/generated/android/BleNitroOnLoad.cpp +6 -6
  25. package/nitrogen/generated/android/c++/JAndroidScanMode.hpp +65 -0
  26. package/nitrogen/generated/android/c++/JBLEDevice.hpp +3 -0
  27. package/nitrogen/generated/android/c++/JFunc_void_bool_std__shared_ptr_ArrayBuffer__std__string.hpp +78 -0
  28. package/nitrogen/generated/android/c++/JFunc_void_std__optional_BLEDevice__std__optional_std__string_.hpp +86 -0
  29. package/nitrogen/generated/android/c++/JFunc_void_std__string_std__shared_ptr_ArrayBuffer_.hpp +78 -0
  30. package/nitrogen/generated/android/c++/JHybridNativeBleNitroSpec.cpp +29 -20
  31. package/nitrogen/generated/android/c++/JHybridNativeBleNitroSpec.hpp +5 -4
  32. package/nitrogen/generated/android/c++/JManufacturerData.hpp +3 -0
  33. package/nitrogen/generated/android/c++/JManufacturerDataEntry.hpp +7 -15
  34. package/nitrogen/generated/android/c++/JScanFilter.hpp +8 -2
  35. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/AndroidScanMode.kt +23 -0
  36. 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
  37. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/{Func_void_BLEDevice.kt → Func_void_std__optional_BLEDevice__std__optional_std__string_.kt} +14 -14
  38. 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
  39. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/HybridNativeBleNitroSpec.kt +12 -8
  40. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/ManufacturerDataEntry.kt +1 -1
  41. package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/ScanFilter.kt +4 -1
  42. package/nitrogen/generated/ios/BleNitro-Swift-Cxx-Bridge.cpp +15 -15
  43. package/nitrogen/generated/ios/BleNitro-Swift-Cxx-Bridge.hpp +69 -56
  44. package/nitrogen/generated/ios/BleNitro-Swift-Cxx-Umbrella.hpp +6 -0
  45. package/nitrogen/generated/ios/c++/HybridNativeBleNitroSpecSwift.hpp +23 -6
  46. package/nitrogen/generated/ios/swift/AndroidScanMode.swift +48 -0
  47. 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
  48. package/nitrogen/generated/ios/swift/Func_void_std__optional_BLEDevice__std__optional_std__string_.swift +59 -0
  49. package/nitrogen/generated/ios/swift/{Func_void_std__string_std__vector_double_.swift → Func_void_std__string_std__shared_ptr_ArrayBuffer_.swift} +11 -11
  50. package/nitrogen/generated/ios/swift/HybridNativeBleNitroSpec.swift +5 -4
  51. package/nitrogen/generated/ios/swift/HybridNativeBleNitroSpec_cxx.swift +41 -29
  52. package/nitrogen/generated/ios/swift/ManufacturerDataEntry.swift +5 -17
  53. package/nitrogen/generated/ios/swift/ScanFilter.swift +13 -2
  54. package/nitrogen/generated/shared/c++/AndroidScanMode.hpp +64 -0
  55. package/nitrogen/generated/shared/c++/HybridNativeBleNitroSpec.cpp +1 -0
  56. package/nitrogen/generated/shared/c++/HybridNativeBleNitroSpec.hpp +10 -6
  57. package/nitrogen/generated/shared/c++/ManufacturerDataEntry.hpp +8 -7
  58. package/nitrogen/generated/shared/c++/ScanFilter.hpp +9 -3
  59. package/package.json +1 -1
  60. package/plugin/build/index.d.ts +2 -0
  61. package/plugin/build/index.js +2 -0
  62. package/plugin/build/withBleNitro.d.ts +5 -1
  63. package/plugin/build/withBleNitro.js +18 -7
  64. package/react-native.config.js +10 -2
  65. package/src/__tests__/index.test.ts +48 -13
  66. package/src/index.ts +74 -16
  67. package/src/specs/NativeBleNitro.nitro.ts +17 -5
  68. package/nitrogen/generated/android/c++/JFunc_void_BLEDevice.hpp +0 -82
  69. package/nitrogen/generated/android/c++/JFunc_void_bool_std__vector_double__std__string.hpp +0 -86
  70. package/nitrogen/generated/android/c++/JFunc_void_std__string_std__vector_double_.hpp +0 -86
  71. package/nitrogen/generated/ios/swift/Func_void_BLEDevice.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.
@@ -32,6 +36,8 @@ namespace BleNitro { class HybridNativeBleNitroSpec_cxx; }
32
36
  #include "ManufacturerData.hpp"
33
37
  #include "ManufacturerDataEntry.hpp"
34
38
  #include "OperationResult.hpp"
39
+ #include <NitroModules/ArrayBuffer.hpp>
40
+ #include <NitroModules/ArrayBufferHolder.hpp>
35
41
  #include <NitroModules/Promise.hpp>
36
42
  #include <NitroModules/PromiseHolder.hpp>
37
43
  #include <NitroModules/Result.hpp>
@@ -59,17 +65,6 @@ namespace margelo::nitro::co::zyke::ble::bridge::swift {
59
65
  return vector;
60
66
  }
61
67
 
62
- // pragma MARK: std::vector<double>
63
- /**
64
- * Specialized version of `std::vector<double>`.
65
- */
66
- using std__vector_double_ = std::vector<double>;
67
- inline std::vector<double> create_std__vector_double_(size_t size) {
68
- std::vector<double> vector;
69
- vector.reserve(size);
70
- return vector;
71
- }
72
-
73
68
  // pragma MARK: std::vector<ManufacturerDataEntry>
74
69
  /**
75
70
  * Specialized version of `std::vector<ManufacturerDataEntry>`.
@@ -81,26 +76,44 @@ namespace margelo::nitro::co::zyke::ble::bridge::swift {
81
76
  return vector;
82
77
  }
83
78
 
84
- // pragma MARK: std::function<void(const BLEDevice& /* device */)>
79
+ // pragma MARK: std::optional<BLEDevice>
85
80
  /**
86
- * Specialized version of `std::function<void(const BLEDevice&)>`.
81
+ * Specialized version of `std::optional<BLEDevice>`.
87
82
  */
88
- using Func_void_BLEDevice = std::function<void(const BLEDevice& /* device */)>;
83
+ using std__optional_BLEDevice_ = std::optional<BLEDevice>;
84
+ inline std::optional<BLEDevice> create_std__optional_BLEDevice_(const BLEDevice& value) {
85
+ return std::optional<BLEDevice>(value);
86
+ }
87
+
88
+ // pragma MARK: std::optional<std::string>
89
89
  /**
90
- * Wrapper class for a `std::function<void(const BLEDevice& / * device * /)>`, this can be used from Swift.
90
+ * Specialized version of `std::optional<std::string>`.
91
91
  */
92
- class Func_void_BLEDevice_Wrapper final {
92
+ using std__optional_std__string_ = std::optional<std::string>;
93
+ inline std::optional<std::string> create_std__optional_std__string_(const std::string& value) {
94
+ return std::optional<std::string>(value);
95
+ }
96
+
97
+ // pragma MARK: std::function<void(const std::optional<BLEDevice>& /* device */, const std::optional<std::string>& /* error */)>
98
+ /**
99
+ * Specialized version of `std::function<void(const std::optional<BLEDevice>&, const std::optional<std::string>&)>`.
100
+ */
101
+ using Func_void_std__optional_BLEDevice__std__optional_std__string_ = std::function<void(const std::optional<BLEDevice>& /* device */, const std::optional<std::string>& /* error */)>;
102
+ /**
103
+ * Wrapper class for a `std::function<void(const std::optional<BLEDevice>& / * device * /, const std::optional<std::string>& / * error * /)>`, this can be used from Swift.
104
+ */
105
+ class Func_void_std__optional_BLEDevice__std__optional_std__string__Wrapper final {
93
106
  public:
94
- explicit Func_void_BLEDevice_Wrapper(std::function<void(const BLEDevice& /* device */)>&& func): _function(std::make_unique<std::function<void(const BLEDevice& /* device */)>>(std::move(func))) {}
95
- inline void call(BLEDevice device) const {
96
- _function->operator()(device);
107
+ explicit Func_void_std__optional_BLEDevice__std__optional_std__string__Wrapper(std::function<void(const std::optional<BLEDevice>& /* device */, const std::optional<std::string>& /* error */)>&& func): _function(std::make_unique<std::function<void(const std::optional<BLEDevice>& /* device */, const std::optional<std::string>& /* error */)>>(std::move(func))) {}
108
+ inline void call(std::optional<BLEDevice> device, std::optional<std::string> error) const {
109
+ _function->operator()(device, error);
97
110
  }
98
111
  private:
99
- std::unique_ptr<std::function<void(const BLEDevice& /* device */)>> _function;
112
+ std::unique_ptr<std::function<void(const std::optional<BLEDevice>& /* device */, const std::optional<std::string>& /* error */)>> _function;
100
113
  } SWIFT_NONCOPYABLE;
101
- Func_void_BLEDevice create_Func_void_BLEDevice(void* _Nonnull swiftClosureWrapper);
102
- inline Func_void_BLEDevice_Wrapper wrap_Func_void_BLEDevice(Func_void_BLEDevice value) {
103
- return Func_void_BLEDevice_Wrapper(std::move(value));
114
+ Func_void_std__optional_BLEDevice__std__optional_std__string_ create_Func_void_std__optional_BLEDevice__std__optional_std__string_(void* _Nonnull swiftClosureWrapper);
115
+ inline Func_void_std__optional_BLEDevice__std__optional_std__string__Wrapper wrap_Func_void_std__optional_BLEDevice__std__optional_std__string_(Func_void_std__optional_BLEDevice__std__optional_std__string_ value) {
116
+ return Func_void_std__optional_BLEDevice__std__optional_std__string__Wrapper(std::move(value));
104
117
  }
105
118
 
106
119
  // pragma MARK: std::vector<BLEDevice>
@@ -189,57 +202,48 @@ namespace margelo::nitro::co::zyke::ble::bridge::swift {
189
202
  return Func_void_bool_std__string_Wrapper(std::move(value));
190
203
  }
191
204
 
192
- // pragma MARK: std::function<void(bool /* success */, const std::vector<double>& /* data */, const std::string& /* error */)>
205
+ // pragma MARK: std::function<void(bool /* success */, const std::shared_ptr<ArrayBuffer>& /* data */, const std::string& /* error */)>
193
206
  /**
194
- * Specialized version of `std::function<void(bool, const std::vector<double>&, const std::string&)>`.
207
+ * Specialized version of `std::function<void(bool, const std::shared_ptr<ArrayBuffer>&, const std::string&)>`.
195
208
  */
196
- using Func_void_bool_std__vector_double__std__string = std::function<void(bool /* success */, const std::vector<double>& /* data */, const std::string& /* error */)>;
209
+ 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 */)>;
197
210
  /**
198
- * Wrapper class for a `std::function<void(bool / * success * /, const std::vector<double>& / * data * /, const std::string& / * error * /)>`, this can be used from Swift.
211
+ * 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.
199
212
  */
200
- class Func_void_bool_std__vector_double__std__string_Wrapper final {
213
+ class Func_void_bool_std__shared_ptr_ArrayBuffer__std__string_Wrapper final {
201
214
  public:
202
- 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))) {}
203
- inline void call(bool success, std::vector<double> data, std::string error) const {
204
- _function->operator()(success, data, error);
215
+ 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))) {}
216
+ inline void call(bool success, ArrayBufferHolder data, std::string error) const {
217
+ _function->operator()(success, data.getArrayBuffer(), error);
205
218
  }
206
219
  private:
207
- std::unique_ptr<std::function<void(bool /* success */, const std::vector<double>& /* data */, const std::string& /* error */)>> _function;
220
+ std::unique_ptr<std::function<void(bool /* success */, const std::shared_ptr<ArrayBuffer>& /* data */, const std::string& /* error */)>> _function;
208
221
  } SWIFT_NONCOPYABLE;
209
- Func_void_bool_std__vector_double__std__string create_Func_void_bool_std__vector_double__std__string(void* _Nonnull swiftClosureWrapper);
210
- 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) {
211
- return Func_void_bool_std__vector_double__std__string_Wrapper(std::move(value));
222
+ Func_void_bool_std__shared_ptr_ArrayBuffer__std__string create_Func_void_bool_std__shared_ptr_ArrayBuffer__std__string(void* _Nonnull swiftClosureWrapper);
223
+ 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) {
224
+ return Func_void_bool_std__shared_ptr_ArrayBuffer__std__string_Wrapper(std::move(value));
212
225
  }
213
226
 
214
- // pragma MARK: std::function<void(const std::string& /* characteristicId */, const std::vector<double>& /* data */)>
227
+ // pragma MARK: std::function<void(const std::string& /* characteristicId */, const std::shared_ptr<ArrayBuffer>& /* data */)>
215
228
  /**
216
- * Specialized version of `std::function<void(const std::string&, const std::vector<double>&)>`.
229
+ * Specialized version of `std::function<void(const std::string&, const std::shared_ptr<ArrayBuffer>&)>`.
217
230
  */
218
- using Func_void_std__string_std__vector_double_ = std::function<void(const std::string& /* characteristicId */, const std::vector<double>& /* data */)>;
231
+ using Func_void_std__string_std__shared_ptr_ArrayBuffer_ = std::function<void(const std::string& /* characteristicId */, const std::shared_ptr<ArrayBuffer>& /* data */)>;
219
232
  /**
220
- * Wrapper class for a `std::function<void(const std::string& / * characteristicId * /, const std::vector<double>& / * data * /)>`, this can be used from Swift.
233
+ * Wrapper class for a `std::function<void(const std::string& / * characteristicId * /, const std::shared_ptr<ArrayBuffer>& / * data * /)>`, this can be used from Swift.
221
234
  */
222
- class Func_void_std__string_std__vector_double__Wrapper final {
235
+ class Func_void_std__string_std__shared_ptr_ArrayBuffer__Wrapper final {
223
236
  public:
224
- 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))) {}
225
- inline void call(std::string characteristicId, std::vector<double> data) const {
226
- _function->operator()(characteristicId, data);
237
+ 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))) {}
238
+ inline void call(std::string characteristicId, ArrayBufferHolder data) const {
239
+ _function->operator()(characteristicId, data.getArrayBuffer());
227
240
  }
228
241
  private:
229
- std::unique_ptr<std::function<void(const std::string& /* characteristicId */, const std::vector<double>& /* data */)>> _function;
242
+ std::unique_ptr<std::function<void(const std::string& /* characteristicId */, const std::shared_ptr<ArrayBuffer>& /* data */)>> _function;
230
243
  } SWIFT_NONCOPYABLE;
231
- Func_void_std__string_std__vector_double_ create_Func_void_std__string_std__vector_double_(void* _Nonnull swiftClosureWrapper);
232
- 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) {
233
- return Func_void_std__string_std__vector_double__Wrapper(std::move(value));
234
- }
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);
244
+ Func_void_std__string_std__shared_ptr_ArrayBuffer_ create_Func_void_std__string_std__shared_ptr_ArrayBuffer_(void* _Nonnull swiftClosureWrapper);
245
+ 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) {
246
+ return Func_void_std__string_std__shared_ptr_ArrayBuffer__Wrapper(std::move(value));
243
247
  }
244
248
 
245
249
  // pragma MARK: std::function<void(BLEState /* state */)>
@@ -359,6 +363,15 @@ namespace margelo::nitro::co::zyke::ble::bridge::swift {
359
363
  return Result<std::vector<BLEDevice>>::withError(error);
360
364
  }
361
365
 
366
+ // pragma MARK: Result<double>
367
+ using Result_double_ = Result<double>;
368
+ inline Result_double_ create_Result_double_(double value) {
369
+ return Result<double>::withValue(std::move(value));
370
+ }
371
+ inline Result_double_ create_Result_double_(const std::exception_ptr& error) {
372
+ return Result<double>::withError(error);
373
+ }
374
+
362
375
  // pragma MARK: Result<std::vector<std::string>>
363
376
  using Result_std__vector_std__string__ = Result<std::vector<std::string>>;
364
377
  inline Result_std__vector_std__string__ create_Result_std__vector_std__string__(const std::vector<std::string>& value) {
@@ -8,6 +8,10 @@
8
8
  #pragma once
9
9
 
10
10
  // Forward declarations of C++ defined types
11
+ // Forward declaration of `AndroidScanMode` to properly resolve imports.
12
+ namespace margelo::nitro::co::zyke::ble { enum class AndroidScanMode; }
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.
@@ -24,6 +28,7 @@ namespace margelo::nitro::co::zyke::ble { struct OperationResult; }
24
28
  namespace margelo::nitro::co::zyke::ble { struct ScanFilter; }
25
29
 
26
30
  // Include C++ defined types
31
+ #include "AndroidScanMode.hpp"
27
32
  #include "BLEDevice.hpp"
28
33
  #include "BLEState.hpp"
29
34
  #include "HybridNativeBleNitroSpec.hpp"
@@ -31,6 +36,7 @@ namespace margelo::nitro::co::zyke::ble { struct ScanFilter; }
31
36
  #include "ManufacturerDataEntry.hpp"
32
37
  #include "OperationResult.hpp"
33
38
  #include "ScanFilter.hpp"
39
+ #include <NitroModules/ArrayBuffer.hpp>
34
40
  #include <NitroModules/Promise.hpp>
35
41
  #include <NitroModules/Result.hpp>
36
42
  #include <exception>
@@ -14,12 +14,18 @@ namespace BleNitro { class HybridNativeBleNitroSpec_cxx; }
14
14
 
15
15
  // Forward declaration of `ScanFilter` to properly resolve imports.
16
16
  namespace margelo::nitro::co::zyke::ble { struct ScanFilter; }
17
+ // Forward declaration of `AndroidScanMode` to properly resolve imports.
18
+ namespace margelo::nitro::co::zyke::ble { enum class AndroidScanMode; }
17
19
  // Forward declaration of `BLEDevice` to properly resolve imports.
18
20
  namespace margelo::nitro::co::zyke::ble { struct BLEDevice; }
19
21
  // Forward declaration of `ManufacturerData` to properly resolve imports.
20
22
  namespace margelo::nitro::co::zyke::ble { struct ManufacturerData; }
21
23
  // Forward declaration of `ManufacturerDataEntry` to properly resolve imports.
22
24
  namespace margelo::nitro::co::zyke::ble { struct ManufacturerDataEntry; }
25
+ // Forward declaration of `ArrayBuffer` to properly resolve imports.
26
+ namespace NitroModules { class ArrayBuffer; }
27
+ // Forward declaration of `ArrayBufferHolder` to properly resolve imports.
28
+ namespace NitroModules { class ArrayBufferHolder; }
23
29
  // Forward declaration of `BLEState` to properly resolve imports.
24
30
  namespace margelo::nitro::co::zyke::ble { enum class BLEState; }
25
31
  // Forward declaration of `OperationResult` to properly resolve imports.
@@ -28,11 +34,14 @@ namespace margelo::nitro::co::zyke::ble { struct OperationResult; }
28
34
  #include "ScanFilter.hpp"
29
35
  #include <string>
30
36
  #include <vector>
37
+ #include "AndroidScanMode.hpp"
31
38
  #include "BLEDevice.hpp"
39
+ #include <optional>
32
40
  #include <functional>
33
41
  #include "ManufacturerData.hpp"
34
42
  #include "ManufacturerDataEntry.hpp"
35
- #include <optional>
43
+ #include <NitroModules/ArrayBuffer.hpp>
44
+ #include <NitroModules/ArrayBufferHolder.hpp>
36
45
  #include "BLEState.hpp"
37
46
  #include "OperationResult.hpp"
38
47
  #include <NitroModules/Promise.hpp>
@@ -78,7 +87,7 @@ namespace margelo::nitro::co::zyke::ble {
78
87
 
79
88
  public:
80
89
  // Methods
81
- inline void startScan(const ScanFilter& filter, const std::function<void(const BLEDevice& /* device */)>& callback) override {
90
+ inline void startScan(const ScanFilter& filter, const std::function<void(const std::optional<BLEDevice>& /* device */, const std::optional<std::string>& /* error */)>& callback) override {
82
91
  auto __result = _swiftPart.startScan(filter, callback);
83
92
  if (__result.hasError()) [[unlikely]] {
84
93
  std::rethrow_exception(__result.error());
@@ -128,6 +137,14 @@ namespace margelo::nitro::co::zyke::ble {
128
137
  auto __value = std::move(__result.value());
129
138
  return __value;
130
139
  }
140
+ inline double requestMTU(const std::string& deviceId, double mtu) override {
141
+ auto __result = _swiftPart.requestMTU(deviceId, std::forward<decltype(mtu)>(mtu));
142
+ if (__result.hasError()) [[unlikely]] {
143
+ std::rethrow_exception(__result.error());
144
+ }
145
+ auto __value = std::move(__result.value());
146
+ return __value;
147
+ }
131
148
  inline void discoverServices(const std::string& deviceId, const std::function<void(bool /* success */, const std::string& /* error */)>& callback) override {
132
149
  auto __result = _swiftPart.discoverServices(deviceId, callback);
133
150
  if (__result.hasError()) [[unlikely]] {
@@ -150,19 +167,19 @@ namespace margelo::nitro::co::zyke::ble {
150
167
  auto __value = std::move(__result.value());
151
168
  return __value;
152
169
  }
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 {
170
+ 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 {
154
171
  auto __result = _swiftPart.readCharacteristic(deviceId, serviceId, characteristicId, callback);
155
172
  if (__result.hasError()) [[unlikely]] {
156
173
  std::rethrow_exception(__result.error());
157
174
  }
158
175
  }
159
- 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 {
160
- auto __result = _swiftPart.writeCharacteristic(deviceId, serviceId, characteristicId, data, std::forward<decltype(withResponse)>(withResponse), callback);
176
+ 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 {
177
+ auto __result = _swiftPart.writeCharacteristic(deviceId, serviceId, characteristicId, ArrayBufferHolder(data), std::forward<decltype(withResponse)>(withResponse), callback);
161
178
  if (__result.hasError()) [[unlikely]] {
162
179
  std::rethrow_exception(__result.error());
163
180
  }
164
181
  }
165
- 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 {
182
+ 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 {
166
183
  auto __result = _swiftPart.subscribeToCharacteristic(deviceId, serviceId, characteristicId, updateCallback, resultCallback);
167
184
  if (__result.hasError()) [[unlikely]] {
168
185
  std::rethrow_exception(__result.error());
@@ -0,0 +1,48 @@
1
+ ///
2
+ /// AndroidScanMode.swift
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
+ /**
9
+ * Represents the JS enum `AndroidScanMode`, backed by a C++ enum.
10
+ */
11
+ public typealias AndroidScanMode = margelo.nitro.co.zyke.ble.AndroidScanMode
12
+
13
+ public extension AndroidScanMode {
14
+ /**
15
+ * Get a AndroidScanMode for the given String value, or
16
+ * return `nil` if the given value was invalid/unknown.
17
+ */
18
+ init?(fromString string: String) {
19
+ switch string {
20
+ case "LowLatency":
21
+ self = .lowlatency
22
+ case "Balanced":
23
+ self = .balanced
24
+ case "LowPower":
25
+ self = .lowpower
26
+ case "Opportunistic":
27
+ self = .opportunistic
28
+ default:
29
+ return nil
30
+ }
31
+ }
32
+
33
+ /**
34
+ * Get the String value this AndroidScanMode represents.
35
+ */
36
+ var stringValue: String {
37
+ switch self {
38
+ case .lowlatency:
39
+ return "LowLatency"
40
+ case .balanced:
41
+ return "Balanced"
42
+ case .lowpower:
43
+ return "LowPower"
44
+ case .opportunistic:
45
+ return "Opportunistic"
46
+ }
47
+ }
48
+ }
@@ -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
  }
@@ -0,0 +1,59 @@
1
+ ///
2
+ /// Func_void_std__optional_BLEDevice__std__optional_std__string_.swift
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
+ import NitroModules
9
+
10
+
11
+ /**
12
+ * Wraps a Swift `(_ device: BLEDevice?, _ error: String?) -> Void` as a class.
13
+ * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
14
+ */
15
+ public final class Func_void_std__optional_BLEDevice__std__optional_std__string_ {
16
+ public typealias bridge = margelo.nitro.co.zyke.ble.bridge.swift
17
+
18
+ private let closure: (_ device: BLEDevice?, _ error: String?) -> Void
19
+
20
+ public init(_ closure: @escaping (_ device: BLEDevice?, _ error: String?) -> Void) {
21
+ self.closure = closure
22
+ }
23
+
24
+ @inline(__always)
25
+ public func call(device: bridge.std__optional_BLEDevice_, error: bridge.std__optional_std__string_) -> Void {
26
+ self.closure({ () -> BLEDevice? in
27
+ if let __unwrapped = device.value {
28
+ return __unwrapped
29
+ } else {
30
+ return nil
31
+ }
32
+ }(), { () -> String? in
33
+ if let __unwrapped = error.value {
34
+ return String(__unwrapped)
35
+ } else {
36
+ return nil
37
+ }
38
+ }())
39
+ }
40
+
41
+ /**
42
+ * Casts this instance to a retained unsafe raw pointer.
43
+ * This acquires one additional strong reference on the object!
44
+ */
45
+ @inline(__always)
46
+ public func toUnsafe() -> UnsafeMutableRawPointer {
47
+ return Unmanaged.passRetained(self).toOpaque()
48
+ }
49
+
50
+ /**
51
+ * Casts an unsafe pointer to a `Func_void_std__optional_BLEDevice__std__optional_std__string_`.
52
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_std__optional_BLEDevice__std__optional_std__string_>`.
53
+ * This removes one strong reference from the object!
54
+ */
55
+ @inline(__always)
56
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__optional_BLEDevice__std__optional_std__string_ {
57
+ return Unmanaged<Func_void_std__optional_BLEDevice__std__optional_std__string_>.fromOpaque(pointer).takeRetainedValue()
58
+ }
59
+ }
@@ -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
  }
@@ -14,19 +14,20 @@ public protocol HybridNativeBleNitroSpec_protocol: HybridObject {
14
14
 
15
15
 
16
16
  // Methods
17
- func startScan(filter: ScanFilter, callback: @escaping (_ device: BLEDevice) -> Void) throws -> Void
17
+ func startScan(filter: ScanFilter, callback: @escaping (_ device: BLEDevice?, _ error: String?) -> Void) throws -> Void
18
18
  func stopScan() throws -> Bool
19
19
  func isScanning() throws -> Bool
20
20
  func getConnectedDevices(services: [String]) throws -> [BLEDevice]
21
21
  func connect(deviceId: String, callback: @escaping (_ success: Bool, _ deviceId: String, _ error: String) -> Void, disconnectCallback: ((_ deviceId: String, _ interrupted: Bool, _ error: String) -> Void)?) throws -> Void
22
22
  func disconnect(deviceId: String, callback: @escaping (_ success: Bool, _ error: String) -> Void) throws -> Void
23
23
  func isConnected(deviceId: String) throws -> Bool
24
+ func requestMTU(deviceId: String, mtu: Double) throws -> Double
24
25
  func discoverServices(deviceId: String, callback: @escaping (_ success: Bool, _ error: String) -> Void) throws -> Void
25
26
  func getServices(deviceId: String) throws -> [String]
26
27
  func getCharacteristics(deviceId: String, serviceId: String) throws -> [String]
27
- func readCharacteristic(deviceId: String, serviceId: String, characteristicId: String, callback: @escaping (_ success: Bool, _ data: [Double], _ error: String) -> Void) throws -> Void
28
- func writeCharacteristic(deviceId: String, serviceId: String, characteristicId: String, data: [Double], withResponse: Bool, callback: @escaping (_ success: Bool, _ error: String) -> Void) throws -> Void
29
- func subscribeToCharacteristic(deviceId: String, serviceId: String, characteristicId: String, updateCallback: @escaping (_ characteristicId: String, _ data: [Double]) -> Void, resultCallback: @escaping (_ success: Bool, _ error: String) -> Void) throws -> Void
28
+ func readCharacteristic(deviceId: String, serviceId: String, characteristicId: String, callback: @escaping (_ success: Bool, _ data: ArrayBuffer, _ error: String) -> Void) throws -> Void
29
+ func writeCharacteristic(deviceId: String, serviceId: String, characteristicId: String, data: ArrayBuffer, withResponse: Bool, callback: @escaping (_ success: Bool, _ error: String) -> Void) throws -> Void
30
+ func subscribeToCharacteristic(deviceId: String, serviceId: String, characteristicId: String, updateCallback: @escaping (_ characteristicId: String, _ data: ArrayBuffer) -> Void, resultCallback: @escaping (_ success: Bool, _ error: String) -> Void) throws -> Void
30
31
  func unsubscribeFromCharacteristic(deviceId: String, serviceId: String, characteristicId: String, callback: @escaping (_ success: Bool, _ error: String) -> Void) throws -> Void
31
32
  func requestBluetoothEnable(callback: @escaping (_ success: Bool, _ error: String) -> Void) throws -> Void
32
33
  func state() throws -> BLEState