Method for manually attaching devices as a workaround for connection issues
This commit is contained in:
parent
1b2c988409
commit
e6c6a3c18f
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "node-poweredup",
|
"name": "node-poweredup",
|
||||||
"version": "6.5.0",
|
"version": "6.5.1",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "node-poweredup",
|
"name": "node-poweredup",
|
||||||
"version": "6.5.0",
|
"version": "6.5.1",
|
||||||
"description": "A Javascript module to interface with LEGO Powered Up components.",
|
"description": "A Javascript module to interface with LEGO Powered Up components.",
|
||||||
"homepage": "https://github.com/nathankellenicki/node-poweredup/",
|
"homepage": "https://github.com/nathankellenicki/node-poweredup/",
|
||||||
"main": "dist/node/index-node.js",
|
"main": "dist/node/index-node.js",
|
||||||
|
@ -331,8 +331,23 @@ export class BaseHub extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public manuallyAttachDevice(deviceType: number, portId: number) {
|
||||||
|
if (!this._attachedDevices[portId]) {
|
||||||
|
const device = this._createDevice(deviceType, portId);
|
||||||
|
this._attachDevice(device);
|
||||||
|
return device;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected _attachDevice (device: Device) {
|
protected _attachDevice (device: Device) {
|
||||||
|
if (this._attachedDevices[device.portId] && this._attachedDevices[device.portId].type === device.type) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this._attachedDevices[device.portId] = device;
|
this._attachedDevices[device.portId] = device;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Emits when a device is attached to the Hub.
|
* Emits when a device is attached to the Hub.
|
||||||
* @event Hub#attach
|
* @event Hub#attach
|
||||||
|
Loading…
x
Reference in New Issue
Block a user