Remove pinging in BLE connection.

This commit is contained in:
Evelyn Eastmond 2018-06-20 21:20:18 -04:00 committed by Ray Schamp
parent 730b798686
commit 701f430e56

View file

@ -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) {