munim-bluetooth 0.3.27 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +476 -74
  3. package/android/gradle.properties +2 -2
  4. package/android/src/main/AndroidManifest.xml +3 -1
  5. package/android/src/main/cpp/cpp-adapter.cpp +4 -1
  6. package/android/src/main/java/com/munimbluetooth/HybridMunimBluetooth.kt +2006 -209
  7. package/android/src/main/java/com/munimbluetooth/MunimBluetoothBackgroundService.kt +561 -53
  8. package/app.plugin.js +155 -0
  9. package/ios/HybridMunimBluetooth.swift +2123 -298
  10. package/ios/MunimBluetoothEventEmitter.swift +68 -8
  11. package/lib/commonjs/index.js +272 -11
  12. package/lib/commonjs/index.js.map +1 -1
  13. package/lib/module/index.js +243 -11
  14. package/lib/module/index.js.map +1 -1
  15. package/lib/typescript/src/index.d.ts +310 -7
  16. package/lib/typescript/src/index.d.ts.map +1 -1
  17. package/lib/typescript/src/specs/munim-bluetooth.nitro.d.ts +219 -5
  18. package/lib/typescript/src/specs/munim-bluetooth.nitro.d.ts.map +1 -1
  19. package/nitro.json +9 -3
  20. package/nitrogen/generated/android/c++/JAdvertisingDataTypes.hpp +96 -96
  21. package/nitrogen/generated/android/c++/JAdvertisingOptions.hpp +8 -8
  22. package/nitrogen/generated/android/c++/JBackgroundSessionOptions.hpp +8 -8
  23. package/nitrogen/generated/android/c++/JBluetoothCapabilities.hpp +105 -0
  24. package/nitrogen/generated/android/c++/JBluetoothPhy.hpp +61 -0
  25. package/nitrogen/generated/android/c++/JBluetoothPhyOption.hpp +61 -0
  26. package/nitrogen/generated/android/c++/JBondState.hpp +64 -0
  27. package/nitrogen/generated/android/c++/JDescriptorValue.hpp +69 -0
  28. package/nitrogen/generated/android/c++/JExtendedAdvertisingOptions.hpp +131 -0
  29. package/nitrogen/generated/android/c++/JGATTCharacteristic.hpp +35 -11
  30. package/nitrogen/generated/android/c++/JGATTDescriptor.hpp +85 -0
  31. package/nitrogen/generated/android/c++/JGATTService.hpp +33 -9
  32. package/nitrogen/generated/android/c++/JHybridMunimBluetoothSpec.cpp +422 -12
  33. package/nitrogen/generated/android/c++/JHybridMunimBluetoothSpec.hpp +29 -0
  34. package/nitrogen/generated/android/c++/JL2CAPChannel.hpp +66 -0
  35. package/nitrogen/generated/android/c++/JMultipeerDiscoveryInfoEntry.hpp +61 -0
  36. package/nitrogen/generated/android/c++/JMultipeerEncryptionPreference.hpp +61 -0
  37. package/nitrogen/generated/android/c++/JMultipeerPeer.hpp +93 -0
  38. package/nitrogen/generated/android/c++/JMultipeerPeerState.hpp +61 -0
  39. package/nitrogen/generated/android/c++/JMultipeerSessionOptions.hpp +105 -0
  40. package/nitrogen/generated/android/c++/JPhyStatus.hpp +62 -0
  41. package/nitrogen/generated/android/c++/JScanOptions.hpp +8 -8
  42. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/AdvertisingDataTypes.kt +47 -0
  43. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/AdvertisingOptions.kt +19 -0
  44. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/BackgroundSessionOptions.kt +27 -0
  45. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/BluetoothCapabilities.kt +111 -0
  46. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/BluetoothPhy.kt +24 -0
  47. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/BluetoothPhyOption.kt +24 -0
  48. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/BondState.kt +25 -0
  49. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/CharacteristicValue.kt +17 -0
  50. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/DescriptorValue.kt +66 -0
  51. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/ExtendedAdvertisingOptions.kt +111 -0
  52. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/GATTCharacteristic.kt +25 -3
  53. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/GATTDescriptor.kt +61 -0
  54. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/GATTService.kt +23 -3
  55. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/HybridMunimBluetoothSpec.kt +138 -22
  56. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/L2CAPChannel.kt +61 -0
  57. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/MultipeerDiscoveryInfoEntry.kt +56 -0
  58. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/MultipeerEncryptionPreference.kt +24 -0
  59. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/MultipeerPeer.kt +66 -0
  60. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/MultipeerPeerState.kt +24 -0
  61. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/MultipeerSessionOptions.kt +81 -0
  62. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/PhyStatus.kt +56 -0
  63. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/ScanOptions.kt +17 -0
  64. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/ServiceDataEntry.kt +15 -0
  65. package/nitrogen/generated/ios/MunimBluetooth+autolinking.rb +2 -0
  66. package/nitrogen/generated/ios/MunimBluetooth-Swift-Cxx-Bridge.cpp +61 -5
  67. package/nitrogen/generated/ios/MunimBluetooth-Swift-Cxx-Bridge.hpp +494 -49
  68. package/nitrogen/generated/ios/MunimBluetooth-Swift-Cxx-Umbrella.hpp +42 -0
  69. package/nitrogen/generated/ios/c++/HybridMunimBluetoothSpecSwift.hpp +254 -0
  70. package/nitrogen/generated/ios/swift/BluetoothCapabilities.swift +89 -0
  71. package/nitrogen/generated/ios/swift/BluetoothPhy.swift +44 -0
  72. package/nitrogen/generated/ios/swift/BluetoothPhyOption.swift +44 -0
  73. package/nitrogen/generated/ios/swift/BondState.swift +48 -0
  74. package/nitrogen/generated/ios/swift/DescriptorValue.swift +44 -0
  75. package/nitrogen/generated/ios/swift/ExtendedAdvertisingOptions.swift +243 -0
  76. package/nitrogen/generated/ios/swift/Func_void_BluetoothCapabilities.swift +46 -0
  77. package/nitrogen/generated/ios/swift/Func_void_BondState.swift +46 -0
  78. package/nitrogen/generated/ios/swift/Func_void_DescriptorValue.swift +46 -0
  79. package/nitrogen/generated/ios/swift/Func_void_L2CAPChannel.swift +46 -0
  80. package/nitrogen/generated/ios/swift/Func_void_PhyStatus.swift +46 -0
  81. package/nitrogen/generated/ios/swift/Func_void_std__string.swift +46 -0
  82. package/nitrogen/generated/ios/swift/Func_void_std__vector_MultipeerPeer_.swift +46 -0
  83. package/nitrogen/generated/ios/swift/GATTCharacteristic.swift +25 -1
  84. package/nitrogen/generated/ios/swift/GATTDescriptor.swift +71 -0
  85. package/nitrogen/generated/ios/swift/GATTService.swift +25 -1
  86. package/nitrogen/generated/ios/swift/HybridMunimBluetoothSpec.swift +29 -0
  87. package/nitrogen/generated/ios/swift/HybridMunimBluetoothSpec_cxx.swift +556 -23
  88. package/nitrogen/generated/ios/swift/L2CAPChannel.swift +52 -0
  89. package/nitrogen/generated/ios/swift/MultipeerDiscoveryInfoEntry.swift +34 -0
  90. package/nitrogen/generated/ios/swift/MultipeerEncryptionPreference.swift +44 -0
  91. package/nitrogen/generated/ios/swift/MultipeerPeer.swift +63 -0
  92. package/nitrogen/generated/ios/swift/MultipeerPeerState.swift +44 -0
  93. package/nitrogen/generated/ios/swift/MultipeerSessionOptions.swift +136 -0
  94. package/nitrogen/generated/ios/swift/PhyStatus.swift +34 -0
  95. package/nitrogen/generated/shared/c++/BluetoothCapabilities.hpp +131 -0
  96. package/nitrogen/generated/shared/c++/BluetoothPhy.hpp +80 -0
  97. package/nitrogen/generated/shared/c++/BluetoothPhyOption.hpp +80 -0
  98. package/nitrogen/generated/shared/c++/BondState.hpp +84 -0
  99. package/nitrogen/generated/shared/c++/DescriptorValue.hpp +95 -0
  100. package/nitrogen/generated/shared/c++/ExtendedAdvertisingOptions.hpp +138 -0
  101. package/nitrogen/generated/shared/c++/GATTCharacteristic.hpp +9 -3
  102. package/nitrogen/generated/shared/c++/GATTDescriptor.hpp +93 -0
  103. package/nitrogen/generated/shared/c++/GATTService.hpp +7 -2
  104. package/nitrogen/generated/shared/c++/HybridMunimBluetoothSpec.cpp +29 -0
  105. package/nitrogen/generated/shared/c++/HybridMunimBluetoothSpec.hpp +61 -2
  106. package/nitrogen/generated/shared/c++/L2CAPChannel.hpp +92 -0
  107. package/nitrogen/generated/shared/c++/MultipeerDiscoveryInfoEntry.hpp +87 -0
  108. package/nitrogen/generated/shared/c++/MultipeerEncryptionPreference.hpp +80 -0
  109. package/nitrogen/generated/shared/c++/MultipeerPeer.hpp +102 -0
  110. package/nitrogen/generated/shared/c++/MultipeerPeerState.hpp +80 -0
  111. package/nitrogen/generated/shared/c++/MultipeerSessionOptions.hpp +114 -0
  112. package/nitrogen/generated/shared/c++/PhyStatus.hpp +88 -0
  113. package/package.json +22 -11
  114. package/src/index.ts +416 -31
  115. package/src/specs/munim-bluetooth.nitro.ts +298 -14
@@ -11,12 +11,32 @@
11
11
  namespace margelo::nitro::munimbluetooth { struct AdvertisingDataTypes; }
12
12
  // Forward declaration of `ServiceDataEntry` to properly resolve imports.
13
13
  namespace margelo::nitro::munimbluetooth { struct ServiceDataEntry; }
14
+ // Forward declaration of `BluetoothCapabilities` to properly resolve imports.
15
+ namespace margelo::nitro::munimbluetooth { struct BluetoothCapabilities; }
14
16
  // Forward declaration of `GATTService` to properly resolve imports.
15
17
  namespace margelo::nitro::munimbluetooth { struct GATTService; }
16
18
  // Forward declaration of `GATTCharacteristic` to properly resolve imports.
17
19
  namespace margelo::nitro::munimbluetooth { struct GATTCharacteristic; }
20
+ // Forward declaration of `GATTDescriptor` to properly resolve imports.
21
+ namespace margelo::nitro::munimbluetooth { struct GATTDescriptor; }
18
22
  // Forward declaration of `CharacteristicValue` to properly resolve imports.
19
23
  namespace margelo::nitro::munimbluetooth { struct CharacteristicValue; }
24
+ // Forward declaration of `DescriptorValue` to properly resolve imports.
25
+ namespace margelo::nitro::munimbluetooth { struct DescriptorValue; }
26
+ // Forward declaration of `PhyStatus` to properly resolve imports.
27
+ namespace margelo::nitro::munimbluetooth { struct PhyStatus; }
28
+ // Forward declaration of `BluetoothPhy` to properly resolve imports.
29
+ namespace margelo::nitro::munimbluetooth { enum class BluetoothPhy; }
30
+ // Forward declaration of `BondState` to properly resolve imports.
31
+ namespace margelo::nitro::munimbluetooth { enum class BondState; }
32
+ // Forward declaration of `L2CAPChannel` to properly resolve imports.
33
+ namespace margelo::nitro::munimbluetooth { struct L2CAPChannel; }
34
+ // Forward declaration of `MultipeerPeer` to properly resolve imports.
35
+ namespace margelo::nitro::munimbluetooth { struct MultipeerPeer; }
36
+ // Forward declaration of `MultipeerPeerState` to properly resolve imports.
37
+ namespace margelo::nitro::munimbluetooth { enum class MultipeerPeerState; }
38
+ // Forward declaration of `MultipeerDiscoveryInfoEntry` to properly resolve imports.
39
+ namespace margelo::nitro::munimbluetooth { struct MultipeerDiscoveryInfoEntry; }
20
40
  // Forward declaration of `AdvertisingOptions` to properly resolve imports.
21
41
  namespace margelo::nitro::munimbluetooth { struct AdvertisingOptions; }
22
42
  // Forward declaration of `ScanOptions` to properly resolve imports.
@@ -25,8 +45,16 @@ namespace margelo::nitro::munimbluetooth { struct ScanOptions; }
25
45
  namespace margelo::nitro::munimbluetooth { enum class ScanMode; }
26
46
  // Forward declaration of `WriteType` to properly resolve imports.
27
47
  namespace margelo::nitro::munimbluetooth { enum class WriteType; }
48
+ // Forward declaration of `BluetoothPhyOption` to properly resolve imports.
49
+ namespace margelo::nitro::munimbluetooth { enum class BluetoothPhyOption; }
50
+ // Forward declaration of `ExtendedAdvertisingOptions` to properly resolve imports.
51
+ namespace margelo::nitro::munimbluetooth { struct ExtendedAdvertisingOptions; }
28
52
  // Forward declaration of `BackgroundSessionOptions` to properly resolve imports.
29
53
  namespace margelo::nitro::munimbluetooth { struct BackgroundSessionOptions; }
54
+ // Forward declaration of `MultipeerSessionOptions` to properly resolve imports.
55
+ namespace margelo::nitro::munimbluetooth { struct MultipeerSessionOptions; }
56
+ // Forward declaration of `MultipeerEncryptionPreference` to properly resolve imports.
57
+ namespace margelo::nitro::munimbluetooth { enum class MultipeerEncryptionPreference; }
30
58
 
31
59
  #include "AdvertisingDataTypes.hpp"
32
60
  #include <NitroModules/Promise.hpp>
@@ -38,12 +66,32 @@ namespace margelo::nitro::munimbluetooth { struct BackgroundSessionOptions; }
38
66
  #include "ServiceDataEntry.hpp"
39
67
  #include "JServiceDataEntry.hpp"
40
68
  #include <NitroModules/JUnit.hpp>
69
+ #include "BluetoothCapabilities.hpp"
70
+ #include "JBluetoothCapabilities.hpp"
41
71
  #include "GATTService.hpp"
42
72
  #include "JGATTService.hpp"
43
73
  #include "GATTCharacteristic.hpp"
44
74
  #include "JGATTCharacteristic.hpp"
75
+ #include "GATTDescriptor.hpp"
76
+ #include "JGATTDescriptor.hpp"
45
77
  #include "CharacteristicValue.hpp"
46
78
  #include "JCharacteristicValue.hpp"
79
+ #include "DescriptorValue.hpp"
80
+ #include "JDescriptorValue.hpp"
81
+ #include "PhyStatus.hpp"
82
+ #include "JPhyStatus.hpp"
83
+ #include "BluetoothPhy.hpp"
84
+ #include "JBluetoothPhy.hpp"
85
+ #include "BondState.hpp"
86
+ #include "JBondState.hpp"
87
+ #include "L2CAPChannel.hpp"
88
+ #include "JL2CAPChannel.hpp"
89
+ #include "MultipeerPeer.hpp"
90
+ #include "JMultipeerPeer.hpp"
91
+ #include "MultipeerPeerState.hpp"
92
+ #include "JMultipeerPeerState.hpp"
93
+ #include "MultipeerDiscoveryInfoEntry.hpp"
94
+ #include "JMultipeerDiscoveryInfoEntry.hpp"
47
95
  #include "AdvertisingOptions.hpp"
48
96
  #include "JAdvertisingOptions.hpp"
49
97
  #include "ScanOptions.hpp"
@@ -52,8 +100,16 @@ namespace margelo::nitro::munimbluetooth { struct BackgroundSessionOptions; }
52
100
  #include "JScanMode.hpp"
53
101
  #include "WriteType.hpp"
54
102
  #include "JWriteType.hpp"
103
+ #include "BluetoothPhyOption.hpp"
104
+ #include "JBluetoothPhyOption.hpp"
105
+ #include "ExtendedAdvertisingOptions.hpp"
106
+ #include "JExtendedAdvertisingOptions.hpp"
55
107
  #include "BackgroundSessionOptions.hpp"
56
108
  #include "JBackgroundSessionOptions.hpp"
109
+ #include "MultipeerSessionOptions.hpp"
110
+ #include "JMultipeerSessionOptions.hpp"
111
+ #include "MultipeerEncryptionPreference.hpp"
112
+ #include "JMultipeerEncryptionPreference.hpp"
57
113
 
58
114
  namespace margelo::nitro::munimbluetooth {
59
115
 
@@ -118,16 +174,31 @@ namespace margelo::nitro::munimbluetooth {
118
174
  }
119
175
  void JHybridMunimBluetoothSpec::setServices(const std::vector<GATTService>& services) {
120
176
  static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JArrayClass<JGATTService>> /* services */)>("setServices");
121
- method(_javaPart, [&]() {
122
- size_t __size = services.size();
177
+ method(_javaPart, [&](auto&& __input) {
178
+ size_t __size = __input.size();
123
179
  jni::local_ref<jni::JArrayClass<JGATTService>> __array = jni::JArrayClass<JGATTService>::newArray(__size);
124
180
  for (size_t __i = 0; __i < __size; __i++) {
125
- const auto& __element = services[__i];
181
+ const auto& __element = __input[__i];
126
182
  auto __elementJni = JGATTService::fromCpp(__element);
127
183
  __array->setElement(__i, *__elementJni);
128
184
  }
129
185
  return __array;
130
- }());
186
+ }(services));
187
+ }
188
+ std::shared_ptr<Promise<void>> JHybridMunimBluetoothSpec::updateCharacteristicValue(const std::string& serviceUUID, const std::string& characteristicUUID, const std::string& value, std::optional<bool> notify) {
189
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* serviceUUID */, jni::alias_ref<jni::JString> /* characteristicUUID */, jni::alias_ref<jni::JString> /* value */, jni::alias_ref<jni::JBoolean> /* notify */)>("updateCharacteristicValue");
190
+ auto __result = method(_javaPart, jni::make_jstring(serviceUUID), jni::make_jstring(characteristicUUID), jni::make_jstring(value), notify.has_value() ? jni::JBoolean::valueOf(notify.value()) : nullptr);
191
+ return [&]() {
192
+ auto __promise = Promise<void>::create();
193
+ __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
194
+ __promise->resolve();
195
+ });
196
+ __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
197
+ jni::JniException __jniError(__throwable);
198
+ __promise->reject(std::make_exception_ptr(__jniError));
199
+ });
200
+ return __promise;
201
+ }();
131
202
  }
132
203
  std::shared_ptr<Promise<bool>> JHybridMunimBluetoothSpec::isBluetoothEnabled() {
133
204
  static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("isBluetoothEnabled");
@@ -161,6 +232,22 @@ namespace margelo::nitro::munimbluetooth {
161
232
  return __promise;
162
233
  }();
163
234
  }
235
+ std::shared_ptr<Promise<BluetoothCapabilities>> JHybridMunimBluetoothSpec::getCapabilities() {
236
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("getCapabilities");
237
+ auto __result = method(_javaPart);
238
+ return [&]() {
239
+ auto __promise = Promise<BluetoothCapabilities>::create();
240
+ __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
241
+ auto __result = jni::static_ref_cast<JBluetoothCapabilities>(__boxedResult);
242
+ __promise->resolve(__result->toCpp());
243
+ });
244
+ __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
245
+ jni::JniException __jniError(__throwable);
246
+ __promise->reject(std::make_exception_ptr(__jniError));
247
+ });
248
+ return __promise;
249
+ }();
250
+ }
164
251
  void JHybridMunimBluetoothSpec::startScan(const std::optional<ScanOptions>& options) {
165
252
  static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JScanOptions> /* options */)>("startScan");
166
253
  method(_javaPart, options.has_value() ? JScanOptions::fromCpp(options.value()) : nullptr);
@@ -195,16 +282,16 @@ namespace margelo::nitro::munimbluetooth {
195
282
  auto __promise = Promise<std::vector<GATTService>>::create();
196
283
  __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
197
284
  auto __result = jni::static_ref_cast<jni::JArrayClass<JGATTService>>(__boxedResult);
198
- __promise->resolve([&]() {
199
- size_t __size = __result->size();
285
+ __promise->resolve([&](auto&& __input) {
286
+ size_t __size = __input->size();
200
287
  std::vector<GATTService> __vector;
201
288
  __vector.reserve(__size);
202
289
  for (size_t __i = 0; __i < __size; __i++) {
203
- auto __element = __result->getElement(__i);
290
+ auto __element = __input->getElement(__i);
204
291
  __vector.push_back(__element->toCpp());
205
292
  }
206
293
  return __vector;
207
- }());
294
+ }(__result));
208
295
  });
209
296
  __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
210
297
  jni::JniException __jniError(__throwable);
@@ -229,6 +316,22 @@ namespace margelo::nitro::munimbluetooth {
229
316
  return __promise;
230
317
  }();
231
318
  }
319
+ std::shared_ptr<Promise<DescriptorValue>> JHybridMunimBluetoothSpec::readDescriptor(const std::string& deviceId, const std::string& serviceUUID, const std::string& characteristicUUID, const std::string& descriptorUUID) {
320
+ 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> /* descriptorUUID */)>("readDescriptor");
321
+ auto __result = method(_javaPart, jni::make_jstring(deviceId), jni::make_jstring(serviceUUID), jni::make_jstring(characteristicUUID), jni::make_jstring(descriptorUUID));
322
+ return [&]() {
323
+ auto __promise = Promise<DescriptorValue>::create();
324
+ __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
325
+ auto __result = jni::static_ref_cast<JDescriptorValue>(__boxedResult);
326
+ __promise->resolve(__result->toCpp());
327
+ });
328
+ __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
329
+ jni::JniException __jniError(__throwable);
330
+ __promise->reject(std::make_exception_ptr(__jniError));
331
+ });
332
+ return __promise;
333
+ }();
334
+ }
232
335
  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) {
233
336
  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");
234
337
  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);
@@ -244,6 +347,21 @@ namespace margelo::nitro::munimbluetooth {
244
347
  return __promise;
245
348
  }();
246
349
  }
