Fixing up BOOST reset and disconnect behavior splitting.

This commit is contained in:
Evelyn Eastmond 2019-06-06 15:46:45 -04:00
parent 56fdd45242
commit 6a032087ce
2 changed files with 8 additions and 1 deletions

View file

@ -823,18 +823,22 @@ class Boost {
} }
/** /**
* Disconnects from the current BLE socket. * Disconnects from the current BLE socket and resets state.
*/ */
disconnect () { disconnect () {
console.log('BOOST DISCONNECT CALLED');
if (this._ble) { if (this._ble) {
this._ble.disconnect(); this._ble.disconnect();
} }
this.reset();
} }
/** /**
* Reset all the state and timeout/interval ids. * Reset all the state and timeout/interval ids.
*/ */
reset () { reset () {
console.log('BOOST RESET CALLED');
this._ports = []; this._ports = [];
this._motors = []; this._motors = [];
this._sensors = { this._sensors = {

View file

@ -72,6 +72,8 @@ class BLE extends JSONRPC {
* Close the websocket. * Close the websocket.
*/ */
disconnect () { disconnect () {
console.log('BLE DISCONNECT CALLED');
if (this._connected) { if (this._connected) {
this._connected = false; this._connected = false;
} }
@ -205,6 +207,7 @@ class BLE extends JSONRPC {
// log.error(`BLE error: ${JSON.stringify(e)}`); // log.error(`BLE error: ${JSON.stringify(e)}`);
if (!this._connected) return; if (!this._connected) return;
console.log('BLE HANDLEDISCONNECTERROR CALLED');
this.disconnect(); this.disconnect();