munim-bluetooth 0.3.27 → 0.4.1
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/CHANGELOG.md +27 -0
- package/LICENSE +201 -21
- package/README.md +480 -75
- package/android/gradle.properties +2 -2
- package/android/src/main/AndroidManifest.xml +3 -1
- package/android/src/main/cpp/cpp-adapter.cpp +4 -1
- package/android/src/main/java/com/munimbluetooth/HybridMunimBluetooth.kt +2006 -209
- package/android/src/main/java/com/munimbluetooth/MunimBluetoothBackgroundService.kt +561 -53
- package/app.plugin.js +155 -0
- package/ios/HybridMunimBluetooth.swift +2123 -298
- package/ios/MunimBluetoothEventEmitter.swift +68 -8
- package/lib/commonjs/index.js +272 -11
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +243 -11
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/index.d.ts +310 -7
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/munim-bluetooth.nitro.d.ts +219 -5
- package/lib/typescript/src/specs/munim-bluetooth.nitro.d.ts.map +1 -1
- package/nitro.json +9 -3
- package/nitrogen/generated/android/c++/JAdvertisingDataTypes.hpp +96 -96
- package/nitrogen/generated/android/c++/JAdvertisingOptions.hpp +8 -8
- package/nitrogen/generated/android/c++/JBackgroundSessionOptions.hpp +8 -8
- package/nitrogen/generated/android/c++/JBluetoothCapabilities.hpp +105 -0
- package/nitrogen/generated/android/c++/JBluetoothPhy.hpp +61 -0
- package/nitrogen/generated/android/c++/JBluetoothPhyOption.hpp +61 -0
- package/nitrogen/generated/android/c++/JBondState.hpp +64 -0
- package/nitrogen/generated/android/c++/JDescriptorValue.hpp +69 -0
- package/nitrogen/generated/android/c++/JExtendedAdvertisingOptions.hpp +131 -0
- package/nitrogen/generated/android/c++/JGATTCharacteristic.hpp +35 -11
- package/nitrogen/generated/android/c++/JGATTDescriptor.hpp +85 -0
- package/nitrogen/generated/android/c++/JGATTService.hpp +33 -9
- package/nitrogen/generated/android/c++/JHybridMunimBluetoothSpec.cpp +422 -12
- package/nitrogen/generated/android/c++/JHybridMunimBluetoothSpec.hpp +29 -0
- package/nitrogen/generated/android/c++/JL2CAPChannel.hpp +66 -0
- package/nitrogen/generated/android/c++/JMultipeerDiscoveryInfoEntry.hpp +61 -0
- package/nitrogen/generated/android/c++/JMultipeerEncryptionPreference.hpp +61 -0
- package/nitrogen/generated/android/c++/JMultipeerPeer.hpp +93 -0
- package/nitrogen/generated/android/c++/JMultipeerPeerState.hpp +61 -0
- package/nitrogen/generated/android/c++/JMultipeerSessionOptions.hpp +105 -0
- package/nitrogen/generated/android/c++/JPhyStatus.hpp +62 -0
- package/nitrogen/generated/android/c++/JScanOptions.hpp +8 -8
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/AdvertisingDataTypes.kt +47 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/AdvertisingOptions.kt +19 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/BackgroundSessionOptions.kt +27 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/BluetoothCapabilities.kt +111 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/BluetoothPhy.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/BluetoothPhyOption.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/BondState.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/CharacteristicValue.kt +17 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/DescriptorValue.kt +66 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/ExtendedAdvertisingOptions.kt +111 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/GATTCharacteristic.kt +25 -3
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/GATTDescriptor.kt +61 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/GATTService.kt +23 -3
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/HybridMunimBluetoothSpec.kt +138 -22
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/L2CAPChannel.kt +61 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/MultipeerDiscoveryInfoEntry.kt +56 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/MultipeerEncryptionPreference.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/MultipeerPeer.kt +66 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/MultipeerPeerState.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/MultipeerSessionOptions.kt +81 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/PhyStatus.kt +56 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/ScanOptions.kt +17 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/ServiceDataEntry.kt +15 -0
- package/nitrogen/generated/ios/MunimBluetooth+autolinking.rb +2 -0
- package/nitrogen/generated/ios/MunimBluetooth-Swift-Cxx-Bridge.cpp +61 -5
- package/nitrogen/generated/ios/MunimBluetooth-Swift-Cxx-Bridge.hpp +494 -49
- package/nitrogen/generated/ios/MunimBluetooth-Swift-Cxx-Umbrella.hpp +42 -0
- package/nitrogen/generated/ios/c++/HybridMunimBluetoothSpecSwift.hpp +254 -0
- package/nitrogen/generated/ios/swift/BluetoothCapabilities.swift +89 -0
- package/nitrogen/generated/ios/swift/BluetoothPhy.swift +44 -0
- package/nitrogen/generated/ios/swift/BluetoothPhyOption.swift +44 -0
- package/nitrogen/generated/ios/swift/BondState.swift +48 -0
- package/nitrogen/generated/ios/swift/DescriptorValue.swift +44 -0
- package/nitrogen/generated/ios/swift/ExtendedAdvertisingOptions.swift +243 -0
- package/nitrogen/generated/ios/swift/Func_void_BluetoothCapabilities.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_BondState.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_DescriptorValue.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_L2CAPChannel.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_PhyStatus.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__string.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_MultipeerPeer_.swift +46 -0
- package/nitrogen/generated/ios/swift/GATTCharacteristic.swift +25 -1
- package/nitrogen/generated/ios/swift/GATTDescriptor.swift +71 -0
- package/nitrogen/generated/ios/swift/GATTService.swift +25 -1
- package/nitrogen/generated/ios/swift/HybridMunimBluetoothSpec.swift +29 -0
- package/nitrogen/generated/ios/swift/HybridMunimBluetoothSpec_cxx.swift +556 -23
- package/nitrogen/generated/ios/swift/L2CAPChannel.swift +52 -0
- package/nitrogen/generated/ios/swift/MultipeerDiscoveryInfoEntry.swift +34 -0
- package/nitrogen/generated/ios/swift/MultipeerEncryptionPreference.swift +44 -0
- package/nitrogen/generated/ios/swift/MultipeerPeer.swift +63 -0
- package/nitrogen/generated/ios/swift/MultipeerPeerState.swift +44 -0
- package/nitrogen/generated/ios/swift/MultipeerSessionOptions.swift +136 -0
- package/nitrogen/generated/ios/swift/PhyStatus.swift +34 -0
- package/nitrogen/generated/shared/c++/BluetoothCapabilities.hpp +131 -0
- package/nitrogen/generated/shared/c++/BluetoothPhy.hpp +80 -0
- package/nitrogen/generated/shared/c++/BluetoothPhyOption.hpp +80 -0
- package/nitrogen/generated/shared/c++/BondState.hpp +84 -0
- package/nitrogen/generated/shared/c++/DescriptorValue.hpp +95 -0
- package/nitrogen/generated/shared/c++/ExtendedAdvertisingOptions.hpp +138 -0
- package/nitrogen/generated/shared/c++/GATTCharacteristic.hpp +9 -3
- package/nitrogen/generated/shared/c++/GATTDescriptor.hpp +93 -0
- package/nitrogen/generated/shared/c++/GATTService.hpp +7 -2
- package/nitrogen/generated/shared/c++/HybridMunimBluetoothSpec.cpp +29 -0
- package/nitrogen/generated/shared/c++/HybridMunimBluetoothSpec.hpp +61 -2
- package/nitrogen/generated/shared/c++/L2CAPChannel.hpp +92 -0
- package/nitrogen/generated/shared/c++/MultipeerDiscoveryInfoEntry.hpp +87 -0
- package/nitrogen/generated/shared/c++/MultipeerEncryptionPreference.hpp +80 -0
- package/nitrogen/generated/shared/c++/MultipeerPeer.hpp +102 -0
- package/nitrogen/generated/shared/c++/MultipeerPeerState.hpp +80 -0
- package/nitrogen/generated/shared/c++/MultipeerSessionOptions.hpp +114 -0
- package/nitrogen/generated/shared/c++/PhyStatus.hpp +88 -0
- package/package.json +23 -12
- package/src/index.ts +416 -31
- package/src/specs/munim-bluetooth.nitro.ts +298 -14
|
@@ -73,130 +73,130 @@ namespace margelo::nitro::munimbluetooth {
|
|
|
73
73
|
jni::local_ref<jni::JString> manufacturerData = this->getFieldValue(fieldManufacturerData);
|
|
74
74
|
return AdvertisingDataTypes(
|
|
75
75
|
flags != nullptr ? std::make_optional(flags->value()) : std::nullopt,
|
|
76
|
-
incompleteServiceUUIDs16 != nullptr ? std::make_optional([&]() {
|
|
77
|
-
size_t __size =
|
|
76
|
+
incompleteServiceUUIDs16 != nullptr ? std::make_optional([&](auto&& __input) {
|
|
77
|
+
size_t __size = __input->size();
|
|
78
78
|
std::vector<std::string> __vector;
|
|
79
79
|
__vector.reserve(__size);
|
|
80
80
|
for (size_t __i = 0; __i < __size; __i++) {
|
|
81
|
-
auto __element =
|
|
81
|
+
auto __element = __input->getElement(__i);
|
|
82
82
|
__vector.push_back(__element->toStdString());
|
|
83
83
|
}
|
|
84
84
|
return __vector;
|
|
85
|
-
}()) : std::nullopt,
|
|
86
|
-
completeServiceUUIDs16 != nullptr ? std::make_optional([&]() {
|
|
87
|
-
size_t __size =
|
|
85
|
+
}(incompleteServiceUUIDs16)) : std::nullopt,
|
|
86
|
+
completeServiceUUIDs16 != nullptr ? std::make_optional([&](auto&& __input) {
|
|
87
|
+
size_t __size = __input->size();
|
|
88
88
|
std::vector<std::string> __vector;
|
|
89
89
|
__vector.reserve(__size);
|
|
90
90
|
for (size_t __i = 0; __i < __size; __i++) {
|
|
91
|
-
auto __element =
|
|
91
|
+
auto __element = __input->getElement(__i);
|
|
92
92
|
__vector.push_back(__element->toStdString());
|
|
93
93
|
}
|
|
94
94
|
return __vector;
|
|
95
|
-
}()) : std::nullopt,
|
|
96
|
-
incompleteServiceUUIDs32 != nullptr ? std::make_optional([&]() {
|
|
97
|
-
size_t __size =
|
|
95
|
+
}(completeServiceUUIDs16)) : std::nullopt,
|
|
96
|
+
incompleteServiceUUIDs32 != nullptr ? std::make_optional([&](auto&& __input) {
|
|
97
|
+
size_t __size = __input->size();
|
|
98
98
|
std::vector<std::string> __vector;
|
|
99
99
|
__vector.reserve(__size);
|
|
100
100
|
for (size_t __i = 0; __i < __size; __i++) {
|
|
101
|
-
auto __element =
|
|
101
|
+
auto __element = __input->getElement(__i);
|
|
102
102
|
__vector.push_back(__element->toStdString());
|
|
103
103
|
}
|
|
104
104
|
return __vector;
|
|
105
|
-
}()) : std::nullopt,
|
|
106
|
-
completeServiceUUIDs32 != nullptr ? std::make_optional([&]() {
|
|
107
|
-
size_t __size =
|
|
105
|
+
}(incompleteServiceUUIDs32)) : std::nullopt,
|
|
106
|
+
completeServiceUUIDs32 != nullptr ? std::make_optional([&](auto&& __input) {
|
|
107
|
+
size_t __size = __input->size();
|
|
108
108
|
std::vector<std::string> __vector;
|
|
109
109
|
__vector.reserve(__size);
|
|
110
110
|
for (size_t __i = 0; __i < __size; __i++) {
|
|
111
|
-
auto __element =
|
|
111
|
+
auto __element = __input->getElement(__i);
|
|
112
112
|
__vector.push_back(__element->toStdString());
|
|
113
113
|
}
|
|
114
114
|
return __vector;
|
|
115
|
-
}()) : std::nullopt,
|
|
116
|
-
incompleteServiceUUIDs128 != nullptr ? std::make_optional([&]() {
|
|
117
|
-
size_t __size =
|
|
115
|
+
}(completeServiceUUIDs32)) : std::nullopt,
|
|
116
|
+
incompleteServiceUUIDs128 != nullptr ? std::make_optional([&](auto&& __input) {
|
|
117
|
+
size_t __size = __input->size();
|
|
118
118
|
std::vector<std::string> __vector;
|
|
119
119
|
__vector.reserve(__size);
|
|
120
120
|
for (size_t __i = 0; __i < __size; __i++) {
|
|
121
|
-
auto __element =
|
|
121
|
+
auto __element = __input->getElement(__i);
|
|
122
122
|
__vector.push_back(__element->toStdString());
|
|
123
123
|
}
|
|
124
124
|
return __vector;
|
|
125
|
-
}()) : std::nullopt,
|
|
126
|
-
completeServiceUUIDs128 != nullptr ? std::make_optional([&]() {
|
|
127
|
-
size_t __size =
|
|
125
|
+
}(incompleteServiceUUIDs128)) : std::nullopt,
|
|
126
|
+
completeServiceUUIDs128 != nullptr ? std::make_optional([&](auto&& __input) {
|
|
127
|
+
size_t __size = __input->size();
|
|
128
128
|
std::vector<std::string> __vector;
|
|
129
129
|
__vector.reserve(__size);
|
|
130
130
|
for (size_t __i = 0; __i < __size; __i++) {
|
|
131
|
-
auto __element =
|
|
131
|
+
auto __element = __input->getElement(__i);
|
|
132
132
|
__vector.push_back(__element->toStdString());
|
|
133
133
|
}
|
|
134
134
|
return __vector;
|
|
135
|
-
}()) : std::nullopt,
|
|
135
|
+
}(completeServiceUUIDs128)) : std::nullopt,
|
|
136
136
|
shortenedLocalName != nullptr ? std::make_optional(shortenedLocalName->toStdString()) : std::nullopt,
|
|
137
137
|
completeLocalName != nullptr ? std::make_optional(completeLocalName->toStdString()) : std::nullopt,
|
|
138
138
|
txPowerLevel != nullptr ? std::make_optional(txPowerLevel->value()) : std::nullopt,
|
|
139
|
-
serviceSolicitationUUIDs16 != nullptr ? std::make_optional([&]() {
|
|
140
|
-
size_t __size =
|
|
139
|
+
serviceSolicitationUUIDs16 != nullptr ? std::make_optional([&](auto&& __input) {
|
|
140
|
+
size_t __size = __input->size();
|
|
141
141
|
std::vector<std::string> __vector;
|
|
142
142
|
__vector.reserve(__size);
|
|
143
143
|
for (size_t __i = 0; __i < __size; __i++) {
|
|
144
|
-
auto __element =
|
|
144
|
+
auto __element = __input->getElement(__i);
|
|
145
145
|
__vector.push_back(__element->toStdString());
|
|
146
146
|
}
|
|
147
147
|
return __vector;
|
|
148
|
-
}()) : std::nullopt,
|
|
149
|
-
serviceSolicitationUUIDs128 != nullptr ? std::make_optional([&]() {
|
|
150
|
-
size_t __size =
|
|
148
|
+
}(serviceSolicitationUUIDs16)) : std::nullopt,
|
|
149
|
+
serviceSolicitationUUIDs128 != nullptr ? std::make_optional([&](auto&& __input) {
|
|
150
|
+
size_t __size = __input->size();
|
|
151
151
|
std::vector<std::string> __vector;
|
|
152
152
|
__vector.reserve(__size);
|
|
153
153
|
for (size_t __i = 0; __i < __size; __i++) {
|
|
154
|
-
auto __element =
|
|
154
|
+
auto __element = __input->getElement(__i);
|
|
155
155
|
__vector.push_back(__element->toStdString());
|
|
156
156
|
}
|
|
157
157
|
return __vector;
|
|
158
|
-
}()) : std::nullopt,
|
|
159
|
-
serviceData16 != nullptr ? std::make_optional([&]() {
|
|
160
|
-
size_t __size =
|
|
158
|
+
}(serviceSolicitationUUIDs128)) : std::nullopt,
|
|
159
|
+
serviceData16 != nullptr ? std::make_optional([&](auto&& __input) {
|
|
160
|
+
size_t __size = __input->size();
|
|
161
161
|
std::vector<ServiceDataEntry> __vector;
|
|
162
162
|
__vector.reserve(__size);
|
|
163
163
|
for (size_t __i = 0; __i < __size; __i++) {
|
|
164
|
-
auto __element =
|
|
164
|
+
auto __element = __input->getElement(__i);
|
|
165
165
|
__vector.push_back(__element->toCpp());
|
|
166
166
|
}
|
|
167
167
|
return __vector;
|
|
168
|
-
}()) : std::nullopt,
|
|
169
|
-
serviceData32 != nullptr ? std::make_optional([&]() {
|
|
170
|
-
size_t __size =
|
|
168
|
+
}(serviceData16)) : std::nullopt,
|
|
169
|
+
serviceData32 != nullptr ? std::make_optional([&](auto&& __input) {
|
|
170
|
+
size_t __size = __input->size();
|
|
171
171
|
std::vector<ServiceDataEntry> __vector;
|
|
172
172
|
__vector.reserve(__size);
|
|
173
173
|
for (size_t __i = 0; __i < __size; __i++) {
|
|
174
|
-
auto __element =
|
|
174
|
+
auto __element = __input->getElement(__i);
|
|
175
175
|
__vector.push_back(__element->toCpp());
|
|
176
176
|
}
|
|
177
177
|
return __vector;
|
|
178
|
-
}()) : std::nullopt,
|
|
179
|
-
serviceData128 != nullptr ? std::make_optional([&]() {
|
|
180
|
-
size_t __size =
|
|
178
|
+
}(serviceData32)) : std::nullopt,
|
|
179
|
+
serviceData128 != nullptr ? std::make_optional([&](auto&& __input) {
|
|
180
|
+
size_t __size = __input->size();
|
|
181
181
|
std::vector<ServiceDataEntry> __vector;
|
|
182
182
|
__vector.reserve(__size);
|
|
183
183
|
for (size_t __i = 0; __i < __size; __i++) {
|
|
184
|
-
auto __element =
|
|
184
|
+
auto __element = __input->getElement(__i);
|
|
185
185
|
__vector.push_back(__element->toCpp());
|
|
186
186
|
}
|
|
187
187
|
return __vector;
|
|
188
|
-
}()) : std::nullopt,
|
|
188
|
+
}(serviceData128)) : std::nullopt,
|
|
189
189
|
appearance != nullptr ? std::make_optional(appearance->value()) : std::nullopt,
|
|
190
|
-
serviceSolicitationUUIDs32 != nullptr ? std::make_optional([&]() {
|
|
191
|
-
size_t __size =
|
|
190
|
+
serviceSolicitationUUIDs32 != nullptr ? std::make_optional([&](auto&& __input) {
|
|
191
|
+
size_t __size = __input->size();
|
|
192
192
|
std::vector<std::string> __vector;
|
|
193
193
|
__vector.reserve(__size);
|
|
194
194
|
for (size_t __i = 0; __i < __size; __i++) {
|
|
195
|
-
auto __element =
|
|
195
|
+
auto __element = __input->getElement(__i);
|
|
196
196
|
__vector.push_back(__element->toStdString());
|
|
197
197
|
}
|
|
198
198
|
return __vector;
|
|
199
|
-
}()) : std::nullopt,
|
|
199
|
+
}(serviceSolicitationUUIDs32)) : std::nullopt,
|
|
200
200
|
manufacturerData != nullptr ? std::make_optional(manufacturerData->toStdString()) : std::nullopt
|
|
201
201
|
);
|
|
202
202
|
}
|
|
@@ -213,130 +213,130 @@ namespace margelo::nitro::munimbluetooth {
|
|
|
213
213
|
return create(
|
|
214
214
|
clazz,
|
|
215
215
|
value.flags.has_value() ? jni::JDouble::valueOf(value.flags.value()) : nullptr,
|
|
216
|
-
value.incompleteServiceUUIDs16.has_value() ? [&]() {
|
|
217
|
-
size_t __size =
|
|
216
|
+
value.incompleteServiceUUIDs16.has_value() ? [&](auto&& __input) {
|
|
217
|
+
size_t __size = __input.size();
|
|
218
218
|
jni::local_ref<jni::JArrayClass<jni::JString>> __array = jni::JArrayClass<jni::JString>::newArray(__size);
|
|
219
219
|
for (size_t __i = 0; __i < __size; __i++) {
|
|
220
|
-
const auto& __element =
|
|
220
|
+
const auto& __element = __input[__i];
|
|
221
221
|
auto __elementJni = jni::make_jstring(__element);
|
|
222
222
|
__array->setElement(__i, *__elementJni);
|
|
223
223
|
}
|
|
224
224
|
return __array;
|
|
225
|
-
}() : nullptr,
|
|
226
|
-
value.completeServiceUUIDs16.has_value() ? [&]() {
|
|
227
|
-
size_t __size =
|
|
225
|
+
}(value.incompleteServiceUUIDs16.value()) : nullptr,
|
|
226
|
+
value.completeServiceUUIDs16.has_value() ? [&](auto&& __input) {
|
|
227
|
+
size_t __size = __input.size();
|
|
228
228
|
jni::local_ref<jni::JArrayClass<jni::JString>> __array = jni::JArrayClass<jni::JString>::newArray(__size);
|
|
229
229
|
for (size_t __i = 0; __i < __size; __i++) {
|
|
230
|
-
const auto& __element =
|
|
230
|
+
const auto& __element = __input[__i];
|
|
231
231
|
auto __elementJni = jni::make_jstring(__element);
|
|
232
232
|
__array->setElement(__i, *__elementJni);
|
|
233
233
|
}
|
|
234
234
|
return __array;
|
|
235
|
-
}() : nullptr,
|
|
236
|
-
value.incompleteServiceUUIDs32.has_value() ? [&]() {
|
|
237
|
-
size_t __size =
|
|
235
|
+
}(value.completeServiceUUIDs16.value()) : nullptr,
|
|
236
|
+
value.incompleteServiceUUIDs32.has_value() ? [&](auto&& __input) {
|
|
237
|
+
size_t __size = __input.size();
|
|
238
238
|
jni::local_ref<jni::JArrayClass<jni::JString>> __array = jni::JArrayClass<jni::JString>::newArray(__size);
|
|
239
239
|
for (size_t __i = 0; __i < __size; __i++) {
|
|
240
|
-
const auto& __element =
|
|
240
|
+
const auto& __element = __input[__i];
|
|
241
241
|
auto __elementJni = jni::make_jstring(__element);
|
|
242
242
|
__array->setElement(__i, *__elementJni);
|
|
243
243
|
}
|
|
244
244
|
return __array;
|
|
245
|
-
}() : nullptr,
|
|
246
|
-
value.completeServiceUUIDs32.has_value() ? [&]() {
|
|
247
|
-
size_t __size =
|
|
245
|
+
}(value.incompleteServiceUUIDs32.value()) : nullptr,
|
|
246
|
+
value.completeServiceUUIDs32.has_value() ? [&](auto&& __input) {
|
|
247
|
+
size_t __size = __input.size();
|
|
248
248
|
jni::local_ref<jni::JArrayClass<jni::JString>> __array = jni::JArrayClass<jni::JString>::newArray(__size);
|
|
249
249
|
for (size_t __i = 0; __i < __size; __i++) {
|
|
250
|
-
const auto& __element =
|
|
250
|
+
const auto& __element = __input[__i];
|
|
251
251
|
auto __elementJni = jni::make_jstring(__element);
|
|
252
252
|
__array->setElement(__i, *__elementJni);
|
|
253
253
|
}
|
|
254
254
|
return __array;
|
|
255
|
-
}() : nullptr,
|
|
256
|
-
value.incompleteServiceUUIDs128.has_value() ? [&]() {
|
|
257
|
-
size_t __size =
|
|
255
|
+
}(value.completeServiceUUIDs32.value()) : nullptr,
|
|
256
|
+
value.incompleteServiceUUIDs128.has_value() ? [&](auto&& __input) {
|
|
257
|
+
size_t __size = __input.size();
|
|
258
258
|
jni::local_ref<jni::JArrayClass<jni::JString>> __array = jni::JArrayClass<jni::JString>::newArray(__size);
|
|
259
259
|
for (size_t __i = 0; __i < __size; __i++) {
|
|
260
|
-
const auto& __element =
|
|
260
|
+
const auto& __element = __input[__i];
|
|
261
261
|
auto __elementJni = jni::make_jstring(__element);
|
|
262
262
|
__array->setElement(__i, *__elementJni);
|
|
263
263
|
}
|
|
264
264
|
return __array;
|
|
265
|
-
}() : nullptr,
|
|
266
|
-
value.completeServiceUUIDs128.has_value() ? [&]() {
|
|
267
|
-
size_t __size =
|
|
265
|
+
}(value.incompleteServiceUUIDs128.value()) : nullptr,
|
|
266
|
+
value.completeServiceUUIDs128.has_value() ? [&](auto&& __input) {
|
|
267
|
+
size_t __size = __input.size();
|
|
268
268
|
jni::local_ref<jni::JArrayClass<jni::JString>> __array = jni::JArrayClass<jni::JString>::newArray(__size);
|
|
269
269
|
for (size_t __i = 0; __i < __size; __i++) {
|
|
270
|
-
const auto& __element =
|
|
270
|
+
const auto& __element = __input[__i];
|
|
271
271
|
auto __elementJni = jni::make_jstring(__element);
|
|
272
272
|
__array->setElement(__i, *__elementJni);
|
|
273
273
|
}
|
|
274
274
|
return __array;
|
|
275
|
-
}() : nullptr,
|
|
275
|
+
}(value.completeServiceUUIDs128.value()) : nullptr,
|
|
276
276
|
value.shortenedLocalName.has_value() ? jni::make_jstring(value.shortenedLocalName.value()) : nullptr,
|
|
277
277
|
value.completeLocalName.has_value() ? jni::make_jstring(value.completeLocalName.value()) : nullptr,
|
|
278
278
|
value.txPowerLevel.has_value() ? jni::JDouble::valueOf(value.txPowerLevel.value()) : nullptr,
|
|
279
|
-
value.serviceSolicitationUUIDs16.has_value() ? [&]() {
|
|
280
|
-
size_t __size =
|
|
279
|
+
value.serviceSolicitationUUIDs16.has_value() ? [&](auto&& __input) {
|
|
280
|
+
size_t __size = __input.size();
|
|
281
281
|
jni::local_ref<jni::JArrayClass<jni::JString>> __array = jni::JArrayClass<jni::JString>::newArray(__size);
|
|
282
282
|
for (size_t __i = 0; __i < __size; __i++) {
|
|
283
|
-
const auto& __element =
|
|
283
|
+
const auto& __element = __input[__i];
|
|
284
284
|
auto __elementJni = jni::make_jstring(__element);
|
|
285
285
|
__array->setElement(__i, *__elementJni);
|
|
286
286
|
}
|
|
287
287
|
return __array;
|
|
288
|
-
}() : nullptr,
|
|
289
|
-
value.serviceSolicitationUUIDs128.has_value() ? [&]() {
|
|
290
|
-
size_t __size =
|
|
288
|
+
}(value.serviceSolicitationUUIDs16.value()) : nullptr,
|
|
289
|
+
value.serviceSolicitationUUIDs128.has_value() ? [&](auto&& __input) {
|
|
290
|
+
size_t __size = __input.size();
|
|
291
291
|
jni::local_ref<jni::JArrayClass<jni::JString>> __array = jni::JArrayClass<jni::JString>::newArray(__size);
|
|
292
292
|
for (size_t __i = 0; __i < __size; __i++) {
|
|
293
|
-
const auto& __element =
|
|
293
|
+
const auto& __element = __input[__i];
|
|
294
294
|
auto __elementJni = jni::make_jstring(__element);
|
|
295
295
|
__array->setElement(__i, *__elementJni);
|
|
296
296
|
}
|
|
297
297
|
return __array;
|
|
298
|
-
}() : nullptr,
|
|
299
|
-
value.serviceData16.has_value() ? [&]() {
|
|
300
|
-
size_t __size =
|
|
298
|
+
}(value.serviceSolicitationUUIDs128.value()) : nullptr,
|
|
299
|
+
value.serviceData16.has_value() ? [&](auto&& __input) {
|
|
300
|
+
size_t __size = __input.size();
|
|
301
301
|
jni::local_ref<jni::JArrayClass<JServiceDataEntry>> __array = jni::JArrayClass<JServiceDataEntry>::newArray(__size);
|
|
302
302
|
for (size_t __i = 0; __i < __size; __i++) {
|
|
303
|
-
const auto& __element =
|
|
303
|
+
const auto& __element = __input[__i];
|
|
304
304
|
auto __elementJni = JServiceDataEntry::fromCpp(__element);
|
|
305
305
|
__array->setElement(__i, *__elementJni);
|
|
306
306
|
}
|
|
307
307
|
return __array;
|
|
308
|
-
}() : nullptr,
|
|
309
|
-
value.serviceData32.has_value() ? [&]() {
|
|
310
|
-
size_t __size =
|
|
308
|
+
}(value.serviceData16.value()) : nullptr,
|
|
309
|
+
value.serviceData32.has_value() ? [&](auto&& __input) {
|
|
310
|
+
size_t __size = __input.size();
|
|
311
311
|
jni::local_ref<jni::JArrayClass<JServiceDataEntry>> __array = jni::JArrayClass<JServiceDataEntry>::newArray(__size);
|
|
312
312
|
for (size_t __i = 0; __i < __size; __i++) {
|
|
313
|
-
const auto& __element =
|
|
313
|
+
const auto& __element = __input[__i];
|
|
314
314
|
auto __elementJni = JServiceDataEntry::fromCpp(__element);
|
|
315
315
|
__array->setElement(__i, *__elementJni);
|
|
316
316
|
}
|
|
317
317
|
return __array;
|
|
318
|
-
}() : nullptr,
|
|
319
|
-
value.serviceData128.has_value() ? [&]() {
|
|
320
|
-
size_t __size =
|
|
318
|
+
}(value.serviceData32.value()) : nullptr,
|
|
319
|
+
value.serviceData128.has_value() ? [&](auto&& __input) {
|
|
320
|
+
size_t __size = __input.size();
|
|
321
321
|
jni::local_ref<jni::JArrayClass<JServiceDataEntry>> __array = jni::JArrayClass<JServiceDataEntry>::newArray(__size);
|
|
322
322
|
for (size_t __i = 0; __i < __size; __i++) {
|
|
323
|
-
const auto& __element =
|
|
323
|
+
const auto& __element = __input[__i];
|
|
324
324
|
auto __elementJni = JServiceDataEntry::fromCpp(__element);
|
|
325
325
|
__array->setElement(__i, *__elementJni);
|
|
326
326
|
}
|
|
327
327
|
return __array;
|
|
328
|
-
}() : nullptr,
|
|
328
|
+
}(value.serviceData128.value()) : nullptr,
|
|
329
329
|
value.appearance.has_value() ? jni::JDouble::valueOf(value.appearance.value()) : nullptr,
|
|
330
|
-
value.serviceSolicitationUUIDs32.has_value() ? [&]() {
|
|
331
|
-
size_t __size =
|
|
330
|
+
value.serviceSolicitationUUIDs32.has_value() ? [&](auto&& __input) {
|
|
331
|
+
size_t __size = __input.size();
|
|
332
332
|
jni::local_ref<jni::JArrayClass<jni::JString>> __array = jni::JArrayClass<jni::JString>::newArray(__size);
|
|
333
333
|
for (size_t __i = 0; __i < __size; __i++) {
|
|
334
|
-
const auto& __element =
|
|
334
|
+
const auto& __element = __input[__i];
|
|
335
335
|
auto __elementJni = jni::make_jstring(__element);
|
|
336
336
|
__array->setElement(__i, *__elementJni);
|
|
337
337
|
}
|
|
338
338
|
return __array;
|
|
339
|
-
}() : nullptr,
|
|
339
|
+
}(value.serviceSolicitationUUIDs32.value()) : nullptr,
|
|
340
340
|
value.manufacturerData.has_value() ? jni::make_jstring(value.manufacturerData.value()) : nullptr
|
|
341
341
|
);
|
|
342
342
|
}
|
|
@@ -46,16 +46,16 @@ namespace margelo::nitro::munimbluetooth {
|
|
|
46
46
|
static const auto fieldAdvertisingData = clazz->getField<JAdvertisingDataTypes>("advertisingData");
|
|
47
47
|
jni::local_ref<JAdvertisingDataTypes> advertisingData = this->getFieldValue(fieldAdvertisingData);
|
|
48
48
|
return AdvertisingOptions(
|
|
49
|
-
[&]() {
|
|
50
|
-
size_t __size =
|
|
49
|
+
[&](auto&& __input) {
|
|
50
|
+
size_t __size = __input->size();
|
|
51
51
|
std::vector<std::string> __vector;
|
|
52
52
|
__vector.reserve(__size);
|
|
53
53
|
for (size_t __i = 0; __i < __size; __i++) {
|
|
54
|
-
auto __element =
|
|
54
|
+
auto __element = __input->getElement(__i);
|
|
55
55
|
__vector.push_back(__element->toStdString());
|
|
56
56
|
}
|
|
57
57
|
return __vector;
|
|
58
|
-
}(),
|
|
58
|
+
}(serviceUUIDs),
|
|
59
59
|
localName != nullptr ? std::make_optional(localName->toStdString()) : std::nullopt,
|
|
60
60
|
manufacturerData != nullptr ? std::make_optional(manufacturerData->toStdString()) : std::nullopt,
|
|
61
61
|
advertisingData != nullptr ? std::make_optional(advertisingData->toCpp()) : std::nullopt
|
|
@@ -73,16 +73,16 @@ namespace margelo::nitro::munimbluetooth {
|
|
|
73
73
|
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
74
74
|
return create(
|
|
75
75
|
clazz,
|
|
76
|
-
[&]() {
|
|
77
|
-
size_t __size =
|
|
76
|
+
[&](auto&& __input) {
|
|
77
|
+
size_t __size = __input.size();
|
|
78
78
|
jni::local_ref<jni::JArrayClass<jni::JString>> __array = jni::JArrayClass<jni::JString>::newArray(__size);
|
|
79
79
|
for (size_t __i = 0; __i < __size; __i++) {
|
|
80
|
-
const auto& __element =
|
|
80
|
+
const auto& __element = __input[__i];
|
|
81
81
|
auto __elementJni = jni::make_jstring(__element);
|
|
82
82
|
__array->setElement(__i, *__elementJni);
|
|
83
83
|
}
|
|
84
84
|
return __array;
|
|
85
|
-
}(),
|
|
85
|
+
}(value.serviceUUIDs),
|
|
86
86
|
value.localName.has_value() ? jni::make_jstring(value.localName.value()) : nullptr,
|
|
87
87
|
value.manufacturerData.has_value() ? jni::make_jstring(value.manufacturerData.value()) : nullptr,
|
|
88
88
|
value.advertisingData.has_value() ? JAdvertisingDataTypes::fromCpp(value.advertisingData.value()) : nullptr
|
|
@@ -52,16 +52,16 @@ namespace margelo::nitro::munimbluetooth {
|
|
|
52
52
|
static const auto fieldAndroidNotificationText = clazz->getField<jni::JString>("androidNotificationText");
|
|
53
53
|
jni::local_ref<jni::JString> androidNotificationText = this->getFieldValue(fieldAndroidNotificationText);
|
|
54
54
|
return BackgroundSessionOptions(
|
|
55
|
-
[&]() {
|
|
56
|
-
size_t __size =
|
|
55
|
+
[&](auto&& __input) {
|
|
56
|
+
size_t __size = __input->size();
|
|
57
57
|
std::vector<std::string> __vector;
|
|
58
58
|
__vector.reserve(__size);
|
|
59
59
|
for (size_t __i = 0; __i < __size; __i++) {
|
|
60
|
-
auto __element =
|
|
60
|
+
auto __element = __input->getElement(__i);
|
|
61
61
|
__vector.push_back(__element->toStdString());
|
|
62
62
|
}
|
|
63
63
|
return __vector;
|
|
64
|
-
}(),
|
|
64
|
+
}(serviceUUIDs),
|
|
65
65
|
localName != nullptr ? std::make_optional(localName->toStdString()) : std::nullopt,
|
|
66
66
|
allowDuplicates != nullptr ? std::make_optional(static_cast<bool>(allowDuplicates->value())) : std::nullopt,
|
|
67
67
|
scanMode != nullptr ? std::make_optional(scanMode->toCpp()) : std::nullopt,
|
|
@@ -83,16 +83,16 @@ namespace margelo::nitro::munimbluetooth {
|
|
|
83
83
|
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
84
84
|
return create(
|
|
85
85
|
clazz,
|
|
86
|
-
[&]() {
|
|
87
|
-
size_t __size =
|
|
86
|
+
[&](auto&& __input) {
|
|
87
|
+
size_t __size = __input.size();
|
|
88
88
|
jni::local_ref<jni::JArrayClass<jni::JString>> __array = jni::JArrayClass<jni::JString>::newArray(__size);
|
|
89
89
|
for (size_t __i = 0; __i < __size; __i++) {
|
|
90
|
-
const auto& __element =
|
|
90
|
+
const auto& __element = __input[__i];
|
|
91
91
|
auto __elementJni = jni::make_jstring(__element);
|
|
92
92
|
__array->setElement(__i, *__elementJni);
|
|
93
93
|
}
|
|
94
94
|
return __array;
|
|
95
|
-
}(),
|
|
95
|
+
}(value.serviceUUIDs),
|
|
96
96
|
value.localName.has_value() ? jni::make_jstring(value.localName.value()) : nullptr,
|
|
97
97
|
value.allowDuplicates.has_value() ? jni::JBoolean::valueOf(value.allowDuplicates.value()) : nullptr,
|
|
98
98
|
value.scanMode.has_value() ? JScanMode::fromCpp(value.scanMode.value()) : nullptr,
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JBluetoothCapabilities.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include "BluetoothCapabilities.hpp"
|
|
12
|
+
|
|
13
|
+
#include <string>
|
|
14
|
+
|
|
15
|
+
namespace margelo::nitro::munimbluetooth {
|
|
16
|
+
|
|
17
|
+
using namespace facebook;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The C++ JNI bridge between the C++ struct "BluetoothCapabilities" and the the Kotlin data class "BluetoothCapabilities".
|
|
21
|
+
*/
|
|
22
|
+
struct JBluetoothCapabilities final: public jni::JavaClass<JBluetoothCapabilities> {
|
|
23
|
+
public:
|
|
24
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/BluetoothCapabilities;";
|
|
25
|
+
|
|
26
|
+
public:
|
|
27
|
+
/**
|
|
28
|
+
* Convert this Java/Kotlin-based struct to the C++ struct BluetoothCapabilities by copying all values to C++.
|
|
29
|
+
*/
|
|
30
|
+
[[maybe_unused]]
|
|
31
|
+
[[nodiscard]]
|
|
32
|
+
BluetoothCapabilities toCpp() const {
|
|
33
|
+
static const auto clazz = javaClassStatic();
|
|
34
|
+
static const auto fieldPlatform = clazz->getField<jni::JString>("platform");
|
|
35
|
+
jni::local_ref<jni::JString> platform = this->getFieldValue(fieldPlatform);
|
|
36
|
+
static const auto fieldSupportsBleCentral = clazz->getField<jboolean>("supportsBleCentral");
|
|
37
|
+
jboolean supportsBleCentral = this->getFieldValue(fieldSupportsBleCentral);
|
|
38
|
+
static const auto fieldSupportsBlePeripheral = clazz->getField<jboolean>("supportsBlePeripheral");
|
|
39
|
+
jboolean supportsBlePeripheral = this->getFieldValue(fieldSupportsBlePeripheral);
|
|
40
|
+
static const auto fieldSupportsDescriptors = clazz->getField<jboolean>("supportsDescriptors");
|
|
41
|
+
jboolean supportsDescriptors = this->getFieldValue(fieldSupportsDescriptors);
|
|
42
|
+
static const auto fieldSupportsIncludedServices = clazz->getField<jboolean>("supportsIncludedServices");
|
|
43
|
+
jboolean supportsIncludedServices = this->getFieldValue(fieldSupportsIncludedServices);
|
|
44
|
+
static const auto fieldSupportsMtu = clazz->getField<jboolean>("supportsMtu");
|
|
45
|
+
jboolean supportsMtu = this->getFieldValue(fieldSupportsMtu);
|
|
46
|
+
static const auto fieldSupportsPhy = clazz->getField<jboolean>("supportsPhy");
|
|
47
|
+
jboolean supportsPhy = this->getFieldValue(fieldSupportsPhy);
|
|
48
|
+
static const auto fieldSupportsBonding = clazz->getField<jboolean>("supportsBonding");
|
|
49
|
+
jboolean supportsBonding = this->getFieldValue(fieldSupportsBonding);
|
|
50
|
+
static const auto fieldSupportsExtendedAdvertising = clazz->getField<jboolean>("supportsExtendedAdvertising");
|
|
51
|
+
jboolean supportsExtendedAdvertising = this->getFieldValue(fieldSupportsExtendedAdvertising);
|
|
52
|
+
static const auto fieldSupportsL2cap = clazz->getField<jboolean>("supportsL2cap");
|
|
53
|
+
jboolean supportsL2cap = this->getFieldValue(fieldSupportsL2cap);
|
|
54
|
+
static const auto fieldSupportsClassicBluetooth = clazz->getField<jboolean>("supportsClassicBluetooth");
|
|
55
|
+
jboolean supportsClassicBluetooth = this->getFieldValue(fieldSupportsClassicBluetooth);
|
|
56
|
+
static const auto fieldSupportsBackgroundBle = clazz->getField<jboolean>("supportsBackgroundBle");
|
|
57
|
+
jboolean supportsBackgroundBle = this->getFieldValue(fieldSupportsBackgroundBle);
|
|
58
|
+
static const auto fieldSupportsMultipeerConnectivity = clazz->getField<jboolean>("supportsMultipeerConnectivity");
|
|
59
|
+
jboolean supportsMultipeerConnectivity = this->getFieldValue(fieldSupportsMultipeerConnectivity);
|
|
60
|
+
return BluetoothCapabilities(
|
|
61
|
+
platform->toStdString(),
|
|
62
|
+
static_cast<bool>(supportsBleCentral),
|
|
63
|
+
static_cast<bool>(supportsBlePeripheral),
|
|
64
|
+
static_cast<bool>(supportsDescriptors),
|
|
65
|
+
static_cast<bool>(supportsIncludedServices),
|
|
66
|
+
static_cast<bool>(supportsMtu),
|
|
67
|
+
static_cast<bool>(supportsPhy),
|
|
68
|
+
static_cast<bool>(supportsBonding),
|
|
69
|
+
static_cast<bool>(supportsExtendedAdvertising),
|
|
70
|
+
static_cast<bool>(supportsL2cap),
|
|
71
|
+
static_cast<bool>(supportsClassicBluetooth),
|
|
72
|
+
static_cast<bool>(supportsBackgroundBle),
|
|
73
|
+
static_cast<bool>(supportsMultipeerConnectivity)
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
public:
|
|
78
|
+
/**
|
|
79
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
80
|
+
*/
|
|
81
|
+
[[maybe_unused]]
|
|
82
|
+
static jni::local_ref<JBluetoothCapabilities::javaobject> fromCpp(const BluetoothCapabilities& value) {
|
|
83
|
+
using JSignature = JBluetoothCapabilities(jni::alias_ref<jni::JString>, jboolean, jboolean, jboolean, jboolean, jboolean, jboolean, jboolean, jboolean, jboolean, jboolean, jboolean, jboolean);
|
|
84
|
+
static const auto clazz = javaClassStatic();
|
|
85
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
86
|
+
return create(
|
|
87
|
+
clazz,
|
|
88
|
+
jni::make_jstring(value.platform),
|
|
89
|
+
value.supportsBleCentral,
|
|
90
|
+
value.supportsBlePeripheral,
|
|
91
|
+
value.supportsDescriptors,
|
|
92
|
+
value.supportsIncludedServices,
|
|
93
|
+
value.supportsMtu,
|
|
94
|
+
value.supportsPhy,
|
|
95
|
+
value.supportsBonding,
|
|
96
|
+
value.supportsExtendedAdvertising,
|
|
97
|
+
value.supportsL2cap,
|
|
98
|
+
value.supportsClassicBluetooth,
|
|
99
|
+
value.supportsBackgroundBle,
|
|
100
|
+
value.supportsMultipeerConnectivity
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
} // namespace margelo::nitro::munimbluetooth
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JBluetoothPhy.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include "BluetoothPhy.hpp"
|
|
12
|
+
|
|
13
|
+
namespace margelo::nitro::munimbluetooth {
|
|
14
|
+
|
|
15
|
+
using namespace facebook;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The C++ JNI bridge between the C++ enum "BluetoothPhy" and the the Kotlin enum "BluetoothPhy".
|
|
19
|
+
*/
|
|
20
|
+
struct JBluetoothPhy final: public jni::JavaClass<JBluetoothPhy> {
|
|
21
|
+
public:
|
|
22
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/BluetoothPhy;";
|
|
23
|
+
|
|
24
|
+
public:
|
|
25
|
+
/**
|
|
26
|
+
* Convert this Java/Kotlin-based enum to the C++ enum BluetoothPhy.
|
|
27
|
+
*/
|
|
28
|
+
[[maybe_unused]]
|
|
29
|
+
[[nodiscard]]
|
|
30
|
+
BluetoothPhy toCpp() const {
|
|
31
|
+
static const auto clazz = javaClassStatic();
|
|
32
|
+
static const auto fieldOrdinal = clazz->getField<int>("value");
|
|
33
|
+
int ordinal = this->getFieldValue(fieldOrdinal);
|
|
34
|
+
return static_cast<BluetoothPhy>(ordinal);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public:
|
|
38
|
+
/**
|
|
39
|
+
* Create a Java/Kotlin-based enum with the given C++ enum's value.
|
|
40
|
+
*/
|
|
41
|
+
[[maybe_unused]]
|
|
42
|
+
static jni::alias_ref<JBluetoothPhy> fromCpp(BluetoothPhy value) {
|
|
43
|
+
static const auto clazz = javaClassStatic();
|
|
44
|
+
switch (value) {
|
|
45
|
+
case BluetoothPhy::LE1M:
|
|
46
|
+
static const auto fieldLE1M = clazz->getStaticField<JBluetoothPhy>("LE1M");
|
|
47
|
+
return clazz->getStaticFieldValue(fieldLE1M);
|
|
48
|
+
case BluetoothPhy::LE2M:
|
|
49
|
+
static const auto fieldLE2M = clazz->getStaticField<JBluetoothPhy>("LE2M");
|
|
50
|
+
return clazz->getStaticFieldValue(fieldLE2M);
|
|
51
|
+
case BluetoothPhy::LECODED:
|
|
52
|
+
static const auto fieldLECODED = clazz->getStaticField<JBluetoothPhy>("LECODED");
|
|
53
|
+
return clazz->getStaticFieldValue(fieldLECODED);
|
|
54
|
+
default:
|
|
55
|
+
std::string stringValue = std::to_string(static_cast<int>(value));
|
|
56
|
+
throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
} // namespace margelo::nitro::munimbluetooth
|