350
+ std::shared_ptr<Promise<void>> JHybridMunimBluetoothSpec::writeDescriptor(const std::string& deviceId, const std::string& serviceUUID, const std::string& characteristicUUID, const std::string& descriptorUUID, const std::string& value) {
351
+ 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> /* descriptorUUID */, jni::alias_ref<jni::JString> /* value */)>("writeDescriptor");
352
+ auto __result = method(_javaPart, jni::make_jstring(deviceId), jni::make_jstring(serviceUUID), jni::make_jstring(characteristicUUID), jni::make_jstring(descriptorUUID), jni::make_jstring(value));
353
+ return [&]() {
354
+ auto __promise = Promise<void>::create();
355
+ __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
356
+ __promise->resolve();
357
+ });
358
+ __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
359
+ jni::JniException __jniError(__throwable);
360
+ __promise->reject(std::make_exception_ptr(__jniError));
361
+ });
362
+ return __promise;
363
+ }();
364
+ }
247
365
  void JHybridMunimBluetoothSpec::subscribeToCharacteristic(const std::string& deviceId, const std::string& serviceUUID, const std::string& characteristicUUID) {
248
366
  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");
249
367
  method(_javaPart, jni::make_jstring(deviceId), jni::make_jstring(serviceUUID), jni::make_jstring(characteristicUUID));
@@ -259,16 +377,16 @@ namespace margelo::nitro::munimbluetooth {
259
377
  auto __promise = Promise<std::vector<std::string>>::create();
260
378
  __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
261
379
  auto __result = jni::static_ref_cast<jni::JArrayClass<jni::JString>>(__boxedResult);
262
- __promise->resolve([&]() {
263
- size_t __size = __result->size();
380
+ __promise->resolve([&](auto&& __input) {
381
+ size_t __size = __input->size();
264
382
  std::vector<std::string> __vector;
265
383
  __vector.reserve(__size);
266
384
  for (size_t __i = 0; __i < __size; __i++) {
267
- auto __element = __result->getElement(__i);
385
+ auto __element = __input->getElement(__i);
268
386
  __vector.push_back(__element->toStdString());
269
387
  }
270
388
  return __vector;
271
- }());
389
+ }(__result));
272
390
  });
273
391
  __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
274
392
  jni::JniException __jniError(__throwable);
@@ -293,6 +411,237 @@ namespace margelo::nitro::munimbluetooth {
293
411
  return __promise;
294
412
  }();
295
413
  }
