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,52 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// L2CAPChannel.swift
|
|
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
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Represents an instance of `L2CAPChannel`, backed by a C++ struct.
|
|
12
|
+
*/
|
|
13
|
+
public typealias L2CAPChannel = margelo.nitro.munimbluetooth.L2CAPChannel
|
|
14
|
+
|
|
15
|
+
public extension L2CAPChannel {
|
|
16
|
+
private typealias bridge = margelo.nitro.munimbluetooth.bridge.swift
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create a new instance of `L2CAPChannel`.
|
|
20
|
+
*/
|
|
21
|
+
init(id: String, psm: Double, deviceId: String?) {
|
|
22
|
+
self.init(std.string(id), psm, { () -> bridge.std__optional_std__string_ in
|
|
23
|
+
if let __unwrappedValue = deviceId {
|
|
24
|
+
return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
|
|
25
|
+
} else {
|
|
26
|
+
return .init()
|
|
27
|
+
}
|
|
28
|
+
}())
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@inline(__always)
|
|
32
|
+
var id: String {
|
|
33
|
+
return String(self.__id)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@inline(__always)
|
|
37
|
+
var psm: Double {
|
|
38
|
+
return self.__psm
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@inline(__always)
|
|
42
|
+
var deviceId: String? {
|
|
43
|
+
return { () -> String? in
|
|
44
|
+
if bridge.has_value_std__optional_std__string_(self.__deviceId) {
|
|
45
|
+
let __unwrapped = bridge.get_std__optional_std__string_(self.__deviceId)
|
|
46
|
+
return String(__unwrapped)
|
|
47
|
+
} else {
|
|
48
|
+
return nil
|
|
49
|
+
}
|
|
50
|
+
}()
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// MultipeerDiscoveryInfoEntry.swift
|
|
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
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Represents an instance of `MultipeerDiscoveryInfoEntry`, backed by a C++ struct.
|
|
12
|
+
*/
|
|
13
|
+
public typealias MultipeerDiscoveryInfoEntry = margelo.nitro.munimbluetooth.MultipeerDiscoveryInfoEntry
|
|
14
|
+
|
|
15
|
+
public extension MultipeerDiscoveryInfoEntry {
|
|
16
|
+
private typealias bridge = margelo.nitro.munimbluetooth.bridge.swift
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create a new instance of `MultipeerDiscoveryInfoEntry`.
|
|
20
|
+
*/
|
|
21
|
+
init(key: String, value: String) {
|
|
22
|
+
self.init(std.string(key), std.string(value))
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@inline(__always)
|
|
26
|
+
var key: String {
|
|
27
|
+
return String(self.__key)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@inline(__always)
|
|
31
|
+
var value: String {
|
|
32
|
+
return String(self.__value)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// MultipeerEncryptionPreference.swift
|
|
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
|
+
/**
|
|
9
|
+
* Represents the JS union `MultipeerEncryptionPreference`, backed by a C++ enum.
|
|
10
|
+
*/
|
|
11
|
+
public typealias MultipeerEncryptionPreference = margelo.nitro.munimbluetooth.MultipeerEncryptionPreference
|
|
12
|
+
|
|
13
|
+
public extension MultipeerEncryptionPreference {
|
|
14
|
+
/**
|
|
15
|
+
* Get a MultipeerEncryptionPreference for the given String value, or
|
|
16
|
+
* return `nil` if the given value was invalid/unknown.
|
|
17
|
+
*/
|
|
18
|
+
init?(fromString string: String) {
|
|
19
|
+
switch string {
|
|
20
|
+
case "none":
|
|
21
|
+
self = .none
|
|
22
|
+
case "optional":
|
|
23
|
+
self = .optional
|
|
24
|
+
case "required":
|
|
25
|
+
self = .required
|
|
26
|
+
default:
|
|
27
|
+
return nil
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Get the String value this MultipeerEncryptionPreference represents.
|
|
33
|
+
*/
|
|
34
|
+
var stringValue: String {
|
|
35
|
+
switch self {
|
|
36
|
+
case .none:
|
|
37
|
+
return "none"
|
|
38
|
+
case .optional:
|
|
39
|
+
return "optional"
|
|
40
|
+
case .required:
|
|
41
|
+
return "required"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// MultipeerPeer.swift
|
|
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
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Represents an instance of `MultipeerPeer`, backed by a C++ struct.
|
|
12
|
+
*/
|
|
13
|
+
public typealias MultipeerPeer = margelo.nitro.munimbluetooth.MultipeerPeer
|
|
14
|
+
|
|
15
|
+
public extension MultipeerPeer {
|
|
16
|
+
private typealias bridge = margelo.nitro.munimbluetooth.bridge.swift
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create a new instance of `MultipeerPeer`.
|
|
20
|
+
*/
|
|
21
|
+
init(id: String, displayName: String, state: MultipeerPeerState, discoveryInfo: [MultipeerDiscoveryInfoEntry]?) {
|
|
22
|
+
self.init(std.string(id), std.string(displayName), state, { () -> bridge.std__optional_std__vector_MultipeerDiscoveryInfoEntry__ in
|
|
23
|
+
if let __unwrappedValue = discoveryInfo {
|
|
24
|
+
return bridge.create_std__optional_std__vector_MultipeerDiscoveryInfoEntry__({ () -> bridge.std__vector_MultipeerDiscoveryInfoEntry_ in
|
|
25
|
+
var __vector = bridge.create_std__vector_MultipeerDiscoveryInfoEntry_(__unwrappedValue.count)
|
|
26
|
+
for __item in __unwrappedValue {
|
|
27
|
+
__vector.push_back(__item)
|
|
28
|
+
}
|
|
29
|
+
return __vector
|
|
30
|
+
}())
|
|
31
|
+
} else {
|
|
32
|
+
return .init()
|
|
33
|
+
}
|
|
34
|
+
}())
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@inline(__always)
|
|
38
|
+
var id: String {
|
|
39
|
+
return String(self.__id)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@inline(__always)
|
|
43
|
+
var displayName: String {
|
|
44
|
+
return String(self.__displayName)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@inline(__always)
|
|
48
|
+
var state: MultipeerPeerState {
|
|
49
|
+
return self.__state
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@inline(__always)
|
|
53
|
+
var discoveryInfo: [MultipeerDiscoveryInfoEntry]? {
|
|
54
|
+
return { () -> [MultipeerDiscoveryInfoEntry]? in
|
|
55
|
+
if bridge.has_value_std__optional_std__vector_MultipeerDiscoveryInfoEntry__(self.__discoveryInfo) {
|
|
56
|
+
let __unwrapped = bridge.get_std__optional_std__vector_MultipeerDiscoveryInfoEntry__(self.__discoveryInfo)
|
|
57
|
+
return __unwrapped.map({ __item in __item })
|
|
58
|
+
} else {
|
|
59
|
+
return nil
|
|
60
|
+
}
|
|
61
|
+
}()
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// MultipeerPeerState.swift
|
|
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
|
+
/**
|
|
9
|
+
* Represents the JS union `MultipeerPeerState`, backed by a C++ enum.
|
|
10
|
+
*/
|
|
11
|
+
public typealias MultipeerPeerState = margelo.nitro.munimbluetooth.MultipeerPeerState
|
|
12
|
+
|
|
13
|
+
public extension MultipeerPeerState {
|
|
14
|
+
/**
|
|
15
|
+
* Get a MultipeerPeerState for the given String value, or
|
|
16
|
+
* return `nil` if the given value was invalid/unknown.
|
|
17
|
+
*/
|
|
18
|
+
init?(fromString string: String) {
|
|
19
|
+
switch string {
|
|
20
|
+
case "notConnected":
|
|
21
|
+
self = .notconnected
|
|
22
|
+
case "connecting":
|
|
23
|
+
self = .connecting
|
|
24
|
+
case "connected":
|
|
25
|
+
self = .connected
|
|
26
|
+
default:
|
|
27
|
+
return nil
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Get the String value this MultipeerPeerState represents.
|
|
33
|
+
*/
|
|
34
|
+
var stringValue: String {
|
|
35
|
+
switch self {
|
|
36
|
+
case .notconnected:
|
|
37
|
+
return "notConnected"
|
|
38
|
+
case .connecting:
|
|
39
|
+
return "connecting"
|
|
40
|
+
case .connected:
|
|
41
|
+
return "connected"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// MultipeerSessionOptions.swift
|
|
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
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Represents an instance of `MultipeerSessionOptions`, backed by a C++ struct.
|
|
12
|
+
*/
|
|
13
|
+
public typealias MultipeerSessionOptions = margelo.nitro.munimbluetooth.MultipeerSessionOptions
|
|
14
|
+
|
|
15
|
+
public extension MultipeerSessionOptions {
|
|
16
|
+
private typealias bridge = margelo.nitro.munimbluetooth.bridge.swift
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create a new instance of `MultipeerSessionOptions`.
|
|
20
|
+
*/
|
|
21
|
+
init(serviceType: String, displayName: String?, discoveryInfo: [MultipeerDiscoveryInfoEntry]?, autoInvite: Bool?, autoAcceptInvitations: Bool?, inviteTimeout: Double?, encryptionPreference: MultipeerEncryptionPreference?) {
|
|
22
|
+
self.init(std.string(serviceType), { () -> bridge.std__optional_std__string_ in
|
|
23
|
+
if let __unwrappedValue = displayName {
|
|
24
|
+
return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
|
|
25
|
+
} else {
|
|
26
|
+
return .init()
|
|
27
|
+
}
|
|
28
|
+
}(), { () -> bridge.std__optional_std__vector_MultipeerDiscoveryInfoEntry__ in
|
|
29
|
+
if let __unwrappedValue = discoveryInfo {
|
|
30
|
+
return bridge.create_std__optional_std__vector_MultipeerDiscoveryInfoEntry__({ () -> bridge.std__vector_MultipeerDiscoveryInfoEntry_ in
|
|
31
|
+
var __vector = bridge.create_std__vector_MultipeerDiscoveryInfoEntry_(__unwrappedValue.count)
|
|
32
|
+
for __item in __unwrappedValue {
|
|
33
|
+
__vector.push_back(__item)
|
|
34
|
+
}
|
|
35
|
+
return __vector
|
|
36
|
+
}())
|
|
37
|
+
} else {
|
|
38
|
+
return .init()
|
|
39
|
+
}
|
|
40
|
+
}(), { () -> bridge.std__optional_bool_ in
|
|
41
|
+
if let __unwrappedValue = autoInvite {
|
|
42
|
+
return bridge.create_std__optional_bool_(__unwrappedValue)
|
|
43
|
+
} else {
|
|
44
|
+
return .init()
|
|
45
|
+
}
|
|
46
|
+
}(), { () -> bridge.std__optional_bool_ in
|
|
47
|
+
if let __unwrappedValue = autoAcceptInvitations {
|
|
48
|
+
return bridge.create_std__optional_bool_(__unwrappedValue)
|
|
49
|
+
} else {
|
|
50
|
+
return .init()
|
|
51
|
+
}
|
|
52
|
+
}(), { () -> bridge.std__optional_double_ in
|
|
53
|
+
if let __unwrappedValue = inviteTimeout {
|
|
54
|
+
return bridge.create_std__optional_double_(__unwrappedValue)
|
|
55
|
+
} else {
|
|
56
|
+
return .init()
|
|
57
|
+
}
|
|
58
|
+
}(), { () -> bridge.std__optional_MultipeerEncryptionPreference_ in
|
|
59
|
+
if let __unwrappedValue = encryptionPreference {
|
|
60
|
+
return bridge.create_std__optional_MultipeerEncryptionPreference_(__unwrappedValue)
|
|
61
|
+
} else {
|
|
62
|
+
return .init()
|
|
63
|
+
}
|
|
64
|
+
}())
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@inline(__always)
|
|
68
|
+
var serviceType: String {
|
|
69
|
+
return String(self.__serviceType)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@inline(__always)
|
|
73
|
+
var displayName: String? {
|
|
74
|
+
return { () -> String? in
|
|
75
|
+
if bridge.has_value_std__optional_std__string_(self.__displayName) {
|
|
76
|
+
let __unwrapped = bridge.get_std__optional_std__string_(self.__displayName)
|
|
77
|
+
return String(__unwrapped)
|
|
78
|
+
} else {
|
|
79
|
+
return nil
|
|
80
|
+
}
|
|
81
|
+
}()
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
@inline(__always)
|
|
85
|
+
var discoveryInfo: [MultipeerDiscoveryInfoEntry]? {
|
|
86
|
+
return { () -> [MultipeerDiscoveryInfoEntry]? in
|
|
87
|
+
if bridge.has_value_std__optional_std__vector_MultipeerDiscoveryInfoEntry__(self.__discoveryInfo) {
|
|
88
|
+
let __unwrapped = bridge.get_std__optional_std__vector_MultipeerDiscoveryInfoEntry__(self.__discoveryInfo)
|
|
89
|
+
return __unwrapped.map({ __item in __item })
|
|
90
|
+
} else {
|
|
91
|
+
return nil
|
|
92
|
+
}
|
|
93
|
+
}()
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
@inline(__always)
|
|
97
|
+
var autoInvite: Bool? {
|
|
98
|
+
return { () -> Bool? in
|
|
99
|
+
if bridge.has_value_std__optional_bool_(self.__autoInvite) {
|
|
100
|
+
let __unwrapped = bridge.get_std__optional_bool_(self.__autoInvite)
|
|
101
|
+
return __unwrapped
|
|
102
|
+
} else {
|
|
103
|
+
return nil
|
|
104
|
+
}
|
|
105
|
+
}()
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
@inline(__always)
|
|
109
|
+
var autoAcceptInvitations: Bool? {
|
|
110
|
+
return { () -> Bool? in
|
|
111
|
+
if bridge.has_value_std__optional_bool_(self.__autoAcceptInvitations) {
|
|
112
|
+
let __unwrapped = bridge.get_std__optional_bool_(self.__autoAcceptInvitations)
|
|
113
|
+
return __unwrapped
|
|
114
|
+
} else {
|
|
115
|
+
return nil
|
|
116
|
+
}
|
|
117
|
+
}()
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
@inline(__always)
|
|
121
|
+
var inviteTimeout: Double? {
|
|
122
|
+
return { () -> Double? in
|
|
123
|
+
if bridge.has_value_std__optional_double_(self.__inviteTimeout) {
|
|
124
|
+
let __unwrapped = bridge.get_std__optional_double_(self.__inviteTimeout)
|
|
125
|
+
return __unwrapped
|
|
126
|
+
} else {
|
|
127
|
+
return nil
|
|
128
|
+
}
|
|
129
|
+
}()
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
@inline(__always)
|
|
133
|
+
var encryptionPreference: MultipeerEncryptionPreference? {
|
|
134
|
+
return self.__encryptionPreference.value
|
|
135
|
+
}
|
|
136
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// PhyStatus.swift
|
|
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
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Represents an instance of `PhyStatus`, backed by a C++ struct.
|
|
12
|
+
*/
|
|
13
|
+
public typealias PhyStatus = margelo.nitro.munimbluetooth.PhyStatus
|
|
14
|
+
|
|
15
|
+
public extension PhyStatus {
|
|
16
|
+
private typealias bridge = margelo.nitro.munimbluetooth.bridge.swift
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create a new instance of `PhyStatus`.
|
|
20
|
+
*/
|
|
21
|
+
init(txPhy: BluetoothPhy, rxPhy: BluetoothPhy) {
|
|
22
|
+
self.init(txPhy, rxPhy)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@inline(__always)
|
|
26
|
+
var txPhy: BluetoothPhy {
|
|
27
|
+
return self.__txPhy
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@inline(__always)
|
|
31
|
+
var rxPhy: BluetoothPhy {
|
|
32
|
+
return self.__rxPhy
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// BluetoothCapabilities.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 (BluetoothCapabilities).
|
|
39
|
+
*/
|
|
40
|
+
struct BluetoothCapabilities final {
|
|
41
|
+
public:
|
|
42
|
+
std::string platform SWIFT_PRIVATE;
|
|
43
|
+
bool supportsBleCentral SWIFT_PRIVATE;
|
|
44
|
+
bool supportsBlePeripheral SWIFT_PRIVATE;
|
|
45
|
+
bool supportsDescriptors SWIFT_PRIVATE;
|
|
46
|
+
bool supportsIncludedServices SWIFT_PRIVATE;
|
|
47
|
+
bool supportsMtu SWIFT_PRIVATE;
|
|
48
|
+
bool supportsPhy SWIFT_PRIVATE;
|
|
49
|
+
bool supportsBonding SWIFT_PRIVATE;
|
|
50
|
+
bool supportsExtendedAdvertising SWIFT_PRIVATE;
|
|
51
|
+
bool supportsL2cap SWIFT_PRIVATE;
|
|
52
|
+
bool supportsClassicBluetooth SWIFT_PRIVATE;
|
|
53
|
+
bool supportsBackgroundBle SWIFT_PRIVATE;
|
|
54
|
+
bool supportsMultipeerConnectivity SWIFT_PRIVATE;
|
|
55
|
+
|
|
56
|
+
public:
|
|
57
|
+
BluetoothCapabilities() = default;
|
|
58
|
+
explicit BluetoothCapabilities(std::string platform, bool supportsBleCentral, bool supportsBlePeripheral, bool supportsDescriptors, bool supportsIncludedServices, bool supportsMtu, bool supportsPhy, bool supportsBonding, bool supportsExtendedAdvertising, bool supportsL2cap, bool supportsClassicBluetooth, bool supportsBackgroundBle, bool supportsMultipeerConnectivity): platform(platform), supportsBleCentral(supportsBleCentral), supportsBlePeripheral(supportsBlePeripheral), supportsDescriptors(supportsDescriptors), supportsIncludedServices(supportsIncludedServices), supportsMtu(supportsMtu), supportsPhy(supportsPhy), supportsBonding(supportsBonding), supportsExtendedAdvertising(supportsExtendedAdvertising), supportsL2cap(supportsL2cap), supportsClassicBluetooth(supportsClassicBluetooth), supportsBackgroundBle(supportsBackgroundBle), supportsMultipeerConnectivity(supportsMultipeerConnectivity) {}
|
|
59
|
+
|
|
60
|
+
public:
|
|
61
|
+
friend bool operator==(const BluetoothCapabilities& lhs, const BluetoothCapabilities& rhs) = default;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
} // namespace margelo::nitro::munimbluetooth
|
|
65
|
+
|
|
66
|
+
namespace margelo::nitro {
|
|
67
|
+
|
|
68
|
+
// C++ BluetoothCapabilities <> JS BluetoothCapabilities (object)
|
|
69
|
+
template <>
|
|
70
|
+
struct JSIConverter<margelo::nitro::munimbluetooth::BluetoothCapabilities> final {
|
|
71
|
+
static inline margelo::nitro::munimbluetooth::BluetoothCapabilities fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
72
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
73
|
+
return margelo::nitro::munimbluetooth::BluetoothCapabilities(
|
|
74
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "platform"))),
|
|
75
|
+
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "supportsBleCentral"))),
|
|
76
|
+
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "supportsBlePeripheral"))),
|
|
77
|
+
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "supportsDescriptors"))),
|
|
78
|
+
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "supportsIncludedServices"))),
|
|
79
|
+
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "supportsMtu"))),
|
|
80
|
+
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "supportsPhy"))),
|
|
81
|
+
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "supportsBonding"))),
|
|
82
|
+
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "supportsExtendedAdvertising"))),
|
|
83
|
+
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "supportsL2cap"))),
|
|
84
|
+
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "supportsClassicBluetooth"))),
|
|
85
|
+
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "supportsBackgroundBle"))),
|
|
86
|
+
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "supportsMultipeerConnectivity")))
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::munimbluetooth::BluetoothCapabilities& arg) {
|
|
90
|
+
jsi::Object obj(runtime);
|
|
91
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "platform"), JSIConverter<std::string>::toJSI(runtime, arg.platform));
|
|
92
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "supportsBleCentral"), JSIConverter<bool>::toJSI(runtime, arg.supportsBleCentral));
|
|
93
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "supportsBlePeripheral"), JSIConverter<bool>::toJSI(runtime, arg.supportsBlePeripheral));
|
|
94
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "supportsDescriptors"), JSIConverter<bool>::toJSI(runtime, arg.supportsDescriptors));
|
|
95
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "supportsIncludedServices"), JSIConverter<bool>::toJSI(runtime, arg.supportsIncludedServices));
|
|
96
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "supportsMtu"), JSIConverter<bool>::toJSI(runtime, arg.supportsMtu));
|
|
97
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "supportsPhy"), JSIConverter<bool>::toJSI(runtime, arg.supportsPhy));
|
|
98
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "supportsBonding"), JSIConverter<bool>::toJSI(runtime, arg.supportsBonding));
|
|
99
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "supportsExtendedAdvertising"), JSIConverter<bool>::toJSI(runtime, arg.supportsExtendedAdvertising));
|
|
100
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "supportsL2cap"), JSIConverter<bool>::toJSI(runtime, arg.supportsL2cap));
|
|
101
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "supportsClassicBluetooth"), JSIConverter<bool>::toJSI(runtime, arg.supportsClassicBluetooth));
|
|
102
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "supportsBackgroundBle"), JSIConverter<bool>::toJSI(runtime, arg.supportsBackgroundBle));
|
|
103
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "supportsMultipeerConnectivity"), JSIConverter<bool>::toJSI(runtime, arg.supportsMultipeerConnectivity));
|
|
104
|
+
return obj;
|
|
105
|
+
}
|
|
106
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
107
|
+
if (!value.isObject()) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
jsi::Object obj = value.getObject(runtime);
|
|
111
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "platform")))) return false;
|
|
115
|
+
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "supportsBleCentral")))) return false;
|
|
116
|
+
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "supportsBlePeripheral")))) return false;
|
|
117
|
+
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "supportsDescriptors")))) return false;
|
|
118
|
+
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "supportsIncludedServices")))) return false;
|
|
119
|
+
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "supportsMtu")))) return false;
|
|
120
|
+
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "supportsPhy")))) return false;
|
|
121
|
+
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "supportsBonding")))) return false;
|
|
122
|
+
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "supportsExtendedAdvertising")))) return false;
|
|
123
|
+
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "supportsL2cap")))) return false;
|
|
124
|
+
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "supportsClassicBluetooth")))) return false;
|
|
125
|
+
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "supportsBackgroundBle")))) return false;
|
|
126
|
+
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "supportsMultipeerConnectivity")))) return false;
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// BluetoothPhy.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 (BluetoothPhy).
|
|
30
|
+
*/
|
|
31
|
+
enum class BluetoothPhy {
|
|
32
|
+
LE1M SWIFT_NAME(le1m) = 0,
|
|
33
|
+
LE2M SWIFT_NAME(le2m) = 1,
|
|
34
|
+
LECODED SWIFT_NAME(lecoded) = 2,
|
|
35
|
+
} CLOSED_ENUM;
|
|
36
|
+
|
|
37
|
+
} // namespace margelo::nitro::munimbluetooth
|
|
38
|
+
|
|
39
|
+
namespace margelo::nitro {
|
|
40
|
+
|
|
41
|
+
// C++ BluetoothPhy <> JS BluetoothPhy (union)
|
|
42
|
+
template <>
|
|
43
|
+
struct JSIConverter<margelo::nitro::munimbluetooth::BluetoothPhy> final {
|
|
44
|
+
static inline margelo::nitro::munimbluetooth::BluetoothPhy 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("le1m"): return margelo::nitro::munimbluetooth::BluetoothPhy::LE1M;
|
|
48
|
+
case hashString("le2m"): return margelo::nitro::munimbluetooth::BluetoothPhy::LE2M;
|
|
49
|
+
case hashString("leCoded"): return margelo::nitro::munimbluetooth::BluetoothPhy::LECODED;
|
|
50
|
+
default: [[unlikely]]
|
|
51
|
+
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum BluetoothPhy - invalid value!");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::munimbluetooth::BluetoothPhy arg) {
|
|
55
|
+
switch (arg) {
|
|
56
|
+
case margelo::nitro::munimbluetooth::BluetoothPhy::LE1M: return JSIConverter<std::string>::toJSI(runtime, "le1m");
|
|
57
|
+
case margelo::nitro::munimbluetooth::BluetoothPhy::LE2M: return JSIConverter<std::string>::toJSI(runtime, "le2m");
|
|
58
|
+
case margelo::nitro::munimbluetooth::BluetoothPhy::LECODED: return JSIConverter<std::string>::toJSI(runtime, "leCoded");
|
|
59
|
+
default: [[unlikely]]
|
|
60
|
+
throw std::invalid_argument("Cannot convert BluetoothPhy 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("le1m"):
|
|
71
|
+
case hashString("le2m"):
|
|
72
|
+
case hashString("leCoded"):
|
|
73
|
+
return true;
|
|
74
|
+
default:
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
} // namespace margelo::nitro
|