mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 14:32:59 -05:00
Merge pull request #1920 from evhan55/extensions/vernier-peripheral-list
Properly disconnect BLE socket in GDX-FOR scan/disconnect
This commit is contained in:
commit
8b2f326469
2 changed files with 4 additions and 8 deletions
|
@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
|
Loading…
Reference in a new issue