mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 14:32:59 -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
|
||||
* 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);
|
||||
|
|
Loading…
Reference in a new issue