Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow customize initialize timeout #7

Merged
merged 2 commits into from
Nov 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "improv-wifi-serial-sdk",
"version": "2.0.0",
"version": "2.1.0",
"description": "Improv Wi-Fi Serial SDK for the browser",
"main": "dist/serial-launch-button.js",
"repository": "https://github.com/improv-wifi/sdk-serial-js",
Expand Down
6 changes: 3 additions & 3 deletions src/serial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ export class ImprovSerial extends EventTarget {

/**
* Detect Improv Serial, fetch the state and return the next URL if provisioned.
* @returns
* @param timeout Timeout in ms to wait for the device to respond. Default to 1000ms.
*/
public async initialize(): Promise<this["info"]> {
public async initialize(timeout = 1000): Promise<this["info"]> {
this.logger.log("Initializing Improv Serial");
this._processInput();
// To give the input processing time to start.
Expand All @@ -58,7 +58,7 @@ export class ImprovSerial extends EventTarget {
await new Promise(async (resolve, reject) => {
setTimeout(
() => reject(new Error("Improv Wi-Fi Serial not detected")),
1000
timeout
);
await this.requestCurrentState();
resolve(undefined);
Expand Down