414
+ std::shared_ptr<Promise<double>> JHybridMunimBluetoothSpec::requestMTU(const std::string& deviceId, double mtu) {
415
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* deviceId */, double /* mtu */)>("requestMTU");
416
+ auto __result = method(_javaPart, jni::make_jstring(deviceId), mtu);
417
+ return [&]() {
418
+ auto __promise = Promise<double>::create();
419
+ __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
420
+ auto __result = jni::static_ref_cast<jni::JDouble>(__boxedResult);
421
+ __promise->resolve(__result->value());
422
+ });
423
+ __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
424
+ jni::JniException __jniError(__throwable);
425
+ __promise->reject(std::make_exception_ptr(__jniError));
426
+ });
427
+ return __promise;
428
+ }();
429
+ }
430
+ std::shared_ptr<Promise<void>> JHybridMunimBluetoothSpec::setPreferredPhy(const std::string& deviceId, BluetoothPhy txPhy, BluetoothPhy rxPhy, std::optional<BluetoothPhyOption> phyOption) {
431
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* deviceId */, jni::alias_ref<JBluetoothPhy> /* txPhy */, jni::alias_ref<JBluetoothPhy> /* rxPhy */, jni::alias_ref<JBluetoothPhyOption> /* phyOption */)>("setPreferredPhy");
432
+ auto __result = method(_javaPart, jni::make_jstring(deviceId), JBluetoothPhy::fromCpp(txPhy), JBluetoothPhy::fromCpp(rxPhy), phyOption.has_value() ? JBluetoothPhyOption::fromCpp(phyOption.value()) : nullptr);
433
+ return [&]() {
434
+ auto __promise = Promise<void>::create();
435
+ __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
436
+ __promise->resolve();
437
+ });
438
+ __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
439
+ jni::JniException __jniError(__throwable);
440
+ __promise->reject(std::make_exception_ptr(__jniError));
441
+ });
442
+ return __promise;
443
+ }();
444
+ }
445
+ std::shared_ptr<Promise<PhyStatus>> JHybridMunimBluetoothSpec::readPhy(const std::string& deviceId) {
446
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* deviceId */)>("readPhy");
447
+ auto __result = method(_javaPart, jni::make_jstring(deviceId));
448
+ return [&]() {
449
+ auto __promise = Promise<PhyStatus>::create();
450
+ __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
451
+ auto __result = jni::static_ref_cast<JPhyStatus>(__boxedResult);
452
+ __promise->resolve(__result->toCpp());
453
+ });
454
+ __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
455
+ jni::JniException __jniError(__throwable);
456
+ __promise->reject(std::make_exception_ptr(__jniError));
457
+ });
458
+ return __promise;
459
+ }();
460
+ }
461
+ std::shared_ptr<Promise<BondState>> JHybridMunimBluetoothSpec::getBondState(const std::string& deviceId) {
462
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* deviceId */)>("getBondState");
463
+ auto __result = method(_javaPart, jni::make_jstring(deviceId));
464
+ return [&]() {
465
+ auto __promise = Promise<BondState>::create();
466
+ __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
467
+ auto __result = jni::static_ref_cast<JBondState>(__boxedResult);
468
+ __promise->resolve(__result->toCpp());
469
+ });
470
+ __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
471
+ jni::JniException __jniError(__throwable);
472
+ __promise->reject(std::make_exception_ptr(__jniError));
473
+ });
474
+ return __promise;
475
+ }();
476
+ }
477
+ std::shared_ptr<Promise<BondState>> JHybridMunimBluetoothSpec::createBond(const std::string& deviceId) {
478
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* deviceId */)>("createBond");
479
+ auto __result = method(_javaPart, jni::make_jstring(deviceId));
480
+ return [&]() {
481
+ auto __promise = Promise<BondState>::create();
482
+ __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
483
+ auto __result = jni::static_ref_cast<JBondState>(__boxedResult);
484
+ __promise->resolve(__result->toCpp());
485
+ });
486
+ __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
487
+ jni::JniException __jniError(__throwable);
488
+ __promise->reject(std::make_exception_ptr(__jniError));
489
+ });
490
+ return __promise;
491
+ }();
492
+ }
493
+ std::shared_ptr<Promise<BondState>> JHybridMunimBluetoothSpec::removeBond(const std::string& deviceId) {
494
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* deviceId */)>("removeBond");
495
+ auto __result = method(_javaPart, jni::make_jstring(deviceId));
496
+ return [&]() {
497
+ auto __promise = Promise<BondState>::create();
498
+ __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
499
+ auto __result = jni::static_ref_cast<JBondState>(__boxedResult);
500
+ __promise->resolve(__result->toCpp());
501
+ });
502
+ __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
503
+ jni::JniException __jniError(__throwable);
504
+ __promise->reject(std::make_exception_ptr(__jniError));
505
+ });
506
+ return __promise;
507
+ }();
508
+ }
509
+ std::shared_ptr<Promise<std::string>> JHybridMunimBluetoothSpec::startExtendedAdvertising(const ExtendedAdvertisingOptions& options) {
510
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<JExtendedAdvertisingOptions> /* options */)>("startExtendedAdvertising");
511
+ auto __result = method(_javaPart, JExtendedAdvertisingOptions::fromCpp(options));
512
+ return [&]() {
513
+ auto __promise = Promise<std::string>::create();
514
+ __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
515
+ auto __result = jni::static_ref_cast<jni::JString>(__boxedResult);
516
+ __promise->resolve(__result->toStdString());
517
+ });
518
+ __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
519
+ jni::JniException __jniError(__throwable);
520
+ __promise->reject(std::make_exception_ptr(__jniError));
521
+ });
522
+ return __promise;
523
+ }();
524
+ }
525
+ void JHybridMunimBluetoothSpec::stopExtendedAdvertising(const std::string& advertisingId) {
526
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* advertisingId */)>("stopExtendedAdvertising");
527
+ method(_javaPart, jni::make_jstring(advertisingId));
528
+ }
529
+ std::shared_ptr<Promise<L2CAPChannel>> JHybridMunimBluetoothSpec::publishL2CAPChannel(std::optional<bool> encryptionRequired) {
530
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JBoolean> /* encryptionRequired */)>("publishL2CAPChannel");
531
+ auto __result = method(_javaPart, encryptionRequired.has_value() ? jni::JBoolean::valueOf(encryptionRequired.value()) : nullptr);
532
+ return [&]() {
533
+ auto __promise = Promise<L2CAPChannel>::create();
534
+ __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
535
+ auto __result = jni::static_ref_cast<JL2CAPChannel>(__boxedResult);
536
+ __promise->resolve(__result->toCpp());
537
+ });
538
+ __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
539
+ jni::JniException __jniError(__throwable);
540
+ __promise->reject(std::make_exception_ptr(__jniError));
541
+ });
542
+ return __promise;
543
+ }();
544
+ }
545
+ void JHybridMunimBluetoothSpec::unpublishL2CAPChannel(double psm) {
546
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(double /* psm */)>("unpublishL2CAPChannel");
547
+ method(_javaPart, psm);
548
+ }
549
+ std::shared_ptr<Promise<L2CAPChannel>> JHybridMunimBluetoothSpec::openL2CAPChannel(const std::string& deviceId, double psm) {
550
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* deviceId */, double /* psm */)>("openL2CAPChannel");
551
+ auto __result = method(_javaPart, jni::make_jstring(deviceId), psm);
552
+ return [&]() {
553
+ auto __promise = Promise<L2CAPChannel>::create();
554
+ __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
555
+ auto __result = jni::static_ref_cast<JL2CAPChannel>(__boxedResult);
556
+ __promise->resolve(__result->toCpp());
557
+ });
558
+ __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
559
+ jni::JniException __jniError(__throwable);
560
+ __promise->reject(std::make_exception_ptr(__jniError));
561
+ });
562
+ return __promise;
563
+ }();
564
+ }
565
+ void JHybridMunimBluetoothSpec::closeL2CAPChannel(const std::string& channelId) {
566
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* channelId */)>("closeL2CAPChannel");
567
+ method(_javaPart, jni::make_jstring(channelId));
568
+ }
569
+ std::shared_ptr<Promise<void>> JHybridMunimBluetoothSpec::sendL2CAPData(const std::string& channelId, const std::string& value) {
570
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* channelId */, jni::alias_ref<jni::JString> /* value */)>("sendL2CAPData");
571
+ auto __result = method(_javaPart, jni::make_jstring(channelId), jni::make_jstring(value));
572
+ return [&]() {
573
+ auto __promise = Promise<void>::create();
574
+ __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
575
+ __promise->resolve();
576
+ });
577
+ __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
578
+ jni::JniException __jniError(__throwable);
579
+ __promise->reject(std::make_exception_ptr(__jniError));
580
+ });
581
+ return __promise;
582
+ }();
583
+ }
584
+ void JHybridMunimBluetoothSpec::startClassicScan() {
585
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void()>("startClassicScan");
586
+ method(_javaPart);
587
+ }
588
+ void JHybridMunimBluetoothSpec::stopClassicScan() {
589
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void()>("stopClassicScan");
590
+ method(_javaPart);
591
+ }
592
+ std::shared_ptr<Promise<void>> JHybridMunimBluetoothSpec::connectClassic(const std::string& deviceId, const std::optional<std::string>& serviceUUID) {
593
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* deviceId */, jni::alias_ref<jni::JString> /* serviceUUID */)>("connectClassic");
594
+ auto __result = method(_javaPart, jni::make_jstring(deviceId), serviceUUID.has_value() ? jni::make_jstring(serviceUUID.value()) : nullptr);
595
+ return [&]() {
596
+ auto __promise = Promise<void>::create();
597
+ __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
598
+ __promise->resolve();
599
+ });
600
+ __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
601
+ jni::JniException __jniError(__throwable);
602
+ __promise->reject(std::make_exception_ptr(__jniError));
603
+ });
604
+ return __promise;
605
+ }();
606
+ }
607
+ std::shared_ptr<Promise<void>> JHybridMunimBluetoothSpec::startClassicServer(const std::optional<std::string>& serviceUUID, const std::optional<std::string>& serviceName) {
608
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* serviceUUID */, jni::alias_ref<jni::JString> /* serviceName */)>("startClassicServer");
609
+ auto __result = method(_javaPart, serviceUUID.has_value() ? jni::make_jstring(serviceUUID.value()) : nullptr, serviceName.has_value() ? jni::make_jstring(serviceName.value()) : nullptr);
610
+ return [&]() {
611
+ auto __promise = Promise<void>::create();
612
+ __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
613
+ __promise->resolve();
614
+ });
615
+ __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
616
+ jni::JniException __jniError(__throwable);
617
+ __promise->reject(std::make_exception_ptr(__jniError));
618
+ });
619
+ return __promise;
620
+ }();
621
+ }
622
+ void JHybridMunimBluetoothSpec::stopClassicServer(const std::optional<std::string>& serviceUUID) {
623
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* serviceUUID */)>("stopClassicServer");
624
+ method(_javaPart, serviceUUID.has_value() ? jni::make_jstring(serviceUUID.value()) : nullptr);
625
+ }
626
+ void JHybridMunimBluetoothSpec::disconnectClassic(const std::string& deviceId) {
627
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* deviceId */)>("disconnectClassic");
628
+ method(_javaPart, jni::make_jstring(deviceId));
629
+ }
630
+ std::shared_ptr<Promise<void>> JHybridMunimBluetoothSpec::writeClassic(const std::string& deviceId, const std::string& value) {
631
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* deviceId */, jni::alias_ref<jni::JString> /* value */)>("writeClassic");
632
+ auto __result = method(_javaPart, jni::make_jstring(deviceId), jni::make_jstring(value));
633
+ return [&]() {
634
+ auto __promise = Promise<void>::create();
635
+ __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
636
+ __promise->resolve();
637
+ });
638
+ __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
639
+ jni::JniException __jniError(__throwable);
640
+ __promise->reject(std::make_exception_ptr(__jniError));
641
+ });
642
+ return __promise;
643
+ }();
644
+ }
296
645
  void JHybridMunimBluetoothSpec::startBackgroundSession(const BackgroundSessionOptions& options) {
297
646
  static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JBackgroundSessionOptions> /* options */)>("startBackgroundSession");
