mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-06-28 07:10:27 -04:00
Merge pull request #2014 from evhan55/extensions/microbit-timeout
Fix micro:bit auto-disconnect from setInterval to setTimeout
This commit is contained in:
commit
cd85e8ddfa
1 changed files with 4 additions and 4 deletions
|
@ -239,7 +239,7 @@ class MicroBit {
|
|||
* Disconnect from the micro:bit.
|
||||
*/
|
||||
disconnect () {
|
||||
window.clearInterval(this._timeoutID);
|
||||
window.clearTimeout(this._timeoutID);
|
||||
if (this._ble) {
|
||||
this._ble.disconnect();
|
||||
}
|
||||
|
@ -299,7 +299,7 @@ class MicroBit {
|
|||
*/
|
||||
_onConnect () {
|
||||
this._ble.read(BLEUUID.service, BLEUUID.rxChar, true, this._onMessage);
|
||||
this._timeoutID = window.setInterval(
|
||||
this._timeoutID = window.setTimeout(
|
||||
() => this._ble.handleDisconnectError(BLEDataStoppedError),
|
||||
BLETimeout
|
||||
);
|
||||
|
@ -329,8 +329,8 @@ class MicroBit {
|
|||
this._sensors.gestureState = data[9];
|
||||
|
||||
// cancel disconnect timeout and start a new one
|
||||
window.clearInterval(this._timeoutID);
|
||||
this._timeoutID = window.setInterval(
|
||||
window.clearTimeout(this._timeoutID);
|
||||
this._timeoutID = window.setTimeout(
|
||||
() => this._ble.handleDisconnectError(BLEDataStoppedError),
|
||||
BLETimeout
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue