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
@@ -19,26 +19,56 @@ namespace margelo::nitro::munimbluetooth { struct AdvertisingOptions; }
19
19
  namespace margelo::nitro::munimbluetooth { struct AdvertisingDataTypes; }
20
20
  // Forward declaration of `GATTService` to properly resolve imports.
21
21
  namespace margelo::nitro::munimbluetooth { struct GATTService; }
22
+ // Forward declaration of `BluetoothCapabilities` to properly resolve imports.
23
+ namespace margelo::nitro::munimbluetooth { struct BluetoothCapabilities; }
22
24
  // Forward declaration of `ScanOptions` to properly resolve imports.
23
25
  namespace margelo::nitro::munimbluetooth { struct ScanOptions; }
24
26
  // Forward declaration of `CharacteristicValue` to properly resolve imports.
25
27
  namespace margelo::nitro::munimbluetooth { struct CharacteristicValue; }
28
+ // Forward declaration of `DescriptorValue` to properly resolve imports.
29
+ namespace margelo::nitro::munimbluetooth { struct DescriptorValue; }
26
30
  // Forward declaration of `WriteType` to properly resolve imports.
27
31
  namespace margelo::nitro::munimbluetooth { enum class WriteType; }
32
+ // Forward declaration of `BluetoothPhy` to properly resolve imports.
33
+ namespace margelo::nitro::munimbluetooth { enum class BluetoothPhy; }
34
+ // Forward declaration of `BluetoothPhyOption` to properly resolve imports.
35
+ namespace margelo::nitro::munimbluetooth { enum class BluetoothPhyOption; }
36
+ // Forward declaration of `PhyStatus` to properly resolve imports.
37
+ namespace margelo::nitro::munimbluetooth { struct PhyStatus; }
38
+ // Forward declaration of `BondState` to properly resolve imports.
39
+ namespace margelo::nitro::munimbluetooth { enum class BondState; }
40
+ // Forward declaration of `ExtendedAdvertisingOptions` to properly resolve imports.
41
+ namespace margelo::nitro::munimbluetooth { struct ExtendedAdvertisingOptions; }
42
+ // Forward declaration of `L2CAPChannel` to properly resolve imports.
43
+ namespace margelo::nitro::munimbluetooth { struct L2CAPChannel; }
28
44
  // Forward declaration of `BackgroundSessionOptions` to properly resolve imports.
29
45
  namespace margelo::nitro::munimbluetooth { struct BackgroundSessionOptions; }
46
+ // Forward declaration of `MultipeerSessionOptions` to properly resolve imports.
47
+ namespace margelo::nitro::munimbluetooth { struct MultipeerSessionOptions; }
48
+ // Forward declaration of `MultipeerPeer` to properly resolve imports.
49
+ namespace margelo::nitro::munimbluetooth { struct MultipeerPeer; }
30
50
 
31
51
  #include "AdvertisingOptions.hpp"
32
52
  #include "AdvertisingDataTypes.hpp"
33
53
  #include <NitroModules/Promise.hpp>
34
54
  #include "GATTService.hpp"
35
55
  #include <vector>
36
- #include "ScanOptions.hpp"
37
- #include <optional>
38
56
  #include <string>
57
+ #include <optional>
58
+ #include "BluetoothCapabilities.hpp"
59
+ #include "ScanOptions.hpp"
39
60
  #include "CharacteristicValue.hpp"
61
+ #include "DescriptorValue.hpp"
40
62
  #include "WriteType.hpp"
63
+ #include "BluetoothPhy.hpp"
64
+ #include "BluetoothPhyOption.hpp"
65
+ #include "PhyStatus.hpp"
66
+ #include "BondState.hpp"
67
+ #include "ExtendedAdvertisingOptions.hpp"
68
+ #include "L2CAPChannel.hpp"
41
69
  #include "BackgroundSessionOptions.hpp"
70
+ #include "MultipeerSessionOptions.hpp"
71
+ #include "MultipeerPeer.hpp"
42
72
 
