diff --git a/src/devices/device.ts b/src/devices/device.ts index adb9a30..e80850d 100644 --- a/src/devices/device.ts +++ b/src/devices/device.ts @@ -28,7 +28,7 @@ export class Device extends EventEmitter { this._modeMap = modeMap; this._isWeDo2SmartHub = (this.hub.type === Consts.HubType.WEDO2_SMART_HUB); - const attachListener = (event: string) => { + const eventAttachListener = (event: string) => { if (event === "detach") { return; } @@ -39,23 +39,23 @@ export class Device extends EventEmitter { } }; - const detachListener = (device: Device) => { + const deviceDetachListener = (device: Device) => { if (device.portId === this.portId) { this._connected = false; - this.hub.removeListener("detach", detachListener); + this.hub.removeListener("detach", deviceDetachListener); this.emit("detach"); } }; for (let event in this._modeMap) { if (this.hub.listenerCount(event) > 0) { - attachListener(event); + eventAttachListener(event); } } - this.hub.on("newListener", attachListener); - this.on("newListener", attachListener); - this.hub.on("detach", detachListener); + this.hub.on("newListener", eventAttachListener); + this.on("newListener", eventAttachListener); + this.hub.on("detach", deviceDetachListener); } public get connected () { diff --git a/src/hubs/hub.ts b/src/hubs/hub.ts index 0e567d4..eb6cf29 100644 --- a/src/hubs/hub.ts +++ b/src/hubs/hub.ts @@ -62,7 +62,10 @@ export namespace Hub { export const PortMap: {[portName: string]: number} = { "A": 0, - "B": 1 + "B": 1, + "HUB_LED": 50, + "CURRENT_SENSOR": 59, + "VOLTAGE_SENSOR": 60 } } \ No newline at end of file diff --git a/src/hubs/movehub.ts b/src/hubs/movehub.ts index a38dbcd..657a083 100644 --- a/src/hubs/movehub.ts +++ b/src/hubs/movehub.ts @@ -62,7 +62,11 @@ export namespace MoveHub { "A": 0, "B": 1, "C": 2, - "D": 3 + "D": 3, + "HUB_LED": 50, + "TILT_SENSOR": 58, + "CURRENT_SENSOR": 59, + "VOLTAGE_SENSOR": 60 } } \ No newline at end of file diff --git a/src/hubs/remotecontrol.ts b/src/hubs/remotecontrol.ts index 3d3c731..50e08b4 100644 --- a/src/hubs/remotecontrol.ts +++ b/src/hubs/remotecontrol.ts @@ -53,7 +53,10 @@ export namespace RemoteControl { export const PortMap: {[portName: string]: number} = { "LEFT": 0, - "RIGHT": 1 + "RIGHT": 1, + "HUB_LED": 52, + "VOLTAGE_SENSOR": 59, + "REMOTE_CONTROL_RSSI": 60 } } \ No newline at end of file diff --git a/src/hubs/technicmediumhub.ts b/src/hubs/technicmediumhub.ts index dc6f2b5..558b113 100644 --- a/src/hubs/technicmediumhub.ts +++ b/src/hubs/technicmediumhub.ts @@ -115,9 +115,12 @@ export namespace TechnicMediumHub { "B": 1, "C": 2, "D": 3, - "ACCEL": 97, - "GYRO": 98, - "TILT": 99 + "HUB_LED": 50, + "CURRENT_SENSOR": 59, + "VOLTAGE_SENSOR": 60, + "ACCELEROMETER": 97, + "GYRO_SENSOR": 98, + "TILT_SENSOR": 99 } } \ No newline at end of file diff --git a/src/hubs/wedo2smarthub.ts b/src/hubs/wedo2smarthub.ts index 74f5868..c392c21 100644 --- a/src/hubs/wedo2smarthub.ts +++ b/src/hubs/wedo2smarthub.ts @@ -232,7 +232,11 @@ export namespace WeDo2SmartHub { export const PortMap: {[portName: string]: number} = { "A": 1, - "B": 2 + "B": 2, + "CURRENT_SENSOR": 3, + "VOLTAGE_SENSOR": 4, + "PIEZO_BUZZER": 5, + "HUB_LED": 6 } } \ No newline at end of file