react-native-ble-nitro 1.12.0 → 1.14.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 +38 -0
- package/android/src/main/java/com/margelo/nitro/co/zyke/ble/BleNitroBleManager.kt +33 -6
- package/ios/BleNitroBleManager.swift +35 -9
- package/lib/commonjs/index.d.ts +1 -1
- package/lib/commonjs/index.d.ts.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/manager.d.ts +8 -0
- package/lib/commonjs/manager.d.ts.map +1 -1
- package/lib/commonjs/manager.js +6 -0
- package/lib/commonjs/manager.js.map +1 -1
- package/lib/commonjs/specs/NativeBleNitro.nitro.d.ts +8 -0
- package/lib/commonjs/specs/NativeBleNitro.nitro.d.ts.map +1 -1
- package/lib/commonjs/specs/NativeBleNitro.nitro.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/manager.d.ts +8 -0
- package/lib/manager.js +6 -0
- package/lib/specs/NativeBleNitro.nitro.d.ts +8 -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 +8 -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/BLEDevice.kt +5 -2
- 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 +6 -0
- package/nitrogen/generated/ios/c++/HybridNativeBleNitroFactorySpecSwift.hpp +6 -0
- package/nitrogen/generated/ios/c++/HybridNativeBleNitroSpecSwift.hpp +6 -0
- package/nitrogen/generated/ios/swift/BLEDevice.swift +7 -2
- package/nitrogen/generated/ios/swift/ServiceData.swift +35 -0
- package/nitrogen/generated/ios/swift/ServiceDataEntry.swift +34 -0
- package/nitrogen/generated/shared/c++/BLEDevice.hpp +8 -1
- 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 +37 -0
- package/src/index.ts +2 -0
- package/src/manager.ts +16 -0
- package/src/specs/NativeBleNitro.nitro.ts +10 -0
|
@@ -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
|
|
|
@@ -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
|
}
|
|
@@ -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>`.
|
|
@@ -26,6 +26,10 @@ namespace margelo::nitro::co::zyke::ble { struct ManufacturerData; }
|
|
|
26
26
|
namespace margelo::nitro::co::zyke::ble { struct OperationResult; }
|
|
27
27
|
// Forward declaration of `ScanFilter` to properly resolve imports.
|
|
28
28
|
namespace margelo::nitro::co::zyke::ble { struct ScanFilter; }
|
|
29
|
+
// Forward declaration of `ServiceDataEntry` to properly resolve imports.
|
|
30
|
+
namespace margelo::nitro::co::zyke::ble { struct ServiceDataEntry; }
|
|
31
|
+
// Forward declaration of `ServiceData` to properly resolve imports.
|
|
32
|
+
namespace margelo::nitro::co::zyke::ble { struct ServiceData; }
|
|
29
33
|
|
|
30
34
|
// Include C++ defined types
|
|
31
35
|
#include "AndroidScanMode.hpp"
|
|
@@ -37,6 +41,8 @@ namespace margelo::nitro::co::zyke::ble { struct ScanFilter; }
|
|
|
37
41
|
#include "ManufacturerDataEntry.hpp"
|
|
38
42
|
#include "OperationResult.hpp"
|
|
39
43
|
#include "ScanFilter.hpp"
|
|
44
|
+
#include "ServiceData.hpp"
|
|
45
|
+
#include "ServiceDataEntry.hpp"
|
|
40
46
|
#include <NitroModules/ArrayBuffer.hpp>
|
|
41
47
|
#include <NitroModules/Null.hpp>
|
|
42
48
|
#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,6 +20,10 @@ 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.
|
|
@@ -38,6 +42,8 @@ namespace margelo::nitro::co::zyke::ble { struct OperationResult; }
|
|
|
38
42
|
#include "ManufacturerDataEntry.hpp"
|
|
39
43
|
#include <NitroModules/ArrayBuffer.hpp>
|
|
40
44
|
#include <NitroModules/ArrayBufferHolder.hpp>
|
|
45
|
+
#include "ServiceData.hpp"
|
|
46
|
+
#include "ServiceDataEntry.hpp"
|
|
41
47
|
#include "ScanFilter.hpp"
|
|
42
48
|
#include "AndroidScanMode.hpp"
|
|
43
49
|
#include <NitroModules/Null.hpp>
|
|
@@ -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) })
|
|
@@ -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
|
+
}
|
|
@@ -30,9 +30,12 @@
|
|
|
30
30
|
|
|
31
31
|
// Forward declaration of `ManufacturerData` to properly resolve imports.
|
|
32
32
|
namespace margelo::nitro::co::zyke::ble { struct ManufacturerData; }
|
|
33
|
+
// Forward declaration of `ServiceData` to properly resolve imports.
|
|
34
|
+
namespace margelo::nitro::co::zyke::ble { struct ServiceData; }
|
|
33
35
|
|
|
34
36
|
#include <string>
|
|
35
37
|
#include "ManufacturerData.hpp"
|
|
38
|
+
#include "ServiceData.hpp"
|
|
36
39
|
#include <vector>
|
|
37
40
|
|
|
38
41
|
namespace margelo::nitro::co::zyke::ble {
|
|
@@ -46,13 +49,14 @@ namespace margelo::nitro::co::zyke::ble {
|
|
|
46
49
|
std::string name SWIFT_PRIVATE;
|
|
47
50
|
double rssi SWIFT_PRIVATE;
|
|
48
51
|
ManufacturerData manufacturerData SWIFT_PRIVATE;
|
|
52
|
+
ServiceData serviceData SWIFT_PRIVATE;
|
|
49
53
|
std::vector<std::string> serviceUUIDs SWIFT_PRIVATE;
|
|
50
54
|
bool isConnectable SWIFT_PRIVATE;
|
|
51
55
|
bool isConnected SWIFT_PRIVATE;
|
|
52
56
|
|
|
53
57
|
public:
|
|
54
58
|
BLEDevice() = default;
|
|
55
|
-
explicit BLEDevice(std::string id, std::string name, double rssi, ManufacturerData manufacturerData, std::vector<std::string> serviceUUIDs, bool isConnectable, bool isConnected): id(id), name(name), rssi(rssi), manufacturerData(manufacturerData), serviceUUIDs(serviceUUIDs), isConnectable(isConnectable), isConnected(isConnected) {}
|
|
59
|
+
explicit BLEDevice(std::string id, std::string name, double rssi, ManufacturerData manufacturerData, ServiceData serviceData, std::vector<std::string> serviceUUIDs, bool isConnectable, bool isConnected): id(id), name(name), rssi(rssi), manufacturerData(manufacturerData), serviceData(serviceData), serviceUUIDs(serviceUUIDs), isConnectable(isConnectable), isConnected(isConnected) {}
|
|
56
60
|
|
|
57
61
|
public:
|
|
58
62
|
friend bool operator==(const BLEDevice& lhs, const BLEDevice& rhs) = default;
|
|
@@ -72,6 +76,7 @@ namespace margelo::nitro {
|
|
|
72
76
|
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "name"))),
|
|
73
77
|
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "rssi"))),
|
|
74
78
|
JSIConverter<margelo::nitro::co::zyke::ble::ManufacturerData>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "manufacturerData"))),
|
|
79
|
+
JSIConverter<margelo::nitro::co::zyke::ble::ServiceData>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "serviceData"))),
|
|
75
80
|
JSIConverter<std::vector<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "serviceUUIDs"))),
|
|
76
81
|
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isConnectable"))),
|
|
77
82
|
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isConnected")))
|
|
@@ -83,6 +88,7 @@ namespace margelo::nitro {
|
|
|
83
88
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "name"), JSIConverter<std::string>::toJSI(runtime, arg.name));
|
|
84
89
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "rssi"), JSIConverter<double>::toJSI(runtime, arg.rssi));
|
|
85
90
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "manufacturerData"), JSIConverter<margelo::nitro::co::zyke::ble::ManufacturerData>::toJSI(runtime, arg.manufacturerData));
|
|
91
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "serviceData"), JSIConverter<margelo::nitro::co::zyke::ble::ServiceData>::toJSI(runtime, arg.serviceData));
|
|
86
92
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "serviceUUIDs"), JSIConverter<std::vector<std::string>>::toJSI(runtime, arg.serviceUUIDs));
|
|
87
93
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "isConnectable"), JSIConverter<bool>::toJSI(runtime, arg.isConnectable));
|
|
88
94
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "isConnected"), JSIConverter<bool>::toJSI(runtime, arg.isConnected));
|
|
@@ -100,6 +106,7 @@ namespace margelo::nitro {
|
|
|
100
106
|
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "name")))) return false;
|
|
101
107
|
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "rssi")))) return false;
|
|
102
108
|
if (!JSIConverter<margelo::nitro::co::zyke::ble::ManufacturerData>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "manufacturerData")))) return false;
|
|
109
|
+
if (!JSIConverter<margelo::nitro::co::zyke::ble::ServiceData>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "serviceData")))) return false;
|
|
103
110
|
if (!JSIConverter<std::vector<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "serviceUUIDs")))) return false;
|
|
104
111
|
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isConnectable")))) return false;
|
|
105
112
|
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isConnected")))) return false;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ServiceData.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 `ServiceDataEntry` to properly resolve imports.
|
|
32
|
+
namespace margelo::nitro::co::zyke::ble { struct ServiceDataEntry; }
|
|
33
|
+
|
|
34
|
+
#include "ServiceDataEntry.hpp"
|
|
35
|
+
#include <vector>
|
|
36
|
+
|
|
37
|
+
namespace margelo::nitro::co::zyke::ble {
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* A struct which can be represented as a JavaScript object (ServiceData).
|
|
41
|
+
*/
|
|
42
|
+
struct ServiceData final {
|
|
43
|
+
public:
|
|
44
|
+
std::vector<ServiceDataEntry> services SWIFT_PRIVATE;
|
|
45
|
+
|
|
46
|
+
public:
|
|
47
|
+
ServiceData() = default;
|
|
48
|
+
explicit ServiceData(std::vector<ServiceDataEntry> services): services(services) {}
|
|
49
|
+
|
|
50
|
+
public:
|
|
51
|
+
friend bool operator==(const ServiceData& lhs, const ServiceData& rhs) = default;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
} // namespace margelo::nitro::co::zyke::ble
|
|
55
|
+
|
|
56
|
+
namespace margelo::nitro {
|
|
57
|
+
|
|
58
|
+
// C++ ServiceData <> JS ServiceData (object)
|
|
59
|
+
template <>
|
|
60
|
+
struct JSIConverter<margelo::nitro::co::zyke::ble::ServiceData> final {
|
|
61
|
+
static inline margelo::nitro::co::zyke::ble::ServiceData fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
62
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
63
|
+
return margelo::nitro::co::zyke::ble::ServiceData(
|
|
64
|
+
JSIConverter<std::vector<margelo::nitro::co::zyke::ble::ServiceDataEntry>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "services")))
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::co::zyke::ble::ServiceData& arg) {
|
|
68
|
+
jsi::Object obj(runtime);
|
|
69
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "services"), JSIConverter<std::vector<margelo::nitro::co::zyke::ble::ServiceDataEntry>>::toJSI(runtime, arg.services));
|
|
70
|
+
return obj;
|
|
71
|
+
}
|
|
72
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
73
|
+
if (!value.isObject()) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
jsi::Object obj = value.getObject(runtime);
|
|
77
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
if (!JSIConverter<std::vector<margelo::nitro::co::zyke::ble::ServiceDataEntry>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "services")))) return false;
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
} // namespace margelo::nitro
|