react-native-ble-nitro 1.13.0 → 1.15.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.
- package/README.md +53 -1
- package/android/build.gradle +6 -0
- package/android/src/main/java/com/margelo/nitro/co/zyke/ble/BleNitroBleManager.kt +128 -11
- package/android/src/main/java/com/margelo/nitro/co/zyke/ble/CccdSubscription.kt +38 -0
- package/android/src/test/java/com/margelo/nitro/co/zyke/ble/CccdSubscriptionTest.kt +48 -0
- package/ios/BleNitroBleManager.swift +28 -3
- package/lib/commonjs/index.d.ts +1 -1
- package/lib/commonjs/index.d.ts.map +1 -1
- package/lib/commonjs/index.js +2 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/manager.d.ts +24 -1
- package/lib/commonjs/manager.d.ts.map +1 -1
- package/lib/commonjs/manager.js +33 -1
- package/lib/commonjs/manager.js.map +1 -1
- package/lib/commonjs/specs/NativeBleNitro.nitro.d.ts +14 -0
- package/lib/commonjs/specs/NativeBleNitro.nitro.d.ts.map +1 -1
- package/lib/commonjs/specs/NativeBleNitro.nitro.js +7 -1
- package/lib/commonjs/specs/NativeBleNitro.nitro.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/manager.d.ts +24 -1
- package/lib/manager.js +32 -1
- package/lib/specs/NativeBleNitro.nitro.d.ts +14 -0
- package/lib/specs/NativeBleNitro.nitro.js +6 -0
- package/nitrogen/generated/android/c++/JAndroidConnectionPriority.hpp +61 -0
- package/nitrogen/generated/android/c++/JBLEDevice.hpp +9 -1
- package/nitrogen/generated/android/c++/JFunc_void_std__optional_std__variant_nitro__NullType__BLEDevice___std__optional_std__variant_nitro__NullType__std__string__.hpp +4 -0
- package/nitrogen/generated/android/c++/JFunc_void_std__vector_BLEDevice_.hpp +4 -0
- package/nitrogen/generated/android/c++/JHybridNativeBleNitroFactorySpec.cpp +8 -0
- package/nitrogen/generated/android/c++/JHybridNativeBleNitroSpec.cpp +17 -0
- package/nitrogen/generated/android/c++/JHybridNativeBleNitroSpec.hpp +1 -0
- package/nitrogen/generated/android/c++/JServiceData.hpp +80 -0
- package/nitrogen/generated/android/c++/JServiceDataEntry.hpp +63 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_BLEDevice.hpp +4 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/AndroidConnectionPriority.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/BLEDevice.kt +5 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/HybridNativeBleNitroSpec.kt +4 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/ServiceData.kt +38 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/ServiceDataEntry.kt +41 -0
- package/nitrogen/generated/ios/BleNitro-Swift-Cxx-Bridge.hpp +17 -0
- package/nitrogen/generated/ios/BleNitro-Swift-Cxx-Umbrella.hpp +9 -0
- package/nitrogen/generated/ios/c++/HybridNativeBleNitroFactorySpecSwift.hpp +6 -0
- package/nitrogen/generated/ios/c++/HybridNativeBleNitroSpecSwift.hpp +17 -0
- package/nitrogen/generated/ios/swift/AndroidConnectionPriority.swift +44 -0
- package/nitrogen/generated/ios/swift/BLEDevice.swift +7 -2
- package/nitrogen/generated/ios/swift/HybridNativeBleNitroSpec.swift +1 -0
- package/nitrogen/generated/ios/swift/HybridNativeBleNitroSpec_cxx.swift +12 -0
- package/nitrogen/generated/ios/swift/ServiceData.swift +35 -0
- package/nitrogen/generated/ios/swift/ServiceDataEntry.swift +34 -0
- package/nitrogen/generated/shared/c++/AndroidConnectionPriority.hpp +63 -0
- package/nitrogen/generated/shared/c++/BLEDevice.hpp +8 -1
- package/nitrogen/generated/shared/c++/HybridNativeBleNitroSpec.cpp +1 -0
- package/nitrogen/generated/shared/c++/HybridNativeBleNitroSpec.hpp +4 -0
- package/nitrogen/generated/shared/c++/ServiceData.hpp +85 -0
- package/nitrogen/generated/shared/c++/ServiceDataEntry.hpp +88 -0
- package/package.json +1 -1
- package/src/__tests__/index.test.ts +69 -2
- package/src/index.ts +3 -0
- package/src/manager.ts +50 -0
- package/src/specs/NativeBleNitro.nitro.ts +18 -1
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JServiceData.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include "ServiceData.hpp"
|
|
12
|
+
|
|
13
|
+
#include "JServiceDataEntry.hpp"
|
|
14
|
+
#include "ServiceDataEntry.hpp"
|
|
15
|
+
#include <NitroModules/ArrayBuffer.hpp>
|
|
16
|
+
#include <NitroModules/JArrayBuffer.hpp>
|
|
17
|
+
#include <string>
|
|
18
|
+
#include <vector>
|
|
19
|
+
|
|
20
|
+
namespace margelo::nitro::co::zyke::ble {
|
|
21
|
+
|
|
22
|
+
using namespace facebook;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The C++ JNI bridge between the C++ struct "ServiceData" and the the Kotlin data class "ServiceData".
|
|
26
|
+
*/
|
|
27
|
+
struct JServiceData final: public jni::JavaClass<JServiceData> {
|
|
28
|
+
public:
|
|
29
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/co/zyke/ble/ServiceData;";
|
|
30
|
+
|
|
31
|
+
public:
|
|
32
|
+
/**
|
|
33
|
+
* Convert this Java/Kotlin-based struct to the C++ struct ServiceData by copying all values to C++.
|
|
34
|
+
*/
|
|
35
|
+
[[maybe_unused]]
|
|
36
|
+
[[nodiscard]]
|
|
37
|
+
ServiceData toCpp() const {
|
|
38
|
+
static const auto clazz = javaClassStatic();
|
|
39
|
+
static const auto fieldServices = clazz->getField<jni::JArrayClass<JServiceDataEntry>>("services");
|
|
40
|
+
jni::local_ref<jni::JArrayClass<JServiceDataEntry>> services = this->getFieldValue(fieldServices);
|
|
41
|
+
return ServiceData(
|
|
42
|
+
[&]() {
|
|
43
|
+
size_t __size = services->size();
|
|
44
|
+
std::vector<ServiceDataEntry> __vector;
|
|
45
|
+
__vector.reserve(__size);
|
|
46
|
+
for (size_t __i = 0; __i < __size; __i++) {
|
|
47
|
+
auto __element = services->getElement(__i);
|
|
48
|
+
__vector.push_back(__element->toCpp());
|
|
49
|
+
}
|
|
50
|
+
return __vector;
|
|
51
|
+
}()
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public:
|
|
56
|
+
/**
|
|
57
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
58
|
+
*/
|
|
59
|
+
[[maybe_unused]]
|
|
60
|
+
static jni::local_ref<JServiceData::javaobject> fromCpp(const ServiceData& value) {
|
|
61
|
+
using JSignature = JServiceData(jni::alias_ref<jni::JArrayClass<JServiceDataEntry>>);
|
|
62
|
+
static const auto clazz = javaClassStatic();
|
|
63
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
64
|
+
return create(
|
|
65
|
+
clazz,
|
|
66
|
+
[&]() {
|
|
67
|
+
size_t __size = value.services.size();
|
|
68
|
+
jni::local_ref<jni::JArrayClass<JServiceDataEntry>> __array = jni::JArrayClass<JServiceDataEntry>::newArray(__size);
|
|
69
|
+
for (size_t __i = 0; __i < __size; __i++) {
|
|
70
|
+
const auto& __element = value.services[__i];
|
|
71
|
+
auto __elementJni = JServiceDataEntry::fromCpp(__element);
|
|
72
|
+
__array->setElement(__i, *__elementJni);
|
|
73
|
+
}
|
|
74
|
+
return __array;
|
|
75
|
+
}()
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
} // namespace margelo::nitro::co::zyke::ble
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JServiceDataEntry.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include "ServiceDataEntry.hpp"
|
|
12
|
+
|
|
13
|
+
#include <NitroModules/ArrayBuffer.hpp>
|
|
14
|
+
#include <NitroModules/JArrayBuffer.hpp>
|
|
15
|
+
#include <string>
|
|
16
|
+
|
|
17
|
+
namespace margelo::nitro::co::zyke::ble {
|
|
18
|
+
|
|
19
|
+
using namespace facebook;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The C++ JNI bridge between the C++ struct "ServiceDataEntry" and the the Kotlin data class "ServiceDataEntry".
|
|
23
|
+
*/
|
|
24
|
+
struct JServiceDataEntry final: public jni::JavaClass<JServiceDataEntry> {
|
|
25
|
+
public:
|
|
26
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/co/zyke/ble/ServiceDataEntry;";
|
|
27
|
+
|
|
28
|
+
public:
|
|
29
|
+
/**
|
|
30
|
+
* Convert this Java/Kotlin-based struct to the C++ struct ServiceDataEntry by copying all values to C++.
|
|
31
|
+
*/
|
|
32
|
+
[[maybe_unused]]
|
|
33
|
+
[[nodiscard]]
|
|
34
|
+
ServiceDataEntry toCpp() const {
|
|
35
|
+
static const auto clazz = javaClassStatic();
|
|
36
|
+
static const auto fieldUuid = clazz->getField<jni::JString>("uuid");
|
|
37
|
+
jni::local_ref<jni::JString> uuid = this->getFieldValue(fieldUuid);
|
|
38
|
+
static const auto fieldData = clazz->getField<JArrayBuffer::javaobject>("data");
|
|
39
|
+
jni::local_ref<JArrayBuffer::javaobject> data = this->getFieldValue(fieldData);
|
|
40
|
+
return ServiceDataEntry(
|
|
41
|
+
uuid->toStdString(),
|
|
42
|
+
data->cthis()->getArrayBuffer()
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
public:
|
|
47
|
+
/**
|
|
48
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
49
|
+
*/
|
|
50
|
+
[[maybe_unused]]
|
|
51
|
+
static jni::local_ref<JServiceDataEntry::javaobject> fromCpp(const ServiceDataEntry& value) {
|
|
52
|
+
using JSignature = JServiceDataEntry(jni::alias_ref<jni::JString>, jni::alias_ref<JArrayBuffer::javaobject>);
|
|
53
|
+
static const auto clazz = javaClassStatic();
|
|
54
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
55
|
+
return create(
|
|
56
|
+
clazz,
|
|
57
|
+
jni::make_jstring(value.uuid),
|
|
58
|
+
JArrayBuffer::wrap(value.data)
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
} // namespace margelo::nitro::co::zyke::ble
|
|
@@ -23,6 +23,10 @@
|
|
|
23
23
|
#include "JManufacturerDataEntry.hpp"
|
|
24
24
|
#include <NitroModules/ArrayBuffer.hpp>
|
|
25
25
|
#include <NitroModules/JArrayBuffer.hpp>
|
|
26
|
+
#include "ServiceData.hpp"
|
|
27
|
+
#include "JServiceData.hpp"
|
|
28
|
+
#include "ServiceDataEntry.hpp"
|
|
29
|
+
#include "JServiceDataEntry.hpp"
|
|
26
30
|
|
|
27
31
|
namespace margelo::nitro::co::zyke::ble {
|
|
28
32
|
|
package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/AndroidConnectionPriority.kt
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// AndroidConnectionPriority.kt
|
|
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
|
+
package com.margelo.nitro.co.zyke.ble
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Represents the JavaScript enum/union "AndroidConnectionPriority".
|
|
15
|
+
*/
|
|
16
|
+
@DoNotStrip
|
|
17
|
+
@Keep
|
|
18
|
+
enum class AndroidConnectionPriority(@DoNotStrip @Keep val value: Int) {
|
|
19
|
+
BALANCED(0),
|
|
20
|
+
HIGH(1),
|
|
21
|
+
LOWPOWER(2);
|
|
22
|
+
|
|
23
|
+
companion object
|
|
24
|
+
}
|
|
@@ -31,6 +31,9 @@ data class BLEDevice(
|
|
|
31
31
|
val manufacturerData: ManufacturerData,
|
|
32
32
|
@DoNotStrip
|
|
33
33
|
@Keep
|
|
34
|
+
val serviceData: ServiceData,
|
|
35
|
+
@DoNotStrip
|
|
36
|
+
@Keep
|
|
34
37
|
val serviceUUIDs: Array<String>,
|
|
35
38
|
@DoNotStrip
|
|
36
39
|
@Keep
|
|
@@ -49,8 +52,8 @@ data class BLEDevice(
|
|
|
49
52
|
@Keep
|
|
50
53
|
@Suppress("unused")
|
|
51
54
|
@JvmStatic
|
|
52
|
-
private fun fromCpp(id: String, name: String, rssi: Double, manufacturerData: ManufacturerData, serviceUUIDs: Array<String>, isConnectable: Boolean, isConnected: Boolean): BLEDevice {
|
|
53
|
-
return BLEDevice(id, name, rssi, manufacturerData, serviceUUIDs, isConnectable, isConnected)
|
|
55
|
+
private fun fromCpp(id: String, name: String, rssi: Double, manufacturerData: ManufacturerData, serviceData: ServiceData, serviceUUIDs: Array<String>, isConnectable: Boolean, isConnected: Boolean): BLEDevice {
|
|
56
|
+
return BLEDevice(id, name, rssi, manufacturerData, serviceData, serviceUUIDs, isConnectable, isConnected)
|
|
54
57
|
}
|
|
55
58
|
}
|
|
56
59
|
}
|
package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/HybridNativeBleNitroSpec.kt
CHANGED
|
@@ -95,6 +95,10 @@ abstract class HybridNativeBleNitroSpec: HybridObject() {
|
|
|
95
95
|
@Keep
|
|
96
96
|
abstract fun requestMTU(deviceId: String, mtu: Double): Double
|
|
97
97
|
|
|
98
|
+
@DoNotStrip
|
|
99
|
+
@Keep
|
|
100
|
+
abstract fun requestConnectionPriority(deviceId: String, androidConnectionPriority: AndroidConnectionPriority): Boolean
|
|
101
|
+
|
|
98
102
|
abstract fun readRSSI(deviceId: String, callback: (success: Boolean, rssi: Double, error: String) -> Unit): Unit
|
|
99
103
|
|
|
100
104
|
@DoNotStrip
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ServiceData.kt
|
|
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
|
+
package com.margelo.nitro.co.zyke.ble
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Represents the JavaScript object/struct "ServiceData".
|
|
16
|
+
*/
|
|
17
|
+
@DoNotStrip
|
|
18
|
+
@Keep
|
|
19
|
+
data class ServiceData(
|
|
20
|
+
@DoNotStrip
|
|
21
|
+
@Keep
|
|
22
|
+
val services: Array<ServiceDataEntry>
|
|
23
|
+
) {
|
|
24
|
+
/* primary constructor */
|
|
25
|
+
|
|
26
|
+
companion object {
|
|
27
|
+
/**
|
|
28
|
+
* Constructor called from C++
|
|
29
|
+
*/
|
|
30
|
+
@DoNotStrip
|
|
31
|
+
@Keep
|
|
32
|
+
@Suppress("unused")
|
|
33
|
+
@JvmStatic
|
|
34
|
+
private fun fromCpp(services: Array<ServiceDataEntry>): ServiceData {
|
|
35
|
+
return ServiceData(services)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ServiceDataEntry.kt
|
|
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
|
+
package com.margelo.nitro.co.zyke.ble
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
import com.margelo.nitro.core.ArrayBuffer
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Represents the JavaScript object/struct "ServiceDataEntry".
|
|
16
|
+
*/
|
|
17
|
+
@DoNotStrip
|
|
18
|
+
@Keep
|
|
19
|
+
data class ServiceDataEntry(
|
|
20
|
+
@DoNotStrip
|
|
21
|
+
@Keep
|
|
22
|
+
val uuid: String,
|
|
23
|
+
@DoNotStrip
|
|
24
|
+
@Keep
|
|
25
|
+
val data: ArrayBuffer
|
|
26
|
+
) {
|
|
27
|
+
/* primary constructor */
|
|
28
|
+
|
|
29
|
+
companion object {
|
|
30
|
+
/**
|
|
31
|
+
* Constructor called from C++
|
|
32
|
+
*/
|
|
33
|
+
@DoNotStrip
|
|
34
|
+
@Keep
|
|
35
|
+
@Suppress("unused")
|
|
36
|
+
@JvmStatic
|
|
37
|
+
private fun fromCpp(uuid: String, data: ArrayBuffer): ServiceDataEntry {
|
|
38
|
+
return ServiceDataEntry(uuid, data)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -24,6 +24,10 @@ namespace margelo::nitro::co::zyke::ble { struct ManufacturerDataEntry; }
|
|
|
24
24
|
namespace margelo::nitro::co::zyke::ble { struct ManufacturerData; }
|
|
25
25
|
// Forward declaration of `OperationResult` to properly resolve imports.
|
|
26
26
|
namespace margelo::nitro::co::zyke::ble { struct OperationResult; }
|
|
27
|
+
// Forward declaration of `ServiceDataEntry` to properly resolve imports.
|
|
28
|
+
namespace margelo::nitro::co::zyke::ble { struct ServiceDataEntry; }
|
|
29
|
+
// Forward declaration of `ServiceData` to properly resolve imports.
|
|
30
|
+
namespace margelo::nitro::co::zyke::ble { struct ServiceData; }
|
|
27
31
|
|
|
28
32
|
// Forward declarations of Swift defined types
|
|
29
33
|
// Forward declaration of `HybridNativeBleNitroFactorySpec_cxx` to properly resolve imports.
|
|
@@ -39,6 +43,8 @@ namespace BleNitro { class HybridNativeBleNitroSpec_cxx; }
|
|
|
39
43
|
#include "ManufacturerData.hpp"
|
|
40
44
|
#include "ManufacturerDataEntry.hpp"
|
|
41
45
|
#include "OperationResult.hpp"
|
|
46
|
+
#include "ServiceData.hpp"
|
|
47
|
+
#include "ServiceDataEntry.hpp"
|
|
42
48
|
#include <NitroModules/ArrayBuffer.hpp>
|
|
43
49
|
#include <NitroModules/ArrayBufferHolder.hpp>
|
|
44
50
|
#include <NitroModules/Null.hpp>
|
|
@@ -85,6 +91,17 @@ namespace margelo::nitro::co::zyke::ble::bridge::swift {
|
|
|
85
91
|
return vector;
|
|
86
92
|
}
|
|
87
93
|
|
|
94
|
+
// pragma MARK: std::vector<ServiceDataEntry>
|
|
95
|
+
/**
|
|
96
|
+
* Specialized version of `std::vector<ServiceDataEntry>`.
|
|
97
|
+
*/
|
|
98
|
+
using std__vector_ServiceDataEntry_ = std::vector<ServiceDataEntry>;
|
|
99
|
+
inline std::vector<ServiceDataEntry> create_std__vector_ServiceDataEntry_(size_t size) noexcept {
|
|
100
|
+
std::vector<ServiceDataEntry> vector;
|
|
101
|
+
vector.reserve(size);
|
|
102
|
+
return vector;
|
|
103
|
+
}
|
|
104
|
+
|
|
88
105
|
// pragma MARK: std::vector<std::string>
|
|
89
106
|
/**
|
|
90
107
|
* Specialized version of `std::vector<std::string>`.
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
#pragma once
|
|
9
9
|
|
|
10
10
|
// Forward declarations of C++ defined types
|
|
11
|
+
// Forward declaration of `AndroidConnectionPriority` to properly resolve imports.
|
|
12
|
+
namespace margelo::nitro::co::zyke::ble { enum class AndroidConnectionPriority; }
|
|
11
13
|
// Forward declaration of `AndroidScanMode` to properly resolve imports.
|
|
12
14
|
namespace margelo::nitro::co::zyke::ble { enum class AndroidScanMode; }
|
|
13
15
|
// Forward declaration of `BLEDevice` to properly resolve imports.
|
|
@@ -26,8 +28,13 @@ namespace margelo::nitro::co::zyke::ble { struct ManufacturerData; }
|
|
|
26
28
|
namespace margelo::nitro::co::zyke::ble { struct OperationResult; }
|
|
27
29
|
// Forward declaration of `ScanFilter` to properly resolve imports.
|
|
28
30
|
namespace margelo::nitro::co::zyke::ble { struct ScanFilter; }
|
|
31
|
+
// Forward declaration of `ServiceDataEntry` to properly resolve imports.
|
|
32
|
+
namespace margelo::nitro::co::zyke::ble { struct ServiceDataEntry; }
|
|
33
|
+
// Forward declaration of `ServiceData` to properly resolve imports.
|
|
34
|
+
namespace margelo::nitro::co::zyke::ble { struct ServiceData; }
|
|
29
35
|
|
|
30
36
|
// Include C++ defined types
|
|
37
|
+
#include "AndroidConnectionPriority.hpp"
|
|
31
38
|
#include "AndroidScanMode.hpp"
|
|
32
39
|
#include "BLEDevice.hpp"
|
|
33
40
|
#include "BLEState.hpp"
|
|
@@ -37,6 +44,8 @@ namespace margelo::nitro::co::zyke::ble { struct ScanFilter; }
|
|
|
37
44
|
#include "ManufacturerDataEntry.hpp"
|
|
38
45
|
#include "OperationResult.hpp"
|
|
39
46
|
#include "ScanFilter.hpp"
|
|
47
|
+
#include "ServiceData.hpp"
|
|
48
|
+
#include "ServiceDataEntry.hpp"
|
|
40
49
|
#include <NitroModules/ArrayBuffer.hpp>
|
|
41
50
|
#include <NitroModules/Null.hpp>
|
|
42
51
|
#include <NitroModules/Promise.hpp>
|
|
@@ -22,6 +22,10 @@ namespace margelo::nitro::co::zyke::ble { struct ManufacturerData; }
|
|
|
22
22
|
namespace margelo::nitro::co::zyke::ble { struct ManufacturerDataEntry; }
|
|
23
23
|
// Forward declaration of `ArrayBufferHolder` to properly resolve imports.
|
|
24
24
|
namespace NitroModules { class ArrayBufferHolder; }
|
|
25
|
+
// Forward declaration of `ServiceData` to properly resolve imports.
|
|
26
|
+
namespace margelo::nitro::co::zyke::ble { struct ServiceData; }
|
|
27
|
+
// Forward declaration of `ServiceDataEntry` to properly resolve imports.
|
|
28
|
+
namespace margelo::nitro::co::zyke::ble { struct ServiceDataEntry; }
|
|
25
29
|
|
|
26
30
|
#include <memory>
|
|
27
31
|
#include "HybridNativeBleNitroSpec.hpp"
|
|
@@ -34,6 +38,8 @@ namespace NitroModules { class ArrayBufferHolder; }
|
|
|
34
38
|
#include "ManufacturerDataEntry.hpp"
|
|
35
39
|
#include <NitroModules/ArrayBuffer.hpp>
|
|
36
40
|
#include <NitroModules/ArrayBufferHolder.hpp>
|
|
41
|
+
#include "ServiceData.hpp"
|
|
42
|
+
#include "ServiceDataEntry.hpp"
|
|
37
43
|
|
|
38
44
|
#include "BleNitro-Swift-Cxx-Umbrella.hpp"
|
|
39
45
|
|
|
@@ -20,10 +20,16 @@ namespace margelo::nitro::co::zyke::ble { struct ManufacturerData; }
|
|
|
20
20
|
namespace margelo::nitro::co::zyke::ble { struct ManufacturerDataEntry; }
|
|
21
21
|
// Forward declaration of `ArrayBufferHolder` to properly resolve imports.
|
|
22
22
|
namespace NitroModules { class ArrayBufferHolder; }
|
|
23
|
+
// Forward declaration of `ServiceData` to properly resolve imports.
|
|
24
|
+
namespace margelo::nitro::co::zyke::ble { struct ServiceData; }
|
|
25
|
+
// Forward declaration of `ServiceDataEntry` to properly resolve imports.
|
|
26
|
+
namespace margelo::nitro::co::zyke::ble { struct ServiceDataEntry; }
|
|
23
27
|
// Forward declaration of `ScanFilter` to properly resolve imports.
|
|
24
28
|
namespace margelo::nitro::co::zyke::ble { struct ScanFilter; }
|
|
25
29
|
// Forward declaration of `AndroidScanMode` to properly resolve imports.
|
|
26
30
|
namespace margelo::nitro::co::zyke::ble { enum class AndroidScanMode; }
|
|
31
|
+
// Forward declaration of `AndroidConnectionPriority` to properly resolve imports.
|
|
32
|
+
namespace margelo::nitro::co::zyke::ble { enum class AndroidConnectionPriority; }
|
|
27
33
|
// Forward declaration of `BLEState` to properly resolve imports.
|
|
28
34
|
namespace margelo::nitro::co::zyke::ble { enum class BLEState; }
|
|
29
35
|
// Forward declaration of `OperationResult` to properly resolve imports.
|
|
@@ -38,10 +44,13 @@ namespace margelo::nitro::co::zyke::ble { struct OperationResult; }
|
|
|
38
44
|
#include "ManufacturerDataEntry.hpp"
|
|
39
45
|
#include <NitroModules/ArrayBuffer.hpp>
|
|
40
46
|
#include <NitroModules/ArrayBufferHolder.hpp>
|
|
47
|
+
#include "ServiceData.hpp"
|
|
48
|
+
#include "ServiceDataEntry.hpp"
|
|
41
49
|
#include "ScanFilter.hpp"
|
|
42
50
|
#include "AndroidScanMode.hpp"
|
|
43
51
|
#include <NitroModules/Null.hpp>
|
|
44
52
|
#include <variant>
|
|
53
|
+
#include "AndroidConnectionPriority.hpp"
|
|
45
54
|
#include "BLEState.hpp"
|
|
46
55
|
#include "OperationResult.hpp"
|
|
47
56
|
#include <NitroModules/Promise.hpp>
|
|
@@ -172,6 +181,14 @@ namespace margelo::nitro::co::zyke::ble {
|
|
|
172
181
|
auto __value = std::move(__result.value());
|
|
173
182
|
return __value;
|
|
174
183
|
}
|
|
184
|
+
inline bool requestConnectionPriority(const std::string& deviceId, AndroidConnectionPriority androidConnectionPriority) override {
|
|
185
|
+
auto __result = _swiftPart.requestConnectionPriority(deviceId, static_cast<int>(androidConnectionPriority));
|
|
186
|
+
if (__result.hasError()) [[unlikely]] {
|
|
187
|
+
std::rethrow_exception(__result.error());
|
|
188
|
+
}
|
|
189
|
+
auto __value = std::move(__result.value());
|
|
190
|
+
return __value;
|
|
191
|
+
}
|
|
175
192
|
inline void readRSSI(const std::string& deviceId, const std::function<void(bool /* success */, double /* rssi */, const std::string& /* error */)>& callback) override {
|
|
176
193
|
auto __result = _swiftPart.readRSSI(deviceId, callback);
|
|
177
194
|
if (__result.hasError()) [[unlikely]] {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// AndroidConnectionPriority.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 enum `AndroidConnectionPriority`, backed by a C++ enum.
|
|
10
|
+
*/
|
|
11
|
+
public typealias AndroidConnectionPriority = margelo.nitro.co.zyke.ble.AndroidConnectionPriority
|
|
12
|
+
|
|
13
|
+
public extension AndroidConnectionPriority {
|
|
14
|
+
/**
|
|
15
|
+
* Get a AndroidConnectionPriority 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 "Balanced":
|
|
21
|
+
self = .balanced
|
|
22
|
+
case "High":
|
|
23
|
+
self = .high
|
|
24
|
+
case "LowPower":
|
|
25
|
+
self = .lowpower
|
|
26
|
+
default:
|
|
27
|
+
return nil
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Get the String value this AndroidConnectionPriority represents.
|
|
33
|
+
*/
|
|
34
|
+
var stringValue: String {
|
|
35
|
+
switch self {
|
|
36
|
+
case .balanced:
|
|
37
|
+
return "Balanced"
|
|
38
|
+
case .high:
|
|
39
|
+
return "High"
|
|
40
|
+
case .lowpower:
|
|
41
|
+
return "LowPower"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -18,8 +18,8 @@ public extension BLEDevice {
|
|
|
18
18
|
/**
|
|
19
19
|
* Create a new instance of `BLEDevice`.
|
|
20
20
|
*/
|
|
21
|
-
init(id: String, name: String, rssi: Double, manufacturerData: ManufacturerData, serviceUUIDs: [String], isConnectable: Bool, isConnected: Bool) {
|
|
22
|
-
self.init(std.string(id), std.string(name), rssi, manufacturerData, { () -> bridge.std__vector_std__string_ in
|
|
21
|
+
init(id: String, name: String, rssi: Double, manufacturerData: ManufacturerData, serviceData: ServiceData, serviceUUIDs: [String], isConnectable: Bool, isConnected: Bool) {
|
|
22
|
+
self.init(std.string(id), std.string(name), rssi, manufacturerData, serviceData, { () -> bridge.std__vector_std__string_ in
|
|
23
23
|
var __vector = bridge.create_std__vector_std__string_(serviceUUIDs.count)
|
|
24
24
|
for __item in serviceUUIDs {
|
|
25
25
|
__vector.push_back(std.string(__item))
|
|
@@ -48,6 +48,11 @@ public extension BLEDevice {
|
|
|
48
48
|
return self.__manufacturerData
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
@inline(__always)
|
|
52
|
+
var serviceData: ServiceData {
|
|
53
|
+
return self.__serviceData
|
|
54
|
+
}
|
|
55
|
+
|
|
51
56
|
@inline(__always)
|
|
52
57
|
var serviceUUIDs: [String] {
|
|
53
58
|
return self.__serviceUUIDs.map({ __item in String(__item) })
|
|
@@ -23,6 +23,7 @@ public protocol HybridNativeBleNitroSpec_protocol: HybridObject {
|
|
|
23
23
|
func disconnect(deviceId: String, callback: @escaping (_ success: Bool, _ error: String) -> Void) throws -> Void
|
|
24
24
|
func isConnected(deviceId: String) throws -> Bool
|
|
25
25
|
func requestMTU(deviceId: String, mtu: Double) throws -> Double
|
|
26
|
+
func requestConnectionPriority(deviceId: String, androidConnectionPriority: AndroidConnectionPriority) throws -> Bool
|
|
26
27
|
func readRSSI(deviceId: String, callback: @escaping (_ success: Bool, _ rssi: Double, _ error: String) -> Void) throws -> Void
|
|
27
28
|
func discoverServices(deviceId: String, callback: @escaping (_ success: Bool, _ error: String) -> Void) throws -> Void
|
|
28
29
|
func discoverServicesWithCharacteristics(deviceId: String, callback: @escaping (_ success: Bool, _ error: String) -> Void) throws -> Void
|
|
@@ -338,6 +338,18 @@ open class HybridNativeBleNitroSpec_cxx {
|
|
|
338
338
|
}
|
|
339
339
|
}
|
|
340
340
|
|
|
341
|
+
@inline(__always)
|
|
342
|
+
public final func requestConnectionPriority(deviceId: std.string, androidConnectionPriority: Int32) -> bridge.Result_bool_ {
|
|
343
|
+
do {
|
|
344
|
+
let __result = try self.__implementation.requestConnectionPriority(deviceId: String(deviceId), androidConnectionPriority: margelo.nitro.co.zyke.ble.AndroidConnectionPriority(rawValue: androidConnectionPriority)!)
|
|
345
|
+
let __resultCpp = __result
|
|
346
|
+
return bridge.create_Result_bool_(__resultCpp)
|
|
347
|
+
} catch (let __error) {
|
|
348
|
+
let __exceptionPtr = __error.toCpp()
|
|
349
|
+
return bridge.create_Result_bool_(__exceptionPtr)
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
341
353
|
@inline(__always)
|
|
342
354
|
public final func readRSSI(deviceId: std.string, callback: bridge.Func_void_bool_double_std__string) -> bridge.Result_void_ {
|
|
343
355
|
do {
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ServiceData.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 `ServiceData`, backed by a C++ struct.
|
|
12
|
+
*/
|
|
13
|
+
public typealias ServiceData = margelo.nitro.co.zyke.ble.ServiceData
|
|
14
|
+
|
|
15
|
+
public extension ServiceData {
|
|
16
|
+
private typealias bridge = margelo.nitro.co.zyke.ble.bridge.swift
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create a new instance of `ServiceData`.
|
|
20
|
+
*/
|
|
21
|
+
init(services: [ServiceDataEntry]) {
|
|
22
|
+
self.init({ () -> bridge.std__vector_ServiceDataEntry_ in
|
|
23
|
+
var __vector = bridge.create_std__vector_ServiceDataEntry_(services.count)
|
|
24
|
+
for __item in services {
|
|
25
|
+
__vector.push_back(__item)
|
|
26
|
+
}
|
|
27
|
+
return __vector
|
|
28
|
+
}())
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@inline(__always)
|
|
32
|
+
var services: [ServiceDataEntry] {
|
|
33
|
+
return self.__services.map({ __item in __item })
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ServiceDataEntry.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 `ServiceDataEntry`, backed by a C++ struct.
|
|
12
|
+
*/
|
|
13
|
+
public typealias ServiceDataEntry = margelo.nitro.co.zyke.ble.ServiceDataEntry
|
|
14
|
+
|
|
15
|
+
public extension ServiceDataEntry {
|
|
16
|
+
private typealias bridge = margelo.nitro.co.zyke.ble.bridge.swift
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create a new instance of `ServiceDataEntry`.
|
|
20
|
+
*/
|
|
21
|
+
init(uuid: String, data: ArrayBuffer) {
|
|
22
|
+
self.init(std.string(uuid), data.getArrayBuffer())
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@inline(__always)
|
|
26
|
+
var uuid: String {
|
|
27
|
+
return String(self.__uuid)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@inline(__always)
|
|
31
|
+
var data: ArrayBuffer {
|
|
32
|
+
return ArrayBuffer(self.__data)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// AndroidConnectionPriority.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
|
+
|
|
21
|
+
namespace margelo::nitro::co::zyke::ble {
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* An enum which can be represented as a JavaScript enum (AndroidConnectionPriority).
|
|
25
|
+
*/
|
|
26
|
+
enum class AndroidConnectionPriority {
|
|
27
|
+
BALANCED SWIFT_NAME(balanced) = 0,
|
|
28
|
+
HIGH SWIFT_NAME(high) = 1,
|
|
29
|
+
LOWPOWER SWIFT_NAME(lowpower) = 2,
|
|
30
|
+
} CLOSED_ENUM;
|
|
31
|
+
|
|
32
|
+
} // namespace margelo::nitro::co::zyke::ble
|
|
33
|
+
|
|
34
|
+
namespace margelo::nitro {
|
|
35
|
+
|
|
36
|
+
// C++ AndroidConnectionPriority <> JS AndroidConnectionPriority (enum)
|
|
37
|
+
template <>
|
|
38
|
+
struct JSIConverter<margelo::nitro::co::zyke::ble::AndroidConnectionPriority> final {
|
|
39
|
+
static inline margelo::nitro::co::zyke::ble::AndroidConnectionPriority fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
40
|
+
int enumValue = JSIConverter<int>::fromJSI(runtime, arg);
|
|
41
|
+
return static_cast<margelo::nitro::co::zyke::ble::AndroidConnectionPriority>(enumValue);
|
|
42
|
+
}
|
|
43
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::co::zyke::ble::AndroidConnectionPriority arg) {
|
|
44
|
+
int enumValue = static_cast<int>(arg);
|
|
45
|
+
return JSIConverter<int>::toJSI(runtime, enumValue);
|
|
46
|
+
}
|
|
47
|
+
static inline bool canConvert(jsi::Runtime&, const jsi::Value& value) {
|
|
48
|
+
if (!value.isNumber()) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
double number = value.getNumber();
|
|
52
|
+
int integer = static_cast<int>(number);
|
|
53
|
+
if (number != integer) {
|
|
54
|
+
// The integer is not the same value as the double - we truncated floating points.
|
|
55
|
+
// Enums are all integers, so the input floating point number is obviously invalid.
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
// Check if we are within the bounds of the enum.
|
|
59
|
+
return integer >= 0 && integer <= 2;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
} // namespace margelo::nitro
|