mirror of
https://github.com/meshcore-dev/meshcore.js.git
synced 2026-04-20 22:13:49 +00:00
Merge 97dff6c195 into 306dadac1c
This commit is contained in:
commit
75f3d8daee
2 changed files with 13 additions and 5 deletions
|
|
@ -9,7 +9,6 @@ class WebBleConnection extends Connection {
|
||||||
this.gattServer = null;
|
this.gattServer = null;
|
||||||
this.rxCharacteristic = null;
|
this.rxCharacteristic = null;
|
||||||
this.txCharacteristic = null;
|
this.txCharacteristic = null;
|
||||||
this.init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static async open() {
|
static async open() {
|
||||||
|
|
@ -36,8 +35,11 @@ class WebBleConnection extends Connection {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new WebBleConnection(device);
|
// create connection and initialize it
|
||||||
|
const connection = new WebBleConnection(device);
|
||||||
|
await connection.init();
|
||||||
|
|
||||||
|
return connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
async init() {
|
async init() {
|
||||||
|
|
@ -71,8 +73,12 @@ class WebBleConnection extends Connection {
|
||||||
this.onFrameReceived(frame);
|
this.onFrameReceived(frame);
|
||||||
});
|
});
|
||||||
|
|
||||||
// fire connected event
|
// wait to fire connected event after the caller has a chance to set up handlers
|
||||||
await this.onConnected();
|
// by calling setTimeout(..., 0), we wait for the next tick of the JavaScript event
|
||||||
|
// loop.
|
||||||
|
setTimeout(async () => {
|
||||||
|
await this.onConnected();
|
||||||
|
}, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,9 @@ class WebSerialConnection extends SerialConnection {
|
||||||
this.onDisconnected();
|
this.onDisconnected();
|
||||||
});
|
});
|
||||||
|
|
||||||
// fire connected callback after constructor has returned
|
// wait to fire connected event after the caller has a chance to set up handlers
|
||||||
|
// by calling setTimeout(..., 0), we wait for the next tick of the JavaScript event
|
||||||
|
// loop.
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
await this.onConnected();
|
await this.onConnected();
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue