diff --git a/src/io/ble.js b/src/io/ble.js index 9e3f33053..3d800ef06 100644 --- a/src/io/ble.js +++ b/src/io/ble.js @@ -190,6 +190,14 @@ class BLE extends JSONRPC { window.clearTimeout(this._discoverTimeoutID); } break; + case 'userDidNotPickPeripheral': + 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..be1ce5db3 100644 --- a/src/io/bt.js +++ b/src/io/bt.js @@ -128,6 +128,24 @@ class BT extends JSONRPC { window.clearTimeout(this._discoverTimeoutID); } break; + 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._runtime.emit( + this._runtime.constructor.PERIPHERAL_SCAN_TIMEOUT + ); + if (this._discoverTimeoutID) { + window.clearTimeout(this._discoverTimeoutID); + } + break; case 'didReceiveMessage': this._messageCallback(params); // TODO: refine? break;