munim-bluetooth 0.3.20 → 0.3.22
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/nitrogen/generated/android/MunimBluetoothOnLoad.cpp +26 -16
- package/nitrogen/generated/android/MunimBluetoothOnLoad.hpp +13 -4
- package/nitrogen/generated/android/c++/JAdvertisingDataTypes.hpp +1 -1
- package/nitrogen/generated/android/c++/JAdvertisingOptions.hpp +1 -1
- package/nitrogen/generated/android/c++/JCharacteristicValue.hpp +1 -1
- package/nitrogen/generated/android/c++/JGATTCharacteristic.hpp +1 -1
- package/nitrogen/generated/android/c++/JGATTService.hpp +1 -1
- package/nitrogen/generated/android/c++/JHybridMunimBluetoothSpec.cpp +38 -44
- package/nitrogen/generated/android/c++/JHybridMunimBluetoothSpec.hpp +19 -22
- package/nitrogen/generated/android/c++/JScanMode.hpp +1 -1
- package/nitrogen/generated/android/c++/JScanOptions.hpp +1 -1
- package/nitrogen/generated/android/c++/JServiceDataEntry.hpp +1 -1
- package/nitrogen/generated/android/c++/JWriteType.hpp +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/HybridMunimBluetoothSpec.kt +1 -1
- package/nitrogen/generated/ios/MunimBluetooth-Swift-Cxx-Bridge.hpp +9 -9
- package/nitrogen/generated/ios/MunimBluetoothAutolinking.mm +1 -1
- package/nitrogen/generated/ios/MunimBluetoothAutolinking.swift +9 -27
- package/nitrogen/generated/ios/swift/AdvertisingDataTypes.swift +24 -4
- package/nitrogen/generated/ios/swift/AdvertisingOptions.swift +0 -1
- package/nitrogen/generated/ios/swift/CharacteristicValue.swift +0 -1
- package/nitrogen/generated/ios/swift/Func_void.swift +0 -1
- package/nitrogen/generated/ios/swift/Func_void_AdvertisingDataTypes.swift +0 -1
- package/nitrogen/generated/ios/swift/Func_void_CharacteristicValue.swift +0 -1
- package/nitrogen/generated/ios/swift/Func_void_bool.swift +0 -1
- package/nitrogen/generated/ios/swift/Func_void_double.swift +0 -1
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +0 -1
- package/nitrogen/generated/ios/swift/Func_void_std__vector_GATTService_.swift +0 -1
- package/nitrogen/generated/ios/swift/Func_void_std__vector_std__string_.swift +0 -1
- package/nitrogen/generated/ios/swift/GATTCharacteristic.swift +0 -1
- package/nitrogen/generated/ios/swift/GATTService.swift +0 -1
- package/nitrogen/generated/ios/swift/HybridMunimBluetoothSpec.swift +2 -5
- package/nitrogen/generated/ios/swift/HybridMunimBluetoothSpec_cxx.swift +0 -1
- package/nitrogen/generated/ios/swift/ScanOptions.swift +0 -1
- package/nitrogen/generated/ios/swift/ServiceDataEntry.swift +0 -1
- package/package.json +4 -4
|
@@ -21,24 +21,34 @@
|
|
|
21
21
|
namespace margelo::nitro::munimbluetooth {
|
|
22
22
|
|
|
23
23
|
int initialize(JavaVM* vm) {
|
|
24
|
+
return facebook::jni::initialize(vm, []() {
|
|
25
|
+
::margelo::nitro::munimbluetooth::registerAllNatives();
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
struct JHybridMunimBluetoothSpecImpl: public jni::JavaClass<JHybridMunimBluetoothSpecImpl, JHybridMunimBluetoothSpec::JavaPart> {
|
|
30
|
+
static constexpr auto kJavaDescriptor = "Lcom/munimbluetooth/HybridMunimBluetooth;";
|
|
31
|
+
static std::shared_ptr<JHybridMunimBluetoothSpec> create() {
|
|
32
|
+
static const auto constructorFn = javaClassStatic()->getConstructor<JHybridMunimBluetoothSpecImpl::javaobject()>();
|
|
33
|
+
jni::local_ref<JHybridMunimBluetoothSpec::JavaPart> javaPart = javaClassStatic()->newObject(constructorFn);
|
|
34
|
+
return javaPart->getJHybridMunimBluetoothSpec();
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
void registerAllNatives() {
|
|
24
39
|
using namespace margelo::nitro;
|
|
25
40
|
using namespace margelo::nitro::munimbluetooth;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
auto instance = object.create();
|
|
38
|
-
return instance->cthis()->shared();
|
|
39
|
-
}
|
|
40
|
-
);
|
|
41
|
-
});
|
|
41
|
+
|
|
42
|
+
// Register native JNI methods
|
|
43
|
+
margelo::nitro::munimbluetooth::JHybridMunimBluetoothSpec::CxxPart::registerNatives();
|
|
44
|
+
|
|
45
|
+
// Register Nitro Hybrid Objects
|
|
46
|
+
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
47
|
+
"MunimBluetooth",
|
|
48
|
+
[]() -> std::shared_ptr<HybridObject> {
|
|
49
|
+
return JHybridMunimBluetoothSpecImpl::create();
|
|
50
|
+
}
|
|
51
|
+
);
|
|
42
52
|
}
|
|
43
53
|
|
|
44
54
|
} // namespace margelo::nitro::munimbluetooth
|
|
@@ -6,20 +6,29 @@
|
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#include <jni.h>
|
|
9
|
+
#include <functional>
|
|
9
10
|
#include <NitroModules/NitroDefines.hpp>
|
|
10
11
|
|
|
11
12
|
namespace margelo::nitro::munimbluetooth {
|
|
12
13
|
|
|
14
|
+
[[deprecated("Use registerNatives() instead.")]]
|
|
15
|
+
int initialize(JavaVM* vm);
|
|
16
|
+
|
|
13
17
|
/**
|
|
14
|
-
*
|
|
15
|
-
* Call this in your `JNI_OnLoad` function (probably inside `cpp-adapter.cpp`)
|
|
18
|
+
* Register the native (C++) part of MunimBluetooth, and autolinks all Hybrid Objects.
|
|
19
|
+
* Call this in your `JNI_OnLoad` function (probably inside `cpp-adapter.cpp`),
|
|
20
|
+
* inside a `facebook::jni::initialize(vm, ...)` call.
|
|
16
21
|
* Example:
|
|
17
22
|
* ```cpp (cpp-adapter.cpp)
|
|
18
23
|
* JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
|
|
19
|
-
* return
|
|
24
|
+
* return facebook::jni::initialize(vm, []() {
|
|
25
|
+
* // register all MunimBluetooth HybridObjects
|
|
26
|
+
* margelo::nitro::munimbluetooth::registerNatives();
|
|
27
|
+
* // any other custom registrations go here.
|
|
28
|
+
* });
|
|
20
29
|
* }
|
|
21
30
|
* ```
|
|
22
31
|
*/
|
|
23
|
-
|
|
32
|
+
void registerAllNatives();
|
|
24
33
|
|
|
25
34
|
} // namespace margelo::nitro::munimbluetooth
|
|
@@ -25,7 +25,7 @@ namespace margelo::nitro::munimbluetooth {
|
|
|
25
25
|
*/
|
|
26
26
|
struct JAdvertisingDataTypes final: public jni::JavaClass<JAdvertisingDataTypes> {
|
|
27
27
|
public:
|
|
28
|
-
static auto
|
|
28
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/AdvertisingDataTypes;";
|
|
29
29
|
|
|
30
30
|
public:
|
|
31
31
|
/**
|
|
@@ -27,7 +27,7 @@ namespace margelo::nitro::munimbluetooth {
|
|
|
27
27
|
*/
|
|
28
28
|
struct JAdvertisingOptions final: public jni::JavaClass<JAdvertisingOptions> {
|
|
29
29
|
public:
|
|
30
|
-
static auto
|
|
30
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/AdvertisingOptions;";
|
|
31
31
|
|
|
32
32
|
public:
|
|
33
33
|
/**
|
|
@@ -21,7 +21,7 @@ namespace margelo::nitro::munimbluetooth {
|
|
|
21
21
|
*/
|
|
22
22
|
struct JCharacteristicValue final: public jni::JavaClass<JCharacteristicValue> {
|
|
23
23
|
public:
|
|
24
|
-
static auto
|
|
24
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/CharacteristicValue;";
|
|
25
25
|
|
|
26
26
|
public:
|
|
27
27
|
/**
|
|
@@ -23,7 +23,7 @@ namespace margelo::nitro::munimbluetooth {
|
|
|
23
23
|
*/
|
|
24
24
|
struct JGATTCharacteristic final: public jni::JavaClass<JGATTCharacteristic> {
|
|
25
25
|
public:
|
|
26
|
-
static auto
|
|
26
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/GATTCharacteristic;";
|
|
27
27
|
|
|
28
28
|
public:
|
|
29
29
|
/**
|
|
@@ -25,7 +25,7 @@ namespace margelo::nitro::munimbluetooth {
|
|
|
25
25
|
*/
|
|
26
26
|
struct JGATTService final: public jni::JavaClass<JGATTService> {
|
|
27
27
|
public:
|
|
28
|
-
static auto
|
|
28
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/GATTService;";
|
|
29
29
|
|
|
30
30
|
public:
|
|
31
31
|
/**
|
|
@@ -53,37 +53,31 @@ namespace margelo::nitro::munimbluetooth { enum class WriteType; }
|
|
|
53
53
|
|
|
54
54
|
namespace margelo::nitro::munimbluetooth {
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
});
|
|
56
|
+
std::shared_ptr<JHybridMunimBluetoothSpec> JHybridMunimBluetoothSpec::JavaPart::getJHybridMunimBluetoothSpec() {
|
|
57
|
+
auto hybridObject = JHybridObject::JavaPart::getJHybridObject();
|
|
58
|
+
auto castHybridObject = std::dynamic_pointer_cast<JHybridMunimBluetoothSpec>(hybridObject);
|
|
59
|
+
if (castHybridObject == nullptr) [[unlikely]] {
|
|
60
|
+
throw std::runtime_error("Failed to downcast JHybridObject to JHybridMunimBluetoothSpec!");
|
|
61
|
+
}
|
|
62
|
+
return castHybridObject;
|
|
64
63
|
}
|
|
65
64
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return method(_javaPart);
|
|
65
|
+
jni::local_ref<JHybridMunimBluetoothSpec::CxxPart::jhybriddata> JHybridMunimBluetoothSpec::CxxPart::initHybrid(jni::alias_ref<jhybridobject> jThis) {
|
|
66
|
+
return makeCxxInstance(jThis);
|
|
69
67
|
}
|
|
70
68
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
69
|
+
std::shared_ptr<JHybridObject> JHybridMunimBluetoothSpec::CxxPart::createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) {
|
|
70
|
+
auto castJavaPart = jni::dynamic_ref_cast<JHybridMunimBluetoothSpec::JavaPart>(javaPart);
|
|
71
|
+
if (castJavaPart == nullptr) [[unlikely]] {
|
|
72
|
+
throw std::runtime_error("Failed to cast JHybridObject::JavaPart to JHybridMunimBluetoothSpec::JavaPart!");
|
|
74
73
|
}
|
|
75
|
-
return
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
void JHybridMunimBluetoothSpec::dispose() noexcept {
|
|
79
|
-
static const auto method = javaClassStatic()->getMethod<void()>("dispose");
|
|
80
|
-
method(_javaPart);
|
|
74
|
+
return std::make_shared<JHybridMunimBluetoothSpec>(castJavaPart);
|
|
81
75
|
}
|
|
82
76
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
77
|
+
void JHybridMunimBluetoothSpec::CxxPart::registerNatives() {
|
|
78
|
+
registerHybrid({
|
|
79
|
+
makeNativeMethod("initHybrid", JHybridMunimBluetoothSpec::CxxPart::initHybrid),
|
|
80
|
+
});
|
|
87
81
|
}
|
|
88
82
|
|
|
89
83
|
// Properties
|
|
@@ -91,15 +85,15 @@ namespace margelo::nitro::munimbluetooth {
|
|
|
91
85
|
|
|
92
86
|
// Methods
|
|
93
87
|
void JHybridMunimBluetoothSpec::startAdvertising(const AdvertisingOptions& options) {
|
|
94
|
-
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JAdvertisingOptions> /* options */)>("startAdvertising");
|
|
88
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JAdvertisingOptions> /* options */)>("startAdvertising");
|
|
95
89
|
method(_javaPart, JAdvertisingOptions::fromCpp(options));
|
|
96
90
|
}
|
|
97
91
|
void JHybridMunimBluetoothSpec::updateAdvertisingData(const AdvertisingDataTypes& advertisingData) {
|
|
98
|
-
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JAdvertisingDataTypes> /* advertisingData */)>("updateAdvertisingData");
|
|
92
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JAdvertisingDataTypes> /* advertisingData */)>("updateAdvertisingData");
|
|
99
93
|
method(_javaPart, JAdvertisingDataTypes::fromCpp(advertisingData));
|
|
100
94
|
}
|
|
101
95
|
std::shared_ptr<Promise<AdvertisingDataTypes>> JHybridMunimBluetoothSpec::getAdvertisingData() {
|
|
102
|
-
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("getAdvertisingData");
|
|
96
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("getAdvertisingData");
|
|
103
97
|
auto __result = method(_javaPart);
|
|
104
98
|
return [&]() {
|
|
105
99
|
auto __promise = Promise<AdvertisingDataTypes>::create();
|
|
@@ -115,11 +109,11 @@ namespace margelo::nitro::munimbluetooth {
|
|
|
115
109
|
}();
|
|
116
110
|
}
|
|
117
111
|
void JHybridMunimBluetoothSpec::stopAdvertising() {
|
|
118
|
-
static const auto method = javaClassStatic()->getMethod<void()>("stopAdvertising");
|
|
112
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void()>("stopAdvertising");
|
|
119
113
|
method(_javaPart);
|
|
120
114
|
}
|
|
121
115
|
void JHybridMunimBluetoothSpec::setServices(const std::vector<GATTService>& services) {
|
|
122
|
-
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JArrayClass<JGATTService>> /* services */)>("setServices");
|
|
116
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JArrayClass<JGATTService>> /* services */)>("setServices");
|
|
123
117
|
method(_javaPart, [&]() {
|
|
124
118
|
size_t __size = services.size();
|
|
125
119
|
jni::local_ref<jni::JArrayClass<JGATTService>> __array = jni::JArrayClass<JGATTService>::newArray(__size);
|
|
@@ -132,7 +126,7 @@ namespace margelo::nitro::munimbluetooth {
|
|
|
132
126
|
}());
|
|
133
127
|
}
|
|
134
128
|
std::shared_ptr<Promise<bool>> JHybridMunimBluetoothSpec::isBluetoothEnabled() {
|
|
135
|
-
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("isBluetoothEnabled");
|
|
129
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("isBluetoothEnabled");
|
|
136
130
|
auto __result = method(_javaPart);
|
|
137
131
|
return [&]() {
|
|
138
132
|
auto __promise = Promise<bool>::create();
|
|
@@ -148,7 +142,7 @@ namespace margelo::nitro::munimbluetooth {
|
|
|
148
142
|
}();
|
|
149
143
|
}
|
|
150
144
|
std::shared_ptr<Promise<bool>> JHybridMunimBluetoothSpec::requestBluetoothPermission() {
|
|
151
|
-
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("requestBluetoothPermission");
|
|
145
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("requestBluetoothPermission");
|
|
152
146
|
auto __result = method(_javaPart);
|
|
153
147
|
return [&]() {
|
|
154
148
|
auto __promise = Promise<bool>::create();
|
|
@@ -164,15 +158,15 @@ namespace margelo::nitro::munimbluetooth {
|
|
|
164
158
|
}();
|
|
165
159
|
}
|
|
166
160
|
void JHybridMunimBluetoothSpec::startScan(const std::optional<ScanOptions>& options) {
|
|
167
|
-
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JScanOptions> /* options */)>("startScan");
|
|
161
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JScanOptions> /* options */)>("startScan");
|
|
168
162
|
method(_javaPart, options.has_value() ? JScanOptions::fromCpp(options.value()) : nullptr);
|
|
169
163
|
}
|
|
170
164
|
void JHybridMunimBluetoothSpec::stopScan() {
|
|
171
|
-
static const auto method = javaClassStatic()->getMethod<void()>("stopScan");
|
|
165
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void()>("stopScan");
|
|
172
166
|
method(_javaPart);
|
|
173
167
|
}
|
|
174
168
|
std::shared_ptr<Promise<void>> JHybridMunimBluetoothSpec::connect(const std::string& deviceId) {
|
|
175
|
-
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* deviceId */)>("connect");
|
|
169
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* deviceId */)>("connect");
|
|
176
170
|
auto __result = method(_javaPart, jni::make_jstring(deviceId));
|
|
177
171
|
return [&]() {
|
|
178
172
|
auto __promise = Promise<void>::create();
|
|
@@ -187,11 +181,11 @@ namespace margelo::nitro::munimbluetooth {
|
|
|
187
181
|
}();
|
|
188
182
|
}
|
|
189
183
|
void JHybridMunimBluetoothSpec::disconnect(const std::string& deviceId) {
|
|
190
|
-
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* deviceId */)>("disconnect");
|
|
184
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* deviceId */)>("disconnect");
|
|
191
185
|
method(_javaPart, jni::make_jstring(deviceId));
|
|
192
186
|
}
|
|
193
187
|
std::shared_ptr<Promise<std::vector<GATTService>>> JHybridMunimBluetoothSpec::discoverServices(const std::string& deviceId) {
|
|
194
|
-
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* deviceId */)>("discoverServices");
|
|
188
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* deviceId */)>("discoverServices");
|
|
195
189
|
auto __result = method(_javaPart, jni::make_jstring(deviceId));
|
|
196
190
|
return [&]() {
|
|
197
191
|
auto __promise = Promise<std::vector<GATTService>>::create();
|
|
@@ -216,7 +210,7 @@ namespace margelo::nitro::munimbluetooth {
|
|
|
216
210
|
}();
|
|
217
211
|
}
|
|
218
212
|
std::shared_ptr<Promise<CharacteristicValue>> JHybridMunimBluetoothSpec::readCharacteristic(const std::string& deviceId, const std::string& serviceUUID, const std::string& characteristicUUID) {
|
|
219
|
-
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* deviceId */, jni::alias_ref<jni::JString> /* serviceUUID */, jni::alias_ref<jni::JString> /* characteristicUUID */)>("readCharacteristic");
|
|
213
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* deviceId */, jni::alias_ref<jni::JString> /* serviceUUID */, jni::alias_ref<jni::JString> /* characteristicUUID */)>("readCharacteristic");
|
|
220
214
|
auto __result = method(_javaPart, jni::make_jstring(deviceId), jni::make_jstring(serviceUUID), jni::make_jstring(characteristicUUID));
|
|
221
215
|
return [&]() {
|
|
222
216
|
auto __promise = Promise<CharacteristicValue>::create();
|
|
@@ -232,7 +226,7 @@ namespace margelo::nitro::munimbluetooth {
|
|
|
232
226
|
}();
|
|
233
227
|
}
|
|
234
228
|
std::shared_ptr<Promise<void>> JHybridMunimBluetoothSpec::writeCharacteristic(const std::string& deviceId, const std::string& serviceUUID, const std::string& characteristicUUID, const std::string& value, std::optional<WriteType> writeType) {
|
|
235
|
-
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* deviceId */, jni::alias_ref<jni::JString> /* serviceUUID */, jni::alias_ref<jni::JString> /* characteristicUUID */, jni::alias_ref<jni::JString> /* value */, jni::alias_ref<JWriteType> /* writeType */)>("writeCharacteristic");
|
|
229
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* deviceId */, jni::alias_ref<jni::JString> /* serviceUUID */, jni::alias_ref<jni::JString> /* characteristicUUID */, jni::alias_ref<jni::JString> /* value */, jni::alias_ref<JWriteType> /* writeType */)>("writeCharacteristic");
|
|
236
230
|
auto __result = method(_javaPart, jni::make_jstring(deviceId), jni::make_jstring(serviceUUID), jni::make_jstring(characteristicUUID), jni::make_jstring(value), writeType.has_value() ? JWriteType::fromCpp(writeType.value()) : nullptr);
|
|
237
231
|
return [&]() {
|
|
238
232
|
auto __promise = Promise<void>::create();
|
|
@@ -247,15 +241,15 @@ namespace margelo::nitro::munimbluetooth {
|
|
|
247
241
|
}();
|
|
248
242
|
}
|
|
249
243
|
void JHybridMunimBluetoothSpec::subscribeToCharacteristic(const std::string& deviceId, const std::string& serviceUUID, const std::string& characteristicUUID) {
|
|
250
|
-
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* deviceId */, jni::alias_ref<jni::JString> /* serviceUUID */, jni::alias_ref<jni::JString> /* characteristicUUID */)>("subscribeToCharacteristic");
|
|
244
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* deviceId */, jni::alias_ref<jni::JString> /* serviceUUID */, jni::alias_ref<jni::JString> /* characteristicUUID */)>("subscribeToCharacteristic");
|
|
251
245
|
method(_javaPart, jni::make_jstring(deviceId), jni::make_jstring(serviceUUID), jni::make_jstring(characteristicUUID));
|
|
252
246
|
}
|
|
253
247
|
void JHybridMunimBluetoothSpec::unsubscribeFromCharacteristic(const std::string& deviceId, const std::string& serviceUUID, const std::string& characteristicUUID) {
|
|
254
|
-
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* deviceId */, jni::alias_ref<jni::JString> /* serviceUUID */, jni::alias_ref<jni::JString> /* characteristicUUID */)>("unsubscribeFromCharacteristic");
|
|
248
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* deviceId */, jni::alias_ref<jni::JString> /* serviceUUID */, jni::alias_ref<jni::JString> /* characteristicUUID */)>("unsubscribeFromCharacteristic");
|
|
255
249
|
method(_javaPart, jni::make_jstring(deviceId), jni::make_jstring(serviceUUID), jni::make_jstring(characteristicUUID));
|
|
256
250
|
}
|
|
257
251
|
std::shared_ptr<Promise<std::vector<std::string>>> JHybridMunimBluetoothSpec::getConnectedDevices() {
|
|
258
|
-
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("getConnectedDevices");
|
|
252
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("getConnectedDevices");
|
|
259
253
|
auto __result = method(_javaPart);
|
|
260
254
|
return [&]() {
|
|
261
255
|
auto __promise = Promise<std::vector<std::string>>::create();
|
|
@@ -280,7 +274,7 @@ namespace margelo::nitro::munimbluetooth {
|
|
|
280
274
|
}();
|
|
281
275
|
}
|
|
282
276
|
std::shared_ptr<Promise<double>> JHybridMunimBluetoothSpec::readRSSI(const std::string& deviceId) {
|
|
283
|
-
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* deviceId */)>("readRSSI");
|
|
277
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* deviceId */)>("readRSSI");
|
|
284
278
|
auto __result = method(_javaPart, jni::make_jstring(deviceId));
|
|
285
279
|
return [&]() {
|
|
286
280
|
auto __promise = Promise<double>::create();
|
|
@@ -296,11 +290,11 @@ namespace margelo::nitro::munimbluetooth {
|
|
|
296
290
|
}();
|
|
297
291
|
}
|
|
298
292
|
void JHybridMunimBluetoothSpec::addListener(const std::string& eventName) {
|
|
299
|
-
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* eventName */)>("addListener");
|
|
293
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* eventName */)>("addListener");
|
|
300
294
|
method(_javaPart, jni::make_jstring(eventName));
|
|
301
295
|
}
|
|
302
296
|
void JHybridMunimBluetoothSpec::removeListeners(double count) {
|
|
303
|
-
static const auto method = javaClassStatic()->getMethod<void(double /* count */)>("removeListeners");
|
|
297
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(double /* count */)>("removeListeners");
|
|
304
298
|
method(_javaPart, count);
|
|
305
299
|
}
|
|
306
300
|
|
|
@@ -18,34 +18,33 @@ namespace margelo::nitro::munimbluetooth {
|
|
|
18
18
|
|
|
19
19
|
using namespace facebook;
|
|
20
20
|
|
|
21
|
-
class JHybridMunimBluetoothSpec: public
|
|
22
|
-
public virtual HybridMunimBluetoothSpec {
|
|
21
|
+
class JHybridMunimBluetoothSpec: public virtual HybridMunimBluetoothSpec, public virtual JHybridObject {
|
|
23
22
|
public:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
HybridBase
|
|
33
|
-
|
|
23
|
+
struct JavaPart: public jni::JavaClass<JavaPart, JHybridObject::JavaPart> {
|
|
24
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/HybridMunimBluetoothSpec;";
|
|
25
|
+
std::shared_ptr<JHybridMunimBluetoothSpec> getJHybridMunimBluetoothSpec();
|
|
26
|
+
};
|
|
27
|
+
struct CxxPart: public jni::HybridClass<CxxPart, JHybridObject::CxxPart> {
|
|
28
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/HybridMunimBluetoothSpec$CxxPart;";
|
|
29
|
+
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis);
|
|
30
|
+
static void registerNatives();
|
|
31
|
+
using HybridBase::HybridBase;
|
|
32
|
+
protected:
|
|
33
|
+
std::shared_ptr<JHybridObject> createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) override;
|
|
34
|
+
};
|
|
34
35
|
|
|
35
36
|
public:
|
|
37
|
+
explicit JHybridMunimBluetoothSpec(const jni::local_ref<JHybridMunimBluetoothSpec::JavaPart>& javaPart):
|
|
38
|
+
HybridObject(HybridMunimBluetoothSpec::TAG),
|
|
39
|
+
JHybridObject(javaPart),
|
|
40
|
+
_javaPart(jni::make_global(javaPart)) {}
|
|
36
41
|
~JHybridMunimBluetoothSpec() override {
|
|
37
42
|
// Hermes GC can destroy JS objects on a non-JNI Thread.
|
|
38
43
|
jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); });
|
|
39
44
|
}
|
|
40
45
|
|
|
41
46
|
public:
|
|
42
|
-
|
|
43
|
-
bool equals(const std::shared_ptr<HybridObject>& other) override;
|
|
44
|
-
void dispose() noexcept override;
|
|
45
|
-
std::string toString() override;
|
|
46
|
-
|
|
47
|
-
public:
|
|
48
|
-
inline const jni::global_ref<JHybridMunimBluetoothSpec::javaobject>& getJavaPart() const noexcept {
|
|
47
|
+
inline const jni::global_ref<JHybridMunimBluetoothSpec::JavaPart>& getJavaPart() const noexcept {
|
|
49
48
|
return _javaPart;
|
|
50
49
|
}
|
|
51
50
|
|
|
@@ -77,9 +76,7 @@ namespace margelo::nitro::munimbluetooth {
|
|
|
77
76
|
void removeListeners(double count) override;
|
|
78
77
|
|
|
79
78
|
private:
|
|
80
|
-
|
|
81
|
-
using HybridBase::HybridBase;
|
|
82
|
-
jni::global_ref<JHybridMunimBluetoothSpec::javaobject> _javaPart;
|
|
79
|
+
jni::global_ref<JHybridMunimBluetoothSpec::JavaPart> _javaPart;
|
|
83
80
|
};
|
|
84
81
|
|
|
85
82
|
} // namespace margelo::nitro::munimbluetooth
|
|
@@ -19,7 +19,7 @@ namespace margelo::nitro::munimbluetooth {
|
|
|
19
19
|
*/
|
|
20
20
|
struct JScanMode final: public jni::JavaClass<JScanMode> {
|
|
21
21
|
public:
|
|
22
|
-
static auto
|
|
22
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/ScanMode;";
|
|
23
23
|
|
|
24
24
|
public:
|
|
25
25
|
/**
|
|
@@ -25,7 +25,7 @@ namespace margelo::nitro::munimbluetooth {
|
|
|
25
25
|
*/
|
|
26
26
|
struct JScanOptions final: public jni::JavaClass<JScanOptions> {
|
|
27
27
|
public:
|
|
28
|
-
static auto
|
|
28
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/ScanOptions;";
|
|
29
29
|
|
|
30
30
|
public:
|
|
31
31
|
/**
|
|
@@ -21,7 +21,7 @@ namespace margelo::nitro::munimbluetooth {
|
|
|
21
21
|
*/
|
|
22
22
|
struct JServiceDataEntry final: public jni::JavaClass<JServiceDataEntry> {
|
|
23
23
|
public:
|
|
24
|
-
static auto
|
|
24
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/ServiceDataEntry;";
|
|
25
25
|
|
|
26
26
|
public:
|
|
27
27
|
/**
|
|
@@ -19,7 +19,7 @@ namespace margelo::nitro::munimbluetooth {
|
|
|
19
19
|
*/
|
|
20
20
|
struct JWriteType final: public jni::JavaClass<JWriteType> {
|
|
21
21
|
public:
|
|
22
|
-
static auto
|
|
22
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/WriteType;";
|
|
23
23
|
|
|
24
24
|
public:
|
|
25
25
|
/**
|
|
@@ -80,7 +80,7 @@ namespace margelo::nitro::munimbluetooth::bridge::swift {
|
|
|
80
80
|
return optional.has_value();
|
|
81
81
|
}
|
|
82
82
|
inline std::string get_std__optional_std__string_(const std::optional<std::string>& optional) noexcept {
|
|
83
|
-
return
|
|
83
|
+
return optional.value();
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
// pragma MARK: std::optional<double>
|
|
@@ -95,7 +95,7 @@ namespace margelo::nitro::munimbluetooth::bridge::swift {
|
|
|
95
95
|
return optional.has_value();
|
|
96
96
|
}
|
|
97
97
|
inline double get_std__optional_double_(const std::optional<double>& optional) noexcept {
|
|
98
|
-
return
|
|
98
|
+
return optional.value();
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
// pragma MARK: std::optional<std::vector<std::string>>
|
|
@@ -110,7 +110,7 @@ namespace margelo::nitro::munimbluetooth::bridge::swift {
|
|
|
110
110
|
return optional.has_value();
|
|
111
111
|
}
|
|
112
112
|
inline std::vector<std::string> get_std__optional_std__vector_std__string__(const std::optional<std::vector<std::string>>& optional) noexcept {
|
|
113
|
-
return
|
|
113
|
+
return optional.value();
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
// pragma MARK: std::vector<ServiceDataEntry>
|
|
@@ -136,7 +136,7 @@ namespace margelo::nitro::munimbluetooth::bridge::swift {
|
|
|
136
136
|
return optional.has_value();
|
|
137
137
|
}
|
|
138
138
|
inline std::vector<ServiceDataEntry> get_std__optional_std__vector_ServiceDataEntry__(const std::optional<std::vector<ServiceDataEntry>>& optional) noexcept {
|
|
139
|
-
return
|
|
139
|
+
return optional.value();
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
// pragma MARK: std::optional<AdvertisingDataTypes>
|
|
@@ -151,7 +151,7 @@ namespace margelo::nitro::munimbluetooth::bridge::swift {
|
|
|
151
151
|
return optional.has_value();
|
|
152
152
|
}
|
|
153
153
|
inline AdvertisingDataTypes get_std__optional_AdvertisingDataTypes_(const std::optional<AdvertisingDataTypes>& optional) noexcept {
|
|
154
|
-
return
|
|
154
|
+
return optional.value();
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
// pragma MARK: std::shared_ptr<Promise<AdvertisingDataTypes>>
|
|
@@ -278,7 +278,7 @@ namespace margelo::nitro::munimbluetooth::bridge::swift {
|
|
|
278
278
|
return optional.has_value();
|
|
279
279
|
}
|
|
280
280
|
inline bool get_std__optional_bool_(const std::optional<bool>& optional) noexcept {
|
|
281
|
-
return
|
|
281
|
+
return optional.value();
|
|
282
282
|
}
|
|
283
283
|
|
|
284
284
|
// pragma MARK: std::optional<ScanMode>
|
|
@@ -293,7 +293,7 @@ namespace margelo::nitro::munimbluetooth::bridge::swift {
|
|
|
293
293
|
return optional.has_value();
|
|
294
294
|
}
|
|
295
295
|
inline ScanMode get_std__optional_ScanMode_(const std::optional<ScanMode>& optional) noexcept {
|
|
296
|
-
return
|
|
296
|
+
return optional.value();
|
|
297
297
|
}
|
|
298
298
|
|
|
299
299
|
// pragma MARK: std::optional<ScanOptions>
|
|
@@ -308,7 +308,7 @@ namespace margelo::nitro::munimbluetooth::bridge::swift {
|
|
|
308
308
|
return optional.has_value();
|
|
309
309
|
}
|
|
310
310
|
inline ScanOptions get_std__optional_ScanOptions_(const std::optional<ScanOptions>& optional) noexcept {
|
|
311
|
-
return
|
|
311
|
+
return optional.value();
|
|
312
312
|
}
|
|
313
313
|
|
|
314
314
|
// pragma MARK: std::shared_ptr<Promise<void>>
|
|
@@ -425,7 +425,7 @@ namespace margelo::nitro::munimbluetooth::bridge::swift {
|
|
|
425
425
|
return optional.has_value();
|
|
426
426
|
}
|
|
427
427
|
inline WriteType get_std__optional_WriteType_(const std::optional<WriteType>& optional) noexcept {
|
|
428
|
-
return
|
|
428
|
+
return optional.value();
|
|
429
429
|
}
|
|
430
430
|
|
|
431
431
|
// pragma MARK: std::shared_ptr<Promise<std::vector<std::string>>>
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
25
25
|
"MunimBluetooth",
|
|
26
26
|
[]() -> std::shared_ptr<HybridObject> {
|
|
27
|
-
std::shared_ptr<HybridMunimBluetoothSpec> hybridObject = MunimBluetooth::MunimBluetoothAutolinking::
|
|
27
|
+
std::shared_ptr<HybridMunimBluetoothSpec> hybridObject = MunimBluetooth::MunimBluetoothAutolinking::createMunimBluetooth();
|
|
28
28
|
return hybridObject;
|
|
29
29
|
}
|
|
30
30
|
);
|
|
@@ -12,33 +12,15 @@ import NitroModules
|
|
|
12
12
|
public final class MunimBluetoothAutolinking {
|
|
13
13
|
public typealias bridge = margelo.nitro.munimbluetooth.bridge.swift
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
* This is generated by Nitrogen and will initialize the class specified
|
|
22
|
-
* in the `"autolinking"` property of `nitro.json`.
|
|
23
|
-
*/
|
|
24
|
-
static func create() -> T
|
|
25
|
-
/**
|
|
26
|
-
* Returns whether this concrete implementation is also
|
|
27
|
-
* conforming to the `RecyclableView` protocol, or not.
|
|
28
|
-
*/
|
|
29
|
-
static var isRecyclableHybridView: Bool { get }
|
|
15
|
+
public static func createMunimBluetooth() -> bridge.std__shared_ptr_HybridMunimBluetoothSpec_ {
|
|
16
|
+
let hybridObject = HybridMunimBluetooth()
|
|
17
|
+
return { () -> bridge.std__shared_ptr_HybridMunimBluetoothSpec_ in
|
|
18
|
+
let __cxxWrapped = hybridObject.getCxxWrapper()
|
|
19
|
+
return __cxxWrapped.getCxxPart()
|
|
20
|
+
}()
|
|
30
21
|
}
|
|
31
|
-
|
|
32
|
-
public
|
|
33
|
-
|
|
34
|
-
let hybridObject = HybridMunimBluetooth()
|
|
35
|
-
return { () -> bridge.std__shared_ptr_HybridMunimBluetoothSpec_ in
|
|
36
|
-
let __cxxWrapped = hybridObject.getCxxWrapper()
|
|
37
|
-
return __cxxWrapped.getCxxPart()
|
|
38
|
-
}()
|
|
39
|
-
}
|
|
40
|
-
public static var isRecyclableHybridView: Bool {
|
|
41
|
-
return HybridMunimBluetooth.self is any RecyclableView.Type
|
|
42
|
-
}
|
|
22
|
+
|
|
23
|
+
public static func isMunimBluetoothRecyclable() -> Bool {
|
|
24
|
+
return HybridMunimBluetooth.self is any RecyclableView.Type
|
|
43
25
|
}
|
|
44
26
|
}
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
|
-
import Foundation
|
|
9
8
|
import NitroModules
|
|
10
9
|
|
|
11
10
|
/**
|
|
@@ -205,7 +204,14 @@ public extension AdvertisingDataTypes {
|
|
|
205
204
|
|
|
206
205
|
@inline(__always)
|
|
207
206
|
var flags: Double? {
|
|
208
|
-
return
|
|
207
|
+
return { () -> Double? in
|
|
208
|
+
if bridge.has_value_std__optional_double_(self.__flags) {
|
|
209
|
+
let __unwrapped = bridge.get_std__optional_double_(self.__flags)
|
|
210
|
+
return __unwrapped
|
|
211
|
+
} else {
|
|
212
|
+
return nil
|
|
213
|
+
}
|
|
214
|
+
}()
|
|
209
215
|
}
|
|
210
216
|
|
|
211
217
|
@inline(__always)
|
|
@@ -306,7 +312,14 @@ public extension AdvertisingDataTypes {
|
|
|
306
312
|
|
|
307
313
|
@inline(__always)
|
|
308
314
|
var txPowerLevel: Double? {
|
|
309
|
-
return
|
|
315
|
+
return { () -> Double? in
|
|
316
|
+
if bridge.has_value_std__optional_double_(self.__txPowerLevel) {
|
|
317
|
+
let __unwrapped = bridge.get_std__optional_double_(self.__txPowerLevel)
|
|
318
|
+
return __unwrapped
|
|
319
|
+
} else {
|
|
320
|
+
return nil
|
|
321
|
+
}
|
|
322
|
+
}()
|
|
310
323
|
}
|
|
311
324
|
|
|
312
325
|
@inline(__always)
|
|
@@ -371,7 +384,14 @@ public extension AdvertisingDataTypes {
|
|
|
371
384
|
|
|
372
385
|
@inline(__always)
|
|
373
386
|
var appearance: Double? {
|
|
374
|
-
return
|
|
387
|
+
return { () -> Double? in
|
|
388
|
+
if bridge.has_value_std__optional_double_(self.__appearance) {
|
|
389
|
+
let __unwrapped = bridge.get_std__optional_double_(self.__appearance)
|
|
390
|
+
return __unwrapped
|
|
391
|
+
} else {
|
|
392
|
+
return nil
|
|
393
|
+
}
|
|
394
|
+
}()
|
|
375
395
|
}
|
|
376
396
|
|
|
377
397
|
@inline(__always)
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
|
-
import Foundation
|
|
9
8
|
import NitroModules
|
|
10
9
|
|
|
11
10
|
/// See ``HybridMunimBluetoothSpec``
|
|
@@ -44,11 +43,9 @@ public extension HybridMunimBluetoothSpec_protocol {
|
|
|
44
43
|
}
|
|
45
44
|
|
|
46
45
|
/// See ``HybridMunimBluetoothSpec``
|
|
47
|
-
open class HybridMunimBluetoothSpec_base
|
|
46
|
+
open class HybridMunimBluetoothSpec_base {
|
|
48
47
|
private weak var cxxWrapper: HybridMunimBluetoothSpec_cxx? = nil
|
|
49
|
-
public
|
|
50
|
-
super.init()
|
|
51
|
-
}
|
|
48
|
+
public init() { }
|
|
52
49
|
public func getCxxWrapper() -> HybridMunimBluetoothSpec_cxx {
|
|
53
50
|
#if DEBUG
|
|
54
51
|
guard self is any HybridMunimBluetoothSpec else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "munim-bluetooth",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.22",
|
|
4
4
|
"description": "A comprehensive React Native library for all your Bluetooth Low Energy (BLE) needs, supporting both peripheral and central roles with Expo support",
|
|
5
5
|
"main": "./lib/commonjs/index.js",
|
|
6
6
|
"module": "./lib/module/index.js",
|
|
@@ -85,12 +85,12 @@
|
|
|
85
85
|
"@semantic-release/git": "^10.0.1",
|
|
86
86
|
"@types/jest": "^29.5.14",
|
|
87
87
|
"@types/react": "19.2.8",
|
|
88
|
-
"
|
|
88
|
+
"conventional-changelog-conventionalcommits": "^9.1.0",
|
|
89
|
+
"nitrogen": "^0.35.2",
|
|
89
90
|
"react": "19.2.3",
|
|
90
91
|
"react-native": "0.83.1",
|
|
91
92
|
"react-native-builder-bob": "^0.40.17",
|
|
92
|
-
"react-native-nitro-modules": "0.35.2",
|
|
93
|
-
"conventional-changelog-conventionalcommits": "^9.1.0",
|
|
93
|
+
"react-native-nitro-modules": "^0.35.2",
|
|
94
94
|
"semantic-release": "^25.0.2",
|
|
95
95
|
"typescript": "^5.8.3"
|
|
96
96
|
},
|