From 1efead8a26bf5cb6a05901706c2c412cafb711af Mon Sep 17 00:00:00 2001 From: Evelyn Eastmond Date: Fri, 5 Oct 2018 11:24:52 -0400 Subject: [PATCH] Resolves #1615: Prevent multiple hardware disconnect alerts. --- src/io/ble.js | 2 +- src/io/bt.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/io/ble.js b/src/io/ble.js index af0dc3086..cf6530f8d 100644 --- a/src/io/ble.js +++ b/src/io/ble.js @@ -172,7 +172,7 @@ class BLE extends JSONRPCWebSocket { } _sendError (/* e */) { - this.disconnect(); + if (this._connected) this.disconnect(); // log.error(`BLE error: ${JSON.stringify(e)}`); this._runtime.emit(this._runtime.constructor.PERIPHERAL_ERROR, { message: `Scratch lost connection to`, diff --git a/src/io/bt.js b/src/io/bt.js index 60e74ff00..bf492f84a 100644 --- a/src/io/bt.js +++ b/src/io/bt.js @@ -115,7 +115,7 @@ class BT extends JSONRPCWebSocket { } _sendError (/* e */) { - this.disconnect(); + if (this._connected) this.disconnect(); // log.error(`BT error: ${JSON.stringify(e)}`); this._runtime.emit(this._runtime.constructor.PERIPHERAL_ERROR, { message: `Scratch lost connection to`,