298
647
  method(_javaPart, JBackgroundSessionOptions::fromCpp(options));
@@ -301,6 +650,67 @@ namespace margelo::nitro::munimbluetooth {
301
650
  static const auto method = _javaPart->javaClassStatic()->getMethod<void()>("stopBackgroundSession");
302
651
  method(_javaPart);
303
652
  }
653
+ void JHybridMunimBluetoothSpec::startMultipeerSession(const MultipeerSessionOptions& options) {
654
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JMultipeerSessionOptions> /* options */)>("startMultipeerSession");
655
+ method(_javaPart, JMultipeerSessionOptions::fromCpp(options));
656
+ }
657
+ void JHybridMunimBluetoothSpec::stopMultipeerSession() {
658
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void()>("stopMultipeerSession");
659
+ method(_javaPart);
660
+ }
661
+ void JHybridMunimBluetoothSpec::inviteMultipeerPeer(const std::string& peerId) {
662
+ static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* peerId */)>("inviteMultipeerPeer");
663
+ method(_javaPart, jni::make_jstring(peerId));
664
+ }
665
+ std::shared_ptr<Promise<std::vector<MultipeerPeer>>> JHybridMunimBluetoothSpec::getMultipeerPeers() {
666
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("getMultipeerPeers");
667
+ auto __result = method(_javaPart);
668
+ return [&]() {
669
+ auto __promise = Promise<std::vector<MultipeerPeer>>::create();
670
+ __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
671
+ auto __result = jni::static_ref_cast<jni::JArrayClass<JMultipeerPeer>>(__boxedResult);
672
+ __promise->resolve([&](auto&& __input) {
673
+ size_t __size = __input->size();
674
+ std::vector<MultipeerPeer> __vector;
675
+ __vector.reserve(__size);
676
+ for (size_t __i = 0; __i < __size; __i++) {
677
+ auto __element = __input->getElement(__i);
678
+ __vector.push_back(__element->toCpp());
679
+ }
680
+ return __vector;
681
+ }(__result));
682
+ });
683
+ __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
684
+ jni::JniException __jniError(__throwable);
685
+ __promise->reject(std::make_exception_ptr(__jniError));
686
+ });
687
+ return __promise;
688
+ }();
689
+ }
690
+ std::shared_ptr<Promise<void>> JHybridMunimBluetoothSpec::sendMultipeerMessage(const std::string& value, const std::optional<std::vector<std::string>>& peerIds, std::optional<bool> reliable) {
691
+ static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* value */, jni::alias_ref<jni::JArrayClass<jni::JString>> /* peerIds */, jni::alias_ref<jni::JBoolean> /* reliable */)>("sendMultipeerMessage");
692
+ auto __result = method(_javaPart, jni::make_jstring(value), peerIds.has_value() ? [&](auto&& __input) {
693
+ size_t __size = __input.size();
694
+ jni::local_ref<jni::JArrayClass<jni::JString>> __array = jni::JArrayClass<jni::JString>::newArray(__size);
695
+ for (size_t __i = 0; __i < __size; __i++) {
696
+ const auto& __element = __input[__i];
697
+ auto __elementJni = jni::make_jstring(__element);
698
+ __array->setElement(__i, *__elementJni);
699
+ }
700
+ return __array;
701
+ }(peerIds.value()) : nullptr, reliable.has_value() ? jni::JBoolean::valueOf(reliable.value()) : nullptr);
702
+ return [&]() {
703
+ auto __promise = Promise<void>::create();
704
+ __result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
705
+ __promise->resolve();
706
+ });
707
+ __result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
708
+ jni::JniException __jniError(__throwable);
709
+ __promise->reject(std::make_exception_ptr(__jniError));
710
+ });
711
+ return __promise;
712
+ }();
713
+ }
304
714
  void JHybridMunimBluetoothSpec::addListener(const std::string& eventName) {
305
715
  static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* eventName */)>("addListener");
