Merge pull request #1920 from evhan55/extensions/vernier-peripheral-list

Properly disconnect BLE socket in GDX-FOR scan/disconnect
This commit is contained in:
Eric Rosenbaum 2019-01-15 10:31:48 -05:00 committed by GitHub
commit 8b2f326469
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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. * Called by the runtime when user wants to scan for a peripheral.
*/ */
scan () { scan () {
if (this._device) { if (this._scratchLinkSocket) {
this._device.close(); this._scratchLinkSocket.disconnect();
} }
this._scratchLinkSocket = new BLE(this._runtime, this._extensionId, { this._scratchLinkSocket = new BLE(this._runtime, this._extensionId, {
@ -104,8 +104,8 @@ class GdxFor {
* Disconnect from the GDX FOR. * Disconnect from the GDX FOR.
*/ */
disconnect () { disconnect () {
if (this._device) { if (this._scratchLinkSocket) {
this._device.close(); this._scratchLinkSocket.disconnect();
} }
} }

View file

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