Skip to content

Commit

Permalink
fix(dbus): Fix very short scan state timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Crespi committed Apr 28, 2021
1 parent 9efda1c commit 3827038
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/bindings/dbus/Adapter.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions lib/bindings/dbus/Adapter.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/bindings/dbus/Adapter.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions src/bindings/dbus/Adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
});
}
Expand Down Expand Up @@ -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);
});
}
Expand Down

0 comments on commit 3827038

Please sign in to comment.