Fixing debug statements and also adding a safety check for timeoutIDs.

This commit is contained in:
Evelyn Eastmond 2019-06-06 16:41:05 -04:00
parent 0e250aef37
commit 704774d6d1
6 changed files with 21 additions and 11 deletions

View file

@ -624,9 +624,11 @@ class EV3 {
}; };
this._motors = [null, null, null, null]; this._motors = [null, null, null, null];
if (this._pollingIntervalID) {
window.clearInterval(this._pollingIntervalID); window.clearInterval(this._pollingIntervalID);
this._pollingIntervalID = null; this._pollingIntervalID = null;
} }
}
/** /**
* Called by the runtime to detect whether the EV3 peripheral is connected. * Called by the runtime to detect whether the EV3 peripheral is connected.

View file

@ -235,7 +235,10 @@ class GdxFor {
spinSpeedZ: 0 spinSpeedZ: 0
}; };
if (this._timeoutID) {
window.clearInterval(this._timeoutID); window.clearInterval(this._timeoutID);
this._timeoutID = null;
}
} }
/** /**

View file

@ -254,7 +254,10 @@ class MicroBit {
reset() { reset() {
console.log('MICROBIT RESET CALLED'); console.log('MICROBIT RESET CALLED');
if (this._timeoutID) {
window.clearTimeout(this._timeoutID); window.clearTimeout(this._timeoutID);
this._timeoutID = null;
}
} }
/** /**

View file

@ -203,8 +203,9 @@ class BLE extends JSONRPC {
* Disconnect the socket, and if the extension using this socket has a * Disconnect the socket, and if the extension using this socket has a
* reset callback, call it. Finally, emit an error to the runtime. * reset callback, call it. Finally, emit an error to the runtime.
*/ */
handleDisconnectError (/* e */) { handleDisconnectError (e) {
// log.error(`BLE error: ${JSON.stringify(e)}`); console.error(`BLE error: ${JSON.stringify(e)}`);
console.error(e);
console.log('BLE HANDLEDISCONNECTERROR CALLED'); console.log('BLE HANDLEDISCONNECTERROR CALLED');
if (!this._connected) return; if (!this._connected) return;

View file

@ -149,8 +149,9 @@ class BT extends JSONRPC {
* Disconnect the socket, and if the extension using this socket has a * Disconnect the socket, and if the extension using this socket has a
* reset callback, call it. Finally, emit an error to the runtime. * reset callback, call it. Finally, emit an error to the runtime.
*/ */
handleDisconnectError (/* e */) { handleDisconnectError (e) {
// log.error(`BT error: ${JSON.stringify(e)}`); console.error(`BT error: ${JSON.stringify(e)}`);
console.error(e);
console.log('BT HANDLEDISCONNECTERROR CALLED'); console.log('BT HANDLEDISCONNECTERROR CALLED');
if (!this._connected) return; if (!this._connected) return;