mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 14:32:59 -05:00
Move micro:bit data stopped error string to constant. Added another jsdoc.
This commit is contained in:
parent
f030afbdc5
commit
d7b6cfae97
1 changed files with 13 additions and 3 deletions
|
@ -25,8 +25,12 @@ const BLECommand = {
|
||||||
CMD_DISPLAY_LED: 0x82
|
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.
|
* 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;
|
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.
|
* Enum for micro:bit protocol.
|
||||||
* https://github.com/LLK/scratch-microbit-firmware/blob/master/protocol.md
|
* https://github.com/LLK/scratch-microbit-firmware/blob/master/protocol.md
|
||||||
|
@ -319,7 +329,7 @@ class MicroBit {
|
||||||
window.clearInterval(this._timeoutID);
|
window.clearInterval(this._timeoutID);
|
||||||
this._timeoutID = window.setInterval(
|
this._timeoutID = window.setInterval(
|
||||||
// send an error to the BLE socket
|
// 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
|
BLETimeout
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue