Change from setInterval to setTimeout for auto disconnect feature.

This commit is contained in:
Evelyn Eastmond 2019-02-22 12:29:24 -05:00
parent bb42c0019c
commit 7a1367d81a

View file

@ -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
);
@ -330,7 +330,7 @@ class MicroBit {
// cancel disconnect timeout and start a new one
window.clearInterval(this._timeoutID);
this._timeoutID = window.setInterval(
this._timeoutID = window.setTimeout(
() => this._ble.handleDisconnectError(BLEDataStoppedError),
BLETimeout
);