From 32a9674b5d79bea4b1b4489b7ad92cfa130da323 Mon Sep 17 00:00:00 2001 From: Kevin Andersen Date: Thu, 14 Feb 2019 13:30:58 -0500 Subject: [PATCH] Added disconnect-handling per new extensions-spec. Motor-commands that fail will now also cause their blocks to complete --- src/extensions/scratch3_boost/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/extensions/scratch3_boost/index.js b/src/extensions/scratch3_boost/index.js index 5875f6c3c..fc7902521 100644 --- a/src/extensions/scratch3_boost/index.js +++ b/src/extensions/scratch3_boost/index.js @@ -570,6 +570,7 @@ class Boost { */ this._rateLimiter = new RateLimiter(BLESendRateMax); + this.disconnect = this.disconnect.bind(this); this._onConnect = this._onConnect.bind(this); this._onMessage = this._onMessage.bind(this); } @@ -703,7 +704,7 @@ class Boost { } }], optionalServices: [] - }, this._onConnect); + }, this._onConnect, this.disconnect); } /** @@ -921,9 +922,11 @@ class Boost { var feedback = data[4]; switch(feedback) { case BoostOutputCommandFeedback.BUFFER_EMPTY_COMMAND_COMPLETED ^ BoostOutputCommandFeedback.IDLE: + case BoostOutputCommandFeedback.CURRENT_COMMAND_DISCARDED ^ BoostOutputCommandFeedback.IDLE: // Resolve even if command didn't complete successfully this._motors[portID].pendingPromiseFunction(); break; default: + console.log(buf2hex(data)) console.log("Got it but didn't find a motor on: " + portID) } break;