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.
- package/README.md +25 -17
- package/ios/BleNitroBleManager.swift +126 -57
- package/ios/BlePeripheralDelegate.swift +36 -8
- package/lib/commonjs/index.d.ts +29 -20
- package/lib/commonjs/index.d.ts.map +1 -1
- package/lib/commonjs/index.js +113 -143
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/specs/NativeBleNitro.nitro.d.ts +19 -14
- package/lib/commonjs/specs/NativeBleNitro.nitro.d.ts.map +1 -1
- package/lib/commonjs/specs/NativeBleNitro.nitro.js.map +1 -1
- package/lib/index.d.ts +29 -20
- package/lib/index.js +112 -142
- package/lib/specs/NativeBleNitro.nitro.d.ts +19 -14
- package/nitrogen/generated/android/BleNitroOnLoad.cpp +6 -12
- package/nitrogen/generated/android/c++/JBLEDevice.hpp +3 -0
- package/nitrogen/generated/android/c++/JFunc_void_BLEDevice.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__string_std__shared_ptr_ArrayBuffer_.hpp +78 -0
- package/nitrogen/generated/android/c++/JHybridNativeBleNitroSpec.cpp +111 -65
- package/nitrogen/generated/android/c++/JHybridNativeBleNitroSpec.hpp +13 -13
- package/nitrogen/generated/android/c++/JManufacturerData.hpp +3 -0
- package/nitrogen/generated/android/c++/JManufacturerDataEntry.hpp +7 -15
- package/nitrogen/generated/android/c++/JOperationResult.hpp +58 -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_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 +20 -65
- 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/OperationResult.kt +32 -0
- package/nitrogen/generated/ios/BleNitro-Swift-Cxx-Bridge.cpp +15 -39
- package/nitrogen/generated/ios/BleNitro-Swift-Cxx-Bridge.hpp +108 -113
- package/nitrogen/generated/ios/BleNitro-Swift-Cxx-Umbrella.hpp +6 -0
- package/nitrogen/generated/ios/c++/HybridNativeBleNitroSpecSwift.hpp +57 -28
- 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__string_std__vector_double_.swift → Func_void_std__string_std__shared_ptr_ArrayBuffer_.swift} +11 -11
- package/nitrogen/generated/ios/swift/HybridNativeBleNitroSpec.swift +13 -13
- package/nitrogen/generated/ios/swift/HybridNativeBleNitroSpec_cxx.swift +84 -136
- package/nitrogen/generated/ios/swift/ManufacturerDataEntry.swift +5 -17
- package/nitrogen/generated/ios/swift/OperationResult.swift +64 -0
- package/nitrogen/generated/shared/c++/HybridNativeBleNitroSpec.cpp +1 -1
- package/nitrogen/generated/shared/c++/HybridNativeBleNitroSpec.hpp +20 -14
- package/nitrogen/generated/shared/c++/ManufacturerDataEntry.hpp +8 -7
- package/nitrogen/generated/shared/c++/OperationResult.hpp +72 -0
- package/package.json +1 -1
- package/react-native.config.js +10 -2
- package/src/__tests__/index.test.ts +19 -22
- package/src/index.ts +147 -164
- package/src/specs/NativeBleNitro.nitro.ts +22 -14
- package/nitrogen/generated/android/c++/JFunc_void_bool.hpp +0 -74
- 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/android/c++/JFunc_void_std__vector_BLEDevice_.hpp +0 -99
- package/nitrogen/generated/android/c++/JFunc_void_std__vector_std__string_.hpp +0 -93
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/Func_void_bool.kt +0 -81
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/Func_void_std__vector_BLEDevice_.kt +0 -81
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/Func_void_std__vector_std__string_.kt +0 -81
- package/nitrogen/generated/ios/swift/Func_void_bool.swift +0 -47
- package/nitrogen/generated/ios/swift/Func_void_std__vector_BLEDevice_.swift +0 -47
- package/nitrogen/generated/ios/swift/Func_void_std__vector_std__string_.swift +0 -47
package/nitrogen/generated/android/c++/JFunc_void_bool_std__shared_ptr_ArrayBuffer__std__string.hpp
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JFunc_void_bool_std__shared_ptr_ArrayBuffer__std__string.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include <functional>
|
|
12
|
+
|
|
13
|
+
#include <NitroModules/ArrayBuffer.hpp>
|
|
14
|
+
#include <string>
|
|
15
|
+
#include <functional>
|
|
16
|
+
#include <NitroModules/JArrayBuffer.hpp>
|
|
17
|
+
#include <NitroModules/JUnit.hpp>
|
|
18
|
+
|
|
19
|
+
namespace margelo::nitro::co::zyke::ble {
|
|
20
|
+
|
|
21
|
+
using namespace facebook;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Represents the Java/Kotlin callback `(success: Boolean, data: ArrayBuffer, error: String) -> Unit`.
|
|
25
|
+
* This can be passed around between C++ and Java/Kotlin.
|
|
26
|
+
*/
|
|
27
|
+
struct JFunc_void_bool_std__shared_ptr_ArrayBuffer__std__string: public jni::JavaClass<JFunc_void_bool_std__shared_ptr_ArrayBuffer__std__string> {
|
|
28
|
+
public:
|
|
29
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/co/zyke/ble/Func_void_bool_std__shared_ptr_ArrayBuffer__std__string;";
|
|
30
|
+
|
|
31
|
+
public:
|
|
32
|
+
/**
|
|
33
|
+
* Invokes the function this `JFunc_void_bool_std__shared_ptr_ArrayBuffer__std__string` instance holds through JNI.
|
|
34
|
+
*/
|
|
35
|
+
void invoke(bool success, const std::shared_ptr<ArrayBuffer>& data, const std::string& error) const {
|
|
36
|
+
static const auto method = javaClassStatic()->getMethod<void(jboolean /* success */, jni::alias_ref<JArrayBuffer::javaobject> /* data */, jni::alias_ref<jni::JString> /* error */)>("invoke");
|
|
37
|
+
method(self(), success, JArrayBuffer::wrap(data), jni::make_jstring(error));
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* An implementation of Func_void_bool_std__shared_ptr_ArrayBuffer__std__string that is backed by a C++ implementation (using `std::function<...>`)
|
|
43
|
+
*/
|
|
44
|
+
struct JFunc_void_bool_std__shared_ptr_ArrayBuffer__std__string_cxx final: public jni::HybridClass<JFunc_void_bool_std__shared_ptr_ArrayBuffer__std__string_cxx, JFunc_void_bool_std__shared_ptr_ArrayBuffer__std__string> {
|
|
45
|
+
public:
|
|
46
|
+
static jni::local_ref<JFunc_void_bool_std__shared_ptr_ArrayBuffer__std__string::javaobject> fromCpp(const std::function<void(bool /* success */, const std::shared_ptr<ArrayBuffer>& /* data */, const std::string& /* error */)>& func) {
|
|
47
|
+
return JFunc_void_bool_std__shared_ptr_ArrayBuffer__std__string_cxx::newObjectCxxArgs(func);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public:
|
|
51
|
+
/**
|
|
52
|
+
* Invokes the C++ `std::function<...>` this `JFunc_void_bool_std__shared_ptr_ArrayBuffer__std__string_cxx` instance holds.
|
|
53
|
+
*/
|
|
54
|
+
void invoke_cxx(jboolean success, jni::alias_ref<JArrayBuffer::javaobject> data, jni::alias_ref<jni::JString> error) {
|
|
55
|
+
_func(static_cast<bool>(success), data->cthis()->getArrayBuffer(), error->toStdString());
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public:
|
|
59
|
+
[[nodiscard]]
|
|
60
|
+
inline const std::function<void(bool /* success */, const std::shared_ptr<ArrayBuffer>& /* data */, const std::string& /* error */)>& getFunction() const {
|
|
61
|
+
return _func;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
public:
|
|
65
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/co/zyke/ble/Func_void_bool_std__shared_ptr_ArrayBuffer__std__string_cxx;";
|
|
66
|
+
static void registerNatives() {
|
|
67
|
+
registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_bool_std__shared_ptr_ArrayBuffer__std__string_cxx::invoke_cxx)});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
private:
|
|
71
|
+
explicit JFunc_void_bool_std__shared_ptr_ArrayBuffer__std__string_cxx(const std::function<void(bool /* success */, const std::shared_ptr<ArrayBuffer>& /* data */, const std::string& /* error */)>& func): _func(func) { }
|
|
72
|
+
|
|
73
|
+
private:
|
|
74
|
+
friend HybridBase;
|
|
75
|
+
std::function<void(bool /* success */, const std::shared_ptr<ArrayBuffer>& /* data */, const std::string& /* error */)> _func;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
} // namespace margelo::nitro::co::zyke::ble
|
package/nitrogen/generated/android/c++/JFunc_void_std__string_std__shared_ptr_ArrayBuffer_.hpp
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JFunc_void_std__string_std__shared_ptr_ArrayBuffer_.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include <functional>
|
|
12
|
+
|
|
13
|
+
#include <string>
|
|
14
|
+
#include <NitroModules/ArrayBuffer.hpp>
|
|
15
|
+
#include <functional>
|
|
16
|
+
#include <NitroModules/JArrayBuffer.hpp>
|
|
17
|
+
#include <NitroModules/JUnit.hpp>
|
|
18
|
+
|
|
19
|
+
namespace margelo::nitro::co::zyke::ble {
|
|
20
|
+
|
|
21
|
+
using namespace facebook;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Represents the Java/Kotlin callback `(characteristicId: String, data: ArrayBuffer) -> Unit`.
|
|
25
|
+
* This can be passed around between C++ and Java/Kotlin.
|
|
26
|
+
*/
|
|
27
|
+
struct JFunc_void_std__string_std__shared_ptr_ArrayBuffer_: public jni::JavaClass<JFunc_void_std__string_std__shared_ptr_ArrayBuffer_> {
|
|
28
|
+
public:
|
|
29
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/co/zyke/ble/Func_void_std__string_std__shared_ptr_ArrayBuffer_;";
|
|
30
|
+
|
|
31
|
+
public:
|
|
32
|
+
/**
|
|
33
|
+
* Invokes the function this `JFunc_void_std__string_std__shared_ptr_ArrayBuffer_` instance holds through JNI.
|
|
34
|
+
*/
|
|
35
|
+
void invoke(const std::string& characteristicId, const std::shared_ptr<ArrayBuffer>& data) const {
|
|
36
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* characteristicId */, jni::alias_ref<JArrayBuffer::javaobject> /* data */)>("invoke");
|
|
37
|
+
method(self(), jni::make_jstring(characteristicId), JArrayBuffer::wrap(data));
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* An implementation of Func_void_std__string_std__shared_ptr_ArrayBuffer_ that is backed by a C++ implementation (using `std::function<...>`)
|
|
43
|
+
*/
|
|
44
|
+
struct JFunc_void_std__string_std__shared_ptr_ArrayBuffer__cxx final: public jni::HybridClass<JFunc_void_std__string_std__shared_ptr_ArrayBuffer__cxx, JFunc_void_std__string_std__shared_ptr_ArrayBuffer_> {
|
|
45
|
+
public:
|
|
46
|
+
static jni::local_ref<JFunc_void_std__string_std__shared_ptr_ArrayBuffer_::javaobject> fromCpp(const std::function<void(const std::string& /* characteristicId */, const std::shared_ptr<ArrayBuffer>& /* data */)>& func) {
|
|
47
|
+
return JFunc_void_std__string_std__shared_ptr_ArrayBuffer__cxx::newObjectCxxArgs(func);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public:
|
|
51
|
+
/**
|
|
52
|
+
* Invokes the C++ `std::function<...>` this `JFunc_void_std__string_std__shared_ptr_ArrayBuffer__cxx` instance holds.
|
|
53
|
+
*/
|
|
54
|
+
void invoke_cxx(jni::alias_ref<jni::JString> characteristicId, jni::alias_ref<JArrayBuffer::javaobject> data) {
|
|
55
|
+
_func(characteristicId->toStdString(), data->cthis()->getArrayBuffer());
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public:
|
|
59
|
+
[[nodiscard]]
|
|
60
|
+
inline const std::function<void(const std::string& /* characteristicId */, const std::shared_ptr<ArrayBuffer>& /* data */)>& getFunction() const {
|
|
61
|
+
return _func;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
public:
|
|
65
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/co/zyke/ble/Func_void_std__string_std__shared_ptr_ArrayBuffer__cxx;";
|
|
66
|
+
static void registerNatives() {
|
|
67
|
+
registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_std__string_std__shared_ptr_ArrayBuffer__cxx::invoke_cxx)});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
private:
|
|
71
|
+
explicit JFunc_void_std__string_std__shared_ptr_ArrayBuffer__cxx(const std::function<void(const std::string& /* characteristicId */, const std::shared_ptr<ArrayBuffer>& /* data */)>& func): _func(func) { }
|
|
72
|
+
|
|
73
|
+
private:
|
|
74
|
+
friend HybridBase;
|
|
75
|
+
std::function<void(const std::string& /* characteristicId */, const std::shared_ptr<ArrayBuffer>& /* data */)> _func;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
} // namespace margelo::nitro::co::zyke::ble
|
|
@@ -7,43 +7,49 @@
|
|
|
7
7
|
|
|
8
8
|
#include "JHybridNativeBleNitroSpec.hpp"
|
|
9
9
|
|
|
10
|
-
// Forward declaration of `ScanFilter` to properly resolve imports.
|
|
11
|
-
namespace margelo::nitro::co::zyke::ble { struct ScanFilter; }
|
|
12
10
|
// Forward declaration of `BLEDevice` to properly resolve imports.
|
|
13
11
|
namespace margelo::nitro::co::zyke::ble { struct BLEDevice; }
|
|
14
12
|
// Forward declaration of `ManufacturerData` to properly resolve imports.
|
|
15
13
|
namespace margelo::nitro::co::zyke::ble { struct ManufacturerData; }
|
|
16
14
|
// Forward declaration of `ManufacturerDataEntry` to properly resolve imports.
|
|
17
15
|
namespace margelo::nitro::co::zyke::ble { struct ManufacturerDataEntry; }
|
|
16
|
+
// Forward declaration of `ArrayBuffer` to properly resolve imports.
|
|
17
|
+
namespace NitroModules { class ArrayBuffer; }
|
|
18
18
|
// Forward declaration of `BLEState` to properly resolve imports.
|
|
19
19
|
namespace margelo::nitro::co::zyke::ble { enum class BLEState; }
|
|
20
|
+
// Forward declaration of `OperationResult` to properly resolve imports.
|
|
21
|
+
namespace margelo::nitro::co::zyke::ble { struct OperationResult; }
|
|
22
|
+
// Forward declaration of `ScanFilter` to properly resolve imports.
|
|
23
|
+
namespace margelo::nitro::co::zyke::ble { struct ScanFilter; }
|
|
20
24
|
|
|
21
|
-
#include <NitroModules/Promise.hpp>
|
|
22
|
-
#include <NitroModules/JPromise.hpp>
|
|
23
|
-
#include "ScanFilter.hpp"
|
|
24
|
-
#include "JScanFilter.hpp"
|
|
25
|
-
#include <string>
|
|
26
|
-
#include <vector>
|
|
27
25
|
#include "BLEDevice.hpp"
|
|
28
|
-
#include <
|
|
29
|
-
#include "JFunc_void_BLEDevice.hpp"
|
|
26
|
+
#include <vector>
|
|
30
27
|
#include "JBLEDevice.hpp"
|
|
28
|
+
#include <string>
|
|
31
29
|
#include "ManufacturerData.hpp"
|
|
32
30
|
#include "JManufacturerData.hpp"
|
|
33
31
|
#include "ManufacturerDataEntry.hpp"
|
|
34
32
|
#include "JManufacturerDataEntry.hpp"
|
|
35
|
-
#include
|
|
36
|
-
#include
|
|
37
|
-
#include
|
|
38
|
-
#include "
|
|
33
|
+
#include <NitroModules/ArrayBuffer.hpp>
|
|
34
|
+
#include <NitroModules/JArrayBuffer.hpp>
|
|
35
|
+
#include <NitroModules/JUnit.hpp>
|
|
36
|
+
#include "BLEState.hpp"
|
|
37
|
+
#include "JBLEState.hpp"
|
|
38
|
+
#include "OperationResult.hpp"
|
|
39
|
+
#include "JOperationResult.hpp"
|
|
39
40
|
#include <optional>
|
|
41
|
+
#include <NitroModules/Promise.hpp>
|
|
42
|
+
#include <NitroModules/JPromise.hpp>
|
|
43
|
+
#include "ScanFilter.hpp"
|
|
44
|
+
#include "JScanFilter.hpp"
|
|
45
|
+
#include <functional>
|
|
46
|
+
#include "JFunc_void_BLEDevice.hpp"
|
|
47
|
+
#include "JFunc_void_bool_std__string_std__string.hpp"
|
|
40
48
|
#include "JFunc_void_std__string_bool_std__string.hpp"
|
|
41
|
-
#include "
|
|
42
|
-
#include "
|
|
43
|
-
#include "
|
|
44
|
-
#include "BLEState.hpp"
|
|
49
|
+
#include "JFunc_void_bool_std__string.hpp"
|
|
50
|
+
#include "JFunc_void_bool_std__shared_ptr_ArrayBuffer__std__string.hpp"
|
|
51
|
+
#include "JFunc_void_std__string_std__shared_ptr_ArrayBuffer_.hpp"
|
|
45
52
|
#include "JFunc_void_BLEState.hpp"
|
|
46
|
-
#include "JBLEState.hpp"
|
|
47
53
|
|
|
48
54
|
namespace margelo::nitro::co::zyke::ble {
|
|
49
55
|
|
|
@@ -75,17 +81,37 @@ namespace margelo::nitro::co::zyke::ble {
|
|
|
75
81
|
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JScanFilter> /* filter */, jni::alias_ref<JFunc_void_BLEDevice::javaobject> /* callback */)>("startScan_cxx");
|
|
76
82
|
method(_javaPart, JScanFilter::fromCpp(filter), JFunc_void_BLEDevice_cxx::fromCpp(callback));
|
|
77
83
|
}
|
|
78
|
-
|
|
79
|
-
static const auto method = javaClassStatic()->getMethod<
|
|
80
|
-
method(_javaPart
|
|
81
|
-
|
|
82
|
-
void JHybridNativeBleNitroSpec::isScanning(const std::function<void(bool /* result */)>& callback) {
|
|
83
|
-
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_bool::javaobject> /* callback */)>("isScanning_cxx");
|
|
84
|
-
method(_javaPart, JFunc_void_bool_cxx::fromCpp(callback));
|
|
84
|
+
bool JHybridNativeBleNitroSpec::stopScan() {
|
|
85
|
+
static const auto method = javaClassStatic()->getMethod<jboolean()>("stopScan");
|
|
86
|
+
auto __result = method(_javaPart);
|
|
87
|
+
return static_cast<bool>(__result);
|
|
85
88
|
}
|
|
86
|
-
|
|
87
|
-
static const auto method = javaClassStatic()->getMethod<
|
|
88
|
-
method(_javaPart
|
|
89
|
+
bool JHybridNativeBleNitroSpec::isScanning() {
|
|
90
|
+
static const auto method = javaClassStatic()->getMethod<jboolean()>("isScanning");
|
|
91
|
+
auto __result = method(_javaPart);
|
|
92
|
+
return static_cast<bool>(__result);
|
|
93
|
+
}
|
|
94
|
+
std::vector<BLEDevice> JHybridNativeBleNitroSpec::getConnectedDevices(const std::vector<std::string>& services) {
|
|
95
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JArrayClass<JBLEDevice>>(jni::alias_ref<jni::JArrayClass<jni::JString>> /* services */)>("getConnectedDevices");
|
|
96
|
+
auto __result = method(_javaPart, [&]() {
|
|
97
|
+
size_t __size = services.size();
|
|
98
|
+
jni::local_ref<jni::JArrayClass<jni::JString>> __array = jni::JArrayClass<jni::JString>::newArray(__size);
|
|
99
|
+
for (size_t __i = 0; __i < __size; __i++) {
|
|
100
|
+
const auto& __element = services[__i];
|
|
101
|
+
__array->setElement(__i, *jni::make_jstring(__element));
|
|
102
|
+
}
|
|
103
|
+
return __array;
|
|
104
|
+
}());
|
|
105
|
+
return [&]() {
|
|
106
|
+
size_t __size = __result->size();
|
|
107
|
+
std::vector<BLEDevice> __vector;
|
|
108
|
+
__vector.reserve(__size);
|
|
109
|
+
for (size_t __i = 0; __i < __size; __i++) {
|
|
110
|
+
auto __element = __result->getElement(__i);
|
|
111
|
+
__vector.push_back(__element->toCpp());
|
|
112
|
+
}
|
|
113
|
+
return __vector;
|
|
114
|
+
}();
|
|
89
115
|
}
|
|
90
116
|
void JHybridNativeBleNitroSpec::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) {
|
|
91
117
|
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* deviceId */, jni::alias_ref<JFunc_void_bool_std__string_std__string::javaobject> /* callback */, jni::alias_ref<JFunc_void_std__string_bool_std__string::javaobject> /* disconnectCallback */)>("connect_cxx");
|
|
@@ -95,62 +121,82 @@ namespace margelo::nitro::co::zyke::ble {
|
|
|
95
121
|
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* deviceId */, jni::alias_ref<JFunc_void_bool_std__string::javaobject> /* callback */)>("disconnect_cxx");
|
|
96
122
|
method(_javaPart, jni::make_jstring(deviceId), JFunc_void_bool_std__string_cxx::fromCpp(callback));
|
|
97
123
|
}
|
|
98
|
-
|
|
99
|
-
static const auto method = javaClassStatic()->getMethod<
|
|
100
|
-
method(_javaPart, jni::make_jstring(deviceId)
|
|
124
|
+
bool JHybridNativeBleNitroSpec::isConnected(const std::string& deviceId) {
|
|
125
|
+
static const auto method = javaClassStatic()->getMethod<jboolean(jni::alias_ref<jni::JString> /* deviceId */)>("isConnected");
|
|
126
|
+
auto __result = method(_javaPart, jni::make_jstring(deviceId));
|
|
127
|
+
return static_cast<bool>(__result);
|
|
128
|
+
}
|
|
129
|
+
double JHybridNativeBleNitroSpec::requestMTU(const std::string& deviceId, double mtu) {
|
|
130
|
+
static const auto method = javaClassStatic()->getMethod<double(jni::alias_ref<jni::JString> /* deviceId */, double /* mtu */)>("requestMTU");
|
|
131
|
+
auto __result = method(_javaPart, jni::make_jstring(deviceId), mtu);
|
|
132
|
+
return __result;
|
|
101
133
|
}
|
|
102
134
|
void JHybridNativeBleNitroSpec::discoverServices(const std::string& deviceId, const std::function<void(bool /* success */, const std::string& /* error */)>& callback) {
|
|
103
135
|
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* deviceId */, jni::alias_ref<JFunc_void_bool_std__string::javaobject> /* callback */)>("discoverServices_cxx");
|
|
104
136
|
method(_javaPart, jni::make_jstring(deviceId), JFunc_void_bool_std__string_cxx::fromCpp(callback));
|
|
105
137
|
}
|
|
106
|
-
|
|
107
|
-
static const auto method = javaClassStatic()->getMethod<
|
|
108
|
-
method(_javaPart, jni::make_jstring(deviceId)
|
|
138
|
+
std::vector<std::string> JHybridNativeBleNitroSpec::getServices(const std::string& deviceId) {
|
|
139
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JArrayClass<jni::JString>>(jni::alias_ref<jni::JString> /* deviceId */)>("getServices");
|
|
140
|
+
auto __result = method(_javaPart, jni::make_jstring(deviceId));
|
|
141
|
+
return [&]() {
|
|
142
|
+
size_t __size = __result->size();
|
|
143
|
+
std::vector<std::string> __vector;
|
|
144
|
+
__vector.reserve(__size);
|
|
145
|
+
for (size_t __i = 0; __i < __size; __i++) {
|
|
146
|
+
auto __element = __result->getElement(__i);
|
|
147
|
+
__vector.push_back(__element->toStdString());
|
|
148
|
+
}
|
|
149
|
+
return __vector;
|
|
150
|
+
}();
|
|
109
151
|
}
|
|
110
|
-
|
|
111
|
-
static const auto method = javaClassStatic()->getMethod<
|
|
112
|
-
method(_javaPart, jni::make_jstring(deviceId), jni::make_jstring(serviceId)
|
|
152
|
+
std::vector<std::string> JHybridNativeBleNitroSpec::getCharacteristics(const std::string& deviceId, const std::string& serviceId) {
|
|
153
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JArrayClass<jni::JString>>(jni::alias_ref<jni::JString> /* deviceId */, jni::alias_ref<jni::JString> /* serviceId */)>("getCharacteristics");
|
|
154
|
+
auto __result = method(_javaPart, jni::make_jstring(deviceId), jni::make_jstring(serviceId));
|
|
155
|
+
return [&]() {
|
|
156
|
+
size_t __size = __result->size();
|
|
157
|
+
std::vector<std::string> __vector;
|
|
158
|
+
__vector.reserve(__size);
|
|
159
|
+
for (size_t __i = 0; __i < __size; __i++) {
|
|
160
|
+
auto __element = __result->getElement(__i);
|
|
161
|
+
__vector.push_back(__element->toStdString());
|
|
162
|
+
}
|
|
163
|
+
return __vector;
|
|
164
|
+
}();
|
|
113
165
|
}
|
|
114
|
-
void JHybridNativeBleNitroSpec::readCharacteristic(const std::string& deviceId, const std::string& serviceId, const std::string& characteristicId, const std::function<void(bool /* success */, const std::
|
|
115
|
-
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* deviceId */, jni::alias_ref<jni::JString> /* serviceId */, jni::alias_ref<jni::JString> /* characteristicId */, jni::alias_ref<
|
|
116
|
-
method(_javaPart, jni::make_jstring(deviceId), jni::make_jstring(serviceId), jni::make_jstring(characteristicId),
|
|
166
|
+
void JHybridNativeBleNitroSpec::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) {
|
|
167
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* deviceId */, jni::alias_ref<jni::JString> /* serviceId */, jni::alias_ref<jni::JString> /* characteristicId */, jni::alias_ref<JFunc_void_bool_std__shared_ptr_ArrayBuffer__std__string::javaobject> /* callback */)>("readCharacteristic_cxx");
|
|
168
|
+
method(_javaPart, jni::make_jstring(deviceId), jni::make_jstring(serviceId), jni::make_jstring(characteristicId), JFunc_void_bool_std__shared_ptr_ArrayBuffer__std__string_cxx::fromCpp(callback));
|
|
117
169
|
}
|
|
118
|
-
void JHybridNativeBleNitroSpec::writeCharacteristic(const std::string& deviceId, const std::string& serviceId, const std::string& characteristicId, const std::
|
|
119
|
-
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* deviceId */, jni::alias_ref<jni::JString> /* serviceId */, jni::alias_ref<jni::JString> /* characteristicId */, jni::alias_ref<
|
|
120
|
-
method(_javaPart, jni::make_jstring(deviceId), jni::make_jstring(serviceId), jni::make_jstring(characteristicId),
|
|
121
|
-
size_t __size = data.size();
|
|
122
|
-
jni::local_ref<jni::JArrayDouble> __array = jni::JArrayDouble::newArray(__size);
|
|
123
|
-
__array->setRegion(0, __size, data.data());
|
|
124
|
-
return __array;
|
|
125
|
-
}(), withResponse, JFunc_void_bool_std__string_cxx::fromCpp(callback));
|
|
170
|
+
void JHybridNativeBleNitroSpec::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) {
|
|
171
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* deviceId */, jni::alias_ref<jni::JString> /* serviceId */, jni::alias_ref<jni::JString> /* characteristicId */, jni::alias_ref<JArrayBuffer::javaobject> /* data */, jboolean /* withResponse */, jni::alias_ref<JFunc_void_bool_std__string::javaobject> /* callback */)>("writeCharacteristic_cxx");
|
|
172
|
+
method(_javaPart, jni::make_jstring(deviceId), jni::make_jstring(serviceId), jni::make_jstring(characteristicId), JArrayBuffer::wrap(data), withResponse, JFunc_void_bool_std__string_cxx::fromCpp(callback));
|
|
126
173
|
}
|
|
127
|
-
void JHybridNativeBleNitroSpec::subscribeToCharacteristic(const std::string& deviceId, const std::string& serviceId, const std::string& characteristicId, const std::function<void(const std::string& /* characteristicId */, const std::
|
|
128
|
-
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* deviceId */, jni::alias_ref<jni::JString> /* serviceId */, jni::alias_ref<jni::JString> /* characteristicId */, jni::alias_ref<
|
|
129
|
-
method(_javaPart, jni::make_jstring(deviceId), jni::make_jstring(serviceId), jni::make_jstring(characteristicId),
|
|
174
|
+
void JHybridNativeBleNitroSpec::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) {
|
|
175
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* deviceId */, jni::alias_ref<jni::JString> /* serviceId */, jni::alias_ref<jni::JString> /* characteristicId */, jni::alias_ref<JFunc_void_std__string_std__shared_ptr_ArrayBuffer_::javaobject> /* updateCallback */, jni::alias_ref<JFunc_void_bool_std__string::javaobject> /* resultCallback */)>("subscribeToCharacteristic_cxx");
|
|
176
|
+
method(_javaPart, jni::make_jstring(deviceId), jni::make_jstring(serviceId), jni::make_jstring(characteristicId), JFunc_void_std__string_std__shared_ptr_ArrayBuffer__cxx::fromCpp(updateCallback), JFunc_void_bool_std__string_cxx::fromCpp(resultCallback));
|
|
130
177
|
}
|
|
131
178
|
void JHybridNativeBleNitroSpec::unsubscribeFromCharacteristic(const std::string& deviceId, const std::string& serviceId, const std::string& characteristicId, const std::function<void(bool /* success */, const std::string& /* error */)>& callback) {
|
|
132
179
|
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* deviceId */, jni::alias_ref<jni::JString> /* serviceId */, jni::alias_ref<jni::JString> /* characteristicId */, jni::alias_ref<JFunc_void_bool_std__string::javaobject> /* callback */)>("unsubscribeFromCharacteristic_cxx");
|
|
133
180
|
method(_javaPart, jni::make_jstring(deviceId), jni::make_jstring(serviceId), jni::make_jstring(characteristicId), JFunc_void_bool_std__string_cxx::fromCpp(callback));
|
|
134
181
|
}
|
|
135
|
-
void JHybridNativeBleNitroSpec::isBluetoothEnabled(const std::function<void(bool /* result */)>& callback) {
|
|
136
|
-
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_bool::javaobject> /* callback */)>("isBluetoothEnabled_cxx");
|
|
137
|
-
method(_javaPart, JFunc_void_bool_cxx::fromCpp(callback));
|
|
138
|
-
}
|
|
139
182
|
void JHybridNativeBleNitroSpec::requestBluetoothEnable(const std::function<void(bool /* success */, const std::string& /* error */)>& callback) {
|
|
140
183
|
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_bool_std__string::javaobject> /* callback */)>("requestBluetoothEnable_cxx");
|
|
141
184
|
method(_javaPart, JFunc_void_bool_std__string_cxx::fromCpp(callback));
|
|
142
185
|
}
|
|
143
|
-
|
|
144
|
-
static const auto method = javaClassStatic()->getMethod<
|
|
145
|
-
method(_javaPart
|
|
186
|
+
BLEState JHybridNativeBleNitroSpec::state() {
|
|
187
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JBLEState>()>("state");
|
|
188
|
+
auto __result = method(_javaPart);
|
|
189
|
+
return __result->toCpp();
|
|
146
190
|
}
|
|
147
|
-
|
|
148
|
-
static const auto method = javaClassStatic()->getMethod<
|
|
149
|
-
method(_javaPart, JFunc_void_BLEState_cxx::fromCpp(stateCallback)
|
|
191
|
+
OperationResult JHybridNativeBleNitroSpec::subscribeToStateChange(const std::function<void(BLEState /* state */)>& stateCallback) {
|
|
192
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JOperationResult>(jni::alias_ref<JFunc_void_BLEState::javaobject> /* stateCallback */)>("subscribeToStateChange_cxx");
|
|
193
|
+
auto __result = method(_javaPart, JFunc_void_BLEState_cxx::fromCpp(stateCallback));
|
|
194
|
+
return __result->toCpp();
|
|
150
195
|
}
|
|
151
|
-
|
|
152
|
-
static const auto method = javaClassStatic()->getMethod<
|
|
153
|
-
method(_javaPart
|
|
196
|
+
OperationResult JHybridNativeBleNitroSpec::unsubscribeFromStateChange() {
|
|
197
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JOperationResult>()>("unsubscribeFromStateChange");
|
|
198
|
+
auto __result = method(_javaPart);
|
|
199
|
+
return __result->toCpp();
|
|
154
200
|
}
|
|
155
201
|
std::shared_ptr<Promise<void>> JHybridNativeBleNitroSpec::openSettings() {
|
|
156
202
|
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("openSettings");
|
|
@@ -54,24 +54,24 @@ namespace margelo::nitro::co::zyke::ble {
|
|
|
54
54
|
public:
|
|
55
55
|
// Methods
|
|
56
56
|
void startScan(const ScanFilter& filter, const std::function<void(const BLEDevice& /* device */)>& callback) override;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
bool stopScan() override;
|
|
58
|
+
bool isScanning() override;
|
|
59
|
+
std::vector<BLEDevice> getConnectedDevices(const std::vector<std::string>& services) override;
|
|
60
60
|
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;
|
|
61
61
|
void disconnect(const std::string& deviceId, const std::function<void(bool /* success */, const std::string& /* error */)>& callback) override;
|
|
62
|
-
|
|
62
|
+
bool isConnected(const std::string& deviceId) override;
|
|
63
|
+
double requestMTU(const std::string& deviceId, double mtu) override;
|
|
63
64
|
void discoverServices(const std::string& deviceId, const std::function<void(bool /* success */, const std::string& /* error */)>& callback) override;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
void readCharacteristic(const std::string& deviceId, const std::string& serviceId, const std::string& characteristicId, const std::function<void(bool /* success */, const std::
|
|
67
|
-
void writeCharacteristic(const std::string& deviceId, const std::string& serviceId, const std::string& characteristicId, const std::
|
|
68
|
-
void subscribeToCharacteristic(const std::string& deviceId, const std::string& serviceId, const std::string& characteristicId, const std::function<void(const std::string& /* characteristicId */, const std::
|
|
65
|
+
std::vector<std::string> getServices(const std::string& deviceId) override;
|
|
66
|
+
std::vector<std::string> getCharacteristics(const std::string& deviceId, const std::string& serviceId) override;
|
|
67
|
+
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;
|
|
68
|
+
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;
|
|
69
|
+
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;
|
|
69
70
|
void unsubscribeFromCharacteristic(const std::string& deviceId, const std::string& serviceId, const std::string& characteristicId, const std::function<void(bool /* success */, const std::string& /* error */)>& callback) override;
|
|
70
|
-
void isBluetoothEnabled(const std::function<void(bool /* result */)>& callback) override;
|
|
71
71
|
void requestBluetoothEnable(const std::function<void(bool /* success */, const std::string& /* error */)>& callback) override;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
BLEState state() override;
|
|
73
|
+
OperationResult subscribeToStateChange(const std::function<void(BLEState /* state */)>& stateCallback) override;
|
|
74
|
+
OperationResult unsubscribeFromStateChange() override;
|
|
75
75
|
std::shared_ptr<Promise<void>> openSettings() override;
|
|
76
76
|
|
|
77
77
|
private:
|
|
@@ -10,8 +10,10 @@
|
|
|
10
10
|
#include <fbjni/fbjni.h>
|
|
11
11
|
#include "ManufacturerDataEntry.hpp"
|
|
12
12
|
|
|
13
|
+
#include <NitroModules/ArrayBuffer.hpp>
|
|
14
|
+
#include <NitroModules/JArrayBuffer.hpp>
|
|
15
|
+
#include <NitroModules/JUnit.hpp>
|
|
13
16
|
#include <string>
|
|
14
|
-
#include <vector>
|
|
15
17
|
|
|
16
18
|
namespace margelo::nitro::co::zyke::ble {
|
|
17
19
|
|
|
@@ -34,16 +36,11 @@ namespace margelo::nitro::co::zyke::ble {
|
|
|
34
36
|
static const auto clazz = javaClassStatic();
|
|
35
37
|
static const auto fieldId = clazz->getField<jni::JString>("id");
|
|
36
38
|
jni::local_ref<jni::JString> id = this->getFieldValue(fieldId);
|
|
37
|
-
static const auto fieldData = clazz->getField<
|
|
38
|
-
jni::local_ref<
|
|
39
|
+
static const auto fieldData = clazz->getField<JArrayBuffer::javaobject>("data");
|
|
40
|
+
jni::local_ref<JArrayBuffer::javaobject> data = this->getFieldValue(fieldData);
|
|
39
41
|
return ManufacturerDataEntry(
|
|
40
42
|
id->toStdString(),
|
|
41
|
-
|
|
42
|
-
size_t __size = data->size();
|
|
43
|
-
std::vector<double> __vector(__size);
|
|
44
|
-
data->getRegion(0, __size, __vector.data());
|
|
45
|
-
return __vector;
|
|
46
|
-
}()
|
|
43
|
+
data->cthis()->getArrayBuffer()
|
|
47
44
|
);
|
|
48
45
|
}
|
|
49
46
|
|
|
@@ -55,12 +52,7 @@ namespace margelo::nitro::co::zyke::ble {
|
|
|
55
52
|
static jni::local_ref<JManufacturerDataEntry::javaobject> fromCpp(const ManufacturerDataEntry& value) {
|
|
56
53
|
return newInstance(
|
|
57
54
|
jni::make_jstring(value.id),
|
|
58
|
-
|
|
59
|
-
size_t __size = value.data.size();
|
|
60
|
-
jni::local_ref<jni::JArrayDouble> __array = jni::JArrayDouble::newArray(__size);
|
|
61
|
-
__array->setRegion(0, __size, value.data.data());
|
|
62
|
-
return __array;
|
|
63
|
-
}()
|
|
55
|
+
JArrayBuffer::wrap(value.data)
|
|
64
56
|
);
|
|
65
57
|
}
|
|
66
58
|
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JOperationResult.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include "OperationResult.hpp"
|
|
12
|
+
|
|
13
|
+
#include <optional>
|
|
14
|
+
#include <string>
|
|
15
|
+
|
|
16
|
+
namespace margelo::nitro::co::zyke::ble {
|
|
17
|
+
|
|
18
|
+
using namespace facebook;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The C++ JNI bridge between the C++ struct "OperationResult" and the the Kotlin data class "OperationResult".
|
|
22
|
+
*/
|
|
23
|
+
struct JOperationResult final: public jni::JavaClass<JOperationResult> {
|
|
24
|
+
public:
|
|
25
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/co/zyke/ble/OperationResult;";
|
|
26
|
+
|
|
27
|
+
public:
|
|
28
|
+
/**
|
|
29
|
+
* Convert this Java/Kotlin-based struct to the C++ struct OperationResult by copying all values to C++.
|
|
30
|
+
*/
|
|
31
|
+
[[maybe_unused]]
|
|
32
|
+
[[nodiscard]]
|
|
33
|
+
OperationResult toCpp() const {
|
|
34
|
+
static const auto clazz = javaClassStatic();
|
|
35
|
+
static const auto fieldSuccess = clazz->getField<jboolean>("success");
|
|
36
|
+
jboolean success = this->getFieldValue(fieldSuccess);
|
|
37
|
+
static const auto fieldError = clazz->getField<jni::JString>("error");
|
|
38
|
+
jni::local_ref<jni::JString> error = this->getFieldValue(fieldError);
|
|
39
|
+
return OperationResult(
|
|
40
|
+
static_cast<bool>(success),
|
|
41
|
+
error != nullptr ? std::make_optional(error->toStdString()) : std::nullopt
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public:
|
|
46
|
+
/**
|
|
47
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
48
|
+
*/
|
|
49
|
+
[[maybe_unused]]
|
|
50
|
+
static jni::local_ref<JOperationResult::javaobject> fromCpp(const OperationResult& value) {
|
|
51
|
+
return newInstance(
|
|
52
|
+
value.success,
|
|
53
|
+
value.error.has_value() ? jni::make_jstring(value.error.value()) : nullptr
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
} // namespace margelo::nitro::co::zyke::ble
|