munim-bluetooth 0.3.27 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -0
- package/LICENSE +201 -21
- package/README.md +480 -75
- package/android/gradle.properties +2 -2
- package/android/src/main/AndroidManifest.xml +3 -1
- package/android/src/main/cpp/cpp-adapter.cpp +4 -1
- package/android/src/main/java/com/munimbluetooth/HybridMunimBluetooth.kt +2006 -209
- package/android/src/main/java/com/munimbluetooth/MunimBluetoothBackgroundService.kt +561 -53
- package/app.plugin.js +155 -0
- package/ios/HybridMunimBluetooth.swift +2123 -298
- package/ios/MunimBluetoothEventEmitter.swift +68 -8
- package/lib/commonjs/index.js +272 -11
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +243 -11
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/index.d.ts +310 -7
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/munim-bluetooth.nitro.d.ts +219 -5
- package/lib/typescript/src/specs/munim-bluetooth.nitro.d.ts.map +1 -1
- package/nitro.json +9 -3
- package/nitrogen/generated/android/c++/JAdvertisingDataTypes.hpp +96 -96
- package/nitrogen/generated/android/c++/JAdvertisingOptions.hpp +8 -8
- package/nitrogen/generated/android/c++/JBackgroundSessionOptions.hpp +8 -8
- package/nitrogen/generated/android/c++/JBluetoothCapabilities.hpp +105 -0
- package/nitrogen/generated/android/c++/JBluetoothPhy.hpp +61 -0
- package/nitrogen/generated/android/c++/JBluetoothPhyOption.hpp +61 -0
- package/nitrogen/generated/android/c++/JBondState.hpp +64 -0
- package/nitrogen/generated/android/c++/JDescriptorValue.hpp +69 -0
- package/nitrogen/generated/android/c++/JExtendedAdvertisingOptions.hpp +131 -0
- package/nitrogen/generated/android/c++/JGATTCharacteristic.hpp +35 -11
- package/nitrogen/generated/android/c++/JGATTDescriptor.hpp +85 -0
- package/nitrogen/generated/android/c++/JGATTService.hpp +33 -9
- package/nitrogen/generated/android/c++/JHybridMunimBluetoothSpec.cpp +422 -12
- package/nitrogen/generated/android/c++/JHybridMunimBluetoothSpec.hpp +29 -0
- package/nitrogen/generated/android/c++/JL2CAPChannel.hpp +66 -0
- package/nitrogen/generated/android/c++/JMultipeerDiscoveryInfoEntry.hpp +61 -0
- package/nitrogen/generated/android/c++/JMultipeerEncryptionPreference.hpp +61 -0
- package/nitrogen/generated/android/c++/JMultipeerPeer.hpp +93 -0
- package/nitrogen/generated/android/c++/JMultipeerPeerState.hpp +61 -0
- package/nitrogen/generated/android/c++/JMultipeerSessionOptions.hpp +105 -0
- package/nitrogen/generated/android/c++/JPhyStatus.hpp +62 -0
- package/nitrogen/generated/android/c++/JScanOptions.hpp +8 -8
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/AdvertisingDataTypes.kt +47 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/AdvertisingOptions.kt +19 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/BackgroundSessionOptions.kt +27 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/BluetoothCapabilities.kt +111 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/BluetoothPhy.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/BluetoothPhyOption.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/BondState.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/CharacteristicValue.kt +17 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/DescriptorValue.kt +66 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/ExtendedAdvertisingOptions.kt +111 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/GATTCharacteristic.kt +25 -3
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/GATTDescriptor.kt +61 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/GATTService.kt +23 -3
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/HybridMunimBluetoothSpec.kt +138 -22
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/L2CAPChannel.kt +61 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/MultipeerDiscoveryInfoEntry.kt +56 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/MultipeerEncryptionPreference.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/MultipeerPeer.kt +66 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/MultipeerPeerState.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/MultipeerSessionOptions.kt +81 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/PhyStatus.kt +56 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/ScanOptions.kt +17 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/ServiceDataEntry.kt +15 -0
- package/nitrogen/generated/ios/MunimBluetooth+autolinking.rb +2 -0
- package/nitrogen/generated/ios/MunimBluetooth-Swift-Cxx-Bridge.cpp +61 -5
- package/nitrogen/generated/ios/MunimBluetooth-Swift-Cxx-Bridge.hpp +494 -49
- package/nitrogen/generated/ios/MunimBluetooth-Swift-Cxx-Umbrella.hpp +42 -0
- package/nitrogen/generated/ios/c++/HybridMunimBluetoothSpecSwift.hpp +254 -0
- package/nitrogen/generated/ios/swift/BluetoothCapabilities.swift +89 -0
- package/nitrogen/generated/ios/swift/BluetoothPhy.swift +44 -0
- package/nitrogen/generated/ios/swift/BluetoothPhyOption.swift +44 -0
- package/nitrogen/generated/ios/swift/BondState.swift +48 -0
- package/nitrogen/generated/ios/swift/DescriptorValue.swift +44 -0
- package/nitrogen/generated/ios/swift/ExtendedAdvertisingOptions.swift +243 -0
- package/nitrogen/generated/ios/swift/Func_void_BluetoothCapabilities.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_BondState.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_DescriptorValue.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_L2CAPChannel.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_PhyStatus.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__string.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_MultipeerPeer_.swift +46 -0
- package/nitrogen/generated/ios/swift/GATTCharacteristic.swift +25 -1
- package/nitrogen/generated/ios/swift/GATTDescriptor.swift +71 -0
- package/nitrogen/generated/ios/swift/GATTService.swift +25 -1
- package/nitrogen/generated/ios/swift/HybridMunimBluetoothSpec.swift +29 -0
- package/nitrogen/generated/ios/swift/HybridMunimBluetoothSpec_cxx.swift +556 -23
- package/nitrogen/generated/ios/swift/L2CAPChannel.swift +52 -0
- package/nitrogen/generated/ios/swift/MultipeerDiscoveryInfoEntry.swift +34 -0
- package/nitrogen/generated/ios/swift/MultipeerEncryptionPreference.swift +44 -0
- package/nitrogen/generated/ios/swift/MultipeerPeer.swift +63 -0
- package/nitrogen/generated/ios/swift/MultipeerPeerState.swift +44 -0
- package/nitrogen/generated/ios/swift/MultipeerSessionOptions.swift +136 -0
- package/nitrogen/generated/ios/swift/PhyStatus.swift +34 -0
- package/nitrogen/generated/shared/c++/BluetoothCapabilities.hpp +131 -0
- package/nitrogen/generated/shared/c++/BluetoothPhy.hpp +80 -0
- package/nitrogen/generated/shared/c++/BluetoothPhyOption.hpp +80 -0
- package/nitrogen/generated/shared/c++/BondState.hpp +84 -0
- package/nitrogen/generated/shared/c++/DescriptorValue.hpp +95 -0
- package/nitrogen/generated/shared/c++/ExtendedAdvertisingOptions.hpp +138 -0
- package/nitrogen/generated/shared/c++/GATTCharacteristic.hpp +9 -3
- package/nitrogen/generated/shared/c++/GATTDescriptor.hpp +93 -0
- package/nitrogen/generated/shared/c++/GATTService.hpp +7 -2
- package/nitrogen/generated/shared/c++/HybridMunimBluetoothSpec.cpp +29 -0
- package/nitrogen/generated/shared/c++/HybridMunimBluetoothSpec.hpp +61 -2
- package/nitrogen/generated/shared/c++/L2CAPChannel.hpp +92 -0
- package/nitrogen/generated/shared/c++/MultipeerDiscoveryInfoEntry.hpp +87 -0
- package/nitrogen/generated/shared/c++/MultipeerEncryptionPreference.hpp +80 -0
- package/nitrogen/generated/shared/c++/MultipeerPeer.hpp +102 -0
- package/nitrogen/generated/shared/c++/MultipeerPeerState.hpp +80 -0
- package/nitrogen/generated/shared/c++/MultipeerSessionOptions.hpp +114 -0
- package/nitrogen/generated/shared/c++/PhyStatus.hpp +88 -0
- package/package.json +23 -12
- package/src/index.ts +416 -31
- package/src/specs/munim-bluetooth.nitro.ts +298 -14
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// BluetoothPhyOption.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 (BluetoothPhyOption).
|
|
30
|
+
*/
|
|
31
|
+
enum class BluetoothPhyOption {
|
|
32
|
+
NONE SWIFT_NAME(none) = 0,
|
|
33
|
+
S2 SWIFT_NAME(s2) = 1,
|
|
34
|
+
S8 SWIFT_NAME(s8) = 2,
|
|
35
|
+
} CLOSED_ENUM;
|
|
36
|
+
|
|
37
|
+
} // namespace margelo::nitro::munimbluetooth
|
|
38
|
+
|
|
39
|
+
namespace margelo::nitro {
|
|
40
|
+
|
|
41
|
+
// C++ BluetoothPhyOption <> JS BluetoothPhyOption (union)
|
|
42
|
+
template <>
|
|
43
|
+
struct JSIConverter<margelo::nitro::munimbluetooth::BluetoothPhyOption> final {
|
|
44
|
+
static inline margelo::nitro::munimbluetooth::BluetoothPhyOption 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::BluetoothPhyOption::NONE;
|
|
48
|
+
case hashString("s2"): return margelo::nitro::munimbluetooth::BluetoothPhyOption::S2;
|
|
49
|
+
case hashString("s8"): return margelo::nitro::munimbluetooth::BluetoothPhyOption::S8;
|
|
50
|
+
default: [[unlikely]]
|
|
51
|
+
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum BluetoothPhyOption - invalid value!");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::munimbluetooth::BluetoothPhyOption arg) {
|
|
55
|
+
switch (arg) {
|
|
56
|
+
case margelo::nitro::munimbluetooth::BluetoothPhyOption::NONE: return JSIConverter<std::string>::toJSI(runtime, "none");
|
|
57
|
+
case margelo::nitro::munimbluetooth::BluetoothPhyOption::S2: return JSIConverter<std::string>::toJSI(runtime, "s2");
|
|
58
|
+
case margelo::nitro::munimbluetooth::BluetoothPhyOption::S8: return JSIConverter<std::string>::toJSI(runtime, "s8");
|
|
59
|
+
default: [[unlikely]]
|
|
60
|
+
throw std::invalid_argument("Cannot convert BluetoothPhyOption 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("s2"):
|
|
72
|
+
case hashString("s8"):
|
|
73
|
+
return true;
|
|
74
|
+
default:
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// BondState.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 (BondState).
|
|
30
|
+
*/
|
|
31
|
+
enum class BondState {
|
|
32
|
+
NONE SWIFT_NAME(none) = 0,
|
|
33
|
+
BONDING SWIFT_NAME(bonding) = 1,
|
|
34
|
+
BONDED SWIFT_NAME(bonded) = 2,
|
|
35
|
+
UNSUPPORTED SWIFT_NAME(unsupported) = 3,
|
|
36
|
+
} CLOSED_ENUM;
|
|
37
|
+
|
|
38
|
+
} // namespace margelo::nitro::munimbluetooth
|
|
39
|
+
|
|
40
|
+
namespace margelo::nitro {
|
|
41
|
+
|
|
42
|
+
// C++ BondState <> JS BondState (union)
|
|
43
|
+
template <>
|
|
44
|
+
struct JSIConverter<margelo::nitro::munimbluetooth::BondState> final {
|
|
45
|
+
static inline margelo::nitro::munimbluetooth::BondState fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
46
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
|
|
47
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
48
|
+
case hashString("none"): return margelo::nitro::munimbluetooth::BondState::NONE;
|
|
49
|
+
case hashString("bonding"): return margelo::nitro::munimbluetooth::BondState::BONDING;
|
|
50
|
+
case hashString("bonded"): return margelo::nitro::munimbluetooth::BondState::BONDED;
|
|
51
|
+
case hashString("unsupported"): return margelo::nitro::munimbluetooth::BondState::UNSUPPORTED;
|
|
52
|
+
default: [[unlikely]]
|
|
53
|
+
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum BondState - invalid value!");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::munimbluetooth::BondState arg) {
|
|
57
|
+
switch (arg) {
|
|
58
|
+
case margelo::nitro::munimbluetooth::BondState::NONE: return JSIConverter<std::string>::toJSI(runtime, "none");
|
|
59
|
+
case margelo::nitro::munimbluetooth::BondState::BONDING: return JSIConverter<std::string>::toJSI(runtime, "bonding");
|
|
60
|
+
case margelo::nitro::munimbluetooth::BondState::BONDED: return JSIConverter<std::string>::toJSI(runtime, "bonded");
|
|
61
|
+
case margelo::nitro::munimbluetooth::BondState::UNSUPPORTED: return JSIConverter<std::string>::toJSI(runtime, "unsupported");
|
|
62
|
+
default: [[unlikely]]
|
|
63
|
+
throw std::invalid_argument("Cannot convert BondState to JS - invalid value: "
|
|
64
|
+
+ std::to_string(static_cast<int>(arg)) + "!");
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
68
|
+
if (!value.isString()) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
|
|
72
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
73
|
+
case hashString("none"):
|
|
74
|
+
case hashString("bonding"):
|
|
75
|
+
case hashString("bonded"):
|
|
76
|
+
case hashString("unsupported"):
|
|
77
|
+
return true;
|
|
78
|
+
default:
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// DescriptorValue.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 (DescriptorValue).
|
|
39
|
+
*/
|
|
40
|
+
struct DescriptorValue final {
|
|
41
|
+
public:
|
|
42
|
+
std::string value SWIFT_PRIVATE;
|
|
43
|
+
std::string serviceUUID SWIFT_PRIVATE;
|
|
44
|
+
std::string characteristicUUID SWIFT_PRIVATE;
|
|
45
|
+
std::string descriptorUUID SWIFT_PRIVATE;
|
|
46
|
+
|
|
47
|
+
public:
|
|
48
|
+
DescriptorValue() = default;
|
|
49
|
+
explicit DescriptorValue(std::string value, std::string serviceUUID, std::string characteristicUUID, std::string descriptorUUID): value(value), serviceUUID(serviceUUID), characteristicUUID(characteristicUUID), descriptorUUID(descriptorUUID) {}
|
|
50
|
+
|
|
51
|
+
public:
|
|
52
|
+
friend bool operator==(const DescriptorValue& lhs, const DescriptorValue& rhs) = default;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
} // namespace margelo::nitro::munimbluetooth
|
|
56
|
+
|
|
57
|
+
namespace margelo::nitro {
|
|
58
|
+
|
|
59
|
+
// C++ DescriptorValue <> JS DescriptorValue (object)
|
|
60
|
+
template <>
|
|
61
|
+
struct JSIConverter<margelo::nitro::munimbluetooth::DescriptorValue> final {
|
|
62
|
+
static inline margelo::nitro::munimbluetooth::DescriptorValue fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
63
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
64
|
+
return margelo::nitro::munimbluetooth::DescriptorValue(
|
|
65
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "value"))),
|
|
66
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "serviceUUID"))),
|
|
67
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "characteristicUUID"))),
|
|
68
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "descriptorUUID")))
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::munimbluetooth::DescriptorValue& arg) {
|
|
72
|
+
jsi::Object obj(runtime);
|
|
73
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "value"), JSIConverter<std::string>::toJSI(runtime, arg.value));
|
|
74
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "serviceUUID"), JSIConverter<std::string>::toJSI(runtime, arg.serviceUUID));
|
|
75
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "characteristicUUID"), JSIConverter<std::string>::toJSI(runtime, arg.characteristicUUID));
|
|
76
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "descriptorUUID"), JSIConverter<std::string>::toJSI(runtime, arg.descriptorUUID));
|
|
77
|
+
return obj;
|
|
78
|
+
}
|
|
79
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
80
|
+
if (!value.isObject()) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
jsi::Object obj = value.getObject(runtime);
|
|
84
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "value")))) return false;
|
|
88
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "serviceUUID")))) return false;
|
|
89
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "characteristicUUID")))) return false;
|
|
90
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "descriptorUUID")))) return false;
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ExtendedAdvertisingOptions.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 `AdvertisingDataTypes` to properly resolve imports.
|
|
32
|
+
namespace margelo::nitro::munimbluetooth { struct AdvertisingDataTypes; }
|
|
33
|
+
// Forward declaration of `BluetoothPhy` to properly resolve imports.
|
|
34
|
+
namespace margelo::nitro::munimbluetooth { enum class BluetoothPhy; }
|
|
35
|
+
|
|
36
|
+
#include <string>
|
|
37
|
+
#include <vector>
|
|
38
|
+
#include <optional>
|
|
39
|
+
#include "AdvertisingDataTypes.hpp"
|
|
40
|
+
#include "BluetoothPhy.hpp"
|
|
41
|
+
|
|
42
|
+
namespace margelo::nitro::munimbluetooth {
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* A struct which can be represented as a JavaScript object (ExtendedAdvertisingOptions).
|
|
46
|
+
*/
|
|
47
|
+
struct ExtendedAdvertisingOptions final {
|
|
48
|
+
public:
|
|
49
|
+
std::optional<std::vector<std::string>> serviceUUIDs SWIFT_PRIVATE;
|
|
50
|
+
std::optional<std::string> localName SWIFT_PRIVATE;
|
|
51
|
+
std::optional<std::string> manufacturerData SWIFT_PRIVATE;
|
|
52
|
+
std::optional<AdvertisingDataTypes> advertisingData SWIFT_PRIVATE;
|
|
53
|
+
std::optional<bool> connectable SWIFT_PRIVATE;
|
|
54
|
+
std::optional<bool> scannable SWIFT_PRIVATE;
|
|
55
|
+
std::optional<bool> legacyMode SWIFT_PRIVATE;
|
|
56
|
+
std::optional<bool> anonymous SWIFT_PRIVATE;
|
|
57
|
+
std::optional<bool> includeTxPower SWIFT_PRIVATE;
|
|
58
|
+
std::optional<double> interval SWIFT_PRIVATE;
|
|
59
|
+
std::optional<double> txPowerLevel SWIFT_PRIVATE;
|
|
60
|
+
std::optional<BluetoothPhy> primaryPhy SWIFT_PRIVATE;
|
|
61
|
+
std::optional<BluetoothPhy> secondaryPhy SWIFT_PRIVATE;
|
|
62
|
+
|
|
63
|
+
public:
|
|
64
|
+
ExtendedAdvertisingOptions() = default;
|
|
65
|
+
explicit ExtendedAdvertisingOptions(std::optional<std::vector<std::string>> serviceUUIDs, std::optional<std::string> localName, std::optional<std::string> manufacturerData, std::optional<AdvertisingDataTypes> advertisingData, std::optional<bool> connectable, std::optional<bool> scannable, std::optional<bool> legacyMode, std::optional<bool> anonymous, std::optional<bool> includeTxPower, std::optional<double> interval, std::optional<double> txPowerLevel, std::optional<BluetoothPhy> primaryPhy, std::optional<BluetoothPhy> secondaryPhy): serviceUUIDs(serviceUUIDs), localName(localName), manufacturerData(manufacturerData), advertisingData(advertisingData), connectable(connectable), scannable(scannable), legacyMode(legacyMode), anonymous(anonymous), includeTxPower(includeTxPower), interval(interval), txPowerLevel(txPowerLevel), primaryPhy(primaryPhy), secondaryPhy(secondaryPhy) {}
|
|
66
|
+
|
|
67
|
+
public:
|
|
68
|
+
friend bool operator==(const ExtendedAdvertisingOptions& lhs, const ExtendedAdvertisingOptions& rhs) = default;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
} // namespace margelo::nitro::munimbluetooth
|
|
72
|
+
|
|
73
|
+
namespace margelo::nitro {
|
|
74
|
+
|
|
75
|
+
// C++ ExtendedAdvertisingOptions <> JS ExtendedAdvertisingOptions (object)
|
|
76
|
+
template <>
|
|
77
|
+
struct JSIConverter<margelo::nitro::munimbluetooth::ExtendedAdvertisingOptions> final {
|
|
78
|
+
static inline margelo::nitro::munimbluetooth::ExtendedAdvertisingOptions fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
79
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
80
|
+
return margelo::nitro::munimbluetooth::ExtendedAdvertisingOptions(
|
|
81
|
+
JSIConverter<std::optional<std::vector<std::string>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "serviceUUIDs"))),
|
|
82
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "localName"))),
|
|
83
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "manufacturerData"))),
|
|
84
|
+
JSIConverter<std::optional<margelo::nitro::munimbluetooth::AdvertisingDataTypes>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "advertisingData"))),
|
|
85
|
+
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "connectable"))),
|
|
86
|
+
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "scannable"))),
|
|
87
|
+
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "legacyMode"))),
|
|
88
|
+
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "anonymous"))),
|
|
89
|
+
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "includeTxPower"))),
|
|
90
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "interval"))),
|
|
91
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "txPowerLevel"))),
|
|
92
|
+
JSIConverter<std::optional<margelo::nitro::munimbluetooth::BluetoothPhy>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "primaryPhy"))),
|
|
93
|
+
JSIConverter<std::optional<margelo::nitro::munimbluetooth::BluetoothPhy>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "secondaryPhy")))
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::munimbluetooth::ExtendedAdvertisingOptions& arg) {
|
|
97
|
+
jsi::Object obj(runtime);
|
|
98
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "serviceUUIDs"), JSIConverter<std::optional<std::vector<std::string>>>::toJSI(runtime, arg.serviceUUIDs));
|
|
99
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "localName"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.localName));
|
|
100
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "manufacturerData"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.manufacturerData));
|
|
101
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "advertisingData"), JSIConverter<std::optional<margelo::nitro::munimbluetooth::AdvertisingDataTypes>>::toJSI(runtime, arg.advertisingData));
|
|
102
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "connectable"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.connectable));
|
|
103
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "scannable"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.scannable));
|
|
104
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "legacyMode"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.legacyMode));
|
|
105
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "anonymous"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.anonymous));
|
|
106
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "includeTxPower"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.includeTxPower));
|
|
107
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "interval"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.interval));
|
|
108
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "txPowerLevel"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.txPowerLevel));
|
|
109
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "primaryPhy"), JSIConverter<std::optional<margelo::nitro::munimbluetooth::BluetoothPhy>>::toJSI(runtime, arg.primaryPhy));
|
|
110
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "secondaryPhy"), JSIConverter<std::optional<margelo::nitro::munimbluetooth::BluetoothPhy>>::toJSI(runtime, arg.secondaryPhy));
|
|
111
|
+
return obj;
|
|
112
|
+
}
|
|
113
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
114
|
+
if (!value.isObject()) {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
jsi::Object obj = value.getObject(runtime);
|
|
118
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
if (!JSIConverter<std::optional<std::vector<std::string>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "serviceUUIDs")))) return false;
|
|
122
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "localName")))) return false;
|
|
123
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "manufacturerData")))) return false;
|
|
124
|
+
if (!JSIConverter<std::optional<margelo::nitro::munimbluetooth::AdvertisingDataTypes>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "advertisingData")))) return false;
|
|
125
|
+
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "connectable")))) return false;
|
|
126
|
+
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "scannable")))) return false;
|
|
127
|
+
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "legacyMode")))) return false;
|
|
128
|
+
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "anonymous")))) return false;
|
|
129
|
+
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "includeTxPower")))) return false;
|
|
130
|
+
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "interval")))) return false;
|
|
131
|
+
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "txPowerLevel")))) return false;
|
|
132
|
+
if (!JSIConverter<std::optional<margelo::nitro::munimbluetooth::BluetoothPhy>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "primaryPhy")))) return false;
|
|
133
|
+
if (!JSIConverter<std::optional<margelo::nitro::munimbluetooth::BluetoothPhy>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "secondaryPhy")))) return false;
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
} // namespace margelo::nitro
|
|
@@ -28,11 +28,13 @@
|
|
|
28
28
|
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
29
29
|
#endif
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
// Forward declaration of `GATTDescriptor` to properly resolve imports.
|
|
32
|
+
namespace margelo::nitro::munimbluetooth { struct GATTDescriptor; }
|
|
32
33
|
|
|
33
34
|
#include <string>
|
|
34
35
|
#include <vector>
|
|
35
36
|
#include <optional>
|
|
37
|
+
#include "GATTDescriptor.hpp"
|
|
36
38
|
|
|
37
39
|
namespace margelo::nitro::munimbluetooth {
|
|
38
40
|
|
|
@@ -44,10 +46,11 @@ namespace margelo::nitro::munimbluetooth {
|
|
|
44
46
|
std::string uuid SWIFT_PRIVATE;
|
|
45
47
|
std::vector<std::string> properties SWIFT_PRIVATE;
|
|
46
48
|
std::optional<std::string> value SWIFT_PRIVATE;
|
|
49
|
+
std::optional<std::vector<GATTDescriptor>> descriptors SWIFT_PRIVATE;
|
|
47
50
|
|
|
48
51
|
public:
|
|
49
52
|
GATTCharacteristic() = default;
|
|
50
|
-
explicit GATTCharacteristic(std::string uuid, std::vector<std::string> properties, std::optional<std::string> value): uuid(uuid), properties(properties), value(value) {}
|
|
53
|
+
explicit GATTCharacteristic(std::string uuid, std::vector<std::string> properties, std::optional<std::string> value, std::optional<std::vector<GATTDescriptor>> descriptors): uuid(uuid), properties(properties), value(value), descriptors(descriptors) {}
|
|
51
54
|
|
|
52
55
|
public:
|
|
53
56
|
friend bool operator==(const GATTCharacteristic& lhs, const GATTCharacteristic& rhs) = default;
|
|
@@ -65,7 +68,8 @@ namespace margelo::nitro {
|
|
|
65
68
|
return margelo::nitro::munimbluetooth::GATTCharacteristic(
|
|
66
69
|
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "uuid"))),
|
|
67
70
|
JSIConverter<std::vector<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "properties"))),
|
|
68
|
-
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "value")))
|
|
71
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "value"))),
|
|
72
|
+
JSIConverter<std::optional<std::vector<margelo::nitro::munimbluetooth::GATTDescriptor>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "descriptors")))
|
|
69
73
|
);
|
|
70
74
|
}
|
|
71
75
|
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::munimbluetooth::GATTCharacteristic& arg) {
|
|
@@ -73,6 +77,7 @@ namespace margelo::nitro {
|
|
|
73
77
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "uuid"), JSIConverter<std::string>::toJSI(runtime, arg.uuid));
|
|
74
78
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "properties"), JSIConverter<std::vector<std::string>>::toJSI(runtime, arg.properties));
|
|
75
79
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "value"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.value));
|
|
80
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "descriptors"), JSIConverter<std::optional<std::vector<margelo::nitro::munimbluetooth::GATTDescriptor>>>::toJSI(runtime, arg.descriptors));
|
|
76
81
|
return obj;
|
|
77
82
|
}
|
|
78
83
|
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
@@ -86,6 +91,7 @@ namespace margelo::nitro {
|
|
|
86
91
|
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "uuid")))) return false;
|
|
87
92
|
if (!JSIConverter<std::vector<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "properties")))) return false;
|
|
88
93
|
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "value")))) return false;
|
|
94
|
+
if (!JSIConverter<std::optional<std::vector<margelo::nitro::munimbluetooth::GATTDescriptor>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "descriptors")))) return false;
|
|
89
95
|
return true;
|
|
90
96
|
}
|
|
91
97
|
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// GATTDescriptor.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
|
+
#include <vector>
|
|
36
|
+
|
|
37
|
+
namespace margelo::nitro::munimbluetooth {
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* A struct which can be represented as a JavaScript object (GATTDescriptor).
|
|
41
|
+
*/
|
|
42
|
+
struct GATTDescriptor final {
|
|
43
|
+
public:
|
|
44
|
+
std::string uuid SWIFT_PRIVATE;
|
|
45
|
+
std::optional<std::string> value SWIFT_PRIVATE;
|
|
46
|
+
std::optional<std::vector<std::string>> permissions SWIFT_PRIVATE;
|
|
47
|
+
|
|
48
|
+
public:
|
|
49
|
+
GATTDescriptor() = default;
|
|
50
|
+
explicit GATTDescriptor(std::string uuid, std::optional<std::string> value, std::optional<std::vector<std::string>> permissions): uuid(uuid), value(value), permissions(permissions) {}
|
|
51
|
+
|
|
52
|
+
public:
|
|
53
|
+
friend bool operator==(const GATTDescriptor& lhs, const GATTDescriptor& rhs) = default;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
} // namespace margelo::nitro::munimbluetooth
|
|
57
|
+
|
|
58
|
+
namespace margelo::nitro {
|
|
59
|
+
|
|
60
|
+
// C++ GATTDescriptor <> JS GATTDescriptor (object)
|
|
61
|
+
template <>
|
|
62
|
+
struct JSIConverter<margelo::nitro::munimbluetooth::GATTDescriptor> final {
|
|
63
|
+
static inline margelo::nitro::munimbluetooth::GATTDescriptor fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
64
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
65
|
+
return margelo::nitro::munimbluetooth::GATTDescriptor(
|
|
66
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "uuid"))),
|
|
67
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "value"))),
|
|
68
|
+
JSIConverter<std::optional<std::vector<std::string>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "permissions")))
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::munimbluetooth::GATTDescriptor& arg) {
|
|
72
|
+
jsi::Object obj(runtime);
|
|
73
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "uuid"), JSIConverter<std::string>::toJSI(runtime, arg.uuid));
|
|
74
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "value"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.value));
|
|
75
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "permissions"), JSIConverter<std::optional<std::vector<std::string>>>::toJSI(runtime, arg.permissions));
|
|
76
|
+
return obj;
|
|
77
|
+
}
|
|
78
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
79
|
+
if (!value.isObject()) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
jsi::Object obj = value.getObject(runtime);
|
|
83
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "uuid")))) return false;
|
|
87
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "value")))) return false;
|
|
88
|
+
if (!JSIConverter<std::optional<std::vector<std::string>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "permissions")))) return false;
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
} // namespace margelo::nitro
|
|
@@ -34,6 +34,7 @@ namespace margelo::nitro::munimbluetooth { struct GATTCharacteristic; }
|
|
|
34
34
|
#include <string>
|
|
35
35
|
#include "GATTCharacteristic.hpp"
|
|
36
36
|
#include <vector>
|
|
37
|
+
#include <optional>
|
|
37
38
|
|
|
38
39
|
namespace margelo::nitro::munimbluetooth {
|
|
39
40
|
|
|
@@ -44,10 +45,11 @@ namespace margelo::nitro::munimbluetooth {
|
|
|
44
45
|
public:
|
|
45
46
|
std::string uuid SWIFT_PRIVATE;
|
|
46
47
|
std::vector<GATTCharacteristic> characteristics SWIFT_PRIVATE;
|
|
48
|
+
std::optional<std::vector<std::string>> includedServices SWIFT_PRIVATE;
|
|
47
49
|
|
|
48
50
|
public:
|
|
49
51
|
GATTService() = default;
|
|
50
|
-
explicit GATTService(std::string uuid, std::vector<GATTCharacteristic> characteristics): uuid(uuid), characteristics(characteristics) {}
|
|
52
|
+
explicit GATTService(std::string uuid, std::vector<GATTCharacteristic> characteristics, std::optional<std::vector<std::string>> includedServices): uuid(uuid), characteristics(characteristics), includedServices(includedServices) {}
|
|
51
53
|
|
|
52
54
|
public:
|
|
53
55
|
friend bool operator==(const GATTService& lhs, const GATTService& rhs) = default;
|
|
@@ -64,13 +66,15 @@ namespace margelo::nitro {
|
|
|
64
66
|
jsi::Object obj = arg.asObject(runtime);
|
|
65
67
|
return margelo::nitro::munimbluetooth::GATTService(
|
|
66
68
|
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "uuid"))),
|
|
67
|
-
JSIConverter<std::vector<margelo::nitro::munimbluetooth::GATTCharacteristic>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "characteristics")))
|
|
69
|
+
JSIConverter<std::vector<margelo::nitro::munimbluetooth::GATTCharacteristic>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "characteristics"))),
|
|
70
|
+
JSIConverter<std::optional<std::vector<std::string>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "includedServices")))
|
|
68
71
|
);
|
|
69
72
|
}
|
|
70
73
|
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::munimbluetooth::GATTService& arg) {
|
|
71
74
|
jsi::Object obj(runtime);
|
|
72
75
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "uuid"), JSIConverter<std::string>::toJSI(runtime, arg.uuid));
|
|
73
76
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "characteristics"), JSIConverter<std::vector<margelo::nitro::munimbluetooth::GATTCharacteristic>>::toJSI(runtime, arg.characteristics));
|
|
77
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "includedServices"), JSIConverter<std::optional<std::vector<std::string>>>::toJSI(runtime, arg.includedServices));
|
|
74
78
|
return obj;
|
|
75
79
|
}
|
|
76
80
|
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
@@ -83,6 +87,7 @@ namespace margelo::nitro {
|
|
|
83
87
|
}
|
|
84
88
|
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "uuid")))) return false;
|
|
85
89
|
if (!JSIConverter<std::vector<margelo::nitro::munimbluetooth::GATTCharacteristic>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "characteristics")))) return false;
|
|
90
|
+
if (!JSIConverter<std::optional<std::vector<std::string>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "includedServices")))) return false;
|
|
86
91
|
return true;
|
|
87
92
|
}
|
|
88
93
|
};
|
|
@@ -19,21 +19,50 @@ namespace margelo::nitro::munimbluetooth {
|
|
|
19
19
|
prototype.registerHybridMethod("getAdvertisingData", &HybridMunimBluetoothSpec::getAdvertisingData);
|
|
20
20
|
prototype.registerHybridMethod("stopAdvertising", &HybridMunimBluetoothSpec::stopAdvertising);
|
|
21
21
|
prototype.registerHybridMethod("setServices", &HybridMunimBluetoothSpec::setServices);
|
|
22
|
+
prototype.registerHybridMethod("updateCharacteristicValue", &HybridMunimBluetoothSpec::updateCharacteristicValue);
|
|
22
23
|
prototype.registerHybridMethod("isBluetoothEnabled", &HybridMunimBluetoothSpec::isBluetoothEnabled);
|
|
23
24
|
prototype.registerHybridMethod("requestBluetoothPermission", &HybridMunimBluetoothSpec::requestBluetoothPermission);
|
|
25
|
+
prototype.registerHybridMethod("getCapabilities", &HybridMunimBluetoothSpec::getCapabilities);
|
|
24
26
|
prototype.registerHybridMethod("startScan", &HybridMunimBluetoothSpec::startScan);
|
|
25
27
|
prototype.registerHybridMethod("stopScan", &HybridMunimBluetoothSpec::stopScan);
|
|
26
28
|
prototype.registerHybridMethod("connect", &HybridMunimBluetoothSpec::connect);
|
|
27
29
|
prototype.registerHybridMethod("disconnect", &HybridMunimBluetoothSpec::disconnect);
|
|
28
30
|
prototype.registerHybridMethod("discoverServices", &HybridMunimBluetoothSpec::discoverServices);
|
|
29
31
|
prototype.registerHybridMethod("readCharacteristic", &HybridMunimBluetoothSpec::readCharacteristic);
|
|
32
|
+
prototype.registerHybridMethod("readDescriptor", &HybridMunimBluetoothSpec::readDescriptor);
|
|
30
33
|
prototype.registerHybridMethod("writeCharacteristic", &HybridMunimBluetoothSpec::writeCharacteristic);
|
|
34
|
+
prototype.registerHybridMethod("writeDescriptor", &HybridMunimBluetoothSpec::writeDescriptor);
|
|
31
35
|
prototype.registerHybridMethod("subscribeToCharacteristic", &HybridMunimBluetoothSpec::subscribeToCharacteristic);
|
|
32
36
|
prototype.registerHybridMethod("unsubscribeFromCharacteristic", &HybridMunimBluetoothSpec::unsubscribeFromCharacteristic);
|
|
33
37
|
prototype.registerHybridMethod("getConnectedDevices", &HybridMunimBluetoothSpec::getConnectedDevices);
|
|
34
38
|
prototype.registerHybridMethod("readRSSI", &HybridMunimBluetoothSpec::readRSSI);
|
|
39
|
+
prototype.registerHybridMethod("requestMTU", &HybridMunimBluetoothSpec::requestMTU);
|
|
40
|
+
prototype.registerHybridMethod("setPreferredPhy", &HybridMunimBluetoothSpec::setPreferredPhy);
|
|
41
|
+
prototype.registerHybridMethod("readPhy", &HybridMunimBluetoothSpec::readPhy);
|
|
42
|
+
prototype.registerHybridMethod("getBondState", &HybridMunimBluetoothSpec::getBondState);
|
|
43
|
+
prototype.registerHybridMethod("createBond", &HybridMunimBluetoothSpec::createBond);
|
|
44
|
+
prototype.registerHybridMethod("removeBond", &HybridMunimBluetoothSpec::removeBond);
|
|
45
|
+
prototype.registerHybridMethod("startExtendedAdvertising", &HybridMunimBluetoothSpec::startExtendedAdvertising);
|
|
46
|
+
prototype.registerHybridMethod("stopExtendedAdvertising", &HybridMunimBluetoothSpec::stopExtendedAdvertising);
|
|
47
|
+
prototype.registerHybridMethod("publishL2CAPChannel", &HybridMunimBluetoothSpec::publishL2CAPChannel);
|
|
48
|
+
prototype.registerHybridMethod("unpublishL2CAPChannel", &HybridMunimBluetoothSpec::unpublishL2CAPChannel);
|
|
49
|
+
prototype.registerHybridMethod("openL2CAPChannel", &HybridMunimBluetoothSpec::openL2CAPChannel);
|
|
50
|
+
prototype.registerHybridMethod("closeL2CAPChannel", &HybridMunimBluetoothSpec::closeL2CAPChannel);
|
|
51
|
+
prototype.registerHybridMethod("sendL2CAPData", &HybridMunimBluetoothSpec::sendL2CAPData);
|
|
52
|
+
prototype.registerHybridMethod("startClassicScan", &HybridMunimBluetoothSpec::startClassicScan);
|
|
53
|
+
prototype.registerHybridMethod("stopClassicScan", &HybridMunimBluetoothSpec::stopClassicScan);
|
|
54
|
+
prototype.registerHybridMethod("connectClassic", &HybridMunimBluetoothSpec::connectClassic);
|
|
55
|
+
prototype.registerHybridMethod("startClassicServer", &HybridMunimBluetoothSpec::startClassicServer);
|
|
56
|
+
prototype.registerHybridMethod("stopClassicServer", &HybridMunimBluetoothSpec::stopClassicServer);
|
|
57
|
+
prototype.registerHybridMethod("disconnectClassic", &HybridMunimBluetoothSpec::disconnectClassic);
|
|
58
|
+
prototype.registerHybridMethod("writeClassic", &HybridMunimBluetoothSpec::writeClassic);
|
|
35
59
|
prototype.registerHybridMethod("startBackgroundSession", &HybridMunimBluetoothSpec::startBackgroundSession);
|
|
36
60
|
prototype.registerHybridMethod("stopBackgroundSession", &HybridMunimBluetoothSpec::stopBackgroundSession);
|
|
61
|
+
prototype.registerHybridMethod("startMultipeerSession", &HybridMunimBluetoothSpec::startMultipeerSession);
|
|
62
|
+
prototype.registerHybridMethod("stopMultipeerSession", &HybridMunimBluetoothSpec::stopMultipeerSession);
|
|
63
|
+
prototype.registerHybridMethod("inviteMultipeerPeer", &HybridMunimBluetoothSpec::inviteMultipeerPeer);
|
|
64
|
+
prototype.registerHybridMethod("getMultipeerPeers", &HybridMunimBluetoothSpec::getMultipeerPeers);
|
|
65
|
+
prototype.registerHybridMethod("sendMultipeerMessage", &HybridMunimBluetoothSpec::sendMultipeerMessage);
|
|
37
66
|
prototype.registerHybridMethod("addListener", &HybridMunimBluetoothSpec::addListener);
|
|
38
67
|
prototype.registerHybridMethod("removeListeners", &HybridMunimBluetoothSpec::removeListeners);
|
|
39
68
|
});
|