Merge pull request #2710 from fsih/useCdm

Handle user did not pick peripheral
This commit is contained in:
DD Liu 2020-11-24 18:35:04 -05:00 committed by GitHub
commit a0c11d6d86
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 0 deletions

View file

@ -190,6 +190,14 @@ class BLE extends JSONRPC {
window.clearTimeout(this._discoverTimeoutID); window.clearTimeout(this._discoverTimeoutID);
} }
break; break;
case 'userDidNotPickPeripheral':
this._runtime.emit(
this._runtime.constructor.PERIPHERAL_SCAN_TIMEOUT
);
if (this._discoverTimeoutID) {
window.clearTimeout(this._discoverTimeoutID);
}
break;
case 'characteristicDidChange': case 'characteristicDidChange':
if (this._characteristicDidChangeCallback) { if (this._characteristicDidChangeCallback) {
this._characteristicDidChangeCallback(params.message); this._characteristicDidChangeCallback(params.message);

View file

@ -128,6 +128,24 @@ class BT extends JSONRPC {
window.clearTimeout(this._discoverTimeoutID); window.clearTimeout(this._discoverTimeoutID);
} }
break; 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': case 'didReceiveMessage':
this._messageCallback(params); // TODO: refine? this._messageCallback(params); // TODO: refine?
break; break;