From f19fd835633bd3aaba7face06a5fdeda319ebb51 Mon Sep 17 00:00:00 2001 From: DD Liu Date: Mon, 23 Nov 2020 01:01:06 -0500 Subject: [PATCH 1/3] Handle user did not pick peripheral --- src/io/ble.js | 9 +++++++++ src/io/bt.js | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/io/ble.js b/src/io/ble.js index 9e3f33053..52a14f0b7 100644 --- a/src/io/ble.js +++ b/src/io/ble.js @@ -190,6 +190,15 @@ class BLE extends JSONRPC { window.clearTimeout(this._discoverTimeoutID); } break; + case 'userDidNotPickPeripheral': + // this._availablePeripherals[params.peripheralId] = params; + this._runtime.emit( + this._runtime.constructor.PERIPHERAL_SCAN_TIMEOUT + ); + if (this._discoverTimeoutID) { + window.clearTimeout(this._discoverTimeoutID); + } + break; case 'characteristicDidChange': if (this._characteristicDidChangeCallback) { this._characteristicDidChangeCallback(params.message); diff --git a/src/io/bt.js b/src/io/bt.js index bb9b10761..312a45170 100644 --- a/src/io/bt.js +++ b/src/io/bt.js @@ -128,6 +128,16 @@ class BT extends JSONRPC { window.clearTimeout(this._discoverTimeoutID); } break; + //TODO why isn't 'user did pick peripheral' here? + case 'userDidNotPickPeripheral': + // this._availablePeripherals[params.peripheralId] = params; + this._runtime.emit( + this._runtime.constructor.PERIPHERAL_SCAN_TIMEOUT + ); + if (this._discoverTimeoutID) { + window.clearTimeout(this._discoverTimeoutID); + } + break; case 'didReceiveMessage': this._messageCallback(params); // TODO: refine? break; From 87cb4a7ef02cb9051d63c08f7179fd725171b9dd Mon Sep 17 00:00:00 2001 From: DD Liu Date: Tue, 24 Nov 2020 16:49:54 -0500 Subject: [PATCH 2/3] Add userDidPickPeripheral to bt --- src/io/bt.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/io/bt.js b/src/io/bt.js index 312a45170..be1ce5db3 100644 --- a/src/io/bt.js +++ b/src/io/bt.js @@ -128,9 +128,17 @@ class BT extends JSONRPC { window.clearTimeout(this._discoverTimeoutID); } break; - //TODO why isn't 'user did pick peripheral' here? + case 'userDidPickPeripheral': + this._availablePeripherals[params.peripheralId] = params; + this._runtime.emit( + this._runtime.constructor.USER_PICKED_PERIPHERAL, + this._availablePeripherals + ); + if (this._discoverTimeoutID) { + window.clearTimeout(this._discoverTimeoutID); + } + break; case 'userDidNotPickPeripheral': - // this._availablePeripherals[params.peripheralId] = params; this._runtime.emit( this._runtime.constructor.PERIPHERAL_SCAN_TIMEOUT ); From 04d401996c0357f60145a5fb28fce6d10f47784f Mon Sep 17 00:00:00 2001 From: DD Liu Date: Tue, 24 Nov 2020 16:54:07 -0500 Subject: [PATCH 3/3] Remove commented code --- src/io/ble.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/io/ble.js b/src/io/ble.js index 52a14f0b7..3d800ef06 100644 --- a/src/io/ble.js +++ b/src/io/ble.js @@ -191,7 +191,6 @@ class BLE extends JSONRPC { } break; case 'userDidNotPickPeripheral': - // this._availablePeripherals[params.peripheralId] = params; this._runtime.emit( this._runtime.constructor.PERIPHERAL_SCAN_TIMEOUT );