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.
@@ -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 >= 0 && timeoutMs <= INT32_MAX) || std::floor(timeoutMs) != timeoutMs) {
62
- throw std::invalid_argument("timeoutMs must be an integer from 0 to 2147483647");
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 < 0 || timeoutMs > 2 ** 31 - 1) {
68
- throw new RangeError('timeoutMs must be an integer from 0 to 2147483647');
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-dev116
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "simplernble",
3
- "version": "1.2.1-dev116",
3
+ "version": "1.2.1-dev122",
4
4
  "description": "SimpleBLE for React Native: a cross-platform Bluetooth Low Energy library for iOS and Android",
5
5
  "keywords": [
6
6
  "react-native",
@@ -8,32 +8,32 @@
8
8
  <key>BinaryPath</key>
9
9
  <string>libsimpleble.a</string>
10
10
  <key>LibraryIdentifier</key>
11
- <string>ios-arm64_x86_64-simulator</string>
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-arm64</string>
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>
@@ -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 < 0 || timeoutMs > 2 ** 31 - 1) {
87
- throw new RangeError('timeoutMs must be an integer from 0 to 2147483647');
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
  }