Merge pull request #54 from aileo/attach

Emit attach event any case
This commit is contained in:
Nathan Kellenicki 2019-12-03 09:57:56 -08:00 committed by GitHub
commit 5a3211a560
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -283,6 +283,7 @@ export class Hub extends EventEmitter {
port.type = type; port.type = type;
if (this.autoSubscribe) { if (this.autoSubscribe) {
this._activatePortDevice(port.value, type, this._getModeForDeviceType(type), 0x00); this._activatePortDevice(port.value, type, this._getModeForDeviceType(type), 0x00);
}
/** /**
* Emits when a motor or sensor is attached to the Hub. * Emits when a motor or sensor is attached to the Hub.
* @event Hub#attach * @event Hub#attach
@ -290,7 +291,6 @@ export class Hub extends EventEmitter {
* @param {DeviceType} type * @param {DeviceType} type
*/ */
this.emit("attach", port.id, type); this.emit("attach", port.id, type);
}
} else { } else {
port.type = Consts.DeviceType.UNKNOWN; port.type = Consts.DeviceType.UNKNOWN;
debug(`Port ${port.id} disconnected`); debug(`Port ${port.id} disconnected`);