Properly disconnect BLE socket.
This commit is contained in:
1 parent
43fd733b15
commit
308bb7095a
2 files changed
+4
-8
No files matched your search
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,10 +39,6 @@ class ScratchLinkDeviceAdapter {
|
||||
const response = new DataView(array.buffer);
|
||||
return this._deviceOnResponse(response);
|
||||
}
|
||||
|
||||
close () {
|
||||
return this.scratchLinkSocket.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ScratchLinkDeviceAdapter;
|
||||
Reference in new issue
Block a user