Properly disconnect BLE socket.

This commit is contained in:
Evelyn Eastmond 2019-01-14 20:17:18 -05:00
parent 43fd733b15
commit 308bb7095a
2 changed files with 4 additions and 8 deletions

View file

@ -75,8 +75,8 @@ class GdxFor {
* Called by the runtime when user wants to scan for a peripheral.
*/
scan () {
if (this._device) {
this._device.close();
if (this._scratchLinkSocket) {
this._scratchLinkSocket.disconnect();
}
this._scratchLinkSocket = new BLE(this._runtime, this._extensionId, {
@ -104,8 +104,8 @@ class GdxFor {
* Disconnect from the GDX FOR.
*/
disconnect () {
if (this._device) {
this._device.close();
if (this._scratchLinkSocket) {
this._scratchLinkSocket.disconnect();
}
}

View file

@ -39,10 +39,6 @@ class ScratchLinkDeviceAdapter {
const response = new DataView(array.buffer);
return this._deviceOnResponse(response);
}
close () {
return this.scratchLinkSocket.disconnect();
}
}
module.exports = ScratchLinkDeviceAdapter;