mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-01-11 10:39:56 -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) {
|
connect (id) {
|
||||||
if (this._bt) {
|
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
|
* 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})
|
this.sendRemoteRequest('connect', {peripheralId: id, pin: pin})
|
||||||
.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