simplejsble 0.0.21 → 0.0.23
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/NitroSimplejsble.podspec +57 -4
- package/app.plugin.js +7 -0
- package/ios/CMakeLists.txt +13 -2
- package/lib/specs/Adapter.nitro.js +1 -1
- package/nitrogen/generated/android/NitroSimplejsble+autolinking.cmake +1 -1
- package/nitrogen/generated/android/NitroSimplejsble+autolinking.gradle +1 -1
- package/nitrogen/generated/android/NitroSimplejsbleOnLoad.cpp +1 -1
- package/nitrogen/generated/android/NitroSimplejsbleOnLoad.hpp +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/simplejsble/NitroSimplejsbleOnLoad.kt +1 -1
- package/nitrogen/generated/ios/NitroSimplejsble+autolinking.rb +1 -1
- package/nitrogen/generated/ios/NitroSimplejsble-Swift-Cxx-Bridge.cpp +1 -1
- package/nitrogen/generated/ios/NitroSimplejsble-Swift-Cxx-Bridge.hpp +1 -1
- package/nitrogen/generated/ios/NitroSimplejsble-Swift-Cxx-Umbrella.hpp +1 -1
- package/nitrogen/generated/ios/NitroSimplejsbleAutolinking.mm +1 -1
- package/nitrogen/generated/ios/NitroSimplejsbleAutolinking.swift +1 -1
- package/nitrogen/generated/shared/c++/HybridAdapterSpec.cpp +1 -1
- package/nitrogen/generated/shared/c++/HybridAdapterSpec.hpp +1 -1
- package/package.json +4 -7
- package/react-native.config.js +0 -4
- package/ios/SimpleBLE.xcframework/Info.plist +0 -47
- package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/Adapter.h +0 -102
- package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/AdapterSafe.h +0 -58
- package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/Advanced.h +0 -50
- package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/Characteristic.h +0 -39
- package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/Config.h +0 -64
- package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/Descriptor.h +0 -30
- package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/Exceptions.h +0 -72
- package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/Logging.h +0 -73
- package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/Peripheral.h +0 -82
- package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/PeripheralSafe.h +0 -64
- package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/Service.h +0 -34
- package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/SimpleBLE.h +0 -8
- package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/Types.h +0 -49
- package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/Utils.h +0 -13
- package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/export.h +0 -43
- package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/kvn/kvn_bytearray.h +0 -297
- package/ios/SimpleBLE.xcframework/ios-arm64/libsimpleble.a +0 -0
- package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/Adapter.h +0 -102
- package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/AdapterSafe.h +0 -58
- package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/Advanced.h +0 -50
- package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/Characteristic.h +0 -39
- package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/Config.h +0 -64
- package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/Descriptor.h +0 -30
- package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/Exceptions.h +0 -72
- package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/Logging.h +0 -73
- package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/Peripheral.h +0 -82
- package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/PeripheralSafe.h +0 -64
- package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/Service.h +0 -34
- package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/SimpleBLE.h +0 -8
- package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/Types.h +0 -49
- package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/Utils.h +0 -13
- package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/export.h +0 -43
- package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/kvn/kvn_bytearray.h +0 -297
- package/ios/SimpleBLE.xcframework/ios-arm64-simulator/libsimpleble.a +0 -0
- package/ios/build_simpleble.sh +0 -51
- package/ios/simpleble_iphoneos_arm64/include/simpleble/Adapter.h +0 -102
- package/ios/simpleble_iphoneos_arm64/include/simpleble/AdapterSafe.h +0 -58
- package/ios/simpleble_iphoneos_arm64/include/simpleble/Advanced.h +0 -50
- package/ios/simpleble_iphoneos_arm64/include/simpleble/Characteristic.h +0 -39
- package/ios/simpleble_iphoneos_arm64/include/simpleble/Config.h +0 -64
- package/ios/simpleble_iphoneos_arm64/include/simpleble/Descriptor.h +0 -30
- package/ios/simpleble_iphoneos_arm64/include/simpleble/Exceptions.h +0 -72
- package/ios/simpleble_iphoneos_arm64/include/simpleble/Logging.h +0 -73
- package/ios/simpleble_iphoneos_arm64/include/simpleble/Peripheral.h +0 -82
- package/ios/simpleble_iphoneos_arm64/include/simpleble/PeripheralSafe.h +0 -64
- package/ios/simpleble_iphoneos_arm64/include/simpleble/Service.h +0 -34
- package/ios/simpleble_iphoneos_arm64/include/simpleble/SimpleBLE.h +0 -8
- package/ios/simpleble_iphoneos_arm64/include/simpleble/Types.h +0 -49
- package/ios/simpleble_iphoneos_arm64/include/simpleble/Utils.h +0 -13
- package/ios/simpleble_iphoneos_arm64/include/simpleble/export.h +0 -43
- package/ios/simpleble_iphoneos_arm64/include/simpleble/kvn/kvn_bytearray.h +0 -297
- package/ios/simpleble_iphoneos_arm64/lib/cmake/simpleble/simpleble-config-release.cmake +0 -19
- package/ios/simpleble_iphoneos_arm64/lib/cmake/simpleble/simpleble-config.cmake +0 -107
- package/ios/simpleble_iphoneos_arm64/lib/libsimpleble.a +0 -0
- package/ios/simpleble_iphoneos_arm64/lib/pkgconfig/simpleble.pc +0 -11
- package/ios/simpleble_iphonesimulator_arm64/include/simpleble/Adapter.h +0 -102
- package/ios/simpleble_iphonesimulator_arm64/include/simpleble/AdapterSafe.h +0 -58
- package/ios/simpleble_iphonesimulator_arm64/include/simpleble/Advanced.h +0 -50
- package/ios/simpleble_iphonesimulator_arm64/include/simpleble/Characteristic.h +0 -39
- package/ios/simpleble_iphonesimulator_arm64/include/simpleble/Config.h +0 -64
- package/ios/simpleble_iphonesimulator_arm64/include/simpleble/Descriptor.h +0 -30
- package/ios/simpleble_iphonesimulator_arm64/include/simpleble/Exceptions.h +0 -72
- package/ios/simpleble_iphonesimulator_arm64/include/simpleble/Logging.h +0 -73
- package/ios/simpleble_iphonesimulator_arm64/include/simpleble/Peripheral.h +0 -82
- package/ios/simpleble_iphonesimulator_arm64/include/simpleble/PeripheralSafe.h +0 -64
- package/ios/simpleble_iphonesimulator_arm64/include/simpleble/Service.h +0 -34
- package/ios/simpleble_iphonesimulator_arm64/include/simpleble/SimpleBLE.h +0 -8
- package/ios/simpleble_iphonesimulator_arm64/include/simpleble/Types.h +0 -49
- package/ios/simpleble_iphonesimulator_arm64/include/simpleble/Utils.h +0 -13
- package/ios/simpleble_iphonesimulator_arm64/include/simpleble/export.h +0 -43
- package/ios/simpleble_iphonesimulator_arm64/include/simpleble/kvn/kvn_bytearray.h +0 -297
- package/ios/simpleble_iphonesimulator_arm64/lib/cmake/simpleble/simpleble-config-release.cmake +0 -19
- package/ios/simpleble_iphonesimulator_arm64/lib/cmake/simpleble/simpleble-config.cmake +0 -107
- package/ios/simpleble_iphonesimulator_arm64/lib/libsimpleble.a +0 -0
- package/ios/simpleble_iphonesimulator_arm64/lib/pkgconfig/simpleble.pc +0 -11
- package/macos/CMakeLists.txt +0 -21
- package/macos/SimpleBLE-macos.xcframework/Info.plist +0 -30
- package/macos/SimpleBLE-macos.xcframework/macos-arm64_x86_64/Headers/simpleble/Adapter.h +0 -102
- package/macos/SimpleBLE-macos.xcframework/macos-arm64_x86_64/Headers/simpleble/AdapterSafe.h +0 -58
- package/macos/SimpleBLE-macos.xcframework/macos-arm64_x86_64/Headers/simpleble/Advanced.h +0 -50
- package/macos/SimpleBLE-macos.xcframework/macos-arm64_x86_64/Headers/simpleble/Characteristic.h +0 -39
- package/macos/SimpleBLE-macos.xcframework/macos-arm64_x86_64/Headers/simpleble/Config.h +0 -64
- package/macos/SimpleBLE-macos.xcframework/macos-arm64_x86_64/Headers/simpleble/Descriptor.h +0 -30
- package/macos/SimpleBLE-macos.xcframework/macos-arm64_x86_64/Headers/simpleble/Exceptions.h +0 -72
- package/macos/SimpleBLE-macos.xcframework/macos-arm64_x86_64/Headers/simpleble/Logging.h +0 -73
- package/macos/SimpleBLE-macos.xcframework/macos-arm64_x86_64/Headers/simpleble/Peripheral.h +0 -82
- package/macos/SimpleBLE-macos.xcframework/macos-arm64_x86_64/Headers/simpleble/PeripheralSafe.h +0 -64
- package/macos/SimpleBLE-macos.xcframework/macos-arm64_x86_64/Headers/simpleble/Service.h +0 -34
- package/macos/SimpleBLE-macos.xcframework/macos-arm64_x86_64/Headers/simpleble/SimpleBLE.h +0 -8
- package/macos/SimpleBLE-macos.xcframework/macos-arm64_x86_64/Headers/simpleble/Types.h +0 -49
- package/macos/SimpleBLE-macos.xcframework/macos-arm64_x86_64/Headers/simpleble/Utils.h +0 -13
- package/macos/SimpleBLE-macos.xcframework/macos-arm64_x86_64/Headers/simpleble/export.h +0 -43
- package/macos/SimpleBLE-macos.xcframework/macos-arm64_x86_64/Headers/simpleble/kvn/kvn_bytearray.h +0 -297
- package/macos/SimpleBLE-macos.xcframework/macos-arm64_x86_64/libsimpleble.a +0 -0
- package/macos/build_simpleble.sh +0 -61
- package/macos/simpleble_macosx_arm64/include/simpleble/Adapter.h +0 -102
- package/macos/simpleble_macosx_arm64/include/simpleble/AdapterSafe.h +0 -58
- package/macos/simpleble_macosx_arm64/include/simpleble/Advanced.h +0 -50
- package/macos/simpleble_macosx_arm64/include/simpleble/Characteristic.h +0 -39
- package/macos/simpleble_macosx_arm64/include/simpleble/Config.h +0 -64
- package/macos/simpleble_macosx_arm64/include/simpleble/Descriptor.h +0 -30
- package/macos/simpleble_macosx_arm64/include/simpleble/Exceptions.h +0 -72
- package/macos/simpleble_macosx_arm64/include/simpleble/Logging.h +0 -73
- package/macos/simpleble_macosx_arm64/include/simpleble/Peripheral.h +0 -82
- package/macos/simpleble_macosx_arm64/include/simpleble/PeripheralSafe.h +0 -64
- package/macos/simpleble_macosx_arm64/include/simpleble/Service.h +0 -34
- package/macos/simpleble_macosx_arm64/include/simpleble/SimpleBLE.h +0 -8
- package/macos/simpleble_macosx_arm64/include/simpleble/Types.h +0 -49
- package/macos/simpleble_macosx_arm64/include/simpleble/Utils.h +0 -13
- package/macos/simpleble_macosx_arm64/include/simpleble/export.h +0 -43
- package/macos/simpleble_macosx_arm64/include/simpleble/kvn/kvn_bytearray.h +0 -297
- package/macos/simpleble_macosx_arm64/lib/cmake/simpleble/simpleble-config-release.cmake +0 -19
- package/macos/simpleble_macosx_arm64/lib/cmake/simpleble/simpleble-config.cmake +0 -107
- package/macos/simpleble_macosx_arm64/lib/libsimpleble.a +0 -0
- package/macos/simpleble_macosx_arm64/lib/pkgconfig/simpleble.pc +0 -11
- package/macos/simpleble_macosx_universal/include/simpleble/Adapter.h +0 -102
- package/macos/simpleble_macosx_universal/include/simpleble/AdapterSafe.h +0 -58
- package/macos/simpleble_macosx_universal/include/simpleble/Advanced.h +0 -50
- package/macos/simpleble_macosx_universal/include/simpleble/Characteristic.h +0 -39
- package/macos/simpleble_macosx_universal/include/simpleble/Config.h +0 -64
- package/macos/simpleble_macosx_universal/include/simpleble/Descriptor.h +0 -30
- package/macos/simpleble_macosx_universal/include/simpleble/Exceptions.h +0 -72
- package/macos/simpleble_macosx_universal/include/simpleble/Logging.h +0 -73
- package/macos/simpleble_macosx_universal/include/simpleble/Peripheral.h +0 -82
- package/macos/simpleble_macosx_universal/include/simpleble/PeripheralSafe.h +0 -64
- package/macos/simpleble_macosx_universal/include/simpleble/Service.h +0 -34
- package/macos/simpleble_macosx_universal/include/simpleble/SimpleBLE.h +0 -8
- package/macos/simpleble_macosx_universal/include/simpleble/Types.h +0 -49
- package/macos/simpleble_macosx_universal/include/simpleble/Utils.h +0 -13
- package/macos/simpleble_macosx_universal/include/simpleble/export.h +0 -43
- package/macos/simpleble_macosx_universal/include/simpleble/kvn/kvn_bytearray.h +0 -297
- package/macos/simpleble_macosx_universal/lib/libsimpleble.a +0 -0
- package/macos/simpleble_macosx_x86_64/include/simpleble/Adapter.h +0 -102
- package/macos/simpleble_macosx_x86_64/include/simpleble/AdapterSafe.h +0 -58
- package/macos/simpleble_macosx_x86_64/include/simpleble/Advanced.h +0 -50
- package/macos/simpleble_macosx_x86_64/include/simpleble/Characteristic.h +0 -39
- package/macos/simpleble_macosx_x86_64/include/simpleble/Config.h +0 -64
- package/macos/simpleble_macosx_x86_64/include/simpleble/Descriptor.h +0 -30
- package/macos/simpleble_macosx_x86_64/include/simpleble/Exceptions.h +0 -72
- package/macos/simpleble_macosx_x86_64/include/simpleble/Logging.h +0 -73
- package/macos/simpleble_macosx_x86_64/include/simpleble/Peripheral.h +0 -82
- package/macos/simpleble_macosx_x86_64/include/simpleble/PeripheralSafe.h +0 -64
- package/macos/simpleble_macosx_x86_64/include/simpleble/Service.h +0 -34
- package/macos/simpleble_macosx_x86_64/include/simpleble/SimpleBLE.h +0 -8
- package/macos/simpleble_macosx_x86_64/include/simpleble/Types.h +0 -49
- package/macos/simpleble_macosx_x86_64/include/simpleble/Utils.h +0 -13
- package/macos/simpleble_macosx_x86_64/include/simpleble/export.h +0 -43
- package/macos/simpleble_macosx_x86_64/include/simpleble/kvn/kvn_bytearray.h +0 -297
- package/macos/simpleble_macosx_x86_64/lib/cmake/simpleble/simpleble-config-release.cmake +0 -19
- package/macos/simpleble_macosx_x86_64/lib/cmake/simpleble/simpleble-config.cmake +0 -107
- package/macos/simpleble_macosx_x86_64/lib/libsimpleble.a +0 -0
- package/macos/simpleble_macosx_x86_64/lib/pkgconfig/simpleble.pc +0 -11
- package/scripts/postinstall.js +0 -138
- package/scripts/prepare-package.js +0 -64
|
@@ -1,297 +0,0 @@
|
|
|
1
|
-
#ifndef KVN_BYTEARRAY_H
|
|
2
|
-
#define KVN_BYTEARRAY_H
|
|
3
|
-
|
|
4
|
-
#include <cstdint>
|
|
5
|
-
#include <cstring>
|
|
6
|
-
#include <iomanip>
|
|
7
|
-
#include <iostream>
|
|
8
|
-
#include <memory>
|
|
9
|
-
#include <sstream>
|
|
10
|
-
#include <stdexcept>
|
|
11
|
-
#include <type_traits>
|
|
12
|
-
#include <vector>
|
|
13
|
-
|
|
14
|
-
namespace kvn {
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* @class bytearray
|
|
18
|
-
* @brief A class to handle byte arrays and their conversion from/to hex strings.
|
|
19
|
-
*/
|
|
20
|
-
class bytearray {
|
|
21
|
-
public:
|
|
22
|
-
/**
|
|
23
|
-
* @brief Default constructor.
|
|
24
|
-
*/
|
|
25
|
-
bytearray() = default;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* @brief Constructs byte array from a vector of uint8_t.
|
|
29
|
-
* @param vec A vector of uint8_t.
|
|
30
|
-
*/
|
|
31
|
-
bytearray(const std::vector<uint8_t>& vec) : data_(vec) {}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* @brief Constructs byte array from a raw pointer and size.
|
|
35
|
-
* @param ptr A pointer to uint8_t data.
|
|
36
|
-
* @param size The size of the data.
|
|
37
|
-
*/
|
|
38
|
-
bytearray(const uint8_t* ptr, size_t size) : data_(ptr, ptr + size) {}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* @brief Constructs byte array from iterators.
|
|
42
|
-
* @tparam InputIt Iterator type.
|
|
43
|
-
* @param first Iterator to the first element.
|
|
44
|
-
* @param last Iterator to one past the last element.
|
|
45
|
-
*/
|
|
46
|
-
template <typename InputIt>
|
|
47
|
-
bytearray(InputIt first, InputIt last) : data_(first, last) {}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* @brief Constructs byte array from a std::string.
|
|
51
|
-
* @param byteArr A string containing byte data.
|
|
52
|
-
*/
|
|
53
|
-
bytearray(const std::string& byteArr) : data_(byteArr.begin(), byteArr.end()) {}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* @brief Constructs byte array from a C-style string and size.
|
|
57
|
-
* @param byteArr A C-style string.
|
|
58
|
-
* @param size The size of the string.
|
|
59
|
-
*/
|
|
60
|
-
bytearray(const char* byteArr, size_t size) : bytearray(std::string(byteArr, size)) {}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* @brief Constructs byte array from a C-style string.
|
|
64
|
-
* @param byteArr A C-style string.
|
|
65
|
-
*/
|
|
66
|
-
bytearray(const char* byteArr) : bytearray(std::string(byteArr)) {}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* @brief Constructs a byte array of specified size, initialized with zeros.
|
|
70
|
-
* @param size The number of bytes to allocate.
|
|
71
|
-
*/
|
|
72
|
-
explicit bytearray(size_t size) : data_(size) {}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* @brief Creates a ByteArray from a hex string.
|
|
76
|
-
*
|
|
77
|
-
* Case is ignored and the string may have a '0x' hex prefix or not.
|
|
78
|
-
*
|
|
79
|
-
* @param hexStr A string containing hex data.
|
|
80
|
-
* @return A ByteArray object.
|
|
81
|
-
* @throws std::invalid_argument If the hex string contains non-hexadecimal characters.
|
|
82
|
-
* @throws std::length_error If the hex string length is not even.
|
|
83
|
-
*/
|
|
84
|
-
static bytearray fromHex(const std::string& hexStr) {
|
|
85
|
-
std::string cleanString(hexStr);
|
|
86
|
-
|
|
87
|
-
// Check and skip the '0x' prefix if present
|
|
88
|
-
if (cleanString.size() >= 2 && cleanString.substr(0, 2) == "0x") {
|
|
89
|
-
cleanString = cleanString.substr(2);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
size_t size = cleanString.size();
|
|
93
|
-
if (size % 2 != 0) {
|
|
94
|
-
throw std::length_error("Hex string length must be even.");
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
bytearray byteArray;
|
|
98
|
-
byteArray.data_.reserve(size / 2);
|
|
99
|
-
|
|
100
|
-
for (size_t i = 0; i < size; i += 2) {
|
|
101
|
-
uint8_t byte = static_cast<uint8_t>(std::stoi(cleanString.substr(i, 2), nullptr, 16));
|
|
102
|
-
byteArray.data_.push_back(byte);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
return byteArray;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* @overload
|
|
110
|
-
*/
|
|
111
|
-
static bytearray fromHex(const char* byteArr) { return fromHex(std::string(byteArr)); }
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* @overload
|
|
115
|
-
*/
|
|
116
|
-
static bytearray fromHex(const char* byteArr, size_t size) { return fromHex(std::string(byteArr, size)); }
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* @brief Converts the byte array to a lowercase hex string without '0x' prefix.
|
|
120
|
-
* @param spacing Whether to include spaces between bytes.
|
|
121
|
-
*
|
|
122
|
-
* @return A hex string representation of the byte array.
|
|
123
|
-
*/
|
|
124
|
-
std::string toHex(bool spacing = false) const {
|
|
125
|
-
std::ostringstream oss;
|
|
126
|
-
for (auto byte : data_) {
|
|
127
|
-
oss << std::hex << std::setw(2) << std::setfill('0') << static_cast<int>(byte);
|
|
128
|
-
if (spacing) {
|
|
129
|
-
oss << " ";
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
return oss.str();
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* @brief Slices the byte array from a specified start index to an end index.
|
|
137
|
-
*
|
|
138
|
-
* This method creates a new byte array containing bytes from the specified range.
|
|
139
|
-
* The start index is inclusive, while the end index is exclusive.
|
|
140
|
-
*
|
|
141
|
-
* @param start The starting index from which to begin slicing.
|
|
142
|
-
* @param end The ending index up to which to slice (exclusive).
|
|
143
|
-
* @return byte array A new byte array containing the sliced segment.
|
|
144
|
-
* @throws std::out_of_range If the start index is greater than the end index or if the end index is out of bounds.
|
|
145
|
-
*/
|
|
146
|
-
bytearray slice(size_t start, size_t end) const {
|
|
147
|
-
if (start > end || end > data_.size()) {
|
|
148
|
-
throw std::out_of_range("Invalid slice range");
|
|
149
|
-
}
|
|
150
|
-
return bytearray(std::vector<uint8_t>(data_.begin() + start, data_.begin() + end));
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* @brief Slices the byte array from a specified start index to the end of the array.
|
|
155
|
-
*
|
|
156
|
-
* This method creates a new byte array containing all bytes from the specified start index to the end of the
|
|
157
|
-
* byte array.
|
|
158
|
-
*
|
|
159
|
-
* @param start The starting index from which to begin slicing.
|
|
160
|
-
* @return byte array A new byte array containing the sliced segment from the start index to the end.
|
|
161
|
-
* @throws std::out_of_range If the start index is out of the bounds of the byte array.
|
|
162
|
-
*/
|
|
163
|
-
bytearray slice_from(size_t start) const { return slice(start, data_.size()); }
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* @brief Slices the byte array from the beginning to a specified end index.
|
|
167
|
-
*
|
|
168
|
-
* This method creates a new byte array containing all bytes from the beginning of the byte array to the specified
|
|
169
|
-
* end index.
|
|
170
|
-
*
|
|
171
|
-
* @param end The ending index up to which to slice (exclusive).
|
|
172
|
-
* @return byte array A new byte array containing the sliced segment from the beginning to the end index.
|
|
173
|
-
* @throws std::out_of_range If the end index is out of the bounds of the byte array.
|
|
174
|
-
*/
|
|
175
|
-
bytearray slice_to(size_t end) const { return slice(0, end); }
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* @brief Overloaded stream insertion operator for byte array.
|
|
179
|
-
* @param os The output stream.
|
|
180
|
-
* @param byteArray The byte array object.
|
|
181
|
-
* @return The output stream.
|
|
182
|
-
*/
|
|
183
|
-
friend std::ostream& operator<<(std::ostream& os, const bytearray& byteArray) {
|
|
184
|
-
os << byteArray.toHex(true);
|
|
185
|
-
return os;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* @brief Conversion operator to convert byte array to std::string.
|
|
190
|
-
*
|
|
191
|
-
* @note This is provided to support code that relies on byte array
|
|
192
|
-
* being representd as a string.
|
|
193
|
-
* @return String containing the raw bytes of the byte array
|
|
194
|
-
*/
|
|
195
|
-
operator std::string() const { return std::string(data_.begin(), data_.end()); }
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* @brief Conversion operator to convert byte array to std::vector<uint8_t>.
|
|
199
|
-
* @return Vector containing the raw bytes of the byte array
|
|
200
|
-
*/
|
|
201
|
-
operator std::vector<uint8_t>() const { return data_; }
|
|
202
|
-
|
|
203
|
-
//! @cond Doxygen_Suppress
|
|
204
|
-
// Expose vector-like functionality
|
|
205
|
-
size_t size() const { return data_.size(); }
|
|
206
|
-
const uint8_t* data() const { return data_.data(); }
|
|
207
|
-
uint8_t* data() { return data_.data(); }
|
|
208
|
-
bool empty() const { return data_.empty(); }
|
|
209
|
-
void clear() { data_.clear(); }
|
|
210
|
-
uint8_t& operator[](size_t index) { return data_[index]; }
|
|
211
|
-
const uint8_t& operator[](size_t index) const { return data_[index]; }
|
|
212
|
-
void push_back(uint8_t byte) { data_.push_back(byte); }
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* @brief Appends a uint16_t value as 2 little-endian bytes.
|
|
216
|
-
* @param value The uint16_t value to append.
|
|
217
|
-
*/
|
|
218
|
-
void push_back(uint16_t value) {
|
|
219
|
-
for (size_t i = 0; i < 2; ++i) {
|
|
220
|
-
data_.push_back(static_cast<uint8_t>(value >> (i * 8)));
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* @brief Appends a uint32_t value as 4 little-endian bytes.
|
|
226
|
-
* @param value The uint32_t value to append.
|
|
227
|
-
*/
|
|
228
|
-
void push_back(uint32_t value) {
|
|
229
|
-
for (size_t i = 0; i < 4; ++i) {
|
|
230
|
-
data_.push_back(static_cast<uint8_t>(value >> (i * 8)));
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* @brief Appends a uint64_t value as 8 little-endian bytes.
|
|
236
|
-
* @param value The uint64_t value to append.
|
|
237
|
-
*/
|
|
238
|
-
void push_back(uint64_t value) {
|
|
239
|
-
for (size_t i = 0; i < 8; ++i) {
|
|
240
|
-
data_.push_back(static_cast<uint8_t>(value >> (i * 8)));
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
auto begin() { return data_.begin(); }
|
|
244
|
-
auto begin() const { return data_.begin(); }
|
|
245
|
-
auto end() { return data_.end(); }
|
|
246
|
-
auto end() const { return data_.end(); }
|
|
247
|
-
|
|
248
|
-
/**
|
|
249
|
-
* @brief Inserts a single byte at the specified position.
|
|
250
|
-
* @param pos Iterator to the position where the element is inserted.
|
|
251
|
-
* @param value The byte to insert.
|
|
252
|
-
* @return Iterator pointing to the inserted element.
|
|
253
|
-
*/
|
|
254
|
-
auto insert(typename std::vector<uint8_t>::iterator pos, uint8_t value) { return data_.insert(pos, value); }
|
|
255
|
-
auto insert(typename std::vector<uint8_t>::const_iterator pos, uint8_t value) { return data_.insert(pos, value); }
|
|
256
|
-
|
|
257
|
-
/**
|
|
258
|
-
* @brief Inserts multiple copies of a byte at the specified position.
|
|
259
|
-
* @param pos Iterator to the position where the elements are inserted.
|
|
260
|
-
* @param count Number of copies to insert.
|
|
261
|
-
* @param value The byte to insert.
|
|
262
|
-
* @return Iterator pointing to the first inserted element.
|
|
263
|
-
*/
|
|
264
|
-
auto insert(typename std::vector<uint8_t>::iterator pos, size_t count, uint8_t value) { return data_.insert(pos, count, value); }
|
|
265
|
-
auto insert(typename std::vector<uint8_t>::const_iterator pos, size_t count, uint8_t value) { return data_.insert(pos, count, value); }
|
|
266
|
-
|
|
267
|
-
/**
|
|
268
|
-
* @brief Inserts elements from a range at the specified position.
|
|
269
|
-
* @tparam InputIt Iterator type.
|
|
270
|
-
* @param pos Iterator to the position where the elements are inserted.
|
|
271
|
-
* @param first Iterator to the first element of the range.
|
|
272
|
-
* @param last Iterator to one past the last element of the range.
|
|
273
|
-
* @return Iterator pointing to the first inserted element.
|
|
274
|
-
*/
|
|
275
|
-
template <typename InputIt>
|
|
276
|
-
auto insert(typename std::vector<uint8_t>::iterator pos, InputIt first, InputIt last) { return data_.insert(pos, first, last); }
|
|
277
|
-
template <typename InputIt>
|
|
278
|
-
auto insert(typename std::vector<uint8_t>::const_iterator pos, InputIt first, InputIt last) { return data_.insert(pos, first, last); }
|
|
279
|
-
|
|
280
|
-
/**
|
|
281
|
-
* @brief Inserts another bytearray at the specified position.
|
|
282
|
-
* @param pos Iterator to the position where the elements are inserted.
|
|
283
|
-
* @param other The bytearray to insert.
|
|
284
|
-
* @return Iterator pointing to the first inserted element.
|
|
285
|
-
*/
|
|
286
|
-
auto insert(typename std::vector<uint8_t>::iterator pos, const bytearray& other) { return data_.insert(pos, other.begin(), other.end()); }
|
|
287
|
-
auto insert(typename std::vector<uint8_t>::const_iterator pos, const bytearray& other) { return data_.insert(pos, other.begin(), other.end()); }
|
|
288
|
-
|
|
289
|
-
//! @endcond
|
|
290
|
-
|
|
291
|
-
private:
|
|
292
|
-
std::vector<uint8_t> data_;
|
|
293
|
-
};
|
|
294
|
-
|
|
295
|
-
} // namespace kvn
|
|
296
|
-
|
|
297
|
-
#endif // KVN_BYTEARRAY_H
|
package/ios/simpleble_iphonesimulator_arm64/lib/cmake/simpleble/simpleble-config-release.cmake
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
#----------------------------------------------------------------
|
|
2
|
-
# Generated CMake target import file for configuration "Release".
|
|
3
|
-
#----------------------------------------------------------------
|
|
4
|
-
|
|
5
|
-
# Commands may need to know the format version.
|
|
6
|
-
set(CMAKE_IMPORT_FILE_VERSION 1)
|
|
7
|
-
|
|
8
|
-
# Import target "simpleble::simpleble" for configuration "Release"
|
|
9
|
-
set_property(TARGET simpleble::simpleble APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
|
|
10
|
-
set_target_properties(simpleble::simpleble PROPERTIES
|
|
11
|
-
IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C;CXX;OBJCXX"
|
|
12
|
-
IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/libsimpleble.a"
|
|
13
|
-
)
|
|
14
|
-
|
|
15
|
-
list(APPEND _cmake_import_check_targets simpleble::simpleble )
|
|
16
|
-
list(APPEND _cmake_import_check_files_for_simpleble::simpleble "${_IMPORT_PREFIX}/lib/libsimpleble.a" )
|
|
17
|
-
|
|
18
|
-
# Commands beyond this point should not need to know the version.
|
|
19
|
-
set(CMAKE_IMPORT_FILE_VERSION)
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
# Generated by CMake
|
|
2
|
-
|
|
3
|
-
if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.8)
|
|
4
|
-
message(FATAL_ERROR "CMake >= 2.8.12 required")
|
|
5
|
-
endif()
|
|
6
|
-
if(CMAKE_VERSION VERSION_LESS "2.8.12")
|
|
7
|
-
message(FATAL_ERROR "CMake >= 2.8.12 required")
|
|
8
|
-
endif()
|
|
9
|
-
cmake_policy(PUSH)
|
|
10
|
-
cmake_policy(VERSION 2.8.12...4.0)
|
|
11
|
-
#----------------------------------------------------------------
|
|
12
|
-
# Generated CMake target import file.
|
|
13
|
-
#----------------------------------------------------------------
|
|
14
|
-
|
|
15
|
-
# Commands may need to know the format version.
|
|
16
|
-
set(CMAKE_IMPORT_FILE_VERSION 1)
|
|
17
|
-
|
|
18
|
-
# Protect against multiple inclusion, which would fail when already imported targets are added once more.
|
|
19
|
-
set(_cmake_targets_defined "")
|
|
20
|
-
set(_cmake_targets_not_defined "")
|
|
21
|
-
set(_cmake_expected_targets "")
|
|
22
|
-
foreach(_cmake_expected_target IN ITEMS simpleble::simpleble)
|
|
23
|
-
list(APPEND _cmake_expected_targets "${_cmake_expected_target}")
|
|
24
|
-
if(TARGET "${_cmake_expected_target}")
|
|
25
|
-
list(APPEND _cmake_targets_defined "${_cmake_expected_target}")
|
|
26
|
-
else()
|
|
27
|
-
list(APPEND _cmake_targets_not_defined "${_cmake_expected_target}")
|
|
28
|
-
endif()
|
|
29
|
-
endforeach()
|
|
30
|
-
unset(_cmake_expected_target)
|
|
31
|
-
if(_cmake_targets_defined STREQUAL _cmake_expected_targets)
|
|
32
|
-
unset(_cmake_targets_defined)
|
|
33
|
-
unset(_cmake_targets_not_defined)
|
|
34
|
-
unset(_cmake_expected_targets)
|
|
35
|
-
unset(CMAKE_IMPORT_FILE_VERSION)
|
|
36
|
-
cmake_policy(POP)
|
|
37
|
-
return()
|
|
38
|
-
endif()
|
|
39
|
-
if(NOT _cmake_targets_defined STREQUAL "")
|
|
40
|
-
string(REPLACE ";" ", " _cmake_targets_defined_text "${_cmake_targets_defined}")
|
|
41
|
-
string(REPLACE ";" ", " _cmake_targets_not_defined_text "${_cmake_targets_not_defined}")
|
|
42
|
-
message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_cmake_targets_defined_text}\nTargets not yet defined: ${_cmake_targets_not_defined_text}\n")
|
|
43
|
-
endif()
|
|
44
|
-
unset(_cmake_targets_defined)
|
|
45
|
-
unset(_cmake_targets_not_defined)
|
|
46
|
-
unset(_cmake_expected_targets)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
# Compute the installation prefix relative to this file.
|
|
50
|
-
get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
|
51
|
-
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
|
|
52
|
-
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
|
|
53
|
-
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
|
|
54
|
-
if(_IMPORT_PREFIX STREQUAL "/")
|
|
55
|
-
set(_IMPORT_PREFIX "")
|
|
56
|
-
endif()
|
|
57
|
-
|
|
58
|
-
# Create imported target simpleble::simpleble
|
|
59
|
-
add_library(simpleble::simpleble STATIC IMPORTED)
|
|
60
|
-
|
|
61
|
-
set_target_properties(simpleble::simpleble PROPERTIES
|
|
62
|
-
INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
|
|
63
|
-
INTERFACE_LINK_LIBRARIES "-framework Foundation;-framework CoreBluetooth;ObjC"
|
|
64
|
-
)
|
|
65
|
-
|
|
66
|
-
# Load information for each installed configuration.
|
|
67
|
-
file(GLOB _cmake_config_files "${CMAKE_CURRENT_LIST_DIR}/simpleble-config-*.cmake")
|
|
68
|
-
foreach(_cmake_config_file IN LISTS _cmake_config_files)
|
|
69
|
-
include("${_cmake_config_file}")
|
|
70
|
-
endforeach()
|
|
71
|
-
unset(_cmake_config_file)
|
|
72
|
-
unset(_cmake_config_files)
|
|
73
|
-
|
|
74
|
-
# Cleanup temporary variables.
|
|
75
|
-
set(_IMPORT_PREFIX)
|
|
76
|
-
|
|
77
|
-
# Loop over all imported files and verify that they actually exist
|
|
78
|
-
foreach(_cmake_target IN LISTS _cmake_import_check_targets)
|
|
79
|
-
if(CMAKE_VERSION VERSION_LESS "3.28"
|
|
80
|
-
OR NOT DEFINED _cmake_import_check_xcframework_for_${_cmake_target}
|
|
81
|
-
OR NOT IS_DIRECTORY "${_cmake_import_check_xcframework_for_${_cmake_target}}")
|
|
82
|
-
foreach(_cmake_file IN LISTS "_cmake_import_check_files_for_${_cmake_target}")
|
|
83
|
-
if(NOT EXISTS "${_cmake_file}")
|
|
84
|
-
message(FATAL_ERROR "The imported target \"${_cmake_target}\" references the file
|
|
85
|
-
\"${_cmake_file}\"
|
|
86
|
-
but this file does not exist. Possible reasons include:
|
|
87
|
-
* The file was deleted, renamed, or moved to another location.
|
|
88
|
-
* An install or uninstall procedure did not complete successfully.
|
|
89
|
-
* The installation package was faulty and contained
|
|
90
|
-
\"${CMAKE_CURRENT_LIST_FILE}\"
|
|
91
|
-
but not all the files it references.
|
|
92
|
-
")
|
|
93
|
-
endif()
|
|
94
|
-
endforeach()
|
|
95
|
-
endif()
|
|
96
|
-
unset(_cmake_file)
|
|
97
|
-
unset("_cmake_import_check_files_for_${_cmake_target}")
|
|
98
|
-
endforeach()
|
|
99
|
-
unset(_cmake_target)
|
|
100
|
-
unset(_cmake_import_check_targets)
|
|
101
|
-
|
|
102
|
-
# This file does not depend on other imported targets which have
|
|
103
|
-
# been exported from the same project but in a separate export set.
|
|
104
|
-
|
|
105
|
-
# Commands beyond this point should not need to know the version.
|
|
106
|
-
set(CMAKE_IMPORT_FILE_VERSION)
|
|
107
|
-
cmake_policy(POP)
|
|
Binary file
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
prefix=/Users/alejorojas/work/caos/simpleble/simplejsble/packages/simplejsble/ios/simpleble_iphonesimulator_arm64
|
|
2
|
-
exec_prefix=/Users/alejorojas/work/caos/simpleble/simplejsble/packages/simplejsble/ios/simpleble_iphonesimulator_arm64
|
|
3
|
-
libdir=/Users/alejorojas/work/caos/simpleble/simplejsble/packages/simplejsble/ios/simpleble_iphonesimulator_arm64/lib
|
|
4
|
-
includedir=/Users/alejorojas/work/caos/simpleble/simplejsble/packages/simplejsble/ios/simpleble_iphonesimulator_arm64/include
|
|
5
|
-
|
|
6
|
-
Name: SimpleBLE
|
|
7
|
-
Description: "The ultimate fully-fledged cross-platform library for Bluetooth Low Energy (BLE)."
|
|
8
|
-
Version: 0.10.4
|
|
9
|
-
Libs: -L${libdir} -lsimpleble
|
|
10
|
-
Cflags: -I${includedir}
|
|
11
|
-
Conflicts:
|
package/macos/CMakeLists.txt
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
cmake_minimum_required(VERSION 3.21)
|
|
2
|
-
|
|
3
|
-
# Path: packages/simplejsble/macos → ../../../.. → repo root (where simpleble/ lives)
|
|
4
|
-
set(PROJECT_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../..)
|
|
5
|
-
set(BUILD_SHARED_LIBS OFF) # Static library for macOS
|
|
6
|
-
|
|
7
|
-
include(${PROJECT_ROOT_DIR}/cmake/prelude.cmake)
|
|
8
|
-
|
|
9
|
-
project(simpleble-macos VERSION ${SIMPLEBLE_VERSION_BASE} LANGUAGES CXX C OBJCXX)
|
|
10
|
-
|
|
11
|
-
include(${PROJECT_ROOT_DIR}/cmake/epilogue.cmake)
|
|
12
|
-
|
|
13
|
-
add_subdirectory(${PROJECT_ROOT_DIR}/simpleble ${CMAKE_BINARY_DIR}/simpleble)
|
|
14
|
-
|
|
15
|
-
# Install library
|
|
16
|
-
install(TARGETS simpleble ARCHIVE DESTINATION lib)
|
|
17
|
-
|
|
18
|
-
# Install headers (including generated export.h)
|
|
19
|
-
install(DIRECTORY ${PROJECT_ROOT_DIR}/simpleble/include/simpleble/ DESTINATION include/simpleble)
|
|
20
|
-
install(DIRECTORY ${CMAKE_BINARY_DIR}/simpleble/export/simpleble/ DESTINATION include/simpleble)
|
|
21
|
-
install(FILES ${PROJECT_ROOT_DIR}/dependencies/external/kvn/kvn_bytearray.h DESTINATION include/simpleble/kvn)
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
-
<plist version="1.0">
|
|
4
|
-
<dict>
|
|
5
|
-
<key>AvailableLibraries</key>
|
|
6
|
-
<array>
|
|
7
|
-
<dict>
|
|
8
|
-
<key>BinaryPath</key>
|
|
9
|
-
<string>libsimpleble.a</string>
|
|
10
|
-
<key>HeadersPath</key>
|
|
11
|
-
<string>Headers</string>
|
|
12
|
-
<key>LibraryIdentifier</key>
|
|
13
|
-
<string>macos-arm64_x86_64</string>
|
|
14
|
-
<key>LibraryPath</key>
|
|
15
|
-
<string>libsimpleble.a</string>
|
|
16
|
-
<key>SupportedArchitectures</key>
|
|
17
|
-
<array>
|
|
18
|
-
<string>arm64</string>
|
|
19
|
-
<string>x86_64</string>
|
|
20
|
-
</array>
|
|
21
|
-
<key>SupportedPlatform</key>
|
|
22
|
-
<string>macos</string>
|
|
23
|
-
</dict>
|
|
24
|
-
</array>
|
|
25
|
-
<key>CFBundlePackageType</key>
|
|
26
|
-
<string>XFWK</string>
|
|
27
|
-
<key>XCFrameworkFormatVersion</key>
|
|
28
|
-
<string>1.0</string>
|
|
29
|
-
</dict>
|
|
30
|
-
</plist>
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include <functional>
|
|
4
|
-
#include <memory>
|
|
5
|
-
#include <string>
|
|
6
|
-
#include <vector>
|
|
7
|
-
|
|
8
|
-
#include <simpleble/export.h>
|
|
9
|
-
|
|
10
|
-
#include <simpleble/Exceptions.h>
|
|
11
|
-
#include <simpleble/Peripheral.h>
|
|
12
|
-
#include <simpleble/Types.h>
|
|
13
|
-
|
|
14
|
-
namespace SimpleBLE {
|
|
15
|
-
|
|
16
|
-
class AdapterBase;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Bluetooth Adapter.
|
|
20
|
-
*
|
|
21
|
-
* A default-constructed Adapter object is not initialized. Calling any method
|
|
22
|
-
* other than `initialized()` on an uninitialized Adapter will throw an exception
|
|
23
|
-
* of type `SimpleBLE::NotInitialized`.
|
|
24
|
-
*
|
|
25
|
-
* NOTE: This class is intended to be used by the user only. Library developers
|
|
26
|
-
* should use shared pointers to `AdapterBase` instead.
|
|
27
|
-
*/
|
|
28
|
-
class SIMPLEBLE_EXPORT Adapter {
|
|
29
|
-
public:
|
|
30
|
-
Adapter() = default;
|
|
31
|
-
virtual ~Adapter() = default;
|
|
32
|
-
|
|
33
|
-
bool initialized() const;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Retrieve the underlying OS object/handle.
|
|
37
|
-
*
|
|
38
|
-
* For certain compatibility with external libraries, we sometimes need to
|
|
39
|
-
* expose the actual OS handle to the user. This is particularly important
|
|
40
|
-
* for MacOS right now.
|
|
41
|
-
*/
|
|
42
|
-
void* underlying() const;
|
|
43
|
-
|
|
44
|
-
std::string identifier();
|
|
45
|
-
BluetoothAddress address();
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Control the power state of the adapter.
|
|
49
|
-
*
|
|
50
|
-
* NOTE: The power on/off functionality is only supported on Windows and Linux (implementation pending).
|
|
51
|
-
* On other platforms, this method will do nothing.
|
|
52
|
-
* NOTE: Callbacks are currently a placeholder for future implementation.
|
|
53
|
-
*/
|
|
54
|
-
void power_on();
|
|
55
|
-
void power_off();
|
|
56
|
-
bool is_powered();
|
|
57
|
-
void set_callback_on_power_on(std::function<void()> on_power_on);
|
|
58
|
-
void set_callback_on_power_off(std::function<void()> on_power_off);
|
|
59
|
-
|
|
60
|
-
void scan_start();
|
|
61
|
-
void scan_stop();
|
|
62
|
-
void scan_for(int timeout_ms);
|
|
63
|
-
bool scan_is_active();
|
|
64
|
-
std::vector<Peripheral> scan_get_results();
|
|
65
|
-
|
|
66
|
-
void set_callback_on_scan_start(std::function<void()> on_scan_start);
|
|
67
|
-
void set_callback_on_scan_stop(std::function<void()> on_scan_stop);
|
|
68
|
-
void set_callback_on_scan_updated(std::function<void(Peripheral)> on_scan_updated);
|
|
69
|
-
void set_callback_on_scan_found(std::function<void(Peripheral)> on_scan_found);
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Retrieve a list of all paired peripherals.
|
|
73
|
-
*
|
|
74
|
-
* NOTE:This method is currently only supported by the Linux, Windows and Android backends.
|
|
75
|
-
*/
|
|
76
|
-
std::vector<Peripheral> get_paired_peripherals();
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Retrieve a list of all connected peripherals.
|
|
80
|
-
*
|
|
81
|
-
* NOTE: This method is currently only supported by the Windows backend. (More backends coming soon.)
|
|
82
|
-
*/
|
|
83
|
-
std::vector<Peripheral> get_connected_peripherals();
|
|
84
|
-
|
|
85
|
-
static bool bluetooth_enabled();
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Fetches a list of all available adapters from all available backends.
|
|
89
|
-
*
|
|
90
|
-
* This will cause backends to be instantiated/initialized and adapters
|
|
91
|
-
* too.
|
|
92
|
-
*/
|
|
93
|
-
static std::vector<Adapter> get_adapters();
|
|
94
|
-
|
|
95
|
-
protected:
|
|
96
|
-
AdapterBase* operator->();
|
|
97
|
-
const AdapterBase* operator->() const;
|
|
98
|
-
|
|
99
|
-
std::shared_ptr<AdapterBase> internal_;
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
} // namespace SimpleBLE
|
package/macos/SimpleBLE-macos.xcframework/macos-arm64_x86_64/Headers/simpleble/AdapterSafe.h
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include <simpleble/export.h>
|
|
4
|
-
|
|
5
|
-
#include <simpleble/Adapter.h>
|
|
6
|
-
#include <simpleble/PeripheralSafe.h>
|
|
7
|
-
#include <memory>
|
|
8
|
-
#include <optional>
|
|
9
|
-
#include <vector>
|
|
10
|
-
|
|
11
|
-
namespace SimpleBLE {
|
|
12
|
-
|
|
13
|
-
namespace Safe {
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Wrapper around the Adapter class that provides a noexcept interface.
|
|
17
|
-
*
|
|
18
|
-
* We use instances of this class directly and not through shared_ptr because
|
|
19
|
-
* this is just a wrapper around the Adapter class, which is already managed by
|
|
20
|
-
* shared_ptr.
|
|
21
|
-
*/
|
|
22
|
-
class SIMPLEBLE_EXPORT Adapter {
|
|
23
|
-
public:
|
|
24
|
-
Adapter(SimpleBLE::Adapter& adapter);
|
|
25
|
-
Adapter(SimpleBLE::Adapter&& adapter);
|
|
26
|
-
virtual ~Adapter() = default;
|
|
27
|
-
|
|
28
|
-
std::optional<std::string> identifier() noexcept;
|
|
29
|
-
std::optional<BluetoothAddress> address() noexcept;
|
|
30
|
-
|
|
31
|
-
bool scan_start() noexcept;
|
|
32
|
-
bool scan_stop() noexcept;
|
|
33
|
-
bool scan_for(int timeout_ms) noexcept;
|
|
34
|
-
std::optional<bool> scan_is_active() noexcept;
|
|
35
|
-
std::optional<std::vector<SimpleBLE::Safe::Peripheral>> scan_get_results() noexcept;
|
|
36
|
-
|
|
37
|
-
bool set_callback_on_scan_start(std::function<void()> on_scan_start) noexcept;
|
|
38
|
-
bool set_callback_on_scan_stop(std::function<void()> on_scan_stop) noexcept;
|
|
39
|
-
bool set_callback_on_scan_updated(std::function<void(SimpleBLE::Safe::Peripheral)> on_scan_updated) noexcept;
|
|
40
|
-
bool set_callback_on_scan_found(std::function<void(SimpleBLE::Safe::Peripheral)> on_scan_found) noexcept;
|
|
41
|
-
|
|
42
|
-
std::optional<std::vector<SimpleBLE::Safe::Peripheral>> get_paired_peripherals() noexcept;
|
|
43
|
-
|
|
44
|
-
static std::optional<bool> bluetooth_enabled() noexcept;
|
|
45
|
-
static std::optional<std::vector<SimpleBLE::Safe::Adapter>> get_adapters() noexcept;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Cast to the underlying adapter object.
|
|
49
|
-
*/
|
|
50
|
-
operator SimpleBLE::Adapter() const noexcept;
|
|
51
|
-
|
|
52
|
-
protected:
|
|
53
|
-
SimpleBLE::Adapter internal_;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
} // namespace Safe
|
|
57
|
-
|
|
58
|
-
} // namespace SimpleBLE
|