43
73
  namespace margelo::nitro::munimbluetooth {
44
74
 
@@ -76,21 +106,50 @@ namespace margelo::nitro::munimbluetooth {
76
106
  virtual std::shared_ptr<Promise<AdvertisingDataTypes>> getAdvertisingData() = 0;
77
107
  virtual void stopAdvertising() = 0;
78
108
  virtual void setServices(const std::vector<GATTService>& services) = 0;
109
+ virtual std::shared_ptr<Promise<void>> updateCharacteristicValue(const std::string& serviceUUID, const std::string& characteristicUUID, const std::string& value, std::optional<bool> notify) = 0;
79
110
  virtual std::shared_ptr<Promise<bool>> isBluetoothEnabled() = 0;
80
111
  virtual std::shared_ptr<Promise<bool>> requestBluetoothPermission() = 0;
112
+ virtual std::shared_ptr<Promise<BluetoothCapabilities>> getCapabilities() = 0;
81
113
  virtual void startScan(const std::optional<ScanOptions>& options) = 0;
82
114
  virtual void stopScan() = 0;
83
115
  virtual std::shared_ptr<Promise<void>> connect(const std::string& deviceId) = 0;
84
116
  virtual void disconnect(const std::string& deviceId) = 0;
85
117
  virtual std::shared_ptr<Promise<std::vector<GATTService>>> discoverServices(const std::string& deviceId) = 0;
86
118
  virtual std::shared_ptr<Promise<CharacteristicValue>> readCharacteristic(const std::string& deviceId, const std::string& serviceUUID, const std::string& characteristicUUID) = 0;
119
+ virtual std::shared_ptr<Promise<DescriptorValue>> readDescriptor(const std::string& deviceId, const std::string& serviceUUID, const std::string& characteristicUUID, const std::string& descriptorUUID) = 0;
87
120
  virtual 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) = 0;
121
+ virtual 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) = 0;
88
122
  virtual void subscribeToCharacteristic(const std::string& deviceId, const std::string& serviceUUID, const std::string& characteristicUUID) = 0;
89
123
  virtual void unsubscribeFromCharacteristic(const std::string& deviceId, const std::string& serviceUUID, const std::string& characteristicUUID) = 0;
90
124
  virtual std::shared_ptr<Promise<std::vector<std::string>>> getConnectedDevices() = 0;
91
125
  virtual std::shared_ptr<Promise<double>> readRSSI(const std::string& deviceId) = 0;
126
+ virtual std::shared_ptr<Promise<double>> requestMTU(const std::string& deviceId, double mtu) = 0;
127
+ virtual std::shared_ptr<Promise<void>> setPreferredPhy(const std::string& deviceId, BluetoothPhy txPhy, BluetoothPhy rxPhy, std::optional<BluetoothPhyOption> phyOption) = 0;
128
+ virtual std::shared_ptr<Promise<PhyStatus>> readPhy(const std::string& deviceId) = 0;
129
+ virtual std::shared_ptr<Promise<BondState>> getBondState(const std::string& deviceId) = 0;
130
+ virtual std::shared_ptr<Promise<BondState>> createBond(const std::string& deviceId) = 0;
131
+ virtual std::shared_ptr<Promise<BondState>> removeBond(const std::string& deviceId) = 0;
132
+ virtual std::shared_ptr<Promise<std::string>> startExtendedAdvertising(const ExtendedAdvertisingOptions& options) = 0;
133
+ virtual void stopExtendedAdvertising(const std::string& advertisingId) = 0;
134
+ virtual std::shared_ptr<Promise<L2CAPChannel>> publishL2CAPChannel(std::optional<bool> encryptionRequired) = 0;
135
+ virtual void unpublishL2CAPChannel(double psm) = 0;
136
+ virtual std::shared_ptr<Promise<L2CAPChannel>> openL2CAPChannel(const std::string& deviceId, double psm) = 0;
137
+ virtual void closeL2CAPChannel(const std::string& channelId) = 0;
138
+ virtual std::shared_ptr<Promise<void>> sendL2CAPData(const std::string& channelId, const std::string& value) = 0;
139
+ virtual void startClassicScan() = 0;
140
+ virtual void stopClassicScan() = 0;
141
+ virtual std::shared_ptr<Promise<void>> connectClassic(const std::string& deviceId, const std::optional<std::string>& serviceUUID) = 0;
142
+ virtual std::shared_ptr<Promise<void>> startClassicServer(const std::optional<std::string>& serviceUUID, const std::optional<std::string>& serviceName) = 0;
143
+ virtual void stopClassicServer(const std::optional<std::string>& serviceUUID) = 0;
144
+ virtual void disconnectClassic(const std::string& deviceId) = 0;
145
+ virtual std::shared_ptr<Promise<void>> writeClassic(const std::string& deviceId, const std::string& value) = 0;
92
146
  virtual void startBackgroundSession(const BackgroundSessionOptions& options) = 0;
