incyclist-devices 1.4.43 → 1.4.44

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.
@@ -13,6 +13,8 @@ const gd_eventlog_1 = require("gd-eventlog");
13
13
  const utils_1 = require("../utils");
14
14
  const ble_1 = require("./ble");
15
15
  const CONNECT_TIMEOUT = 5000;
16
+ const DEFAULT_SCAN_TIMEOUT = 20000;
17
+ const BACKGROUND_SCAN_TIMEOUT = 30000;
16
18
  class BleInterface extends ble_1.BleInterfaceClass {
17
19
  constructor(props = {}) {
18
20
  super(props);
@@ -72,7 +74,7 @@ class BleInterface extends ble_1.BleInterfaceClass {
72
74
  const timeout = props.timeout || 2000;
73
75
  const runBackgroundScan = () => {
74
76
  this.scanState.isBackgroundScan = true;
75
- this.scan({ timeout: 5000, isBackgroundScan: true })
77
+ this.scan({ timeout: BACKGROUND_SCAN_TIMEOUT, isBackgroundScan: true })
76
78
  .then(() => {
77
79
  this.scanState.isBackgroundScan = false;
78
80
  })
@@ -261,13 +263,13 @@ class BleInterface extends ble_1.BleInterfaceClass {
261
263
  }, 100);
262
264
  });
263
265
  }
264
- connectDevice(requested, timeout = CONNECT_TIMEOUT) {
266
+ connectDevice(requested, timeout = DEFAULT_SCAN_TIMEOUT + CONNECT_TIMEOUT) {
265
267
  return __awaiter(this, void 0, void 0, function* () {
266
268
  const { id, name, address, getProfile } = requested;
267
269
  const profile = getProfile && typeof (getProfile) === 'function' ? getProfile() : undefined;
268
270
  this.logEvent({ message: 'connectDevice', id, name, address, profile, isbusy: this.scanState.isConnecting });
269
271
  if (this.scanState.isConnecting) {
270
- yield this.waitForConnectFinished(10000);
272
+ yield this.waitForConnectFinished(CONNECT_TIMEOUT);
271
273
  }
272
274
  this.scanState.isConnecting = true;
273
275
  let devices = [];
@@ -278,7 +280,7 @@ class BleInterface extends ble_1.BleInterfaceClass {
278
280
  this.logEvent({ message: 'retry connect device', id, name, address, profile, retryCount });
279
281
  }
280
282
  try {
281
- devices = yield this.scan({ timeout, device: requested });
283
+ devices = yield this.scan({ timeout: DEFAULT_SCAN_TIMEOUT, device: requested });
282
284
  if (devices.length === 0) {
283
285
  retryCount++;
284
286
  retry = retryCount < 5;
@@ -348,7 +350,7 @@ class BleInterface extends ble_1.BleInterfaceClass {
348
350
  }
349
351
  scan(props) {
350
352
  return __awaiter(this, void 0, void 0, function* () {
351
- const { timeout = 5000, deviceTypes = [], device } = props;
353
+ const { timeout = DEFAULT_SCAN_TIMEOUT, deviceTypes = [], device } = props;
352
354
  const scanForDevice = (device !== null && device !== undefined);
353
355
  const services = this.getServicesFromDeviceTypes(deviceTypes);
354
356
  const bleBinding = this.getBinding();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "incyclist-devices",
3
- "version": "1.4.43",
3
+ "version": "1.4.44",
4
4
  "dependencies": {
5
5
  "@serialport/parser-byte-length": "^9.0.1",
6
6
  "@serialport/parser-delimiter": "^9.0.1",