munim-bluetooth 0.2.7 → 0.3.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/MunimBluetooth.podspec +1 -0
- package/lib/typescript/src/specs/munim-bluetooth.nitro.d.ts +24 -25
- package/lib/typescript/src/specs/munim-bluetooth.nitro.d.ts.map +1 -1
- package/nitrogen/generated/.gitattributes +1 -0
- package/nitrogen/generated/android/MunimBluetooth+autolinking.cmake +81 -0
- package/nitrogen/generated/android/MunimBluetooth+autolinking.gradle +27 -0
- package/nitrogen/generated/android/MunimBluetoothOnLoad.cpp +44 -0
- package/nitrogen/generated/android/MunimBluetoothOnLoad.hpp +25 -0
- package/nitrogen/generated/android/c++/JAdvertisingDataTypes.hpp +345 -0
- package/nitrogen/generated/android/c++/JAdvertisingOptions.hpp +93 -0
- package/nitrogen/generated/android/c++/JCharacteristicValue.hpp +65 -0
- package/nitrogen/generated/android/c++/JGATTCharacteristic.hpp +85 -0
- package/nitrogen/generated/android/c++/JGATTService.hpp +83 -0
- package/nitrogen/generated/android/c++/JHybridMunimBluetoothSpec.cpp +307 -0
- package/nitrogen/generated/android/c++/JHybridMunimBluetoothSpec.hpp +85 -0
- package/nitrogen/generated/android/c++/JScanMode.hpp +61 -0
- package/nitrogen/generated/android/c++/JScanOptions.hpp +87 -0
- package/nitrogen/generated/android/c++/JServiceDataEntry.hpp +61 -0
- package/nitrogen/generated/android/c++/JWriteType.hpp +58 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/AdvertisingDataTypes.kt +89 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/AdvertisingOptions.kt +47 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/CharacteristicValue.kt +44 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/GATTCharacteristic.kt +44 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/GATTService.kt +41 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/HybridMunimBluetoothSpec.kt +134 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/MunimBluetoothOnLoad.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/ScanMode.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/ScanOptions.kt +44 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/ServiceDataEntry.kt +41 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/WriteType.kt +23 -0
- package/nitrogen/generated/ios/MunimBluetooth+autolinking.rb +60 -0
- package/nitrogen/generated/ios/MunimBluetooth-Swift-Cxx-Bridge.cpp +97 -0
- package/nitrogen/generated/ios/MunimBluetooth-Swift-Cxx-Bridge.hpp +583 -0
- package/nitrogen/generated/ios/MunimBluetooth-Swift-Cxx-Umbrella.hpp +74 -0
- package/nitrogen/generated/ios/MunimBluetoothAutolinking.mm +33 -0
- package/nitrogen/generated/ios/MunimBluetoothAutolinking.swift +44 -0
- package/nitrogen/generated/ios/c++/HybridMunimBluetoothSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridMunimBluetoothSpecSwift.hpp +241 -0
- package/nitrogen/generated/ios/swift/AdvertisingDataTypes.swift +400 -0
- package/nitrogen/generated/ios/swift/AdvertisingOptions.swift +83 -0
- package/nitrogen/generated/ios/swift/CharacteristicValue.swift +40 -0
- package/nitrogen/generated/ios/swift/Func_void.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_AdvertisingDataTypes.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_CharacteristicValue.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_bool.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_double.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_GATTService_.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_std__string_.swift +47 -0
- package/nitrogen/generated/ios/swift/GATTCharacteristic.swift +59 -0
- package/nitrogen/generated/ios/swift/GATTService.swift +41 -0
- package/nitrogen/generated/ios/swift/HybridMunimBluetoothSpec.swift +75 -0
- package/nitrogen/generated/ios/swift/HybridMunimBluetoothSpec_cxx.swift +431 -0
- package/nitrogen/generated/ios/swift/ScanMode.swift +44 -0
- package/nitrogen/generated/ios/swift/ScanOptions.swift +78 -0
- package/nitrogen/generated/ios/swift/ServiceDataEntry.swift +35 -0
- package/nitrogen/generated/ios/swift/WriteType.swift +40 -0
- package/nitrogen/generated/shared/c++/AdvertisingDataTypes.hpp +155 -0
- package/nitrogen/generated/shared/c++/AdvertisingOptions.hpp +99 -0
- package/nitrogen/generated/shared/c++/CharacteristicValue.hpp +91 -0
- package/nitrogen/generated/shared/c++/GATTCharacteristic.hpp +93 -0
- package/nitrogen/generated/shared/c++/GATTService.hpp +90 -0
- package/nitrogen/generated/shared/c++/HybridMunimBluetoothSpec.cpp +40 -0
- package/nitrogen/generated/shared/c++/HybridMunimBluetoothSpec.hpp +101 -0
- package/nitrogen/generated/shared/c++/ScanMode.hpp +80 -0
- package/nitrogen/generated/shared/c++/ScanOptions.hpp +95 -0
- package/nitrogen/generated/shared/c++/ServiceDataEntry.hpp +87 -0
- package/nitrogen/generated/shared/c++/WriteType.hpp +76 -0
- package/package.json +9 -9
- package/src/specs/munim-bluetooth.nitro.ts +34 -25
- package/lib/module/package.json +0 -1
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JAdvertisingOptions.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 "AdvertisingOptions.hpp"
|
|
12
|
+
|
|
13
|
+
#include "AdvertisingDataTypes.hpp"
|
|
14
|
+
#include "JAdvertisingDataTypes.hpp"
|
|
15
|
+
#include "JServiceDataEntry.hpp"
|
|
16
|
+
#include "ServiceDataEntry.hpp"
|
|
17
|
+
#include <optional>
|
|
18
|
+
#include <string>
|
|
19
|
+
#include <vector>
|
|
20
|
+
|
|
21
|
+
namespace margelo::nitro::munimbluetooth {
|
|
22
|
+
|
|
23
|
+
using namespace facebook;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The C++ JNI bridge between the C++ struct "AdvertisingOptions" and the the Kotlin data class "AdvertisingOptions".
|
|
27
|
+
*/
|
|
28
|
+
struct JAdvertisingOptions final: public jni::JavaClass<JAdvertisingOptions> {
|
|
29
|
+
public:
|
|
30
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/AdvertisingOptions;";
|
|
31
|
+
|
|
32
|
+
public:
|
|
33
|
+
/**
|
|
34
|
+
* Convert this Java/Kotlin-based struct to the C++ struct AdvertisingOptions by copying all values to C++.
|
|
35
|
+
*/
|
|
36
|
+
[[maybe_unused]]
|
|
37
|
+
[[nodiscard]]
|
|
38
|
+
AdvertisingOptions toCpp() const {
|
|
39
|
+
static const auto clazz = javaClassStatic();
|
|
40
|
+
static const auto fieldServiceUUIDs = clazz->getField<jni::JArrayClass<jni::JString>>("serviceUUIDs");
|
|
41
|
+
jni::local_ref<jni::JArrayClass<jni::JString>> serviceUUIDs = this->getFieldValue(fieldServiceUUIDs);
|
|
42
|
+
static const auto fieldLocalName = clazz->getField<jni::JString>("localName");
|
|
43
|
+
jni::local_ref<jni::JString> localName = this->getFieldValue(fieldLocalName);
|
|
44
|
+
static const auto fieldManufacturerData = clazz->getField<jni::JString>("manufacturerData");
|
|
45
|
+
jni::local_ref<jni::JString> manufacturerData = this->getFieldValue(fieldManufacturerData);
|
|
46
|
+
static const auto fieldAdvertisingData = clazz->getField<JAdvertisingDataTypes>("advertisingData");
|
|
47
|
+
jni::local_ref<JAdvertisingDataTypes> advertisingData = this->getFieldValue(fieldAdvertisingData);
|
|
48
|
+
return AdvertisingOptions(
|
|
49
|
+
[&]() {
|
|
50
|
+
size_t __size = serviceUUIDs->size();
|
|
51
|
+
std::vector<std::string> __vector;
|
|
52
|
+
__vector.reserve(__size);
|
|
53
|
+
for (size_t __i = 0; __i < __size; __i++) {
|
|
54
|
+
auto __element = serviceUUIDs->getElement(__i);
|
|
55
|
+
__vector.push_back(__element->toStdString());
|
|
56
|
+
}
|
|
57
|
+
return __vector;
|
|
58
|
+
}(),
|
|
59
|
+
localName != nullptr ? std::make_optional(localName->toStdString()) : std::nullopt,
|
|
60
|
+
manufacturerData != nullptr ? std::make_optional(manufacturerData->toStdString()) : std::nullopt,
|
|
61
|
+
advertisingData != nullptr ? std::make_optional(advertisingData->toCpp()) : std::nullopt
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
public:
|
|
66
|
+
/**
|
|
67
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
68
|
+
*/
|
|
69
|
+
[[maybe_unused]]
|
|
70
|
+
static jni::local_ref<JAdvertisingOptions::javaobject> fromCpp(const AdvertisingOptions& value) {
|
|
71
|
+
using JSignature = JAdvertisingOptions(jni::alias_ref<jni::JArrayClass<jni::JString>>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<JAdvertisingDataTypes>);
|
|
72
|
+
static const auto clazz = javaClassStatic();
|
|
73
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
74
|
+
return create(
|
|
75
|
+
clazz,
|
|
76
|
+
[&]() {
|
|
77
|
+
size_t __size = value.serviceUUIDs.size();
|
|
78
|
+
jni::local_ref<jni::JArrayClass<jni::JString>> __array = jni::JArrayClass<jni::JString>::newArray(__size);
|
|
79
|
+
for (size_t __i = 0; __i < __size; __i++) {
|
|
80
|
+
const auto& __element = value.serviceUUIDs[__i];
|
|
81
|
+
auto __elementJni = jni::make_jstring(__element);
|
|
82
|
+
__array->setElement(__i, *__elementJni);
|
|
83
|
+
}
|
|
84
|
+
return __array;
|
|
85
|
+
}(),
|
|
86
|
+
value.localName.has_value() ? jni::make_jstring(value.localName.value()) : nullptr,
|
|
87
|
+
value.manufacturerData.has_value() ? jni::make_jstring(value.manufacturerData.value()) : nullptr,
|
|
88
|
+
value.advertisingData.has_value() ? JAdvertisingDataTypes::fromCpp(value.advertisingData.value()) : nullptr
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
} // namespace margelo::nitro::munimbluetooth
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JCharacteristicValue.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 "CharacteristicValue.hpp"
|
|
12
|
+
|
|
13
|
+
#include <string>
|
|
14
|
+
|
|
15
|
+
namespace margelo::nitro::munimbluetooth {
|
|
16
|
+
|
|
17
|
+
using namespace facebook;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The C++ JNI bridge between the C++ struct "CharacteristicValue" and the the Kotlin data class "CharacteristicValue".
|
|
21
|
+
*/
|
|
22
|
+
struct JCharacteristicValue final: public jni::JavaClass<JCharacteristicValue> {
|
|
23
|
+
public:
|
|
24
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/CharacteristicValue;";
|
|
25
|
+
|
|
26
|
+
public:
|
|
27
|
+
/**
|
|
28
|
+
* Convert this Java/Kotlin-based struct to the C++ struct CharacteristicValue by copying all values to C++.
|
|
29
|
+
*/
|
|
30
|
+
[[maybe_unused]]
|
|
31
|
+
[[nodiscard]]
|
|
32
|
+
CharacteristicValue toCpp() const {
|
|
33
|
+
static const auto clazz = javaClassStatic();
|
|
34
|
+
static const auto fieldValue = clazz->getField<jni::JString>("value");
|
|
35
|
+
jni::local_ref<jni::JString> value = this->getFieldValue(fieldValue);
|
|
36
|
+
static const auto fieldServiceUUID = clazz->getField<jni::JString>("serviceUUID");
|
|
37
|
+
jni::local_ref<jni::JString> serviceUUID = this->getFieldValue(fieldServiceUUID);
|
|
38
|
+
static const auto fieldCharacteristicUUID = clazz->getField<jni::JString>("characteristicUUID");
|
|
39
|
+
jni::local_ref<jni::JString> characteristicUUID = this->getFieldValue(fieldCharacteristicUUID);
|
|
40
|
+
return CharacteristicValue(
|
|
41
|
+
value->toStdString(),
|
|
42
|
+
serviceUUID->toStdString(),
|
|
43
|
+
characteristicUUID->toStdString()
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public:
|
|
48
|
+
/**
|
|
49
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
50
|
+
*/
|
|
51
|
+
[[maybe_unused]]
|
|
52
|
+
static jni::local_ref<JCharacteristicValue::javaobject> fromCpp(const CharacteristicValue& value) {
|
|
53
|
+
using JSignature = JCharacteristicValue(jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>);
|
|
54
|
+
static const auto clazz = javaClassStatic();
|
|
55
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
56
|
+
return create(
|
|
57
|
+
clazz,
|
|
58
|
+
jni::make_jstring(value.value),
|
|
59
|
+
jni::make_jstring(value.serviceUUID),
|
|
60
|
+
jni::make_jstring(value.characteristicUUID)
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
} // namespace margelo::nitro::munimbluetooth
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JGATTCharacteristic.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 "GATTCharacteristic.hpp"
|
|
12
|
+
|
|
13
|
+
#include <optional>
|
|
14
|
+
#include <string>
|
|
15
|
+
#include <vector>
|
|
16
|
+
|
|
17
|
+
namespace margelo::nitro::munimbluetooth {
|
|
18
|
+
|
|
19
|
+
using namespace facebook;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The C++ JNI bridge between the C++ struct "GATTCharacteristic" and the the Kotlin data class "GATTCharacteristic".
|
|
23
|
+
*/
|
|
24
|
+
struct JGATTCharacteristic final: public jni::JavaClass<JGATTCharacteristic> {
|
|
25
|
+
public:
|
|
26
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/GATTCharacteristic;";
|
|
27
|
+
|
|
28
|
+
public:
|
|
29
|
+
/**
|
|
30
|
+
* Convert this Java/Kotlin-based struct to the C++ struct GATTCharacteristic by copying all values to C++.
|
|
31
|
+
*/
|
|
32
|
+
[[maybe_unused]]
|
|
33
|
+
[[nodiscard]]
|
|
34
|
+
GATTCharacteristic 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 fieldProperties = clazz->getField<jni::JArrayClass<jni::JString>>("properties");
|
|
39
|
+
jni::local_ref<jni::JArrayClass<jni::JString>> properties = this->getFieldValue(fieldProperties);
|
|
40
|
+
static const auto fieldValue = clazz->getField<jni::JString>("value");
|
|
41
|
+
jni::local_ref<jni::JString> value = this->getFieldValue(fieldValue);
|
|
42
|
+
return GATTCharacteristic(
|
|
43
|
+
uuid->toStdString(),
|
|
44
|
+
[&]() {
|
|
45
|
+
size_t __size = properties->size();
|
|
46
|
+
std::vector<std::string> __vector;
|
|
47
|
+
__vector.reserve(__size);
|
|
48
|
+
for (size_t __i = 0; __i < __size; __i++) {
|
|
49
|
+
auto __element = properties->getElement(__i);
|
|
50
|
+
__vector.push_back(__element->toStdString());
|
|
51
|
+
}
|
|
52
|
+
return __vector;
|
|
53
|
+
}(),
|
|
54
|
+
value != nullptr ? std::make_optional(value->toStdString()) : std::nullopt
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public:
|
|
59
|
+
/**
|
|
60
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
61
|
+
*/
|
|
62
|
+
[[maybe_unused]]
|
|
63
|
+
static jni::local_ref<JGATTCharacteristic::javaobject> fromCpp(const GATTCharacteristic& value) {
|
|
64
|
+
using JSignature = JGATTCharacteristic(jni::alias_ref<jni::JString>, jni::alias_ref<jni::JArrayClass<jni::JString>>, jni::alias_ref<jni::JString>);
|
|
65
|
+
static const auto clazz = javaClassStatic();
|
|
66
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
67
|
+
return create(
|
|
68
|
+
clazz,
|
|
69
|
+
jni::make_jstring(value.uuid),
|
|
70
|
+
[&]() {
|
|
71
|
+
size_t __size = value.properties.size();
|
|
72
|
+
jni::local_ref<jni::JArrayClass<jni::JString>> __array = jni::JArrayClass<jni::JString>::newArray(__size);
|
|
73
|
+
for (size_t __i = 0; __i < __size; __i++) {
|
|
74
|
+
const auto& __element = value.properties[__i];
|
|
75
|
+
auto __elementJni = jni::make_jstring(__element);
|
|
76
|
+
__array->setElement(__i, *__elementJni);
|
|
77
|
+
}
|
|
78
|
+
return __array;
|
|
79
|
+
}(),
|
|
80
|
+
value.value.has_value() ? jni::make_jstring(value.value.value()) : nullptr
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
} // namespace margelo::nitro::munimbluetooth
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JGATTService.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 "GATTService.hpp"
|
|
12
|
+
|
|
13
|
+
#include "GATTCharacteristic.hpp"
|
|
14
|
+
#include "JGATTCharacteristic.hpp"
|
|
15
|
+
#include <optional>
|
|
16
|
+
#include <string>
|
|
17
|
+
#include <vector>
|
|
18
|
+
|
|
19
|
+
namespace margelo::nitro::munimbluetooth {
|
|
20
|
+
|
|
21
|
+
using namespace facebook;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The C++ JNI bridge between the C++ struct "GATTService" and the the Kotlin data class "GATTService".
|
|
25
|
+
*/
|
|
26
|
+
struct JGATTService final: public jni::JavaClass<JGATTService> {
|
|
27
|
+
public:
|
|
28
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/GATTService;";
|
|
29
|
+
|
|
30
|
+
public:
|
|
31
|
+
/**
|
|
32
|
+
* Convert this Java/Kotlin-based struct to the C++ struct GATTService by copying all values to C++.
|
|
33
|
+
*/
|
|
34
|
+
[[maybe_unused]]
|
|
35
|
+
[[nodiscard]]
|
|
36
|
+
GATTService toCpp() const {
|
|
37
|
+
static const auto clazz = javaClassStatic();
|
|
38
|
+
static const auto fieldUuid = clazz->getField<jni::JString>("uuid");
|
|
39
|
+
jni::local_ref<jni::JString> uuid = this->getFieldValue(fieldUuid);
|
|
40
|
+
static const auto fieldCharacteristics = clazz->getField<jni::JArrayClass<JGATTCharacteristic>>("characteristics");
|
|
41
|
+
jni::local_ref<jni::JArrayClass<JGATTCharacteristic>> characteristics = this->getFieldValue(fieldCharacteristics);
|
|
42
|
+
return GATTService(
|
|
43
|
+
uuid->toStdString(),
|
|
44
|
+
[&]() {
|
|
45
|
+
size_t __size = characteristics->size();
|
|
46
|
+
std::vector<GATTCharacteristic> __vector;
|
|
47
|
+
__vector.reserve(__size);
|
|
48
|
+
for (size_t __i = 0; __i < __size; __i++) {
|
|
49
|
+
auto __element = characteristics->getElement(__i);
|
|
50
|
+
__vector.push_back(__element->toCpp());
|
|
51
|
+
}
|
|
52
|
+
return __vector;
|
|
53
|
+
}()
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public:
|
|
58
|
+
/**
|
|
59
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
60
|
+
*/
|
|
61
|
+
[[maybe_unused]]
|
|
62
|
+
static jni::local_ref<JGATTService::javaobject> fromCpp(const GATTService& value) {
|
|
63
|
+
using JSignature = JGATTService(jni::alias_ref<jni::JString>, jni::alias_ref<jni::JArrayClass<JGATTCharacteristic>>);
|
|
64
|
+
static const auto clazz = javaClassStatic();
|
|
65
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
66
|
+
return create(
|
|
67
|
+
clazz,
|
|
68
|
+
jni::make_jstring(value.uuid),
|
|
69
|
+
[&]() {
|
|
70
|
+
size_t __size = value.characteristics.size();
|
|
71
|
+
jni::local_ref<jni::JArrayClass<JGATTCharacteristic>> __array = jni::JArrayClass<JGATTCharacteristic>::newArray(__size);
|
|
72
|
+
for (size_t __i = 0; __i < __size; __i++) {
|
|
73
|
+
const auto& __element = value.characteristics[__i];
|
|
74
|
+
auto __elementJni = JGATTCharacteristic::fromCpp(__element);
|
|
75
|
+
__array->setElement(__i, *__elementJni);
|
|
76
|
+
}
|
|
77
|
+
return __array;
|
|
78
|
+
}()
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
} // namespace margelo::nitro::munimbluetooth
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JHybridMunimBluetoothSpec.cpp
|
|
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
|
+
#include "JHybridMunimBluetoothSpec.hpp"
|
|
9
|
+
|
|
10
|
+
// Forward declaration of `AdvertisingDataTypes` to properly resolve imports.
|
|
11
|
+
namespace margelo::nitro::munimbluetooth { struct AdvertisingDataTypes; }
|
|
12
|
+
// Forward declaration of `ServiceDataEntry` to properly resolve imports.
|
|
13
|
+
namespace margelo::nitro::munimbluetooth { struct ServiceDataEntry; }
|
|
14
|
+
// Forward declaration of `GATTService` to properly resolve imports.
|
|
15
|
+
namespace margelo::nitro::munimbluetooth { struct GATTService; }
|
|
16
|
+
// Forward declaration of `GATTCharacteristic` to properly resolve imports.
|
|
17
|
+
namespace margelo::nitro::munimbluetooth { struct GATTCharacteristic; }
|
|
18
|
+
// Forward declaration of `CharacteristicValue` to properly resolve imports.
|
|
19
|
+
namespace margelo::nitro::munimbluetooth { struct CharacteristicValue; }
|
|
20
|
+
// Forward declaration of `AdvertisingOptions` to properly resolve imports.
|
|
21
|
+
namespace margelo::nitro::munimbluetooth { struct AdvertisingOptions; }
|
|
22
|
+
// Forward declaration of `ScanOptions` to properly resolve imports.
|
|
23
|
+
namespace margelo::nitro::munimbluetooth { struct ScanOptions; }
|
|
24
|
+
// Forward declaration of `ScanMode` to properly resolve imports.
|
|
25
|
+
namespace margelo::nitro::munimbluetooth { enum class ScanMode; }
|
|
26
|
+
// Forward declaration of `WriteType` to properly resolve imports.
|
|
27
|
+
namespace margelo::nitro::munimbluetooth { enum class WriteType; }
|
|
28
|
+
|
|
29
|
+
#include "AdvertisingDataTypes.hpp"
|
|
30
|
+
#include <NitroModules/Promise.hpp>
|
|
31
|
+
#include <NitroModules/JPromise.hpp>
|
|
32
|
+
#include "JAdvertisingDataTypes.hpp"
|
|
33
|
+
#include <optional>
|
|
34
|
+
#include <string>
|
|
35
|
+
#include <vector>
|
|
36
|
+
#include "ServiceDataEntry.hpp"
|
|
37
|
+
#include "JServiceDataEntry.hpp"
|
|
38
|
+
#include <NitroModules/JUnit.hpp>
|
|
39
|
+
#include "GATTService.hpp"
|
|
40
|
+
#include "JGATTService.hpp"
|
|
41
|
+
#include "GATTCharacteristic.hpp"
|
|
42
|
+
#include "JGATTCharacteristic.hpp"
|
|
43
|
+
#include "CharacteristicValue.hpp"
|
|
44
|
+
#include "JCharacteristicValue.hpp"
|
|
45
|
+
#include "AdvertisingOptions.hpp"
|
|
46
|
+
#include "JAdvertisingOptions.hpp"
|
|
47
|
+
#include "ScanOptions.hpp"
|
|
48
|
+
#include "JScanOptions.hpp"
|
|
49
|
+
#include "ScanMode.hpp"
|
|
50
|
+
#include "JScanMode.hpp"
|
|
51
|
+
#include "WriteType.hpp"
|
|
52
|
+
#include "JWriteType.hpp"
|
|
53
|
+
|
|
54
|
+
namespace margelo::nitro::munimbluetooth {
|
|
55
|
+
|
|
56
|
+
jni::local_ref<JHybridMunimBluetoothSpec::jhybriddata> JHybridMunimBluetoothSpec::initHybrid(jni::alias_ref<jhybridobject> jThis) {
|
|
57
|
+
return makeCxxInstance(jThis);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
void JHybridMunimBluetoothSpec::registerNatives() {
|
|
61
|
+
registerHybrid({
|
|
62
|
+
makeNativeMethod("initHybrid", JHybridMunimBluetoothSpec::initHybrid),
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
size_t JHybridMunimBluetoothSpec::getExternalMemorySize() noexcept {
|
|
67
|
+
static const auto method = javaClassStatic()->getMethod<jlong()>("getMemorySize");
|
|
68
|
+
return method(_javaPart);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
bool JHybridMunimBluetoothSpec::equals(const std::shared_ptr<HybridObject>& other) {
|
|
72
|
+
if (auto otherCast = std::dynamic_pointer_cast<JHybridMunimBluetoothSpec>(other)) {
|
|
73
|
+
return _javaPart == otherCast->_javaPart;
|
|
74
|
+
}
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
void JHybridMunimBluetoothSpec::dispose() noexcept {
|
|
79
|
+
static const auto method = javaClassStatic()->getMethod<void()>("dispose");
|
|
80
|
+
method(_javaPart);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
std::string JHybridMunimBluetoothSpec::toString() {
|
|
84
|
+
static const auto method = javaClassStatic()->getMethod<jni::JString()>("toString");
|
|
85
|
+
auto javaString = method(_javaPart);
|
|
86
|
+
return javaString->toStdString();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Properties
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
// Methods
|
|
93
|
+
void JHybridMunimBluetoothSpec::startAdvertising(const AdvertisingOptions& options) {
|
|
94
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JAdvertisingOptions> /* options */)>("startAdvertising");
|
|
95
|
+
method(_javaPart, JAdvertisingOptions::fromCpp(options));
|
|
96
|
+
}
|
|
97
|
+
void JHybridMunimBluetoothSpec::updateAdvertisingData(const AdvertisingDataTypes& advertisingData) {
|
|
98
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JAdvertisingDataTypes> /* advertisingData */)>("updateAdvertisingData");
|
|
99
|
+
method(_javaPart, JAdvertisingDataTypes::fromCpp(advertisingData));
|
|
100
|
+
}
|
|
101
|
+
std::shared_ptr<Promise<AdvertisingDataTypes>> JHybridMunimBluetoothSpec::getAdvertisingData() {
|
|
102
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("getAdvertisingData");
|
|
103
|
+
auto __result = method(_javaPart);
|
|
104
|
+
return [&]() {
|
|
105
|
+
auto __promise = Promise<AdvertisingDataTypes>::create();
|
|
106
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
107
|
+
auto __result = jni::static_ref_cast<JAdvertisingDataTypes>(__boxedResult);
|
|
108
|
+
__promise->resolve(__result->toCpp());
|
|
109
|
+
});
|
|
110
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
111
|
+
jni::JniException __jniError(__throwable);
|
|
112
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
113
|
+
});
|
|
114
|
+
return __promise;
|
|
115
|
+
}();
|
|
116
|
+
}
|
|
117
|
+
void JHybridMunimBluetoothSpec::stopAdvertising() {
|
|
118
|
+
static const auto method = javaClassStatic()->getMethod<void()>("stopAdvertising");
|
|
119
|
+
method(_javaPart);
|
|
120
|
+
}
|
|
121
|
+
void JHybridMunimBluetoothSpec::setServices(const std::vector<GATTService>& services) {
|
|
122
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JArrayClass<JGATTService>> /* services */)>("setServices");
|
|
123
|
+
method(_javaPart, [&]() {
|
|
124
|
+
size_t __size = services.size();
|
|
125
|
+
jni::local_ref<jni::JArrayClass<JGATTService>> __array = jni::JArrayClass<JGATTService>::newArray(__size);
|
|
126
|
+
for (size_t __i = 0; __i < __size; __i++) {
|
|
127
|
+
const auto& __element = services[__i];
|
|
128
|
+
auto __elementJni = JGATTService::fromCpp(__element);
|
|
129
|
+
__array->setElement(__i, *__elementJni);
|
|
130
|
+
}
|
|
131
|
+
return __array;
|
|
132
|
+
}());
|
|
133
|
+
}
|
|
134
|
+
std::shared_ptr<Promise<bool>> JHybridMunimBluetoothSpec::isBluetoothEnabled() {
|
|
135
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("isBluetoothEnabled");
|
|
136
|
+
auto __result = method(_javaPart);
|
|
137
|
+
return [&]() {
|
|
138
|
+
auto __promise = Promise<bool>::create();
|
|
139
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
140
|
+
auto __result = jni::static_ref_cast<jni::JBoolean>(__boxedResult);
|
|
141
|
+
__promise->resolve(static_cast<bool>(__result->value()));
|
|
142
|
+
});
|
|
143
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
144
|
+
jni::JniException __jniError(__throwable);
|
|
145
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
146
|
+
});
|
|
147
|
+
return __promise;
|
|
148
|
+
}();
|
|
149
|
+
}
|
|
150
|
+
std::shared_ptr<Promise<bool>> JHybridMunimBluetoothSpec::requestBluetoothPermission() {
|
|
151
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("requestBluetoothPermission");
|
|
152
|
+
auto __result = method(_javaPart);
|
|
153
|
+
return [&]() {
|
|
154
|
+
auto __promise = Promise<bool>::create();
|
|
155
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
156
|
+
auto __result = jni::static_ref_cast<jni::JBoolean>(__boxedResult);
|
|
157
|
+
__promise->resolve(static_cast<bool>(__result->value()));
|
|
158
|
+
});
|
|
159
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
160
|
+
jni::JniException __jniError(__throwable);
|
|
161
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
162
|
+
});
|
|
163
|
+
return __promise;
|
|
164
|
+
}();
|
|
165
|
+
}
|
|
166
|
+
void JHybridMunimBluetoothSpec::startScan(const std::optional<ScanOptions>& options) {
|
|
167
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JScanOptions> /* options */)>("startScan");
|
|
168
|
+
method(_javaPart, options.has_value() ? JScanOptions::fromCpp(options.value()) : nullptr);
|
|
169
|
+
}
|
|
170
|
+
void JHybridMunimBluetoothSpec::stopScan() {
|
|
171
|
+
static const auto method = javaClassStatic()->getMethod<void()>("stopScan");
|
|
172
|
+
method(_javaPart);
|
|
173
|
+
}
|
|
174
|
+
std::shared_ptr<Promise<void>> JHybridMunimBluetoothSpec::connect(const std::string& deviceId) {
|
|
175
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* deviceId */)>("connect");
|
|
176
|
+
auto __result = method(_javaPart, jni::make_jstring(deviceId));
|
|
177
|
+
return [&]() {
|
|
178
|
+
auto __promise = Promise<void>::create();
|
|
179
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
|
|
180
|
+
__promise->resolve();
|
|
181
|
+
});
|
|
182
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
183
|
+
jni::JniException __jniError(__throwable);
|
|
184
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
185
|
+
});
|
|
186
|
+
return __promise;
|
|
187
|
+
}();
|
|
188
|
+
}
|
|
189
|
+
void JHybridMunimBluetoothSpec::disconnect(const std::string& deviceId) {
|
|
190
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* deviceId */)>("disconnect");
|
|
191
|
+
method(_javaPart, jni::make_jstring(deviceId));
|
|
192
|
+
}
|
|
193
|
+
std::shared_ptr<Promise<std::vector<GATTService>>> JHybridMunimBluetoothSpec::discoverServices(const std::string& deviceId) {
|
|
194
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* deviceId */)>("discoverServices");
|
|
195
|
+
auto __result = method(_javaPart, jni::make_jstring(deviceId));
|
|
196
|
+
return [&]() {
|
|
197
|
+
auto __promise = Promise<std::vector<GATTService>>::create();
|
|
198
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
199
|
+
auto __result = jni::static_ref_cast<jni::JArrayClass<JGATTService>>(__boxedResult);
|
|
200
|
+
__promise->resolve([&]() {
|
|
201
|
+
size_t __size = __result->size();
|
|
202
|
+
std::vector<GATTService> __vector;
|
|
203
|
+
__vector.reserve(__size);
|
|
204
|
+
for (size_t __i = 0; __i < __size; __i++) {
|
|
205
|
+
auto __element = __result->getElement(__i);
|
|
206
|
+
__vector.push_back(__element->toCpp());
|
|
207
|
+
}
|
|
208
|
+
return __vector;
|
|
209
|
+
}());
|
|
210
|
+
});
|
|
211
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
212
|
+
jni::JniException __jniError(__throwable);
|
|
213
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
214
|
+
});
|
|
215
|
+
return __promise;
|
|
216
|
+
}();
|
|
217
|
+
}
|
|
218
|
+
std::shared_ptr<Promise<CharacteristicValue>> JHybridMunimBluetoothSpec::readCharacteristic(const std::string& deviceId, const std::string& serviceUUID, const std::string& characteristicUUID) {
|
|
219
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* deviceId */, jni::alias_ref<jni::JString> /* serviceUUID */, jni::alias_ref<jni::JString> /* characteristicUUID */)>("readCharacteristic");
|
|
220
|
+
auto __result = method(_javaPart, jni::make_jstring(deviceId), jni::make_jstring(serviceUUID), jni::make_jstring(characteristicUUID));
|
|
221
|
+
return [&]() {
|
|
222
|
+
auto __promise = Promise<CharacteristicValue>::create();
|
|
223
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
224
|
+
auto __result = jni::static_ref_cast<JCharacteristicValue>(__boxedResult);
|
|
225
|
+
__promise->resolve(__result->toCpp());
|
|
226
|
+
});
|
|
227
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
228
|
+
jni::JniException __jniError(__throwable);
|
|
229
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
230
|
+
});
|
|
231
|
+
return __promise;
|
|
232
|
+
}();
|
|
233
|
+
}
|
|
234
|
+
std::shared_ptr<Promise<void>> JHybridMunimBluetoothSpec::writeCharacteristic(const std::string& deviceId, const std::string& serviceUUID, const std::string& characteristicUUID, const std::string& value, std::optional<WriteType> writeType) {
|
|
235
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* deviceId */, jni::alias_ref<jni::JString> /* serviceUUID */, jni::alias_ref<jni::JString> /* characteristicUUID */, jni::alias_ref<jni::JString> /* value */, jni::alias_ref<JWriteType> /* writeType */)>("writeCharacteristic");
|
|
236
|
+
auto __result = method(_javaPart, jni::make_jstring(deviceId), jni::make_jstring(serviceUUID), jni::make_jstring(characteristicUUID), jni::make_jstring(value), writeType.has_value() ? JWriteType::fromCpp(writeType.value()) : nullptr);
|
|
237
|
+
return [&]() {
|
|
238
|
+
auto __promise = Promise<void>::create();
|
|
239
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
|
|
240
|
+
__promise->resolve();
|
|
241
|
+
});
|
|
242
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
243
|
+
jni::JniException __jniError(__throwable);
|
|
244
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
245
|
+
});
|
|
246
|
+
return __promise;
|
|
247
|
+
}();
|
|
248
|
+
}
|
|
249
|
+
void JHybridMunimBluetoothSpec::subscribeToCharacteristic(const std::string& deviceId, const std::string& serviceUUID, const std::string& characteristicUUID) {
|
|
250
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* deviceId */, jni::alias_ref<jni::JString> /* serviceUUID */, jni::alias_ref<jni::JString> /* characteristicUUID */)>("subscribeToCharacteristic");
|
|
251
|
+
method(_javaPart, jni::make_jstring(deviceId), jni::make_jstring(serviceUUID), jni::make_jstring(characteristicUUID));
|
|
252
|
+
}
|
|
253
|
+
void JHybridMunimBluetoothSpec::unsubscribeFromCharacteristic(const std::string& deviceId, const std::string& serviceUUID, const std::string& characteristicUUID) {
|
|
254
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* deviceId */, jni::alias_ref<jni::JString> /* serviceUUID */, jni::alias_ref<jni::JString> /* characteristicUUID */)>("unsubscribeFromCharacteristic");
|
|
255
|
+
method(_javaPart, jni::make_jstring(deviceId), jni::make_jstring(serviceUUID), jni::make_jstring(characteristicUUID));
|
|
256
|
+
}
|
|
257
|
+
std::shared_ptr<Promise<std::vector<std::string>>> JHybridMunimBluetoothSpec::getConnectedDevices() {
|
|
258
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("getConnectedDevices");
|
|
259
|
+
auto __result = method(_javaPart);
|
|
260
|
+
return [&]() {
|
|
261
|
+
auto __promise = Promise<std::vector<std::string>>::create();
|
|
262
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
263
|
+
auto __result = jni::static_ref_cast<jni::JArrayClass<jni::JString>>(__boxedResult);
|
|
264
|
+
__promise->resolve([&]() {
|
|
265
|
+
size_t __size = __result->size();
|
|
266
|
+
std::vector<std::string> __vector;
|
|
267
|
+
__vector.reserve(__size);
|
|
268
|
+
for (size_t __i = 0; __i < __size; __i++) {
|
|
269
|
+
auto __element = __result->getElement(__i);
|
|
270
|
+
__vector.push_back(__element->toStdString());
|
|
271
|
+
}
|
|
272
|
+
return __vector;
|
|
273
|
+
}());
|
|
274
|
+
});
|
|
275
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
276
|
+
jni::JniException __jniError(__throwable);
|
|
277
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
278
|
+
});
|
|
279
|
+
return __promise;
|
|
280
|
+
}();
|
|
281
|
+
}
|
|
282
|
+
std::shared_ptr<Promise<double>> JHybridMunimBluetoothSpec::readRSSI(const std::string& deviceId) {
|
|
283
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* deviceId */)>("readRSSI");
|
|
284
|
+
auto __result = method(_javaPart, jni::make_jstring(deviceId));
|
|
285
|
+
return [&]() {
|
|
286
|
+
auto __promise = Promise<double>::create();
|
|
287
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
288
|
+
auto __result = jni::static_ref_cast<jni::JDouble>(__boxedResult);
|
|
289
|
+
__promise->resolve(__result->value());
|
|
290
|
+
});
|
|
291
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
292
|
+
jni::JniException __jniError(__throwable);
|
|
293
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
294
|
+
});
|
|
295
|
+
return __promise;
|
|
296
|
+
}();
|
|
297
|
+
}
|
|
298
|
+
void JHybridMunimBluetoothSpec::addListener(const std::string& eventName) {
|
|
299
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* eventName */)>("addListener");
|
|
300
|
+
method(_javaPart, jni::make_jstring(eventName));
|
|
301
|
+
}
|
|
302
|
+
void JHybridMunimBluetoothSpec::removeListeners(double count) {
|
|
303
|
+
static const auto method = javaClassStatic()->getMethod<void(double /* count */)>("removeListeners");
|
|
304
|
+
method(_javaPart, count);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
} // namespace margelo::nitro::munimbluetooth
|