93
147
  virtual void stopBackgroundSession() = 0;
148
+ virtual void startMultipeerSession(const MultipeerSessionOptions& options) = 0;
149
+ virtual void stopMultipeerSession() = 0;
150
+ virtual void inviteMultipeerPeer(const std::string& peerId) = 0;
151
+ virtual std::shared_ptr<Promise<std::vector<MultipeerPeer>>> getMultipeerPeers() = 0;
152
+ virtual std::shared_ptr<Promise<void>> sendMultipeerMessage(const std::string& value, const std::optional<std::vector<std::string>>& peerIds, std::optional<bool> reliable) = 0;
94
153
  virtual void addListener(const std::string& eventName) = 0;
95
154
  virtual void removeListeners(double count) = 0;
96
155
 
@@ -0,0 +1,92 @@
1
+ ///
2
+ /// L2CAPChannel.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
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
11
+ #include <NitroModules/JSIConverter.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
16
+ #include <NitroModules/NitroDefines.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+ #if __has_include(<NitroModules/PropNameIDCache.hpp>)
26
+ #include <NitroModules/PropNameIDCache.hpp>
27
+ #else
28
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
+ #endif
30
+
31
+
32
+
33
+ #include <string>
34
+ #include <optional>
35
+
36
+ namespace margelo::nitro::munimbluetooth {
37
+
38
+ /**
39
+ * A struct which can be represented as a JavaScript object (L2CAPChannel).
40
+ */
41
+ struct L2CAPChannel final {
42
+ public:
43
+ std::string id SWIFT_PRIVATE;
44
+ double psm SWIFT_PRIVATE;
45
+ std::optional<std::string> deviceId SWIFT_PRIVATE;
46
+
47
+ public:
48
+ L2CAPChannel() = default;
49
+ explicit L2CAPChannel(std::string id, double psm, std::optional<std::string> deviceId): id(id), psm(psm), deviceId(deviceId) {}
50
+
51
+ public:
52
+ friend bool operator==(const L2CAPChannel& lhs, const L2CAPChannel& rhs) = default;
53
+ };
54
+
55
+ } // namespace margelo::nitro::munimbluetooth
56
+
57
+ namespace margelo::nitro {
58
+
59
+ // C++ L2CAPChannel <> JS L2CAPChannel (object)
60
+ template <>
61
+ struct JSIConverter<margelo::nitro::munimbluetooth::L2CAPChannel> final {
62
+ static inline margelo::nitro::munimbluetooth::L2CAPChannel fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
63
+ jsi::Object obj = arg.asObject(runtime);
64
+ return margelo::nitro::munimbluetooth::L2CAPChannel(
65
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "id"))),
66
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "psm"))),
67
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "deviceId")))
68
+ );
69
+ }
70
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::munimbluetooth::L2CAPChannel& arg) {
71
+ jsi::Object obj(runtime);
72
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "id"), JSIConverter<std::string>::toJSI(runtime, arg.id));
73
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "psm"), JSIConverter<double>::toJSI(runtime, arg.psm));
74
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "deviceId"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.deviceId));
75
+ return obj;
76
+ }
77
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
78
+ if (!value.isObject()) {
79
+ return false;
80
+ }
81
+ jsi::Object obj = value.getObject(runtime);
82
+ if (!nitro::isPlainObject(runtime, obj)) {
83
+ return false;
84
+ }
85
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "id")))) return false;
86
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "psm")))) return false;
87
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "deviceId")))) return false;
88
+ return true;
89
+ }
90
+ };
91
+
92
+ } // namespace margelo::nitro
@@ -0,0 +1,87 @@
1
+ ///
2
+ /// MultipeerDiscoveryInfoEntry.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
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
11
+ #include <NitroModules/JSIConverter.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
16
+ #include <NitroModules/NitroDefines.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+ #if __has_include(<NitroModules/PropNameIDCache.hpp>)
26
+ #include <NitroModules/PropNameIDCache.hpp>
27
+ #else
28
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
+ #endif
30
+
31
+
32
+
33
+ #include <string>
34
+
35
+ namespace margelo::nitro::munimbluetooth {
36
+
37
+ /**
38
+ * A struct which can be represented as a JavaScript object (MultipeerDiscoveryInfoEntry).
39
+ */
40
+ struct MultipeerDiscoveryInfoEntry final {
41
+ public:
42
+ std::string key SWIFT_PRIVATE;
43
+ std::string value SWIFT_PRIVATE;
44
+
45
+ public:
46
+ MultipeerDiscoveryInfoEntry() = default;
47
+ explicit MultipeerDiscoveryInfoEntry(std::string key, std::string value): key(key), value(value) {}
48
+
49
+ public:
50
+ friend bool operator==(const MultipeerDiscoveryInfoEntry& lhs, const MultipeerDiscoveryInfoEntry& rhs) = default;
51
+ };
52
+
53
+ } // namespace margelo::nitro::munimbluetooth
54
+
55
+ namespace margelo::nitro {
56
+
57
+ // C++ MultipeerDiscoveryInfoEntry <> JS MultipeerDiscoveryInfoEntry (object)
58
+ template <>
59
+ struct JSIConverter<margelo::nitro::munimbluetooth::MultipeerDiscoveryInfoEntry> final {
60
+ static inline margelo::nitro::munimbluetooth::MultipeerDiscoveryInfoEntry fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
61
+ jsi::Object obj = arg.asObject(runtime);
62
+ return margelo::nitro::munimbluetooth::MultipeerDiscoveryInfoEntry(
63
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "key"))),
64
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "value")))
65
+ );
66
+ }
67
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::munimbluetooth::MultipeerDiscoveryInfoEntry& arg) {
68
+ jsi::Object obj(runtime);
69
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "key"), JSIConverter<std::string>::toJSI(runtime, arg.key));
70
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "value"), JSIConverter<std::string>::toJSI(runtime, arg.value));
71
+ return obj;
72
+ }
73
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
74
+ if (!value.isObject()) {
75
+ return false;
76
+ }
77
+ jsi::Object obj = value.getObject(runtime);
78
+ if (!nitro::isPlainObject(runtime, obj)) {
79
+ return false;
80
+ }
81
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "key")))) return false;
82
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "value")))) return false;
83
+ return true;
84
+ }
85
+ };
86
+
87
+ } // namespace margelo::nitro
@@ -0,0 +1,80 @@
1
+ ///
2
+ /// MultipeerEncryptionPreference.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
+ #if __has_include(<NitroModules/NitroHash.hpp>)
11
+ #include <NitroModules/NitroHash.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
16
+ #include <NitroModules/JSIConverter.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
21
+ #include <NitroModules/NitroDefines.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+
26
+ namespace margelo::nitro::munimbluetooth {
27
+
28
+ /**
29
+ * An enum which can be represented as a JavaScript union (MultipeerEncryptionPreference).
30
+ */
31
+ enum class MultipeerEncryptionPreference {
32
+ NONE SWIFT_NAME(none) = 0,
33
+ OPTIONAL SWIFT_NAME(optional) = 1,
34
+ REQUIRED SWIFT_NAME(required) = 2,
35
+ } CLOSED_ENUM;
36
+
37
+ } // namespace margelo::nitro::munimbluetooth
38
+
39
+ namespace margelo::nitro {
40
+
41
+ // C++ MultipeerEncryptionPreference <> JS MultipeerEncryptionPreference (union)
42
+ template <>
43
+ struct JSIConverter<margelo::nitro::munimbluetooth::MultipeerEncryptionPreference> final {
44
+ static inline margelo::nitro::munimbluetooth::MultipeerEncryptionPreference fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
45
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
46
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
47
+ case hashString("none"): return margelo::nitro::munimbluetooth::MultipeerEncryptionPreference::NONE;
48
+ case hashString("optional"): return margelo::nitro::munimbluetooth::MultipeerEncryptionPreference::OPTIONAL;
49
+ case hashString("required"): return margelo::nitro::munimbluetooth::MultipeerEncryptionPreference::REQUIRED;
50
+ default: [[unlikely]]
51
+ throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum MultipeerEncryptionPreference - invalid value!");
52
+ }
53
+ }
54
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::munimbluetooth::MultipeerEncryptionPreference arg) {
55
+ switch (arg) {
56
+ case margelo::nitro::munimbluetooth::MultipeerEncryptionPreference::NONE: return JSIConverter<std::string>::toJSI(runtime, "none");
57
+ case margelo::nitro::munimbluetooth::MultipeerEncryptionPreference::OPTIONAL: return JSIConverter<std::string>::toJSI(runtime, "optional");
58
+ case margelo::nitro::munimbluetooth::MultipeerEncryptionPreference::REQUIRED: return JSIConverter<std::string>::toJSI(runtime, "required");
59
+ default: [[unlikely]]
60
+ throw std::invalid_argument("Cannot convert MultipeerEncryptionPreference to JS - invalid value: "
61
+ + std::to_string(static_cast<int>(arg)) + "!");
62
+ }
63
+ }
64
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
65
+ if (!value.isString()) {
66
+ return false;
67
+ }
68
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
69
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
70
+ case hashString("none"):
71
+ case hashString("optional"):
72
+ case hashString("required"):
73
+ return true;
74
+ default:
75
+ return false;
76
+ }
77
+ }
78
+ };
79
+
80
+ } // namespace margelo::nitro
@@ -0,0 +1,102 @@
1
+ ///
2
+ /// MultipeerPeer.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
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
11
+ #include <NitroModules/JSIConverter.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
16
+ #include <NitroModules/NitroDefines.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+ #if __has_include(<NitroModules/PropNameIDCache.hpp>)
26
+ #include <NitroModules/PropNameIDCache.hpp>
27
+ #else
28
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
+ #endif
30
+
31
+ // Forward declaration of `MultipeerPeerState` to properly resolve imports.
32
+ namespace margelo::nitro::munimbluetooth { enum class MultipeerPeerState; }
33
+ // Forward declaration of `MultipeerDiscoveryInfoEntry` to properly resolve imports.
34
+ namespace margelo::nitro::munimbluetooth { struct MultipeerDiscoveryInfoEntry; }
35
+
36
+ #include <string>
37
+ #include "MultipeerPeerState.hpp"
38
+ #include "MultipeerDiscoveryInfoEntry.hpp"
39
+ #include <vector>
40
+ #include <optional>
41
+
42
+ namespace margelo::nitro::munimbluetooth {
43
+
44
+ /**
45
+ * A struct which can be represented as a JavaScript object (MultipeerPeer).
46
+ */
47
+ struct MultipeerPeer final {
48
+ public:
49
+ std::string id SWIFT_PRIVATE;
50
+ std::string displayName SWIFT_PRIVATE;
51
+ MultipeerPeerState state SWIFT_PRIVATE;
52
+ std::optional<std::vector<MultipeerDiscoveryInfoEntry>> discoveryInfo SWIFT_PRIVATE;
53
+
54
+ public:
55
+ MultipeerPeer() = default;
56
+ explicit MultipeerPeer(std::string id, std::string displayName, MultipeerPeerState state, std::optional<std::vector<MultipeerDiscoveryInfoEntry>> discoveryInfo): id(id), displayName(displayName), state(state), discoveryInfo(discoveryInfo) {}
57
+
58
+ public:
59
+ friend bool operator==(const MultipeerPeer& lhs, const MultipeerPeer& rhs) = default;
60
+ };
61
+
62
+ } // namespace margelo::nitro::munimbluetooth
63
+
64
+ namespace margelo::nitro {
65
+
66
+ // C++ MultipeerPeer <> JS MultipeerPeer (object)
67
+ template <>
68
+ struct JSIConverter<margelo::nitro::munimbluetooth::MultipeerPeer> final {
69
+ static inline margelo::nitro::munimbluetooth::MultipeerPeer fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
70
+ jsi::Object obj = arg.asObject(runtime);
71
+ return margelo::nitro::munimbluetooth::MultipeerPeer(
72
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "id"))),
73
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "displayName"))),
74
+ JSIConverter<margelo::nitro::munimbluetooth::MultipeerPeerState>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "state"))),
75
+ JSIConverter<std::optional<std::vector<margelo::nitro::munimbluetooth::MultipeerDiscoveryInfoEntry>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "discoveryInfo")))
76
+ );
77
+ }
78
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::munimbluetooth::MultipeerPeer& arg) {
79
+ jsi::Object obj(runtime);
80
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "id"), JSIConverter<std::string>::toJSI(runtime, arg.id));
81
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "displayName"), JSIConverter<std::string>::toJSI(runtime, arg.displayName));
82
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "state"), JSIConverter<margelo::nitro::munimbluetooth::MultipeerPeerState>::toJSI(runtime, arg.state));
83
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "discoveryInfo"), JSIConverter<std::optional<std::vector<margelo::nitro::munimbluetooth::MultipeerDiscoveryInfoEntry>>>::toJSI(runtime, arg.discoveryInfo));
84
+ return obj;
85
+ }
86
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
87
+ if (!value.isObject()) {
88
+ return false;
89
+ }
90
+ jsi::Object obj = value.getObject(runtime);
91
+ if (!nitro::isPlainObject(runtime, obj)) {
92
+ return false;
93
+ }
94
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "id")))) return false;
95
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "displayName")))) return false;
96
+ if (!JSIConverter<margelo::nitro::munimbluetooth::MultipeerPeerState>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "state")))) return false;
97
+ if (!JSIConverter<std::optional<std::vector<margelo::nitro::munimbluetooth::MultipeerDiscoveryInfoEntry>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "discoveryInfo")))) return false;
98
+ return true;
99
+ }
100
+ };
101
+
102
+ } // namespace margelo::nitro
@@ -0,0 +1,80 @@
1
+ ///
2
+ /// MultipeerPeerState.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
+ #if __has_include(<NitroModules/NitroHash.hpp>)
11
+ #include <NitroModules/NitroHash.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
16
+ #include <NitroModules/JSIConverter.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
21
+ #include <NitroModules/NitroDefines.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+
26
+ namespace margelo::nitro::munimbluetooth {
27
+
28
+ /**
29
+ * An enum which can be represented as a JavaScript union (MultipeerPeerState).
30
+ */
31
+ enum class MultipeerPeerState {
32
+ NOTCONNECTED SWIFT_NAME(notconnected) = 0,
33
+ CONNECTING SWIFT_NAME(connecting) = 1,
34
+ CONNECTED SWIFT_NAME(connected) = 2,
35
+ } CLOSED_ENUM;
36
+
37
+ } // namespace margelo::nitro::munimbluetooth
38
+
39
+ namespace margelo::nitro {
40
+
41
+ // C++ MultipeerPeerState <> JS MultipeerPeerState (union)
42
+ template <>
43
+ struct JSIConverter<margelo::nitro::munimbluetooth::MultipeerPeerState> final {
44
+ static inline margelo::nitro::munimbluetooth::MultipeerPeerState fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
45
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
46
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
47
+ case hashString("notConnected"): return margelo::nitro::munimbluetooth::MultipeerPeerState::NOTCONNECTED;
48
+ case hashString("connecting"): return margelo::nitro::munimbluetooth::MultipeerPeerState::CONNECTING;
49
+ case hashString("connected"): return margelo::nitro::munimbluetooth::MultipeerPeerState::CONNECTED;
50
+ default: [[unlikely]]
51
+ throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum MultipeerPeerState - invalid value!");
52
+ }
53
+ }
54
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::munimbluetooth::MultipeerPeerState arg) {
55
+ switch (arg) {
56
+ case margelo::nitro::munimbluetooth::MultipeerPeerState::NOTCONNECTED: return JSIConverter<std::string>::toJSI(runtime, "notConnected");
57
+ case margelo::nitro::munimbluetooth::MultipeerPeerState::CONNECTING: return JSIConverter<std::string>::toJSI(runtime, "connecting");
58
+ case margelo::nitro::munimbluetooth::MultipeerPeerState::CONNECTED: return JSIConverter<std::string>::toJSI(runtime, "connected");
59
+ default: [[unlikely]]
60
+ throw std::invalid_argument("Cannot convert MultipeerPeerState to JS - invalid value: "
61
+ + std::to_string(static_cast<int>(arg)) + "!");
62
+ }
63
+ }
64
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
65
+ if (!value.isString()) {
66
+ return false;
67
+ }
68
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
69
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
70
+ case hashString("notConnected"):
71
+ case hashString("connecting"):
72
+ case hashString("connected"):
73
+ return true;
74
+ default:
75
+ return false;
76
+ }
77
+ }
78
+ };
79
+
80
+ } // namespace margelo::nitro