mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 06:52:40 -05:00
Merge pull request #2191 from evhan55/bt-pairing-changes
Add optional 'pin' parameter to BT connections
This commit is contained in:
commit
6e80c92703
2 changed files with 14 additions and 3 deletions
File diff suppressed because one or more lines are too long
|
@ -57,9 +57,14 @@ class BT extends JSONRPC {
|
||||||
* Try connecting to the input peripheral id, and then call the connect
|
* Try connecting to the input peripheral id, and then call the connect
|
||||||
* callback if connection is successful.
|
* callback if connection is successful.
|
||||||
* @param {number} id - the id of the peripheral to connect to
|
* @param {number} id - the id of the peripheral to connect to
|
||||||
|
* @param {string} pin - an optional pin for pairing
|
||||||
*/
|
*/
|
||||||
connectPeripheral (id) {
|
connectPeripheral (id, pin = null) {
|
||||||
this.sendRemoteRequest('connect', {peripheralId: id})
|
const params = {peripheralId: id};
|
||||||
|
if (pin) {
|
||||||
|
params.pin = pin;
|
||||||
|
}
|
||||||
|
this.sendRemoteRequest('connect', params)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this._connected = true;
|
this._connected = true;
|
||||||
this._runtime.emit(this._runtime.constructor.PERIPHERAL_CONNECTED);
|
this._runtime.emit(this._runtime.constructor.PERIPHERAL_CONNECTED);
|
||||||
|
|
Loading…
Reference in a new issue