diff --git a/src/extensions/scratch3_microbit/index.js b/src/extensions/scratch3_microbit/index.js index 436167d29..894c822e0 100644 --- a/src/extensions/scratch3_microbit/index.js +++ b/src/extensions/scratch3_microbit/index.js @@ -25,8 +25,12 @@ const BLECommand = { CMD_DISPLAY_LED: 0x82 }; -// TODO: Needs comment -const BLETimeout = 4500; // TODO: might need tweaking based on how long the peripheral takes to start sending data + +/** + * A time interval to wait (in milliseconds) before reporting to the BLE socket + * that data has stopped coming from the peripheral. + */ +const BLETimeout = 4500; /** * A time interval to wait (in milliseconds) while a block that sends a BLE message is running. @@ -34,6 +38,12 @@ const BLETimeout = 4500; // TODO: might need tweaking based on how long the peri */ const BLESendInterval = 100; +/** + * A string to report to the BLE socket when the micro:bit has stopped receiving data. + * @type {string} + */ +const BLEDataStoppedError = 'micro:bit extension stopped receiving data'; + /** * Enum for micro:bit protocol. * https://github.com/LLK/scratch-microbit-firmware/blob/master/protocol.md @@ -319,7 +329,7 @@ class MicroBit { window.clearInterval(this._timeoutID); this._timeoutID = window.setInterval( // send an error to the BLE socket - this._ble._sendDisconnectError.bind(this._ble, 'micro:bit extension stopped receiving data'), + this._ble._sendDisconnectError.bind(this._ble, BLEDataStoppedError), BLETimeout ); }