From 3827038e6ebd3b23f32b845c83dc88e9ad8a2700 Mon Sep 17 00:00:00 2001 From: Marco Crespi Date: Wed, 28 Apr 2021 14:22:44 +0200 Subject: [PATCH] fix(dbus): Fix very short scan state timeouts --- lib/bindings/dbus/Adapter.d.ts.map | 2 +- lib/bindings/dbus/Adapter.js | 5 +++-- lib/bindings/dbus/Adapter.js.map | 2 +- src/bindings/dbus/Adapter.ts | 5 +++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/bindings/dbus/Adapter.d.ts.map b/lib/bindings/dbus/Adapter.d.ts.map index 16bac83c..6330204f 100644 --- a/lib/bindings/dbus/Adapter.d.ts.map +++ b/lib/bindings/dbus/Adapter.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"Adapter.d.ts","sourceRoot":"","sources":["../../../src/bindings/dbus/Adapter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAe,SAAS,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG3E,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAKxC,qBAAa,WAAY,SAAQ,OAAO;IAChC,OAAO,EAAE,WAAW,CAAC;IAC5B,SAAgB,IAAI,EAAE,MAAM,CAAC;IAE7B,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,YAAY,CAAkB;IACtC,OAAO,CAAC,UAAU,CAAkB;IAEpC,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,WAAW,CAAe;IAClC,OAAO,CAAC,mBAAmB,CAAuC;IAElE,OAAO,CAAC,WAAW,CAAsC;gBAEtC,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;YAMtE,IAAI;YA4CJ,IAAI;IAKL,qBAAqB,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;IAIpD,UAAU,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C,OAAO,CAAC,WAAW;IAON,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAqC1C,OAAO,CAAC,UAAU;IAkBlB,OAAO,CAAC,aAAa,CAwBnB;IAEF,OAAO,CAAC,iBAAiB,CAgBvB;IAEK,aAAa,IAAI,OAAO;IAIlB,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IAGjC,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAIhC,SAAS,IAAI,OAAO,CAAC,SAAS,CAAC;CAG5C"} \ No newline at end of file diff --git a/lib/bindings/dbus/Adapter.js b/lib/bindings/dbus/Adapter.js index 8d98c6e5..eaeb7e76 100644 --- a/lib/bindings/dbus/Adapter.js +++ b/lib/bindings/dbus/Adapter.js @@ -14,6 +14,7 @@ const models_1 = require("../../models"); const misc_1 = require("./misc"); const Peripheral_1 = require("./Peripheral"); const UPDATE_INTERVAL = 5; // in seconds +const SCAN_STATE_TIMEOUT = 10; // in seconds class DbusAdapter extends models_1.Adapter { constructor(modblue, path, name, address) { super(modblue, path.replace(`/org/bluez/`, ''), name, address); @@ -148,7 +149,7 @@ class DbusAdapter extends models_1.Adapter { resolve(); } }; - const timer = setTimeout(() => reject(new Error('Scan state never changed'))); + const timer = setTimeout(() => reject(new Error('No scan state change')), SCAN_STATE_TIMEOUT * 1000); this.scanChangeListeners.push(listener); }); } @@ -195,7 +196,7 @@ class DbusAdapter extends models_1.Adapter { resolve(); } }; - const timer = setTimeout(() => reject(new Error('Scan state never changed'))); + const timer = setTimeout(() => reject(new Error('No scan state change')), SCAN_STATE_TIMEOUT * 1000); this.scanChangeListeners.push(listener); }); } diff --git a/lib/bindings/dbus/Adapter.js.map b/lib/bindings/dbus/Adapter.js.map index a8e3596a..4abe8ea7 100644 --- a/lib/bindings/dbus/Adapter.js.map +++ b/lib/bindings/dbus/Adapter.js.map @@ -1 +1 @@ -{"version":3,"file":"Adapter.js","sourceRoot":"","sources":["../../../src/bindings/dbus/Adapter.ts"],"names":[],"mappings":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AC,CAAC;gBACzC,CAAC,CAAC,CAAC;aACH;QACF,CAAC;KAAA;IAEO,UAAU;QACjB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QAEtB,IAAI,IAAI,CAAC,eAAe,EAAE;YACzB,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,mBAAmB,EAAE;gBAChD,QAAQ,CAAC,KAAK,CAAC,CAAC;aAChB;YAED,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC;YAC7B,OAAO;SACP;QAED,8FAA8F;QAC9F,IAAI,CAAC,aAAa,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE;YAC/B,QAAQ;QACT,CAAC,CAAC,CAAC;IACJ,CAAC;IA8CM,aAAa;QACnB,OAAO,KAAK,CAAC;IACd,CAAC;IAEY,gBAAgB;;YAC5B,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC5C,CAAC;KAAA;IACY,eAAe;;YAC3B,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC5C,CAAC;KAAA;IAEY,SAAS;;YACrB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC5C,CAAC;KAAA;CACD;AA3PD,kCA2PC"} \ No newline at end of file diff --git a/src/bindings/dbus/Adapter.ts b/src/bindings/dbus/Adapter.ts index 5c8627eb..8c45b01a 100644 --- a/src/bindings/dbus/Adapter.ts +++ b/src/bindings/dbus/Adapter.ts @@ -7,6 +7,7 @@ import { DbusMODblue } from './MODblue'; import { DbusPeripheral } from './Peripheral'; const UPDATE_INTERVAL = 5; // in seconds +const SCAN_STATE_TIMEOUT = 10; // in seconds export class DbusAdapter extends Adapter { public modblue: DbusMODblue; @@ -124,7 +125,7 @@ export class DbusAdapter extends Adapter { resolve(); } }; - const timer = setTimeout(() => reject(new Error('Scan state never changed'))); + const timer = setTimeout(() => reject(new Error('No scan state change')), SCAN_STATE_TIMEOUT * 1000); this.scanChangeListeners.push(listener); }); } @@ -177,7 +178,7 @@ export class DbusAdapter extends Adapter { resolve(); } }; - const timer = setTimeout(() => reject(new Error('Scan state never changed'))); + const timer = setTimeout(() => reject(new Error('No scan state change')), SCAN_STATE_TIMEOUT * 1000); this.scanChangeListeners.push(listener); }); }