munim-bluetooth 0.2.8 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ios/HybridMunimBluetooth.swift +1 -1
- 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,85 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridMunimBluetoothSpec.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 <NitroModules/JHybridObject.hpp>
|
|
11
|
+
#include <fbjni/fbjni.h>
|
|
12
|
+
#include "HybridMunimBluetoothSpec.hpp"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
namespace margelo::nitro::munimbluetooth {
|
|
18
|
+
|
|
19
|
+
using namespace facebook;
|
|
20
|
+
|
|
21
|
+
class JHybridMunimBluetoothSpec: public jni::HybridClass<JHybridMunimBluetoothSpec, JHybridObject>,
|
|
22
|
+
public virtual HybridMunimBluetoothSpec {
|
|
23
|
+
public:
|
|
24
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/HybridMunimBluetoothSpec;";
|
|
25
|
+
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis);
|
|
26
|
+
static void registerNatives();
|
|
27
|
+
|
|
28
|
+
protected:
|
|
29
|
+
// C++ constructor (called from Java via `initHybrid()`)
|
|
30
|
+
explicit JHybridMunimBluetoothSpec(jni::alias_ref<jhybridobject> jThis) :
|
|
31
|
+
HybridObject(HybridMunimBluetoothSpec::TAG),
|
|
32
|
+
HybridBase(jThis),
|
|
33
|
+
_javaPart(jni::make_global(jThis)) {}
|
|
34
|
+
|
|
35
|
+
public:
|
|
36
|
+
~JHybridMunimBluetoothSpec() override {
|
|
37
|
+
// Hermes GC can destroy JS objects on a non-JNI Thread.
|
|
38
|
+
jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); });
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public:
|
|
42
|
+
size_t getExternalMemorySize() noexcept override;
|
|
43
|
+
bool equals(const std::shared_ptr<HybridObject>& other) override;
|
|
44
|
+
void dispose() noexcept override;
|
|
45
|
+
std::string toString() override;
|
|
46
|
+
|
|
47
|
+
public:
|
|
48
|
+
inline const jni::global_ref<JHybridMunimBluetoothSpec::javaobject>& getJavaPart() const noexcept {
|
|
49
|
+
return _javaPart;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public:
|
|
53
|
+
// Properties
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
public:
|
|
57
|
+
// Methods
|
|
58
|
+
void startAdvertising(const AdvertisingOptions& options) override;
|
|
59
|
+
void updateAdvertisingData(const AdvertisingDataTypes& advertisingData) override;
|
|
60
|
+
std::shared_ptr<Promise<AdvertisingDataTypes>> getAdvertisingData() override;
|
|
61
|
+
void stopAdvertising() override;
|
|
62
|
+
void setServices(const std::vector<GATTService>& services) override;
|
|
63
|
+
std::shared_ptr<Promise<bool>> isBluetoothEnabled() override;
|
|
64
|
+
std::shared_ptr<Promise<bool>> requestBluetoothPermission() override;
|
|
65
|
+
void startScan(const std::optional<ScanOptions>& options) override;
|
|
66
|
+
void stopScan() override;
|
|
67
|
+
std::shared_ptr<Promise<void>> connect(const std::string& deviceId) override;
|
|
68
|
+
void disconnect(const std::string& deviceId) override;
|
|
69
|
+
std::shared_ptr<Promise<std::vector<GATTService>>> discoverServices(const std::string& deviceId) override;
|
|
70
|
+
std::shared_ptr<Promise<CharacteristicValue>> readCharacteristic(const std::string& deviceId, const std::string& serviceUUID, const std::string& characteristicUUID) override;
|
|
71
|
+
std::shared_ptr<Promise<void>> writeCharacteristic(const std::string& deviceId, const std::string& serviceUUID, const std::string& characteristicUUID, const std::string& value, std::optional<WriteType> writeType) override;
|
|
72
|
+
void subscribeToCharacteristic(const std::string& deviceId, const std::string& serviceUUID, const std::string& characteristicUUID) override;
|
|
73
|
+
void unsubscribeFromCharacteristic(const std::string& deviceId, const std::string& serviceUUID, const std::string& characteristicUUID) override;
|
|
74
|
+
std::shared_ptr<Promise<std::vector<std::string>>> getConnectedDevices() override;
|
|
75
|
+
std::shared_ptr<Promise<double>> readRSSI(const std::string& deviceId) override;
|
|
76
|
+
void addListener(const std::string& eventName) override;
|
|
77
|
+
void removeListeners(double count) override;
|
|
78
|
+
|
|
79
|
+
private:
|
|
80
|
+
friend HybridBase;
|
|
81
|
+
using HybridBase::HybridBase;
|
|
82
|
+
jni::global_ref<JHybridMunimBluetoothSpec::javaobject> _javaPart;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
} // namespace margelo::nitro::munimbluetooth
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JScanMode.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 "ScanMode.hpp"
|
|
12
|
+
|
|
13
|
+
namespace margelo::nitro::munimbluetooth {
|
|
14
|
+
|
|
15
|
+
using namespace facebook;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The C++ JNI bridge between the C++ enum "ScanMode" and the the Kotlin enum "ScanMode".
|
|
19
|
+
*/
|
|
20
|
+
struct JScanMode final: public jni::JavaClass<JScanMode> {
|
|
21
|
+
public:
|
|
22
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/ScanMode;";
|
|
23
|
+
|
|
24
|
+
public:
|
|
25
|
+
/**
|
|
26
|
+
* Convert this Java/Kotlin-based enum to the C++ enum ScanMode.
|
|
27
|
+
*/
|
|
28
|
+
[[maybe_unused]]
|
|
29
|
+
[[nodiscard]]
|
|
30
|
+
ScanMode toCpp() const {
|
|
31
|
+
static const auto clazz = javaClassStatic();
|
|
32
|
+
static const auto fieldOrdinal = clazz->getField<int>("value");
|
|
33
|
+
int ordinal = this->getFieldValue(fieldOrdinal);
|
|
34
|
+
return static_cast<ScanMode>(ordinal);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public:
|
|
38
|
+
/**
|
|
39
|
+
* Create a Java/Kotlin-based enum with the given C++ enum's value.
|
|
40
|
+
*/
|
|
41
|
+
[[maybe_unused]]
|
|
42
|
+
static jni::alias_ref<JScanMode> fromCpp(ScanMode value) {
|
|
43
|
+
static const auto clazz = javaClassStatic();
|
|
44
|
+
switch (value) {
|
|
45
|
+
case ScanMode::LOWPOWER:
|
|
46
|
+
static const auto fieldLOWPOWER = clazz->getStaticField<JScanMode>("LOWPOWER");
|
|
47
|
+
return clazz->getStaticFieldValue(fieldLOWPOWER);
|
|
48
|
+
case ScanMode::BALANCED:
|
|
49
|
+
static const auto fieldBALANCED = clazz->getStaticField<JScanMode>("BALANCED");
|
|
50
|
+
return clazz->getStaticFieldValue(fieldBALANCED);
|
|
51
|
+
case ScanMode::LOWLATENCY:
|
|
52
|
+
static const auto fieldLOWLATENCY = clazz->getStaticField<JScanMode>("LOWLATENCY");
|
|
53
|
+
return clazz->getStaticFieldValue(fieldLOWLATENCY);
|
|
54
|
+
default:
|
|
55
|
+
std::string stringValue = std::to_string(static_cast<int>(value));
|
|
56
|
+
throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
} // namespace margelo::nitro::munimbluetooth
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JScanOptions.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 "ScanOptions.hpp"
|
|
12
|
+
|
|
13
|
+
#include "JScanMode.hpp"
|
|
14
|
+
#include "ScanMode.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 "ScanOptions" and the the Kotlin data class "ScanOptions".
|
|
25
|
+
*/
|
|
26
|
+
struct JScanOptions final: public jni::JavaClass<JScanOptions> {
|
|
27
|
+
public:
|
|
28
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/ScanOptions;";
|
|
29
|
+
|
|
30
|
+
public:
|
|
31
|
+
/**
|
|
32
|
+
* Convert this Java/Kotlin-based struct to the C++ struct ScanOptions by copying all values to C++.
|
|
33
|
+
*/
|
|
34
|
+
[[maybe_unused]]
|
|
35
|
+
[[nodiscard]]
|
|
36
|
+
ScanOptions toCpp() const {
|
|
37
|
+
static const auto clazz = javaClassStatic();
|
|
38
|
+
static const auto fieldServiceUUIDs = clazz->getField<jni::JArrayClass<jni::JString>>("serviceUUIDs");
|
|
39
|
+
jni::local_ref<jni::JArrayClass<jni::JString>> serviceUUIDs = this->getFieldValue(fieldServiceUUIDs);
|
|
40
|
+
static const auto fieldAllowDuplicates = clazz->getField<jni::JBoolean>("allowDuplicates");
|
|
41
|
+
jni::local_ref<jni::JBoolean> allowDuplicates = this->getFieldValue(fieldAllowDuplicates);
|
|
42
|
+
static const auto fieldScanMode = clazz->getField<JScanMode>("scanMode");
|
|
43
|
+
jni::local_ref<JScanMode> scanMode = this->getFieldValue(fieldScanMode);
|
|
44
|
+
return ScanOptions(
|
|
45
|
+
serviceUUIDs != nullptr ? std::make_optional([&]() {
|
|
46
|
+
size_t __size = serviceUUIDs->size();
|
|
47
|
+
std::vector<std::string> __vector;
|
|
48
|
+
__vector.reserve(__size);
|
|
49
|
+
for (size_t __i = 0; __i < __size; __i++) {
|
|
50
|
+
auto __element = serviceUUIDs->getElement(__i);
|
|
51
|
+
__vector.push_back(__element->toStdString());
|
|
52
|
+
}
|
|
53
|
+
return __vector;
|
|
54
|
+
}()) : std::nullopt,
|
|
55
|
+
allowDuplicates != nullptr ? std::make_optional(static_cast<bool>(allowDuplicates->value())) : std::nullopt,
|
|
56
|
+
scanMode != nullptr ? std::make_optional(scanMode->toCpp()) : std::nullopt
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
public:
|
|
61
|
+
/**
|
|
62
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
63
|
+
*/
|
|
64
|
+
[[maybe_unused]]
|
|
65
|
+
static jni::local_ref<JScanOptions::javaobject> fromCpp(const ScanOptions& value) {
|
|
66
|
+
using JSignature = JScanOptions(jni::alias_ref<jni::JArrayClass<jni::JString>>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<JScanMode>);
|
|
67
|
+
static const auto clazz = javaClassStatic();
|
|
68
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
69
|
+
return create(
|
|
70
|
+
clazz,
|
|
71
|
+
value.serviceUUIDs.has_value() ? [&]() {
|
|
72
|
+
size_t __size = value.serviceUUIDs.value().size();
|
|
73
|
+
jni::local_ref<jni::JArrayClass<jni::JString>> __array = jni::JArrayClass<jni::JString>::newArray(__size);
|
|
74
|
+
for (size_t __i = 0; __i < __size; __i++) {
|
|
75
|
+
const auto& __element = value.serviceUUIDs.value()[__i];
|
|
76
|
+
auto __elementJni = jni::make_jstring(__element);
|
|
77
|
+
__array->setElement(__i, *__elementJni);
|
|
78
|
+
}
|
|
79
|
+
return __array;
|
|
80
|
+
}() : nullptr,
|
|
81
|
+
value.allowDuplicates.has_value() ? jni::JBoolean::valueOf(value.allowDuplicates.value()) : nullptr,
|
|
82
|
+
value.scanMode.has_value() ? JScanMode::fromCpp(value.scanMode.value()) : nullptr
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
} // namespace margelo::nitro::munimbluetooth
|
|
@@ -0,0 +1,61 @@
|
|
|
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 <string>
|
|
14
|
+
|
|
15
|
+
namespace margelo::nitro::munimbluetooth {
|
|
16
|
+
|
|
17
|
+
using namespace facebook;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The C++ JNI bridge between the C++ struct "ServiceDataEntry" and the the Kotlin data class "ServiceDataEntry".
|
|
21
|
+
*/
|
|
22
|
+
struct JServiceDataEntry final: public jni::JavaClass<JServiceDataEntry> {
|
|
23
|
+
public:
|
|
24
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/ServiceDataEntry;";
|
|
25
|
+
|
|
26
|
+
public:
|
|
27
|
+
/**
|
|
28
|
+
* Convert this Java/Kotlin-based struct to the C++ struct ServiceDataEntry by copying all values to C++.
|
|
29
|
+
*/
|
|
30
|
+
[[maybe_unused]]
|
|
31
|
+
[[nodiscard]]
|
|
32
|
+
ServiceDataEntry toCpp() const {
|
|
33
|
+
static const auto clazz = javaClassStatic();
|
|
34
|
+
static const auto fieldUuid = clazz->getField<jni::JString>("uuid");
|
|
35
|
+
jni::local_ref<jni::JString> uuid = this->getFieldValue(fieldUuid);
|
|
36
|
+
static const auto fieldData = clazz->getField<jni::JString>("data");
|
|
37
|
+
jni::local_ref<jni::JString> data = this->getFieldValue(fieldData);
|
|
38
|
+
return ServiceDataEntry(
|
|
39
|
+
uuid->toStdString(),
|
|
40
|
+
data->toStdString()
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public:
|
|
45
|
+
/**
|
|
46
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
47
|
+
*/
|
|
48
|
+
[[maybe_unused]]
|
|
49
|
+
static jni::local_ref<JServiceDataEntry::javaobject> fromCpp(const ServiceDataEntry& value) {
|
|
50
|
+
using JSignature = JServiceDataEntry(jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>);
|
|
51
|
+
static const auto clazz = javaClassStatic();
|
|
52
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
53
|
+
return create(
|
|
54
|
+
clazz,
|
|
55
|
+
jni::make_jstring(value.uuid),
|
|
56
|
+
jni::make_jstring(value.data)
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
} // namespace margelo::nitro::munimbluetooth
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JWriteType.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 "WriteType.hpp"
|
|
12
|
+
|
|
13
|
+
namespace margelo::nitro::munimbluetooth {
|
|
14
|
+
|
|
15
|
+
using namespace facebook;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The C++ JNI bridge between the C++ enum "WriteType" and the the Kotlin enum "WriteType".
|
|
19
|
+
*/
|
|
20
|
+
struct JWriteType final: public jni::JavaClass<JWriteType> {
|
|
21
|
+
public:
|
|
22
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/munimbluetooth/WriteType;";
|
|
23
|
+
|
|
24
|
+
public:
|
|
25
|
+
/**
|
|
26
|
+
* Convert this Java/Kotlin-based enum to the C++ enum WriteType.
|
|
27
|
+
*/
|
|
28
|
+
[[maybe_unused]]
|
|
29
|
+
[[nodiscard]]
|
|
30
|
+
WriteType toCpp() const {
|
|
31
|
+
static const auto clazz = javaClassStatic();
|
|
32
|
+
static const auto fieldOrdinal = clazz->getField<int>("value");
|
|
33
|
+
int ordinal = this->getFieldValue(fieldOrdinal);
|
|
34
|
+
return static_cast<WriteType>(ordinal);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public:
|
|
38
|
+
/**
|
|
39
|
+
* Create a Java/Kotlin-based enum with the given C++ enum's value.
|
|
40
|
+
*/
|
|
41
|
+
[[maybe_unused]]
|
|
42
|
+
static jni::alias_ref<JWriteType> fromCpp(WriteType value) {
|
|
43
|
+
static const auto clazz = javaClassStatic();
|
|
44
|
+
switch (value) {
|
|
45
|
+
case WriteType::WRITE:
|
|
46
|
+
static const auto fieldWRITE = clazz->getStaticField<JWriteType>("WRITE");
|
|
47
|
+
return clazz->getStaticFieldValue(fieldWRITE);
|
|
48
|
+
case WriteType::WRITEWITHOUTRESPONSE:
|
|
49
|
+
static const auto fieldWRITEWITHOUTRESPONSE = clazz->getStaticField<JWriteType>("WRITEWITHOUTRESPONSE");
|
|
50
|
+
return clazz->getStaticFieldValue(fieldWRITEWITHOUTRESPONSE);
|
|
51
|
+
default:
|
|
52
|
+
std::string stringValue = std::to_string(static_cast<int>(value));
|
|
53
|
+
throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
} // namespace margelo::nitro::munimbluetooth
|
package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/AdvertisingDataTypes.kt
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// AdvertisingDataTypes.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.munimbluetooth
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Represents the JavaScript object/struct "AdvertisingDataTypes".
|
|
16
|
+
*/
|
|
17
|
+
@DoNotStrip
|
|
18
|
+
@Keep
|
|
19
|
+
data class AdvertisingDataTypes(
|
|
20
|
+
@DoNotStrip
|
|
21
|
+
@Keep
|
|
22
|
+
val flags: Double?,
|
|
23
|
+
@DoNotStrip
|
|
24
|
+
@Keep
|
|
25
|
+
val incompleteServiceUUIDs16: Array<String>?,
|
|
26
|
+
@DoNotStrip
|
|
27
|
+
@Keep
|
|
28
|
+
val completeServiceUUIDs16: Array<String>?,
|
|
29
|
+
@DoNotStrip
|
|
30
|
+
@Keep
|
|
31
|
+
val incompleteServiceUUIDs32: Array<String>?,
|
|
32
|
+
@DoNotStrip
|
|
33
|
+
@Keep
|
|
34
|
+
val completeServiceUUIDs32: Array<String>?,
|
|
35
|
+
@DoNotStrip
|
|
36
|
+
@Keep
|
|
37
|
+
val incompleteServiceUUIDs128: Array<String>?,
|
|
38
|
+
@DoNotStrip
|
|
39
|
+
@Keep
|
|
40
|
+
val completeServiceUUIDs128: Array<String>?,
|
|
41
|
+
@DoNotStrip
|
|
42
|
+
@Keep
|
|
43
|
+
val shortenedLocalName: String?,
|
|
44
|
+
@DoNotStrip
|
|
45
|
+
@Keep
|
|
46
|
+
val completeLocalName: String?,
|
|
47
|
+
@DoNotStrip
|
|
48
|
+
@Keep
|
|
49
|
+
val txPowerLevel: Double?,
|
|
50
|
+
@DoNotStrip
|
|
51
|
+
@Keep
|
|
52
|
+
val serviceSolicitationUUIDs16: Array<String>?,
|
|
53
|
+
@DoNotStrip
|
|
54
|
+
@Keep
|
|
55
|
+
val serviceSolicitationUUIDs128: Array<String>?,
|
|
56
|
+
@DoNotStrip
|
|
57
|
+
@Keep
|
|
58
|
+
val serviceData16: Array<ServiceDataEntry>?,
|
|
59
|
+
@DoNotStrip
|
|
60
|
+
@Keep
|
|
61
|
+
val serviceData32: Array<ServiceDataEntry>?,
|
|
62
|
+
@DoNotStrip
|
|
63
|
+
@Keep
|
|
64
|
+
val serviceData128: Array<ServiceDataEntry>?,
|
|
65
|
+
@DoNotStrip
|
|
66
|
+
@Keep
|
|
67
|
+
val appearance: Double?,
|
|
68
|
+
@DoNotStrip
|
|
69
|
+
@Keep
|
|
70
|
+
val serviceSolicitationUUIDs32: Array<String>?,
|
|
71
|
+
@DoNotStrip
|
|
72
|
+
@Keep
|
|
73
|
+
val manufacturerData: String?
|
|
74
|
+
) {
|
|
75
|
+
/* primary constructor */
|
|
76
|
+
|
|
77
|
+
companion object {
|
|
78
|
+
/**
|
|
79
|
+
* Constructor called from C++
|
|
80
|
+
*/
|
|
81
|
+
@DoNotStrip
|
|
82
|
+
@Keep
|
|
83
|
+
@Suppress("unused")
|
|
84
|
+
@JvmStatic
|
|
85
|
+
private fun fromCpp(flags: Double?, incompleteServiceUUIDs16: Array<String>?, completeServiceUUIDs16: Array<String>?, incompleteServiceUUIDs32: Array<String>?, completeServiceUUIDs32: Array<String>?, incompleteServiceUUIDs128: Array<String>?, completeServiceUUIDs128: Array<String>?, shortenedLocalName: String?, completeLocalName: String?, txPowerLevel: Double?, serviceSolicitationUUIDs16: Array<String>?, serviceSolicitationUUIDs128: Array<String>?, serviceData16: Array<ServiceDataEntry>?, serviceData32: Array<ServiceDataEntry>?, serviceData128: Array<ServiceDataEntry>?, appearance: Double?, serviceSolicitationUUIDs32: Array<String>?, manufacturerData: String?): AdvertisingDataTypes {
|
|
86
|
+
return AdvertisingDataTypes(flags, incompleteServiceUUIDs16, completeServiceUUIDs16, incompleteServiceUUIDs32, completeServiceUUIDs32, incompleteServiceUUIDs128, completeServiceUUIDs128, shortenedLocalName, completeLocalName, txPowerLevel, serviceSolicitationUUIDs16, serviceSolicitationUUIDs128, serviceData16, serviceData32, serviceData128, appearance, serviceSolicitationUUIDs32, manufacturerData)
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/AdvertisingOptions.kt
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// AdvertisingOptions.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.munimbluetooth
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Represents the JavaScript object/struct "AdvertisingOptions".
|
|
16
|
+
*/
|
|
17
|
+
@DoNotStrip
|
|
18
|
+
@Keep
|
|
19
|
+
data class AdvertisingOptions(
|
|
20
|
+
@DoNotStrip
|
|
21
|
+
@Keep
|
|
22
|
+
val serviceUUIDs: Array<String>,
|
|
23
|
+
@DoNotStrip
|
|
24
|
+
@Keep
|
|
25
|
+
val localName: String?,
|
|
26
|
+
@DoNotStrip
|
|
27
|
+
@Keep
|
|
28
|
+
val manufacturerData: String?,
|
|
29
|
+
@DoNotStrip
|
|
30
|
+
@Keep
|
|
31
|
+
val advertisingData: AdvertisingDataTypes?
|
|
32
|
+
) {
|
|
33
|
+
/* primary constructor */
|
|
34
|
+
|
|
35
|
+
companion object {
|
|
36
|
+
/**
|
|
37
|
+
* Constructor called from C++
|
|
38
|
+
*/
|
|
39
|
+
@DoNotStrip
|
|
40
|
+
@Keep
|
|
41
|
+
@Suppress("unused")
|
|
42
|
+
@JvmStatic
|
|
43
|
+
private fun fromCpp(serviceUUIDs: Array<String>, localName: String?, manufacturerData: String?, advertisingData: AdvertisingDataTypes?): AdvertisingOptions {
|
|
44
|
+
return AdvertisingOptions(serviceUUIDs, localName, manufacturerData, advertisingData)
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/CharacteristicValue.kt
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// CharacteristicValue.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.munimbluetooth
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Represents the JavaScript object/struct "CharacteristicValue".
|
|
16
|
+
*/
|
|
17
|
+
@DoNotStrip
|
|
18
|
+
@Keep
|
|
19
|
+
data class CharacteristicValue(
|
|
20
|
+
@DoNotStrip
|
|
21
|
+
@Keep
|
|
22
|
+
val value: String,
|
|
23
|
+
@DoNotStrip
|
|
24
|
+
@Keep
|
|
25
|
+
val serviceUUID: String,
|
|
26
|
+
@DoNotStrip
|
|
27
|
+
@Keep
|
|
28
|
+
val characteristicUUID: String
|
|
29
|
+
) {
|
|
30
|
+
/* primary constructor */
|
|
31
|
+
|
|
32
|
+
companion object {
|
|
33
|
+
/**
|
|
34
|
+
* Constructor called from C++
|
|
35
|
+
*/
|
|
36
|
+
@DoNotStrip
|
|
37
|
+
@Keep
|
|
38
|
+
@Suppress("unused")
|
|
39
|
+
@JvmStatic
|
|
40
|
+
private fun fromCpp(value: String, serviceUUID: String, characteristicUUID: String): CharacteristicValue {
|
|
41
|
+
return CharacteristicValue(value, serviceUUID, characteristicUUID)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimbluetooth/GATTCharacteristic.kt
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// GATTCharacteristic.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.munimbluetooth
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Represents the JavaScript object/struct "GATTCharacteristic".
|
|
16
|
+
*/
|
|
17
|
+
@DoNotStrip
|
|
18
|
+
@Keep
|
|
19
|
+
data class GATTCharacteristic(
|
|
20
|
+
@DoNotStrip
|
|
21
|
+
@Keep
|
|
22
|
+
val uuid: String,
|
|
23
|
+
@DoNotStrip
|
|
24
|
+
@Keep
|
|
25
|
+
val properties: Array<String>,
|
|
26
|
+
@DoNotStrip
|
|
27
|
+
@Keep
|
|
28
|
+
val value: String?
|
|
29
|
+
) {
|
|
30
|
+
/* primary constructor */
|
|
31
|
+
|
|
32
|
+
companion object {
|
|
33
|
+
/**
|
|
34
|
+
* Constructor called from C++
|
|
35
|
+
*/
|
|
36
|
+
@DoNotStrip
|
|
37
|
+
@Keep
|
|
38
|
+
@Suppress("unused")
|
|
39
|
+
@JvmStatic
|
|
40
|
+
private fun fromCpp(uuid: String, properties: Array<String>, value: String?): GATTCharacteristic {
|
|
41
|
+
return GATTCharacteristic(uuid, properties, value)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// GATTService.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.munimbluetooth
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Represents the JavaScript object/struct "GATTService".
|
|
16
|
+
*/
|
|
17
|
+
@DoNotStrip
|
|
18
|
+
@Keep
|
|
19
|
+
data class GATTService(
|
|
20
|
+
@DoNotStrip
|
|
21
|
+
@Keep
|
|
22
|
+
val uuid: String,
|
|
23
|
+
@DoNotStrip
|
|
24
|
+
@Keep
|
|
25
|
+
val characteristics: Array<GATTCharacteristic>
|
|
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, characteristics: Array<GATTCharacteristic>): GATTService {
|
|
38
|
+
return GATTService(uuid, characteristics)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|