Merge pull request #2191 from evhan55/bt-pairing-changes

Add optional 'pin' parameter to BT connections
This commit is contained in:
Evelyn Eastmond 2019-06-04 11:26:47 -04:00 committed by GitHub
commit 6e80c92703
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 3 deletions

File diff suppressed because one or more lines are too long

View file

@ -57,9 +57,14 @@ class BT extends JSONRPC {
* Try connecting to the input peripheral id, and then call the connect
* callback if connection is successful.
* @param {number} id - the id of the peripheral to connect to
* @param {string} pin - an optional pin for pairing
*/
connectPeripheral (id) {
this.sendRemoteRequest('connect', {peripheralId: id})
connectPeripheral (id, pin = null) {
const params = {peripheralId: id};
if (pin) {
params.pin = pin;
}
this.sendRemoteRequest('connect', params)
.then(() => {
this._connected = true;
this._runtime.emit(this._runtime.constructor.PERIPHERAL_CONNECTED);