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.
- package/README.md +87 -20
- package/android/CMakeLists.txt +32 -0
- package/android/build.gradle +140 -0
- package/android/fix-prefab.gradle +51 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/cpp/cpp-adapter.cpp +6 -0
- package/android/src/main/java/com/margelo/nitro/co/zyke/ble/BleNitroBleManager.kt +899 -0
- package/android/src/main/java/com/margelo/nitro/co/zyke/ble/BleNitroPackage.kt +38 -0
- package/ios/BleNitroBleManager.swift +56 -17
- package/ios/BlePeripheralDelegate.swift +36 -8
- package/lib/commonjs/index.d.ts +22 -9
- package/lib/commonjs/index.d.ts.map +1 -1
- package/lib/commonjs/index.js +63 -12
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/specs/NativeBleNitro.nitro.d.ts +14 -5
- package/lib/commonjs/specs/NativeBleNitro.nitro.d.ts.map +1 -1
- package/lib/commonjs/specs/NativeBleNitro.nitro.js +8 -1
- package/lib/commonjs/specs/NativeBleNitro.nitro.js.map +1 -1
- package/lib/index.d.ts +22 -9
- package/lib/index.js +61 -10
- package/lib/specs/NativeBleNitro.nitro.d.ts +14 -5
- package/lib/specs/NativeBleNitro.nitro.js +7 -0
- package/nitrogen/generated/android/BleNitroOnLoad.cpp +6 -6
- package/nitrogen/generated/android/c++/JAndroidScanMode.hpp +65 -0
- package/nitrogen/generated/android/c++/JBLEDevice.hpp +3 -0
- package/nitrogen/generated/android/c++/JFunc_void_bool_std__shared_ptr_ArrayBuffer__std__string.hpp +78 -0
- package/nitrogen/generated/android/c++/JFunc_void_std__optional_BLEDevice__std__optional_std__string_.hpp +86 -0
- package/nitrogen/generated/android/c++/JFunc_void_std__string_std__shared_ptr_ArrayBuffer_.hpp +78 -0
- package/nitrogen/generated/android/c++/JHybridNativeBleNitroSpec.cpp +29 -20
- package/nitrogen/generated/android/c++/JHybridNativeBleNitroSpec.hpp +5 -4
- package/nitrogen/generated/android/c++/JManufacturerData.hpp +3 -0
- package/nitrogen/generated/android/c++/JManufacturerDataEntry.hpp +7 -15
- package/nitrogen/generated/android/c++/JScanFilter.hpp +8 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/AndroidScanMode.kt +23 -0
- 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
- 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
- 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
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/HybridNativeBleNitroSpec.kt +12 -8
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/ManufacturerDataEntry.kt +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/ScanFilter.kt +4 -1
- package/nitrogen/generated/ios/BleNitro-Swift-Cxx-Bridge.cpp +15 -15
- package/nitrogen/generated/ios/BleNitro-Swift-Cxx-Bridge.hpp +69 -56
- package/nitrogen/generated/ios/BleNitro-Swift-Cxx-Umbrella.hpp +6 -0
- package/nitrogen/generated/ios/c++/HybridNativeBleNitroSpecSwift.hpp +23 -6
- package/nitrogen/generated/ios/swift/AndroidScanMode.swift +48 -0
- 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
- package/nitrogen/generated/ios/swift/Func_void_std__optional_BLEDevice__std__optional_std__string_.swift +59 -0
- package/nitrogen/generated/ios/swift/{Func_void_std__string_std__vector_double_.swift → Func_void_std__string_std__shared_ptr_ArrayBuffer_.swift} +11 -11
- package/nitrogen/generated/ios/swift/HybridNativeBleNitroSpec.swift +5 -4
- package/nitrogen/generated/ios/swift/HybridNativeBleNitroSpec_cxx.swift +41 -29
- package/nitrogen/generated/ios/swift/ManufacturerDataEntry.swift +5 -17
- package/nitrogen/generated/ios/swift/ScanFilter.swift +13 -2
- package/nitrogen/generated/shared/c++/AndroidScanMode.hpp +64 -0
- package/nitrogen/generated/shared/c++/HybridNativeBleNitroSpec.cpp +1 -0
- package/nitrogen/generated/shared/c++/HybridNativeBleNitroSpec.hpp +10 -6
- package/nitrogen/generated/shared/c++/ManufacturerDataEntry.hpp +8 -7
- package/nitrogen/generated/shared/c++/ScanFilter.hpp +9 -3
- package/package.json +1 -1
- package/plugin/build/index.d.ts +2 -0
- package/plugin/build/index.js +2 -0
- package/plugin/build/withBleNitro.d.ts +5 -1
- package/plugin/build/withBleNitro.js +18 -7
- package/react-native.config.js +10 -2
- package/src/__tests__/index.test.ts +48 -13
- package/src/index.ts +74 -16
- package/src/specs/NativeBleNitro.nitro.ts +17 -5
- package/nitrogen/generated/android/c++/JFunc_void_BLEDevice.hpp +0 -82
- package/nitrogen/generated/android/c++/JFunc_void_bool_std__vector_double__std__string.hpp +0 -86
- package/nitrogen/generated/android/c++/JFunc_void_std__string_std__vector_double_.hpp +0 -86
- 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::
|
|
79
|
+
// pragma MARK: std::optional<BLEDevice>
|
|
85
80
|
/**
|
|
86
|
-
* Specialized version of `std::
|
|
81
|
+
* Specialized version of `std::optional<BLEDevice>`.
|
|
87
82
|
*/
|
|
88
|
-
using
|
|
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
|
-
*
|
|
90
|
+
* Specialized version of `std::optional<std::string>`.
|
|
91
91
|
*/
|
|
92
|
-
|
|
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
|
|
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
|
|
112
|
+
std::unique_ptr<std::function<void(const std::optional<BLEDevice>& /* device */, const std::optional<std::string>& /* error */)>> _function;
|
|
100
113
|
} SWIFT_NONCOPYABLE;
|
|
101
|
-
|
|
102
|
-
inline
|
|
103
|
-
return
|
|
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::
|
|
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::
|
|
207
|
+
* Specialized version of `std::function<void(bool, const std::shared_ptr<ArrayBuffer>&, const std::string&)>`.
|
|
195
208
|
*/
|
|
196
|
-
using
|
|
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::
|
|
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
|
|
213
|
+
class Func_void_bool_std__shared_ptr_ArrayBuffer__std__string_Wrapper final {
|
|
201
214
|
public:
|
|
202
|
-
explicit
|
|
203
|
-
inline void call(bool success,
|
|
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::
|
|
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
|
-
|
|
210
|
-
inline
|
|
211
|
-
return
|
|
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::
|
|
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::
|
|
229
|
+
* Specialized version of `std::function<void(const std::string&, const std::shared_ptr<ArrayBuffer>&)>`.
|
|
217
230
|
*/
|
|
218
|
-
using
|
|
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::
|
|
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
|
|
235
|
+
class Func_void_std__string_std__shared_ptr_ArrayBuffer__Wrapper final {
|
|
223
236
|
public:
|
|
224
|
-
explicit
|
|
225
|
-
inline void call(std::string characteristicId,
|
|
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::
|
|
242
|
+
std::unique_ptr<std::function<void(const std::string& /* characteristicId */, const std::shared_ptr<ArrayBuffer>& /* data */)>> _function;
|
|
230
243
|
} SWIFT_NONCOPYABLE;
|
|
231
|
-
|
|
232
|
-
inline
|
|
233
|
-
return
|
|
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 <
|
|
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
|
|
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::
|
|
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::
|
|
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::
|
|
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
|
-
///
|
|
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:
|
|
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
|
|
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:
|
|
18
|
+
private let closure: (_ success: Bool, _ data: ArrayBuffer, _ error: String) -> Void
|
|
19
19
|
|
|
20
|
-
public init(_ closure: @escaping (_ success: Bool, _ data:
|
|
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:
|
|
26
|
-
self.closure(success, data
|
|
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 `
|
|
40
|
-
* The pointer has to be a retained opaque `Unmanaged<
|
|
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) ->
|
|
45
|
-
return Unmanaged<
|
|
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
|
-
///
|
|
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:
|
|
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
|
|
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:
|
|
18
|
+
private let closure: (_ characteristicId: String, _ data: ArrayBuffer) -> Void
|
|
19
19
|
|
|
20
|
-
public init(_ closure: @escaping (_ characteristicId: String, _ data:
|
|
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:
|
|
26
|
-
self.closure(String(characteristicId), data
|
|
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 `
|
|
40
|
-
* The pointer has to be a retained opaque `Unmanaged<
|
|
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) ->
|
|
45
|
-
return Unmanaged<
|
|
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:
|
|
28
|
-
func writeCharacteristic(deviceId: String, serviceId: String, characteristicId: String, data:
|
|
29
|
-
func subscribeToCharacteristic(deviceId: String, serviceId: String, characteristicId: String, updateCallback: @escaping (_ characteristicId: String, _ data:
|
|
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
|