306
716
  method(_javaPart, jni::make_jstring(eventName));
@@ -59,21 +59,50 @@ namespace margelo::nitro::munimbluetooth {
59
59
  std::shared_ptr<Promise<AdvertisingDataTypes>> getAdvertisingData() override;
60
60
  void stopAdvertising() override;
61
61
  void setServices(const std::vector<GATTService>& services) override;
62
+ std::shared_ptr<Promise<void>> updateCharacteristicValue(const std::string& serviceUUID, const std::string& characteristicUUID, const std::string& value, std::optional<bool> notify) override;
62
63
  std::shared_ptr<Promise<bool>> isBluetoothEnabled() override;
63
64
  std::shared_ptr<Promise<bool>> requestBluetoothPermission() override;
65
+ std::shared_ptr<Promise<BluetoothCapabilities>> getCapabilities() override;
64
66
  void startScan(const std::optional<ScanOptions>& options) override;
65
67
  void stopScan() override;
66
68
  std::shared_ptr<Promise<void>> connect(const std::string& deviceId) override;
67
69
  void disconnect(const std::string& deviceId) override;
68
70
  std::shared_ptr<Promise<std::vector<GATTService>>> discoverServices(const std::string& deviceId) override;
69
71
  std::shared_ptr<Promise<CharacteristicValue>> readCharacteristic(const std::string& deviceId, const std::string& serviceUUID, const std::string& characteristicUUID) override;
72
+ std::shared_ptr<Promise<DescriptorValue>> readDescriptor(const std::string& deviceId, const std::string& serviceUUID, const std::string& characteristicUUID, const std::string& descriptorUUID) override;
70
73
  std::shared_ptr<Promise<void>> writeCharacteristic(const std::string& deviceId, const std::string& serviceUUID, const std::string& characteristicUUID, const std::string& value, std::optional<WriteType> writeType) override;
74
+ std::shared_ptr<Promise<void>> writeDescriptor(const std::string& deviceId, const std::string& serviceUUID, const std::string& characteristicUUID, const std::string& descriptorUUID, const std::string& value) override;
71
75
  void subscribeToCharacteristic(const std::string& deviceId, const std::string& serviceUUID, const std::string& characteristicUUID) override;
72
76
  void unsubscribeFromCharacteristic(const std::string& deviceId, const std::string& serviceUUID, const std::string& characteristicUUID) override;
73
77
  std::shared_ptr<Promise<std::vector<std::string>>> getConnectedDevices() override;
74
78
  std::shared_ptr<Promise<double>> readRSSI(const std::string& deviceId) override;
79
+ std::shared_ptr<Promise<double>> requestMTU(const std::string& deviceId, double mtu) override;
80
+ std::shared_ptr<Promise<void>> setPreferredPhy(const std::string& deviceId, BluetoothPhy txPhy, BluetoothPhy rxPhy, std::optional<BluetoothPhyOption> phyOption) override;
81
+ std::shared_ptr<Promise<PhyStatus>> readPhy(const std::string& deviceId) override;
82
+ std::shared_ptr<Promise<BondState>> getBondState(const std::string& deviceId) override;
83
+ std::shared_ptr<Promise<BondState>> createBond(const std::string& deviceId) override;
84
+ std::shared_ptr<Promise<BondState>> removeBond(const std::string& deviceId) override;
85
+ std::shared_ptr<Promise<std::string>> startExtendedAdvertising(const ExtendedAdvertisingOptions& options) override;
86
+ void stopExtendedAdvertising(const std::string& advertisingId) override;
87
+ std::shared_ptr<Promise<L2CAPChannel>> publishL2CAPChannel(std::optional<bool> encryptionRequired) override;
88
+ void unpublishL2CAPChannel(double psm) override;
89
+ std::shared_ptr<Promise<L2CAPChannel>> openL2CAPChannel(const std::string& deviceId, double psm) override;
90
+ void closeL2CAPChannel(const std::string& channelId) override;
91
+ std::shared_ptr<Promise<void>> sendL2CAPData(const std::string& channelId, const std::string& value) override;
92
+ void startClassicScan() override;
93
+ void stopClassicScan() override;
94
+ std::shared_ptr<Promise<void>> connectClassic(const std::string& deviceId, const std::optional<std::string>& serviceUUID) override;
95
+ std::shared_ptr<Promise<void>> startClassicServer(const std::optional<std::string>& serviceUUID, const std::optional<std::string>& serviceName) override;
96
+ void stopClassicServer(const std::optional<std::string>& serviceUUID) override;
97
+ void disconnectClassic(const std::string& deviceId) override;
98
+ std::shared_ptr<Promise<void>> writeClassic(const std::string& deviceId, const std::string& value) override;
75
99
  void startBackgroundSession(const BackgroundSessionOptions& options) override;
76
100
  void stopBackgroundSession() override;
101
+ void startMultipeerSession(const MultipeerSessionOptions& options) override;
102
+ void stopMultipeerSession() override;
103
+ void inviteMultipeerPeer(const std::string& peerId) override;
104
+ std::shared_ptr<Promise<std::vector<MultipeerPeer>>> getMultipeerPeers() override;
105
+ std::shared_ptr<Promise<void>> sendMultipeerMessage(const std::string& value, const std::optional<std::vector<std::string>>& peerIds, std::optional<bool> reliable) override;
77
106
  void addListener(const std::string& eventName) override;
78
107
  void removeListeners(double count) override;
79
108