munim-bluetooth 0.3.26 → 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 (116) 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/BluetoothPermissionUtils.kt +40 -0
  7. package/android/src/main/java/com/munimbluetooth/HybridMunimBluetooth.kt +2116 -217
  8. package/android/src/main/java/com/munimbluetooth/MunimBluetoothBackgroundService.kt +591 -56
  9. package/app.plugin.js +155 -0
  10. package/ios/HybridMunimBluetooth.swift +2123 -298
  11. package/ios/MunimBluetoothEventEmitter.swift +68 -8
  12. package/lib/commonjs/index.js +272 -11
  13. package/lib/commonjs/index.js.map +1 -1
  14. package/lib/module/index.js +243 -11
  15. package/lib/module/index.js.map +1 -1
  16. package/lib/typescript/src/index.d.ts +310 -7
  17. package/lib/typescript/src/index.d.ts.map +1 -1
  18. package/lib/typescript/src/specs/munim-bluetooth.nitro.d.ts +219 -5
  19. package/lib/typescript/src/specs/munim-bluetooth.nitro.d.ts.map +1 -1
  20. package/nitro.json +9 -3
  21. package/nitrogen/generated/android/c++/JAdvertisingDataTypes.hpp +96 -96
  22. package/nitrogen/generated/android/c++/JAdvertisingOptions.hpp +8 -8
  23. package/nitrogen/generated/android/c++/JBackgroundSessionOptions.hpp +8 -8
  24. package/nitrogen/generated/android/c++/JBluetoothCapabilities.hpp +105 -0
  25. package/nitrogen/generated/android/c++/JBluetoothPhy.hpp +61 -0
  26. package/nitrogen/generated/android/c++/JBluetoothPhyOption.hpp +61 -0
  27. package/nitrogen/generated/android/c++/JBondState.hpp +64 -0
  28. package/nitrogen/generated/android/c++/JDescriptorValue.hpp +69 -0
  29. package/nitrogen/generated/android/c++/JExtendedAdvertisingOptions.hpp +131 -0
  30. package/nitrogen/generated/android/c++/JGATTCharacteristic.hpp +35 -11
  31. package/nitrogen/generated/android/c++/JGATTDescriptor.hpp +85 -0
  32. package/nitrogen/generated/android/c++/JGATTService.hpp +33 -9
  33. package/nitrogen/generated/android/c++/JHybridMunimBluetoothSpec.cpp +422 -12
  34. package/nitrogen/generated/android/c++/JHybridMunimBluetoothSpec.hpp +29 -0
  35. package/nitrogen/generated/android/c++/JL2CAPChannel.hpp +66 -0
  36. package/nitrogen/generated/android/c++/JMultipeerDiscoveryInfoEntry.hpp +61 -0
  37. package/nitrogen/generated/android/c++/JMultipeerEncryptionPreference.hpp +61 -0
  38. package/nitrogen/generated/android/c++/JMultipeerPeer.hpp +93 -0
  39. package/nitrogen/generated/android/c++/JMultipeerPeerState.hpp +61 -0
  40. package/nitrogen/generated/android/c++/JMultipeerSessionOptions.hpp +105 -0
  41. package/nitrogen/generated/android/c++/JPhyStatus.hpp +62 -0
  42. package/nitrogen/generated/android/c++/JScanOptions.hpp +8 -8
  43. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/AdvertisingDataTypes.kt +47 -0
  44. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/AdvertisingOptions.kt +19 -0
  45. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/BackgroundSessionOptions.kt +27 -0
  46. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/BluetoothCapabilities.kt +111 -0
  47. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/BluetoothPhy.kt +24 -0
  48. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/BluetoothPhyOption.kt +24 -0
  49. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/BondState.kt +25 -0
  50. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/CharacteristicValue.kt +17 -0
  51. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/DescriptorValue.kt +66 -0
  52. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/ExtendedAdvertisingOptions.kt +111 -0
  53. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/GATTCharacteristic.kt +25 -3
  54. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/GATTDescriptor.kt +61 -0
  55. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/GATTService.kt +23 -3
  56. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/HybridMunimBluetoothSpec.kt +138 -22
  57. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/L2CAPChannel.kt +61 -0
  58. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/MultipeerDiscoveryInfoEntry.kt +56 -0
  59. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/MultipeerEncryptionPreference.kt +24 -0
  60. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/MultipeerPeer.kt +66 -0
  61. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/MultipeerPeerState.kt +24 -0
  62. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/MultipeerSessionOptions.kt +81 -0
  63. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/PhyStatus.kt +56 -0
  64. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/ScanOptions.kt +17 -0
  65. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/ServiceDataEntry.kt +15 -0
  66. package/nitrogen/generated/ios/MunimBluetooth+autolinking.rb +2 -0
  67. package/nitrogen/generated/ios/MunimBluetooth-Swift-Cxx-Bridge.cpp +61 -5
  68. package/nitrogen/generated/ios/MunimBluetooth-Swift-Cxx-Bridge.hpp +494 -49
  69. package/nitrogen/generated/ios/MunimBluetooth-Swift-Cxx-Umbrella.hpp +42 -0
  70. package/nitrogen/generated/ios/c++/HybridMunimBluetoothSpecSwift.hpp +254 -0
  71. package/nitrogen/generated/ios/swift/BluetoothCapabilities.swift +89 -0
  72. package/nitrogen/generated/ios/swift/BluetoothPhy.swift +44 -0
  73. package/nitrogen/generated/ios/swift/BluetoothPhyOption.swift +44 -0
  74. package/nitrogen/generated/ios/swift/BondState.swift +48 -0
  75. package/nitrogen/generated/ios/swift/DescriptorValue.swift +44 -0
  76. package/nitrogen/generated/ios/swift/ExtendedAdvertisingOptions.swift +243 -0
  77. package/nitrogen/generated/ios/swift/Func_void_BluetoothCapabilities.swift +46 -0
  78. package/nitrogen/generated/ios/swift/Func_void_BondState.swift +46 -0
  79. package/nitrogen/generated/ios/swift/Func_void_DescriptorValue.swift +46 -0
  80. package/nitrogen/generated/ios/swift/Func_void_L2CAPChannel.swift +46 -0
  81. package/nitrogen/generated/ios/swift/Func_void_PhyStatus.swift +46 -0
  82. package/nitrogen/generated/ios/swift/Func_void_std__string.swift +46 -0
  83. package/nitrogen/generated/ios/swift/Func_void_std__vector_MultipeerPeer_.swift +46 -0
  84. package/nitrogen/generated/ios/swift/GATTCharacteristic.swift +25 -1
  85. package/nitrogen/generated/ios/swift/GATTDescriptor.swift +71 -0
  86. package/nitrogen/generated/ios/swift/GATTService.swift +25 -1
  87. package/nitrogen/generated/ios/swift/HybridMunimBluetoothSpec.swift +29 -0
  88. package/nitrogen/generated/ios/swift/HybridMunimBluetoothSpec_cxx.swift +556 -23
  89. package/nitrogen/generated/ios/swift/L2CAPChannel.swift +52 -0
  90. package/nitrogen/generated/ios/swift/MultipeerDiscoveryInfoEntry.swift +34 -0
  91. package/nitrogen/generated/ios/swift/MultipeerEncryptionPreference.swift +44 -0
  92. package/nitrogen/generated/ios/swift/MultipeerPeer.swift +63 -0
  93. package/nitrogen/generated/ios/swift/MultipeerPeerState.swift +44 -0
  94. package/nitrogen/generated/ios/swift/MultipeerSessionOptions.swift +136 -0
  95. package/nitrogen/generated/ios/swift/PhyStatus.swift +34 -0
  96. package/nitrogen/generated/shared/c++/BluetoothCapabilities.hpp +131 -0
  97. package/nitrogen/generated/shared/c++/BluetoothPhy.hpp +80 -0
  98. package/nitrogen/generated/shared/c++/BluetoothPhyOption.hpp +80 -0
  99. package/nitrogen/generated/shared/c++/BondState.hpp +84 -0
  100. package/nitrogen/generated/shared/c++/DescriptorValue.hpp +95 -0
  101. package/nitrogen/generated/shared/c++/ExtendedAdvertisingOptions.hpp +138 -0
  102. package/nitrogen/generated/shared/c++/GATTCharacteristic.hpp +9 -3
  103. package/nitrogen/generated/shared/c++/GATTDescriptor.hpp +93 -0
  104. package/nitrogen/generated/shared/c++/GATTService.hpp +7 -2
  105. package/nitrogen/generated/shared/c++/HybridMunimBluetoothSpec.cpp +29 -0
  106. package/nitrogen/generated/shared/c++/HybridMunimBluetoothSpec.hpp +61 -2
  107. package/nitrogen/generated/shared/c++/L2CAPChannel.hpp +92 -0
  108. package/nitrogen/generated/shared/c++/MultipeerDiscoveryInfoEntry.hpp +87 -0
  109. package/nitrogen/generated/shared/c++/MultipeerEncryptionPreference.hpp +80 -0
  110. package/nitrogen/generated/shared/c++/MultipeerPeer.hpp +102 -0
  111. package/nitrogen/generated/shared/c++/MultipeerPeerState.hpp +80 -0
  112. package/nitrogen/generated/shared/c++/MultipeerSessionOptions.hpp +114 -0
  113. package/nitrogen/generated/shared/c++/PhyStatus.hpp +88 -0
  114. package/package.json +22 -11
  115. package/src/index.ts +416 -31
  116. package/src/specs/munim-bluetooth.nitro.ts +298 -14
