simplernble 1.2.1-dev116 → 1.2.1-dev122
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/cpp/HybridAdapterHandle.cpp +2 -2
- package/lib/adapter.js +2 -2
- package/native/VERSION +1 -1
- package/native/simpleble/include/simpleble/Exceptions.h +6 -0
- package/native/simpleble/src/Exceptions.cpp +6 -0
- package/native/simpleble/src/frontends/base/Adapter.cpp +2 -0
- package/package.json +1 -1
- package/prebuilt/release/SimpleBLE.xcframework/Info.plist +5 -5
- package/prebuilt/release/SimpleBLE.xcframework/ios-arm64/libsimpleble.a +0 -0
- package/prebuilt/release/SimpleBLE.xcframework/ios-arm64_x86_64-simulator/libsimpleble.a +0 -0
- package/prebuilt/release/include/simpleble/Exceptions.h +6 -0
- package/src/adapter.ts +2 -2
|
@@ -58,8 +58,8 @@ std::shared_ptr<Promise<void>> HybridAdapterHandle::scanStop() {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
std::shared_ptr<Promise<void>> HybridAdapterHandle::scanFor(double timeoutMs) {
|
|
61
|
-
if (!(timeoutMs >=
|
|
62
|
-
throw std::invalid_argument("timeoutMs must be
|
|
61
|
+
if (!(timeoutMs >= INT32_MIN && timeoutMs <= INT32_MAX) || std::floor(timeoutMs) != timeoutMs) {
|
|
62
|
+
throw std::invalid_argument("timeoutMs must be a 32-bit integer");
|
|
63
63
|
}
|
|
64
64
|
auto adapter = adapter_;
|
|
65
65
|
const int timeout = static_cast<int>(timeoutMs);
|
package/lib/adapter.js
CHANGED
|
@@ -64,8 +64,8 @@ class Adapter extends registry_1.NativeEmitter {
|
|
|
64
64
|
async scanFor(timeoutMs) {
|
|
65
65
|
if (typeof timeoutMs !== 'number')
|
|
66
66
|
throw new TypeError('timeoutMs must be a number');
|
|
67
|
-
if (!Number.isInteger(timeoutMs) || timeoutMs <
|
|
68
|
-
throw new RangeError('timeoutMs must be
|
|
67
|
+
if (!Number.isInteger(timeoutMs) || timeoutMs < -(2 ** 31) || timeoutMs > 2 ** 31 - 1) {
|
|
68
|
+
throw new RangeError('timeoutMs must be a 32-bit integer');
|
|
69
69
|
}
|
|
70
70
|
return (0, errors_1.async)(() => this.#handle.scanFor(timeoutMs));
|
|
71
71
|
}
|
package/native/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.2.1-
|
|
1
|
+
1.2.1-dev122
|
|
@@ -135,6 +135,12 @@ class SIMPLEBLE_EXPORT AdapterInUse : public BaseException {
|
|
|
135
135
|
std::unique_ptr<Error> make_error() const override;
|
|
136
136
|
};
|
|
137
137
|
|
|
138
|
+
class SIMPLEBLE_EXPORT InvalidArgument : public BaseException {
|
|
139
|
+
public:
|
|
140
|
+
InvalidArgument(const std::string& err_msg);
|
|
141
|
+
std::unique_ptr<Error> make_error() const override;
|
|
142
|
+
};
|
|
143
|
+
|
|
138
144
|
} // namespace Exception
|
|
139
145
|
|
|
140
146
|
} // namespace SimpleBLE
|
|
@@ -103,3 +103,9 @@ AdapterInUse::AdapterInUse(const std::string& adapter)
|
|
|
103
103
|
std::unique_ptr<Error> AdapterInUse::make_error() const {
|
|
104
104
|
return std::make_unique<Error>(ErrorCode::ADAPTER_IN_USE, std::make_unique<AdapterInUse>(*this));
|
|
105
105
|
}
|
|
106
|
+
|
|
107
|
+
InvalidArgument::InvalidArgument(const std::string& err_msg) : BaseException(err_msg) {}
|
|
108
|
+
|
|
109
|
+
std::unique_ptr<Error> InvalidArgument::make_error() const {
|
|
110
|
+
return std::make_unique<Error>(ErrorCode::INVALID_ARGUMENT, std::make_unique<InvalidArgument>(*this));
|
|
111
|
+
}
|
|
@@ -89,6 +89,8 @@ void Adapter::scan_stop() {
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
void Adapter::scan_for(int timeout_ms) {
|
|
92
|
+
if (timeout_ms < 0) throw Exception::InvalidArgument("timeout_ms must not be negative");
|
|
93
|
+
|
|
92
94
|
if (!(*this)->bluetooth_enabled()) {
|
|
93
95
|
SIMPLEBLE_LOG_WARN(fmt::format("Bluetooth is not enabled."));
|
|
94
96
|
return;
|
package/package.json
CHANGED
|
@@ -8,32 +8,32 @@
|
|
|
8
8
|
<key>BinaryPath</key>
|
|
9
9
|
<string>libsimpleble.a</string>
|
|
10
10
|
<key>LibraryIdentifier</key>
|
|
11
|
-
<string>ios-
|
|
11
|
+
<string>ios-arm64</string>
|
|
12
12
|
<key>LibraryPath</key>
|
|
13
13
|
<string>libsimpleble.a</string>
|
|
14
14
|
<key>SupportedArchitectures</key>
|
|
15
15
|
<array>
|
|
16
16
|
<string>arm64</string>
|
|
17
|
-
<string>x86_64</string>
|
|
18
17
|
</array>
|
|
19
18
|
<key>SupportedPlatform</key>
|
|
20
19
|
<string>ios</string>
|
|
21
|
-
<key>SupportedPlatformVariant</key>
|
|
22
|
-
<string>simulator</string>
|
|
23
20
|
</dict>
|
|
24
21
|
<dict>
|
|
25
22
|
<key>BinaryPath</key>
|
|
26
23
|
<string>libsimpleble.a</string>
|
|
27
24
|
<key>LibraryIdentifier</key>
|
|
28
|
-
<string>ios-
|
|
25
|
+
<string>ios-arm64_x86_64-simulator</string>
|
|
29
26
|
<key>LibraryPath</key>
|
|
30
27
|
<string>libsimpleble.a</string>
|
|
31
28
|
<key>SupportedArchitectures</key>
|
|
32
29
|
<array>
|
|
33
30
|
<string>arm64</string>
|
|
31
|
+
<string>x86_64</string>
|
|
34
32
|
</array>
|
|
35
33
|
<key>SupportedPlatform</key>
|
|
36
34
|
<string>ios</string>
|
|
35
|
+
<key>SupportedPlatformVariant</key>
|
|
36
|
+
<string>simulator</string>
|
|
37
37
|
</dict>
|
|
38
38
|
</array>
|
|
39
39
|
<key>CFBundlePackageType</key>
|
|
Binary file
|
|
Binary file
|
|
@@ -135,6 +135,12 @@ class SIMPLEBLE_EXPORT AdapterInUse : public BaseException {
|
|
|
135
135
|
std::unique_ptr<Error> make_error() const override;
|
|
136
136
|
};
|
|
137
137
|
|
|
138
|
+
class SIMPLEBLE_EXPORT InvalidArgument : public BaseException {
|
|
139
|
+
public:
|
|
140
|
+
InvalidArgument(const std::string& err_msg);
|
|
141
|
+
std::unique_ptr<Error> make_error() const override;
|
|
142
|
+
};
|
|
143
|
+
|
|
138
144
|
} // namespace Exception
|
|
139
145
|
|
|
140
146
|
} // namespace SimpleBLE
|
package/src/adapter.ts
CHANGED
|
@@ -83,8 +83,8 @@ export class Adapter extends NativeEmitter<AdapterEvents> {
|
|
|
83
83
|
/** Scans for `timeoutMs` milliseconds, then stops. Other calls on this adapter wait for it. */
|
|
84
84
|
async scanFor(timeoutMs: number): Promise<void> {
|
|
85
85
|
if (typeof timeoutMs !== 'number') throw new TypeError('timeoutMs must be a number');
|
|
86
|
-
if (!Number.isInteger(timeoutMs) || timeoutMs <
|
|
87
|
-
throw new RangeError('timeoutMs must be
|
|
86
|
+
if (!Number.isInteger(timeoutMs) || timeoutMs < -(2 ** 31) || timeoutMs > 2 ** 31 - 1) {
|
|
87
|
+
throw new RangeError('timeoutMs must be a 32-bit integer');
|
|
88
88
|
}
|
|
89
89
|
return async(() => this.#handle.scanFor(timeoutMs));
|
|
90
90
|
}
|