simplejsble 0.0.30 → 0.0.32
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 +9 -114
- package/ios/SimpleBLE.xcframework/Info.plist +64 -0
- package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/Adapter.h +102 -0
- package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/AdapterSafe.h +58 -0
- package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/Advanced.h +50 -0
- package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/Characteristic.h +39 -0
- package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/Config.h +64 -0
- package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/Descriptor.h +30 -0
- package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/Exceptions.h +72 -0
- package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/Logging.h +73 -0
- package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/Peripheral.h +82 -0
- package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/PeripheralSafe.h +64 -0
- package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/Service.h +34 -0
- package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/SimpleBLE.h +8 -0
- package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/Types.h +49 -0
- package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/Utils.h +13 -0
- package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/export.h +43 -0
- package/ios/SimpleBLE.xcframework/ios-arm64/Headers/simpleble/kvn/kvn_bytearray.h +304 -0
- package/ios/SimpleBLE.xcframework/ios-arm64/libsimpleble.a +0 -0
- package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/Adapter.h +102 -0
- package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/AdapterSafe.h +58 -0
- package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/Advanced.h +50 -0
- package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/Characteristic.h +39 -0
- package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/Config.h +64 -0
- package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/Descriptor.h +30 -0
- package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/Exceptions.h +72 -0
- package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/Logging.h +73 -0
- package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/Peripheral.h +82 -0
- package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/PeripheralSafe.h +64 -0
- package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/Service.h +34 -0
- package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/SimpleBLE.h +8 -0
- package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/Types.h +49 -0
- package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/Utils.h +13 -0
- package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/export.h +43 -0
- package/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers/simpleble/kvn/kvn_bytearray.h +304 -0
- package/ios/SimpleBLE.xcframework/ios-arm64-simulator/libsimpleble.a +0 -0
- package/ios/SimpleBLE.xcframework/macos-arm64_x86_64/Headers/simpleble/Adapter.h +102 -0
- package/ios/SimpleBLE.xcframework/macos-arm64_x86_64/Headers/simpleble/AdapterSafe.h +58 -0
- package/ios/SimpleBLE.xcframework/macos-arm64_x86_64/Headers/simpleble/Advanced.h +50 -0
- package/ios/SimpleBLE.xcframework/macos-arm64_x86_64/Headers/simpleble/Characteristic.h +39 -0
- package/ios/SimpleBLE.xcframework/macos-arm64_x86_64/Headers/simpleble/Config.h +64 -0
- package/ios/SimpleBLE.xcframework/macos-arm64_x86_64/Headers/simpleble/Descriptor.h +30 -0
- package/ios/SimpleBLE.xcframework/macos-arm64_x86_64/Headers/simpleble/Exceptions.h +72 -0
- package/ios/SimpleBLE.xcframework/macos-arm64_x86_64/Headers/simpleble/Logging.h +73 -0
- package/ios/SimpleBLE.xcframework/macos-arm64_x86_64/Headers/simpleble/Peripheral.h +82 -0
- package/ios/SimpleBLE.xcframework/macos-arm64_x86_64/Headers/simpleble/PeripheralSafe.h +64 -0
- package/ios/SimpleBLE.xcframework/macos-arm64_x86_64/Headers/simpleble/Service.h +34 -0
- package/ios/SimpleBLE.xcframework/macos-arm64_x86_64/Headers/simpleble/SimpleBLE.h +8 -0
- package/ios/SimpleBLE.xcframework/macos-arm64_x86_64/Headers/simpleble/Types.h +49 -0
- package/ios/SimpleBLE.xcframework/macos-arm64_x86_64/Headers/simpleble/Utils.h +13 -0
- package/ios/SimpleBLE.xcframework/macos-arm64_x86_64/Headers/simpleble/export.h +43 -0
- package/ios/SimpleBLE.xcframework/macos-arm64_x86_64/Headers/simpleble/kvn/kvn_bytearray.h +304 -0
- package/ios/SimpleBLE.xcframework/macos-arm64_x86_64/libsimpleble.a +0 -0
- package/package.json +1 -1
package/NitroSimplejsble.podspec
CHANGED
|
@@ -11,116 +11,14 @@ Pod::Spec.new do |s|
|
|
|
11
11
|
s.authors = package["author"]
|
|
12
12
|
|
|
13
13
|
s.platforms = {
|
|
14
|
-
:ios =>
|
|
14
|
+
:ios => '13.4',
|
|
15
15
|
:osx => '10.13'
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
s.source = { :path => "." }
|
|
19
19
|
|
|
20
|
-
#
|
|
21
|
-
#
|
|
22
|
-
s.prepare_command = <<-CMD
|
|
23
|
-
# Build iOS/macOS XCFramework if not present
|
|
24
|
-
if [ -d "ios/SimpleBLE.xcframework" ]; then
|
|
25
|
-
echo "SimpleBLE.xcframework already exists, skipping build"
|
|
26
|
-
else
|
|
27
|
-
echo "Building SimpleBLE for iOS and macOS..."
|
|
28
|
-
set -e
|
|
29
|
-
IOS_DIR="ios"
|
|
30
|
-
IOS_DEPLOYMENT_TARGET="${IOS_DEPLOYMENT_TARGET:-13.4}"
|
|
31
|
-
MACOS_DEPLOYMENT_TARGET="${MACOS_DEPLOYMENT_TARGET:-10.13}"
|
|
32
|
-
|
|
33
|
-
# Build for iOS platforms (iphoneos, iphonesimulator)
|
|
34
|
-
build_for_ios_platform() {
|
|
35
|
-
local PLATFORM=$1 # iphoneos or iphonesimulator
|
|
36
|
-
local ARCH=$2 # arm64 or x86_64
|
|
37
|
-
|
|
38
|
-
local BUILD_DIR="${IOS_DIR}/build_${PLATFORM}_${ARCH}"
|
|
39
|
-
local INSTALL_DIR="${IOS_DIR}/simpleble_${PLATFORM}_${ARCH}"
|
|
40
|
-
|
|
41
|
-
echo "Building SimpleBLE for ${PLATFORM} (${ARCH})..."
|
|
42
|
-
|
|
43
|
-
cmake -B "${BUILD_DIR}" -S "${IOS_DIR}" \
|
|
44
|
-
-DCMAKE_BUILD_TYPE=Release \
|
|
45
|
-
-DCMAKE_SYSTEM_NAME=iOS \
|
|
46
|
-
-DCMAKE_OSX_SYSROOT="${PLATFORM}" \
|
|
47
|
-
-DCMAKE_OSX_ARCHITECTURES="${ARCH}" \
|
|
48
|
-
-DCMAKE_OSX_DEPLOYMENT_TARGET="${IOS_DEPLOYMENT_TARGET}" \
|
|
49
|
-
-DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
|
|
50
|
-
-DBUILD_SHARED_LIBS=OFF \
|
|
51
|
-
-DSIMPLEBLE_EXCLUDE_C=ON
|
|
52
|
-
|
|
53
|
-
cmake --build "${BUILD_DIR}" --config Release --parallel
|
|
54
|
-
cmake --install "${BUILD_DIR}" --config Release
|
|
55
|
-
|
|
56
|
-
echo "Installed to ${INSTALL_DIR}"
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
# Build for macOS platforms
|
|
60
|
-
build_for_macos_platform() {
|
|
61
|
-
local ARCH=$1 # arm64 or x86_64
|
|
62
|
-
|
|
63
|
-
local BUILD_DIR="${IOS_DIR}/build_macosx_${ARCH}"
|
|
64
|
-
local INSTALL_DIR="${IOS_DIR}/simpleble_macosx_${ARCH}"
|
|
65
|
-
|
|
66
|
-
echo "Building SimpleBLE for macOS (${ARCH})..."
|
|
67
|
-
|
|
68
|
-
cmake -B "${BUILD_DIR}" -S "${IOS_DIR}" \
|
|
69
|
-
-DCMAKE_BUILD_TYPE=Release \
|
|
70
|
-
-DCMAKE_SYSTEM_NAME=Darwin \
|
|
71
|
-
-DCMAKE_OSX_SYSROOT="macosx" \
|
|
72
|
-
-DCMAKE_OSX_ARCHITECTURES="${ARCH}" \
|
|
73
|
-
-DCMAKE_OSX_DEPLOYMENT_TARGET="${MACOS_DEPLOYMENT_TARGET}" \
|
|
74
|
-
-DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
|
|
75
|
-
-DBUILD_SHARED_LIBS=OFF \
|
|
76
|
-
-DSIMPLEBLE_EXCLUDE_C=ON
|
|
77
|
-
|
|
78
|
-
cmake --build "${BUILD_DIR}" --config Release --parallel
|
|
79
|
-
cmake --install "${BUILD_DIR}" --config Release
|
|
80
|
-
|
|
81
|
-
echo "Installed to ${INSTALL_DIR}"
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
# Build for iOS device
|
|
85
|
-
build_for_ios_platform "iphoneos" "arm64"
|
|
86
|
-
|
|
87
|
-
# Build for iOS simulator (Apple Silicon)
|
|
88
|
-
build_for_ios_platform "iphonesimulator" "arm64"
|
|
89
|
-
|
|
90
|
-
# Build for macOS (Apple Silicon)
|
|
91
|
-
build_for_macos_platform "arm64"
|
|
92
|
-
|
|
93
|
-
# Build for macOS (Intel)
|
|
94
|
-
build_for_macos_platform "x86_64"
|
|
95
|
-
|
|
96
|
-
# Create universal macOS library
|
|
97
|
-
echo "Creating universal macOS library..."
|
|
98
|
-
MACOS_UNIVERSAL_DIR="${IOS_DIR}/simpleble_macosx_universal"
|
|
99
|
-
mkdir -p "${MACOS_UNIVERSAL_DIR}/lib"
|
|
100
|
-
cp -r "${IOS_DIR}/simpleble_macosx_arm64/include" "${MACOS_UNIVERSAL_DIR}/"
|
|
101
|
-
lipo -create \
|
|
102
|
-
"${IOS_DIR}/simpleble_macosx_arm64/lib/libsimpleble.a" \
|
|
103
|
-
"${IOS_DIR}/simpleble_macosx_x86_64/lib/libsimpleble.a" \
|
|
104
|
-
-output "${MACOS_UNIVERSAL_DIR}/lib/libsimpleble.a"
|
|
105
|
-
|
|
106
|
-
# Create XCFramework from the static libraries (iOS + macOS)
|
|
107
|
-
echo "Creating XCFramework..."
|
|
108
|
-
XCFRAMEWORK_PATH="${IOS_DIR}/SimpleBLE.xcframework"
|
|
109
|
-
rm -rf "${XCFRAMEWORK_PATH}"
|
|
110
|
-
|
|
111
|
-
xcodebuild -create-xcframework \
|
|
112
|
-
-library "${IOS_DIR}/simpleble_iphoneos_arm64/lib/libsimpleble.a" \
|
|
113
|
-
-headers "${IOS_DIR}/simpleble_iphoneos_arm64/include" \
|
|
114
|
-
-library "${IOS_DIR}/simpleble_iphonesimulator_arm64/lib/libsimpleble.a" \
|
|
115
|
-
-headers "${IOS_DIR}/simpleble_iphonesimulator_arm64/include" \
|
|
116
|
-
-library "${MACOS_UNIVERSAL_DIR}/lib/libsimpleble.a" \
|
|
117
|
-
-headers "${MACOS_UNIVERSAL_DIR}/include" \
|
|
118
|
-
-output "${XCFRAMEWORK_PATH}"
|
|
119
|
-
|
|
120
|
-
echo "SimpleBLE build complete!"
|
|
121
|
-
echo "XCFramework created at: ${XCFRAMEWORK_PATH}"
|
|
122
|
-
fi
|
|
123
|
-
CMD
|
|
20
|
+
# XCFramework is pre-built during npm publish (scripts/build-xcframework.sh)
|
|
21
|
+
# No prepare_command needed - the XCFramework is included in the npm package
|
|
124
22
|
|
|
125
23
|
s.source_files = [
|
|
126
24
|
# Implementation (Swift)
|
|
@@ -150,19 +48,16 @@ Pod::Spec.new do |s|
|
|
|
150
48
|
s.ios.vendored_frameworks = 'ios/SimpleBLE.xcframework'
|
|
151
49
|
s.osx.vendored_frameworks = 'ios/SimpleBLE.xcframework'
|
|
152
50
|
|
|
153
|
-
# Configure header search paths for SimpleBLE
|
|
51
|
+
# Configure header search paths for SimpleBLE XCFramework
|
|
52
|
+
# Headers are inside the XCFramework slices - we include all platforms so it works for any target
|
|
154
53
|
current_pod_target_xcconfig = s.attributes_hash['pod_target_xcconfig'] || {}
|
|
155
54
|
s.pod_target_xcconfig = current_pod_target_xcconfig.merge({
|
|
156
55
|
'HEADER_SEARCH_PATHS' => [
|
|
157
56
|
'"$(inherited)"',
|
|
158
|
-
#
|
|
159
|
-
'"$(PODS_TARGET_SRCROOT)/ios/
|
|
160
|
-
'"$(PODS_TARGET_SRCROOT)/ios/
|
|
161
|
-
|
|
162
|
-
'"$(PODS_TARGET_SRCROOT)/ios/simpleble_macosx_arm64/include"',
|
|
163
|
-
'"$(PODS_TARGET_SRCROOT)/ios/simpleble_macosx_x86_64/include"',
|
|
164
|
-
'"$(PODS_TARGET_SRCROOT)/ios/simpleble_macosx_universal/include"',
|
|
57
|
+
# XCFramework headers for each platform slice
|
|
58
|
+
'"$(PODS_TARGET_SRCROOT)/ios/SimpleBLE.xcframework/ios-arm64/Headers"',
|
|
59
|
+
'"$(PODS_TARGET_SRCROOT)/ios/SimpleBLE.xcframework/ios-arm64-simulator/Headers"',
|
|
60
|
+
'"$(PODS_TARGET_SRCROOT)/ios/SimpleBLE.xcframework/macos-arm64_x86_64/Headers"',
|
|
165
61
|
].join(' '),
|
|
166
|
-
'GCC_PREPROCESSOR_DEFINITIONS' => ['$(inherited)', 'OS_OBJECT_USE_OBJC=1']
|
|
167
62
|
})
|
|
168
63
|
end
|
|
@@ -0,0 +1,64 @@
|
|
|
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>ios-arm64-simulator</string>
|
|
14
|
+
<key>LibraryPath</key>
|
|
15
|
+
<string>libsimpleble.a</string>
|
|
16
|
+
<key>SupportedArchitectures</key>
|
|
17
|
+
<array>
|
|
18
|
+
<string>arm64</string>
|
|
19
|
+
</array>
|
|
20
|
+
<key>SupportedPlatform</key>
|
|
21
|
+
<string>ios</string>
|
|
22
|
+
<key>SupportedPlatformVariant</key>
|
|
23
|
+
<string>simulator</string>
|
|
24
|
+
</dict>
|
|
25
|
+
<dict>
|
|
26
|
+
<key>BinaryPath</key>
|
|
27
|
+
<string>libsimpleble.a</string>
|
|
28
|
+
<key>HeadersPath</key>
|
|
29
|
+
<string>Headers</string>
|
|
30
|
+
<key>LibraryIdentifier</key>
|
|
31
|
+
<string>ios-arm64</string>
|
|
32
|
+
<key>LibraryPath</key>
|
|
33
|
+
<string>libsimpleble.a</string>
|
|
34
|
+
<key>SupportedArchitectures</key>
|
|
35
|
+
<array>
|
|
36
|
+
<string>arm64</string>
|
|
37
|
+
</array>
|
|
38
|
+
<key>SupportedPlatform</key>
|
|
39
|
+
<string>ios</string>
|
|
40
|
+
</dict>
|
|
41
|
+
<dict>
|
|
42
|
+
<key>BinaryPath</key>
|
|
43
|
+
<string>libsimpleble.a</string>
|
|
44
|
+
<key>HeadersPath</key>
|
|
45
|
+
<string>Headers</string>
|
|
46
|
+
<key>LibraryIdentifier</key>
|
|
47
|
+
<string>macos-arm64_x86_64</string>
|
|
48
|
+
<key>LibraryPath</key>
|
|
49
|
+
<string>libsimpleble.a</string>
|
|
50
|
+
<key>SupportedArchitectures</key>
|
|
51
|
+
<array>
|
|
52
|
+
<string>arm64</string>
|
|
53
|
+
<string>x86_64</string>
|
|
54
|
+
</array>
|
|
55
|
+
<key>SupportedPlatform</key>
|
|
56
|
+
<string>macos</string>
|
|
57
|
+
</dict>
|
|
58
|
+
</array>
|
|
59
|
+
<key>CFBundlePackageType</key>
|
|
60
|
+
<string>XFWK</string>
|
|
61
|
+
<key>XCFrameworkFormatVersion</key>
|
|
62
|
+
<string>1.0</string>
|
|
63
|
+
</dict>
|
|
64
|
+
</plist>
|
|
@@ -0,0 +1,102 @@
|
|
|
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
|
|
@@ -0,0 +1,58 @@
|
|
|
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
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <simpleble/export.h>
|
|
4
|
+
|
|
5
|
+
#if __APPLE__
|
|
6
|
+
#include "TargetConditionals.h"
|
|
7
|
+
#endif
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Advanced Features
|
|
11
|
+
*
|
|
12
|
+
* The functions presented in this namespace are OS-specific backdoors that are
|
|
13
|
+
* not part of the standard SimpleBLE API, which allow the user to access
|
|
14
|
+
* low-level details of the implementation for advanced use cases.
|
|
15
|
+
*
|
|
16
|
+
* These functions should be used with caution.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
#if defined(_WIN32)
|
|
20
|
+
namespace SimpleBLE::Advanced::Windows {}
|
|
21
|
+
|
|
22
|
+
#endif
|
|
23
|
+
|
|
24
|
+
#if TARGET_OS_OSX
|
|
25
|
+
namespace SimpleBLE::Advanced::MacOS {}
|
|
26
|
+
|
|
27
|
+
#endif
|
|
28
|
+
|
|
29
|
+
#if TARGET_OS_IOS
|
|
30
|
+
namespace SimpleBLE::Advanced::iOS {}
|
|
31
|
+
|
|
32
|
+
#endif
|
|
33
|
+
|
|
34
|
+
#if defined(__ANDROID__)
|
|
35
|
+
|
|
36
|
+
#include <jni.h>
|
|
37
|
+
|
|
38
|
+
namespace SimpleBLE::Advanced::Android {
|
|
39
|
+
|
|
40
|
+
JavaVM* SIMPLEBLE_EXPORT get_jvm();
|
|
41
|
+
void SIMPLEBLE_EXPORT set_jvm(JavaVM* jvm);
|
|
42
|
+
|
|
43
|
+
} // namespace SimpleBLE::Advanced::Android
|
|
44
|
+
|
|
45
|
+
#endif
|
|
46
|
+
|
|
47
|
+
#if defined(__linux__) && !defined(__ANDROID__)
|
|
48
|
+
namespace SimpleBLE::Advanced::Linux {}
|
|
49
|
+
|
|
50
|
+
#endif
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
|
|
5
|
+
#include <simpleble/export.h>
|
|
6
|
+
|
|
7
|
+
#include <simpleble/Descriptor.h>
|
|
8
|
+
#include <simpleble/Exceptions.h>
|
|
9
|
+
#include <simpleble/Types.h>
|
|
10
|
+
|
|
11
|
+
namespace SimpleBLE {
|
|
12
|
+
|
|
13
|
+
class CharacteristicBase;
|
|
14
|
+
|
|
15
|
+
class SIMPLEBLE_EXPORT Characteristic {
|
|
16
|
+
public:
|
|
17
|
+
Characteristic() = default;
|
|
18
|
+
virtual ~Characteristic() = default;
|
|
19
|
+
|
|
20
|
+
bool initialized() const;
|
|
21
|
+
|
|
22
|
+
BluetoothUUID uuid();
|
|
23
|
+
std::vector<Descriptor> descriptors();
|
|
24
|
+
std::vector<std::string> capabilities();
|
|
25
|
+
|
|
26
|
+
bool can_read();
|
|
27
|
+
bool can_write_request();
|
|
28
|
+
bool can_write_command();
|
|
29
|
+
bool can_notify();
|
|
30
|
+
bool can_indicate();
|
|
31
|
+
|
|
32
|
+
protected:
|
|
33
|
+
CharacteristicBase* operator->();
|
|
34
|
+
const CharacteristicBase* operator->() const;
|
|
35
|
+
|
|
36
|
+
std::shared_ptr<CharacteristicBase> internal_;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
} // namespace SimpleBLE
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
#include <chrono>
|
|
3
|
+
|
|
4
|
+
namespace SimpleBLE {
|
|
5
|
+
namespace Config {
|
|
6
|
+
namespace SimpleBluez {
|
|
7
|
+
extern bool use_legacy_bluez_backend;
|
|
8
|
+
extern std::chrono::steady_clock::duration connection_timeout;
|
|
9
|
+
extern std::chrono::steady_clock::duration disconnection_timeout;
|
|
10
|
+
|
|
11
|
+
static void reset() {
|
|
12
|
+
use_legacy_bluez_backend = true;
|
|
13
|
+
connection_timeout = std::chrono::seconds(2);
|
|
14
|
+
disconnection_timeout = std::chrono::seconds(1);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
namespace WinRT {
|
|
19
|
+
extern bool experimental_use_own_mta_apartment;
|
|
20
|
+
extern bool experimental_reinitialize_winrt_apartment_on_main_thread;
|
|
21
|
+
|
|
22
|
+
static void reset() {
|
|
23
|
+
experimental_use_own_mta_apartment = true;
|
|
24
|
+
experimental_reinitialize_winrt_apartment_on_main_thread = false;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
namespace CoreBluetooth {
|
|
29
|
+
static void reset() {}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
namespace Android {
|
|
33
|
+
enum class ConnectionPriorityRequest {
|
|
34
|
+
DISABLED = -1,
|
|
35
|
+
BALANCED = 0,
|
|
36
|
+
HIGH = 1,
|
|
37
|
+
LOW_POWER = 2,
|
|
38
|
+
DCK = 3
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
extern ConnectionPriorityRequest connection_priority_request;
|
|
42
|
+
|
|
43
|
+
static void reset() {
|
|
44
|
+
connection_priority_request = ConnectionPriorityRequest::DISABLED;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
namespace Dongl {
|
|
49
|
+
extern bool use_dongl_backend;
|
|
50
|
+
static void reset() {
|
|
51
|
+
use_dongl_backend = false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
namespace Base {
|
|
56
|
+
static void reset_all() {
|
|
57
|
+
SimpleBluez::reset();
|
|
58
|
+
WinRT::reset();
|
|
59
|
+
CoreBluetooth::reset();
|
|
60
|
+
Android::reset();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
} // namespace Config
|
|
64
|
+
} // namespace SimpleBLE
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
|
|
5
|
+
#include <simpleble/export.h>
|
|
6
|
+
|
|
7
|
+
#include <simpleble/Exceptions.h>
|
|
8
|
+
#include <simpleble/Types.h>
|
|
9
|
+
|
|
10
|
+
namespace SimpleBLE {
|
|
11
|
+
|
|
12
|
+
class DescriptorBase;
|
|
13
|
+
|
|
14
|
+
class SIMPLEBLE_EXPORT Descriptor {
|
|
15
|
+
public:
|
|
16
|
+
Descriptor() = default;
|
|
17
|
+
virtual ~Descriptor() = default;
|
|
18
|
+
|
|
19
|
+
bool initialized() const;
|
|
20
|
+
|
|
21
|
+
BluetoothUUID uuid();
|
|
22
|
+
|
|
23
|
+
protected:
|
|
24
|
+
DescriptorBase* operator->();
|
|
25
|
+
const DescriptorBase* operator->() const;
|
|
26
|
+
|
|
27
|
+
std::shared_ptr<DescriptorBase> internal_;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
} // namespace SimpleBLE
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <stdexcept>
|
|
4
|
+
#include <string>
|
|
5
|
+
|
|
6
|
+
#include <simpleble/export.h>
|
|
7
|
+
|
|
8
|
+
#include "Types.h"
|
|
9
|
+
|
|
10
|
+
namespace SimpleBLE {
|
|
11
|
+
|
|
12
|
+
namespace Exception {
|
|
13
|
+
|
|
14
|
+
class SIMPLEBLE_EXPORT BaseException : public std::runtime_error {
|
|
15
|
+
public:
|
|
16
|
+
BaseException(const std::string& __arg) : std::runtime_error(__arg) {}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
class SIMPLEBLE_EXPORT NotInitialized : public BaseException {
|
|
20
|
+
public:
|
|
21
|
+
NotInitialized();
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
class SIMPLEBLE_EXPORT NotConnected : public BaseException {
|
|
25
|
+
public:
|
|
26
|
+
NotConnected();
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
class SIMPLEBLE_EXPORT InvalidReference : public BaseException {
|
|
30
|
+
public:
|
|
31
|
+
InvalidReference();
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
class SIMPLEBLE_EXPORT ServiceNotFound : public BaseException {
|
|
35
|
+
public:
|
|
36
|
+
ServiceNotFound(BluetoothUUID uuid);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
class SIMPLEBLE_EXPORT CharacteristicNotFound : public BaseException {
|
|
40
|
+
public:
|
|
41
|
+
CharacteristicNotFound(BluetoothUUID uuid);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
class SIMPLEBLE_EXPORT DescriptorNotFound : public BaseException {
|
|
45
|
+
public:
|
|
46
|
+
DescriptorNotFound(BluetoothUUID uuid);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
class SIMPLEBLE_EXPORT OperationNotSupported : public BaseException {
|
|
50
|
+
public:
|
|
51
|
+
OperationNotSupported();
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
class SIMPLEBLE_EXPORT OperationFailed : public BaseException {
|
|
55
|
+
public:
|
|
56
|
+
OperationFailed();
|
|
57
|
+
OperationFailed(const std::string& err_msg);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
class SIMPLEBLE_EXPORT WinRTException : public BaseException {
|
|
61
|
+
public:
|
|
62
|
+
WinRTException(int32_t err_code, const std::string& err_msg);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
class SIMPLEBLE_EXPORT CoreBluetoothException : public BaseException {
|
|
66
|
+
public:
|
|
67
|
+
CoreBluetoothException(const std::string& err_msg);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
} // namespace Exception
|
|
71
|
+
|
|
72
|
+
} // namespace SimpleBLE
|