@@ -0,0 +1,61 @@
1
+ ///
2
+ /// JBluetoothPhyOption.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 "BluetoothPhyOption.hpp"
12
+
13
+ namespace margelo::nitro::munimbluetooth {
14
+
15
+ using namespace facebook;
16
+
17
+ /**
18
+ * The C++ JNI bridge between the C++ enum "BluetoothPhyOption" and the the Kotlin enum "BluetoothPhyOption".
19
+ */
20
+ struct JBluetoothPhyOption final: public jni::JavaClass<JBluetoothPhyOption> {
21
+ public:
22
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/BluetoothPhyOption;";
23
+
24
+ public:
25
+ /**
26
+ * Convert this Java/Kotlin-based enum to the C++ enum BluetoothPhyOption.
27
+ */
28
+ [[maybe_unused]]
29
+ [[nodiscard]]
30
+ BluetoothPhyOption 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<BluetoothPhyOption>(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<JBluetoothPhyOption> fromCpp(BluetoothPhyOption value) {
43
+ static const auto clazz = javaClassStatic();
44
+ switch (value) {
45
+ case BluetoothPhyOption::NONE:
46
+ static const auto fieldNONE = clazz->getStaticField<JBluetoothPhyOption>("NONE");
47
+ return clazz->getStaticFieldValue(fieldNONE);
48
+ case BluetoothPhyOption::S2:
49
+ static const auto fieldS2 = clazz->getStaticField<JBluetoothPhyOption>("S2");
50
+ return clazz->getStaticFieldValue(fieldS2);
51
+ case BluetoothPhyOption::S8:
52
+ static const auto fieldS8 = clazz->getStaticField<JBluetoothPhyOption>("S8");
53
+ return clazz->getStaticFieldValue(fieldS8);
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
@@ -0,0 +1,64 @@
1
+ ///
2
+ /// JBondState.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 "BondState.hpp"
12
+
13
+ namespace margelo::nitro::munimbluetooth {
14
+
15
+ using namespace facebook;
16
+
17
+ /**
18
+ * The C++ JNI bridge between the C++ enum "BondState" and the the Kotlin enum "BondState".
19
+ */
20
+ struct JBondState final: public jni::JavaClass<JBondState> {
21
+ public:
22
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/BondState;";
23
+
24
+ public:
25
+ /**
26
+ * Convert this Java/Kotlin-based enum to the C++ enum BondState.
27
+ */
28
+ [[maybe_unused]]
29
+ [[nodiscard]]
30
+ BondState 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<BondState>(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<JBondState> fromCpp(BondState value) {
43
+ static const auto clazz = javaClassStatic();
44
+ switch (value) {
45
+ case BondState::NONE:
46
+ static const auto fieldNONE = clazz->getStaticField<JBondState>("NONE");
47
+ return clazz->getStaticFieldValue(fieldNONE);
48
+ case BondState::BONDING:
49
+ static const auto fieldBONDING = clazz->getStaticField<JBondState>("BONDING");
50
+ return clazz->getStaticFieldValue(fieldBONDING);
51
+ case BondState::BONDED:
52
+ static const auto fieldBONDED = clazz->getStaticField<JBondState>("BONDED");
53
+ return clazz->getStaticFieldValue(fieldBONDED);
54
+ case BondState::UNSUPPORTED:
55
+ static const auto fieldUNSUPPORTED = clazz->getStaticField<JBondState>("UNSUPPORTED");
56
+ return clazz->getStaticFieldValue(fieldUNSUPPORTED);
57
+ default:
58
+ std::string stringValue = std::to_string(static_cast<int>(value));
59
+ throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
60
+ }
61
+ }
62
+ };
63
+
64
+ } // namespace margelo::nitro::munimbluetooth
@@ -0,0 +1,69 @@
1
+ ///
2
+ /// JDescriptorValue.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 "DescriptorValue.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 "DescriptorValue" and the the Kotlin data class "DescriptorValue".
21
+ */
22
+ struct JDescriptorValue final: public jni::JavaClass<JDescriptorValue> {
23
+ public:
24
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/DescriptorValue;";
25
+
26
+ public:
27
+ /**
28
+ * Convert this Java/Kotlin-based struct to the C++ struct DescriptorValue by copying all values to C++.
29
+ */
30
+ [[maybe_unused]]
31
+ [[nodiscard]]
32
+ DescriptorValue toCpp() const {
33
+ static const auto clazz = javaClassStatic();
34
+ static const auto fieldValue = clazz->getField<jni::JString>("value");
35
+ jni::local_ref<jni::JString> value = this->getFieldValue(fieldValue);
36
+ static const auto fieldServiceUUID = clazz->getField<jni::JString>("serviceUUID");
37
+ jni::local_ref<jni::JString> serviceUUID = this->getFieldValue(fieldServiceUUID);
38
+ static const auto fieldCharacteristicUUID = clazz->getField<jni::JString>("characteristicUUID");
39
+ jni::local_ref<jni::JString> characteristicUUID = this->getFieldValue(fieldCharacteristicUUID);
40
+ static const auto fieldDescriptorUUID = clazz->getField<jni::JString>("descriptorUUID");
41
+ jni::local_ref<jni::JString> descriptorUUID = this->getFieldValue(fieldDescriptorUUID);
42
+ return DescriptorValue(
43
+ value->toStdString(),
44
+ serviceUUID->toStdString(),
45
+ characteristicUUID->toStdString(),
46
+ descriptorUUID->toStdString()
47
+ );
48
+ }
49
+
50
+ public:
51
+ /**
52
+ * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
53
+ */
54
+ [[maybe_unused]]
55
+ static jni::local_ref<JDescriptorValue::javaobject> fromCpp(const DescriptorValue& value) {
56
+ using JSignature = JDescriptorValue(jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>);
57
+ static const auto clazz = javaClassStatic();
58
+ static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
59
+ return create(
60
+ clazz,
61
+ jni::make_jstring(value.value),
62
+ jni::make_jstring(value.serviceUUID),
63
+ jni::make_jstring(value.characteristicUUID),
64
+ jni::make_jstring(value.descriptorUUID)
65
+ );
66
+ }
67
+ };
68
+
69
+ } // namespace margelo::nitro::munimbluetooth
@@ -0,0 +1,131 @@
1
+ ///
2
+ /// JExtendedAdvertisingOptions.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 "ExtendedAdvertisingOptions.hpp"
12
+
13
+ #include "AdvertisingDataTypes.hpp"
14
+ #include "BluetoothPhy.hpp"
15
+ #include "JAdvertisingDataTypes.hpp"
16
+ #include "JBluetoothPhy.hpp"
17
+ #include "JServiceDataEntry.hpp"
18
+ #include "ServiceDataEntry.hpp"
19
+ #include <optional>
20
+ #include <string>
21
+ #include <vector>
22
+
23
+ namespace margelo::nitro::munimbluetooth {
24
+
25
+ using namespace facebook;
26
+
27
+ /**
28
+ * The C++ JNI bridge between the C++ struct "ExtendedAdvertisingOptions" and the the Kotlin data class "ExtendedAdvertisingOptions".
29
+ */
30
+ struct JExtendedAdvertisingOptions final: public jni::JavaClass<JExtendedAdvertisingOptions> {
31
+ public:
32
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/ExtendedAdvertisingOptions;";
33
+
34
+ public:
35
+ /**
36
+ * Convert this Java/Kotlin-based struct to the C++ struct ExtendedAdvertisingOptions by copying all values to C++.
37
+ */
38
+ [[maybe_unused]]
39
+ [[nodiscard]]
40
+ ExtendedAdvertisingOptions toCpp() const {
41
+ static const auto clazz = javaClassStatic();
42
+ static const auto fieldServiceUUIDs = clazz->getField<jni::JArrayClass<jni::JString>>("serviceUUIDs");
43
+ jni::local_ref<jni::JArrayClass<jni::JString>> serviceUUIDs = this->getFieldValue(fieldServiceUUIDs);
44
+ static const auto fieldLocalName = clazz->getField<jni::JString>("localName");
45
+ jni::local_ref<jni::JString> localName = this->getFieldValue(fieldLocalName);
46
+ static const auto fieldManufacturerData = clazz->getField<jni::JString>("manufacturerData");
47
+ jni::local_ref<jni::JString> manufacturerData = this->getFieldValue(fieldManufacturerData);
48
+ static const auto fieldAdvertisingData = clazz->getField<JAdvertisingDataTypes>("advertisingData");
49
+ jni::local_ref<JAdvertisingDataTypes> advertisingData = this->getFieldValue(fieldAdvertisingData);
50
+ static const auto fieldConnectable = clazz->getField<jni::JBoolean>("connectable");
51
+ jni::local_ref<jni::JBoolean> connectable = this->getFieldValue(fieldConnectable);
52
+ static const auto fieldScannable = clazz->getField<jni::JBoolean>("scannable");
53
+ jni::local_ref<jni::JBoolean> scannable = this->getFieldValue(fieldScannable);
54
+ static const auto fieldLegacyMode = clazz->getField<jni::JBoolean>("legacyMode");
55
+ jni::local_ref<jni::JBoolean> legacyMode = this->getFieldValue(fieldLegacyMode);
56
+ static const auto fieldAnonymous = clazz->getField<jni::JBoolean>("anonymous");
57
+ jni::local_ref<jni::JBoolean> anonymous = this->getFieldValue(fieldAnonymous);
58
+ static const auto fieldIncludeTxPower = clazz->getField<jni::JBoolean>("includeTxPower");
59
+ jni::local_ref<jni::JBoolean> includeTxPower = this->getFieldValue(fieldIncludeTxPower);
60
+ static const auto fieldInterval = clazz->getField<jni::JDouble>("interval");
61
+ jni::local_ref<jni::JDouble> interval = this->getFieldValue(fieldInterval);
62
+ static const auto fieldTxPowerLevel = clazz->getField<jni::JDouble>("txPowerLevel");
63
+ jni::local_ref<jni::JDouble> txPowerLevel = this->getFieldValue(fieldTxPowerLevel);
64
+ static const auto fieldPrimaryPhy = clazz->getField<JBluetoothPhy>("primaryPhy");
65
+ jni::local_ref<JBluetoothPhy> primaryPhy = this->getFieldValue(fieldPrimaryPhy);
66
+ static const auto fieldSecondaryPhy = clazz->getField<JBluetoothPhy>("secondaryPhy");
67
+ jni::local_ref<JBluetoothPhy> secondaryPhy = this->getFieldValue(fieldSecondaryPhy);
68
+ return ExtendedAdvertisingOptions(
69
+ serviceUUIDs != nullptr ? std::make_optional([&](auto&& __input) {
70
+ size_t __size = __input->size();
71
+ std::vector<std::string> __vector;
72
+ __vector.reserve(__size);
73
+ for (size_t __i = 0; __i < __size; __i++) {
74
+ auto __element = __input->getElement(__i);
75
+ __vector.push_back(__element->toStdString());
76
+ }
77
+ return __vector;
78
+ }(serviceUUIDs)) : std::nullopt,
79
+ localName != nullptr ? std::make_optional(localName->toStdString()) : std::nullopt,
80
+ manufacturerData != nullptr ? std::make_optional(manufacturerData->toStdString()) : std::nullopt,
81
+ advertisingData != nullptr ? std::make_optional(advertisingData->toCpp()) : std::nullopt,
82
+ connectable != nullptr ? std::make_optional(static_cast<bool>(connectable->value())) : std::nullopt,
83
+ scannable != nullptr ? std::make_optional(static_cast<bool>(scannable->value())) : std::nullopt,
84
+ legacyMode != nullptr ? std::make_optional(static_cast<bool>(legacyMode->value())) : std::nullopt,
85
+ anonymous != nullptr ? std::make_optional(static_cast<bool>(anonymous->value())) : std::nullopt,
86
+ includeTxPower != nullptr ? std::make_optional(static_cast<bool>(includeTxPower->value())) : std::nullopt,
87
+ interval != nullptr ? std::make_optional(interval->value()) : std::nullopt,
88
+ txPowerLevel != nullptr ? std::make_optional(txPowerLevel->value()) : std::nullopt,
89
+ primaryPhy != nullptr ? std::make_optional(primaryPhy->toCpp()) : std::nullopt,
90
+ secondaryPhy != nullptr ? std::make_optional(secondaryPhy->toCpp()) : std::nullopt
91
+ );
92
+ }
93
+
94
+ public:
95
+ /**
96
+ * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
97
+ */
98
+ [[maybe_unused]]
99
+ static jni::local_ref<JExtendedAdvertisingOptions::javaobject> fromCpp(const ExtendedAdvertisingOptions& value) {
100
+ using JSignature = JExtendedAdvertisingOptions(jni::alias_ref<jni::JArrayClass<jni::JString>>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<JAdvertisingDataTypes>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>, jni::alias_ref<JBluetoothPhy>, jni::alias_ref<JBluetoothPhy>);
101
+ static const auto clazz = javaClassStatic();
102
+ static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
103
+ return create(
104
+ clazz,
105
+ value.serviceUUIDs.has_value() ? [&](auto&& __input) {
106
+ size_t __size = __input.size();
107
+ jni::local_ref<jni::JArrayClass<jni::JString>> __array = jni::JArrayClass<jni::JString>::newArray(__size);
108
+ for (size_t __i = 0; __i < __size; __i++) {
109
+ const auto& __element = __input[__i];
110
+ auto __elementJni = jni::make_jstring(__element);
111
+ __array->setElement(__i, *__elementJni);
112
+ }
113
+ return __array;
114
+ }(value.serviceUUIDs.value()) : nullptr,
115
+ value.localName.has_value() ? jni::make_jstring(value.localName.value()) : nullptr,
116
+ value.manufacturerData.has_value() ? jni::make_jstring(value.manufacturerData.value()) : nullptr,
117
+ value.advertisingData.has_value() ? JAdvertisingDataTypes::fromCpp(value.advertisingData.value()) : nullptr,
118
+ value.connectable.has_value() ? jni::JBoolean::valueOf(value.connectable.value()) : nullptr,
119
+ value.scannable.has_value() ? jni::JBoolean::valueOf(value.scannable.value()) : nullptr,
120
+ value.legacyMode.has_value() ? jni::JBoolean::valueOf(value.legacyMode.value()) : nullptr,
121
+ value.anonymous.has_value() ? jni::JBoolean::valueOf(value.anonymous.value()) : nullptr,
122
+ value.includeTxPower.has_value() ? jni::JBoolean::valueOf(value.includeTxPower.value()) : nullptr,
123
+ value.interval.has_value() ? jni::JDouble::valueOf(value.interval.value()) : nullptr,
124
+ value.txPowerLevel.has_value() ? jni::JDouble::valueOf(value.txPowerLevel.value()) : nullptr,
125
+ value.primaryPhy.has_value() ? JBluetoothPhy::fromCpp(value.primaryPhy.value()) : nullptr,
126
+ value.secondaryPhy.has_value() ? JBluetoothPhy::fromCpp(value.secondaryPhy.value()) : nullptr
127
+ );
128
+ }
129
+ };
130
+
131
+ } // namespace margelo::nitro::munimbluetooth
@@ -10,6 +10,8 @@
10
10
  #include <fbjni/fbjni.h>
11
11
  #include "GATTCharacteristic.hpp"
12
12
 
13
+ #include "GATTDescriptor.hpp"
14
+ #include "JGATTDescriptor.hpp"
13
15
  #include <optional>
14
16
  #include <string>
15
17
  #include <vector>
@@ -39,19 +41,31 @@ namespace margelo::nitro::munimbluetooth {
39
41
  jni::local_ref<jni::JArrayClass<jni::JString>> properties = this->getFieldValue(fieldProperties);
40
42
  static const auto fieldValue = clazz->getField<jni::JString>("value");
41
43
  jni::local_ref<jni::JString> value = this->getFieldValue(fieldValue);
44
+ static const auto fieldDescriptors = clazz->getField<jni::JArrayClass<JGATTDescriptor>>("descriptors");
45
+ jni::local_ref<jni::JArrayClass<JGATTDescriptor>> descriptors = this->getFieldValue(fieldDescriptors);
42
46
  return GATTCharacteristic(
43
47
  uuid->toStdString(),
44
- [&]() {
45
- size_t __size = properties->size();
48
+ [&](auto&& __input) {
49
+ size_t __size = __input->size();
46
50
  std::vector<std::string> __vector;
47
51
  __vector.reserve(__size);
48
52
  for (size_t __i = 0; __i < __size; __i++) {
49
- auto __element = properties->getElement(__i);
53
+ auto __element = __input->getElement(__i);
50
54
  __vector.push_back(__element->toStdString());
51
55
  }
52
56
  return __vector;
53
- }(),
54
- value != nullptr ? std::make_optional(value->toStdString()) : std::nullopt
57
+ }(properties),
58
+ value != nullptr ? std::make_optional(value->toStdString()) : std::nullopt,
59
+ descriptors != nullptr ? std::make_optional([&](auto&& __input) {
60
+ size_t __size = __input->size();
61
+ std::vector<GATTDescriptor> __vector;
62
+ __vector.reserve(__size);
63
+ for (size_t __i = 0; __i < __size; __i++) {
64
+ auto __element = __input->getElement(__i);
65
+ __vector.push_back(__element->toCpp());
66
+ }
67
+ return __vector;
68
+ }(descriptors)) : std::nullopt
55
69
  );
56
70
  }
57
71
 
@@ -61,23 +75,33 @@ namespace margelo::nitro::munimbluetooth {
61
75
  */
62
76
  [[maybe_unused]]
63
77
  static jni::local_ref<JGATTCharacteristic::javaobject> fromCpp(const GATTCharacteristic& value) {
64
- using JSignature = JGATTCharacteristic(jni::alias_ref<jni::JString>, jni::alias_ref<jni::JArrayClass<jni::JString>>, jni::alias_ref<jni::JString>);
78
+ using JSignature = JGATTCharacteristic(jni::alias_ref<jni::JString>, jni::alias_ref<jni::JArrayClass<jni::JString>>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JArrayClass<JGATTDescriptor>>);
65
79
  static const auto clazz = javaClassStatic();
66
80
  static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
67
81
  return create(
68
82
  clazz,
69
83
  jni::make_jstring(value.uuid),
70
- [&]() {
71
- size_t __size = value.properties.size();
84
+ [&](auto&& __input) {
85
+ size_t __size = __input.size();
72
86
  jni::local_ref<jni::JArrayClass<jni::JString>> __array = jni::JArrayClass<jni::JString>::newArray(__size);
73
87
  for (size_t __i = 0; __i < __size; __i++) {
74
- const auto& __element = value.properties[__i];
88
+ const auto& __element = __input[__i];
75
89
  auto __elementJni = jni::make_jstring(__element);
76
90
  __array->setElement(__i, *__elementJni);
77
91
  }
78
92
  return __array;
79
- }(),
80
- value.value.has_value() ? jni::make_jstring(value.value.value()) : nullptr
93
+ }(value.properties),
94
+ value.value.has_value() ? jni::make_jstring(value.value.value()) : nullptr,
95
+ value.descriptors.has_value() ? [&](auto&& __input) {
96
+ size_t __size = __input.size();
97
+ jni::local_ref<jni::JArrayClass<JGATTDescriptor>> __array = jni::JArrayClass<JGATTDescriptor>::newArray(__size);
98
+ for (size_t __i = 0; __i < __size; __i++) {
99
+ const auto& __element = __input[__i];
100
+ auto __elementJni = JGATTDescriptor::fromCpp(__element);
101
+ __array->setElement(__i, *__elementJni);
102
+ }
103
+ return __array;
104
+ }(value.descriptors.value()) : nullptr
81
105
  );
82
106
  }
83
107
  };
@@ -0,0 +1,85 @@
1
+ ///
2
+ /// JGATTDescriptor.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 "GATTDescriptor.hpp"
12
+
13
+ #include <optional>
14
+ #include <string>
15
+ #include <vector>
16
+
17
+ namespace margelo::nitro::munimbluetooth {
18
+
19
+ using namespace facebook;
20
+
21
+ /**
22
+ * The C++ JNI bridge between the C++ struct "GATTDescriptor" and the the Kotlin data class "GATTDescriptor".
23
+ */
24
+ struct JGATTDescriptor final: public jni::JavaClass<JGATTDescriptor> {
25
+ public:
26
+ static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/GATTDescriptor;";
27
+
28
+ public:
29
+ /**
30
+ * Convert this Java/Kotlin-based struct to the C++ struct GATTDescriptor by copying all values to C++.
31
+ */
32
+ [[maybe_unused]]
33
+ [[nodiscard]]
34
+ GATTDescriptor toCpp() const {
35
+ static const auto clazz = javaClassStatic();
36
+ static const auto fieldUuid = clazz->getField<jni::JString>("uuid");
37
+ jni::local_ref<jni::JString> uuid = this->getFieldValue(fieldUuid);
38
+ static const auto fieldValue = clazz->getField<jni::JString>("value");
39
+ jni::local_ref<jni::JString> value = this->getFieldValue(fieldValue);
40
+ static const auto fieldPermissions = clazz->getField<jni::JArrayClass<jni::JString>>("permissions");
41
+ jni::local_ref<jni::JArrayClass<jni::JString>> permissions = this->getFieldValue(fieldPermissions);
42
+ return GATTDescriptor(
43
+ uuid->toStdString(),
44
+ value != nullptr ? std::make_optional(value->toStdString()) : std::nullopt,
45
+ permissions != nullptr ? std::make_optional([&](auto&& __input) {
46
+ size_t __size = __input->size();
47
+ std::vector<std::string> __vector;
48
+ __vector.reserve(__size);
49
+ for (size_t __i = 0; __i < __size; __i++) {
50
+ auto __element = __input->getElement(__i);
51
+ __vector.push_back(__element->toStdString());
52
+ }
53
+ return __vector;
54
+ }(permissions)) : std::nullopt
55
+ );
56
+ }
57
+
58
+ public:
59
+ /**
60
+ * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
61
+ */
62
+ [[maybe_unused]]
63
+ static jni::local_ref<JGATTDescriptor::javaobject> fromCpp(const GATTDescriptor& value) {
64
+ using JSignature = JGATTDescriptor(jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JArrayClass<jni::JString>>);
65
+ static const auto clazz = javaClassStatic();
66
+ static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
67
+ return create(
68
+ clazz,
69
+ jni::make_jstring(value.uuid),
70
+ value.value.has_value() ? jni::make_jstring(value.value.value()) : nullptr,
71
+ value.permissions.has_value() ? [&](auto&& __input) {
72
+ size_t __size = __input.size();
73
+ jni::local_ref<jni::JArrayClass<jni::JString>> __array = jni::JArrayClass<jni::JString>::newArray(__size);
74
+ for (size_t __i = 0; __i < __size; __i++) {
75
+ const auto& __element = __input[__i];
76
+ auto __elementJni = jni::make_jstring(__element);
77
+ __array->setElement(__i, *__elementJni);
78
+ }
79
+ return __array;
80
+ }(value.permissions.value()) : nullptr
81
+ );
82
+ }
83
+ };
84
+
85
+ } // namespace margelo::nitro::munimbluetooth
@@ -11,7 +11,9 @@
11
11
  #include "GATTService.hpp"
12
12
 
13
13
  #include "GATTCharacteristic.hpp"
14
+ #include "GATTDescriptor.hpp"
14
15
  #include "JGATTCharacteristic.hpp"
16
+ #include "JGATTDescriptor.hpp"
15
17
  #include <optional>
16
18
  #include <string>
17
19
  #include <vector>
@@ -39,18 +41,30 @@ namespace margelo::nitro::munimbluetooth {
39
41
  jni::local_ref<jni::JString> uuid = this->getFieldValue(fieldUuid);
40
42
  static const auto fieldCharacteristics = clazz->getField<jni::JArrayClass<JGATTCharacteristic>>("characteristics");
41
43
  jni::local_ref<jni::JArrayClass<JGATTCharacteristic>> characteristics = this->getFieldValue(fieldCharacteristics);
44
+ static const auto fieldIncludedServices = clazz->getField<jni::JArrayClass<jni::JString>>("includedServices");
45
+ jni::local_ref<jni::JArrayClass<jni::JString>> includedServices = this->getFieldValue(fieldIncludedServices);
42
46
  return GATTService(
43
47
  uuid->toStdString(),
44
- [&]() {
45
- size_t __size = characteristics->size();
48
+ [&](auto&& __input) {
49
+ size_t __size = __input->size();
46
50
  std::vector<GATTCharacteristic> __vector;
47
51
  __vector.reserve(__size);
48
52
  for (size_t __i = 0; __i < __size; __i++) {
49
- auto __element = characteristics->getElement(__i);
53
+ auto __element = __input->getElement(__i);
50
54
  __vector.push_back(__element->toCpp());
51
55
  }
52
56
  return __vector;
53
- }()
57
+ }(characteristics),
58
+ includedServices != nullptr ? std::make_optional([&](auto&& __input) {
59
+ size_t __size = __input->size();
60
+ std::vector<std::string> __vector;
61
+ __vector.reserve(__size);
62
+ for (size_t __i = 0; __i < __size; __i++) {
63
+ auto __element = __input->getElement(__i);
64
+ __vector.push_back(__element->toStdString());
65
+ }
66
+ return __vector;
67
+ }(includedServices)) : std::nullopt
54
68
  );
55
69
  }
56
70
 
@@ -60,22 +74,32 @@ namespace margelo::nitro::munimbluetooth {
60
74
  */
61
75
  [[maybe_unused]]
62
76
  static jni::local_ref<JGATTService::javaobject> fromCpp(const GATTService& value) {
63
- using JSignature = JGATTService(jni::alias_ref<jni::JString>, jni::alias_ref<jni::JArrayClass<JGATTCharacteristic>>);
77
+ using JSignature = JGATTService(jni::alias_ref<jni::JString>, jni::alias_ref<jni::JArrayClass<JGATTCharacteristic>>, jni::alias_ref<jni::JArrayClass<jni::JString>>);
64
78
  static const auto clazz = javaClassStatic();
65
79
  static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
66
80
  return create(
67
81
  clazz,
68
82
  jni::make_jstring(value.uuid),
69
- [&]() {
70
- size_t __size = value.characteristics.size();
83
+ [&](auto&& __input) {
84
+ size_t __size = __input.size();
71
85
  jni::local_ref<jni::JArrayClass<JGATTCharacteristic>> __array = jni::JArrayClass<JGATTCharacteristic>::newArray(__size);
72
86
  for (size_t __i = 0; __i < __size; __i++) {
73
- const auto& __element = value.characteristics[__i];
87
+ const auto& __element = __input[__i];
74
88
  auto __elementJni = JGATTCharacteristic::fromCpp(__element);
75
89
  __array->setElement(__i, *__elementJni);
76
90
  }
77
91
  return __array;
78
- }()
92
+ }(value.characteristics),
93
+ value.includedServices.has_value() ? [&](auto&& __input) {
94
+ size_t __size = __input.size();
95
+ jni::local_ref<jni::JArrayClass<jni::JString>> __array = jni::JArrayClass<jni::JString>::newArray(__size);
96
+ for (size_t __i = 0; __i < __size; __i++) {
97
+ const auto& __element = __input[__i];
98
+ auto __elementJni = jni::make_jstring(__element);
99
+ __array->setElement(__i, *__elementJni);
100
+ }
101
+ return __array;
102
+ }(value.includedServices.value()) : nullptr
79
103
  );
80
104
  }
81
105
  };