mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-08-28 22:30:40 -04:00
Remove pinging in BLE connection.
This commit is contained in:
parent
730b798686
commit
701f430e56
1 changed files with 5 additions and 4 deletions
|
@ -37,16 +37,14 @@ class BLESession extends JSONRPCWebSocket {
|
||||||
requestDevice () {
|
requestDevice () {
|
||||||
// TODO: add timeout for 'no devices yet found' ?
|
// TODO: add timeout for 'no devices yet found' ?
|
||||||
if (this._ws.readyState === 1) {
|
if (this._ws.readyState === 1) {
|
||||||
this.sendRemoteRequest('pingMe') // TODO: remove pingMe when no longer needed
|
this.sendRemoteRequest('discover', this._deviceOptions)
|
||||||
.then(() => this.sendRemoteRequest('discover', this._deviceOptions))
|
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
// TODO: what if discover doesn't initiate?
|
// TODO: what if discover doesn't initiate?
|
||||||
this._sendError(e);
|
this._sendError(e);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// Try again to connect to the websocket
|
// Try again to connect to the websocket
|
||||||
this._socketPromise(this.sendRemoteRequest('pingMe') // TODO: remove pingMe when no longer needed
|
this._socketPromise(this.sendRemoteRequest('discover', this._deviceOptions))
|
||||||
.then(() => this.sendRemoteRequest('discover', this._deviceOptions)))
|
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
// TODO: what if discover doesn't initiate?
|
// TODO: what if discover doesn't initiate?
|
||||||
this._sendError(e);
|
this._sendError(e);
|
||||||
|
@ -115,6 +113,7 @@ class BLESession extends JSONRPCWebSocket {
|
||||||
}
|
}
|
||||||
this._characteristicDidChangeCallback = onCharacteristicChanged;
|
this._characteristicDidChangeCallback = onCharacteristicChanged;
|
||||||
return this.sendRemoteRequest('read', params);
|
return this.sendRemoteRequest('read', params);
|
||||||
|
// TODO: handle error here
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -131,6 +130,8 @@ class BLESession extends JSONRPCWebSocket {
|
||||||
params.encoding = encoding;
|
params.encoding = encoding;
|
||||||
}
|
}
|
||||||
return this.sendRemoteRequest('write', params);
|
return this.sendRemoteRequest('write', params);
|
||||||
|
// TODO: .then() to clear a busy flag cuz it returned
|
||||||
|
// TODO: send error to runtime to stop yielding
|
||||||
}
|
}
|
||||||
|
|
||||||
_sendError (e) {
|
_sendError (e) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue