mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 14:32:59 -05:00
Add optional pin parameter to peripheral connection.
This commit is contained in:
parent
11b52c4e60
commit
8e302ac90c
2 changed files with 4 additions and 3 deletions
|
@ -571,7 +571,7 @@ class EV3 {
|
|||
*/
|
||||
connect (id) {
|
||||
if (this._bt) {
|
||||
this._bt.connectPeripheral(id);
|
||||
this._bt.connectPeripheral(id, '1234');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -58,9 +58,10 @@ class BT extends JSONRPCWebSocket {
|
|||
* 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) {
|
||||
this.sendRemoteRequest('connect', {peripheralId: id, pin: pin})
|
||||
.then(() => {
|
||||
this._connected = true;
|
||||
this._runtime.emit(this._runtime.constructor.PERIPHERAL_CONNECTED);
|
||||
|
|
Loading…
Reference in a new issue