diff --git a/src/devices/device.ts b/src/devices/device.ts index def6488..556e193 100644 --- a/src/devices/device.ts +++ b/src/devices/device.ts @@ -107,11 +107,15 @@ export class Device extends EventEmitter { } } + public unsubscribe (mode: number) { + this._ensureConnected(); + } + public receive (message: Buffer) { this.emitGlobal("receive", { message }); } - public emitGlobal (event: string, ...args: any) { + public emitGlobal (event: string, ...args: any[]) { this.emit(event, ...args); if (this.hub.listenerCount(event) > 0) { this.hub.emit(event, this, ...args); diff --git a/src/hubs/basehub.ts b/src/hubs/basehub.ts index e711455..d9ace2d 100644 --- a/src/hubs/basehub.ts +++ b/src/hubs/basehub.ts @@ -289,6 +289,11 @@ export class BaseHub extends EventEmitter { } + public unsubscribe (portId: number, deviceType: number, mode: number) { + // NK Do nothing here + } + + protected _attachDevice (device: Device) { this._attachedDevices[device.portId] = device; /** diff --git a/src/hubs/wedo2smarthub.ts b/src/hubs/wedo2smarthub.ts index b2afaad..1da11d1 100644 --- a/src/hubs/wedo2smarthub.ts +++ b/src/hubs/wedo2smarthub.ts @@ -141,8 +141,8 @@ export class WeDo2SmartHub extends BaseHub { } - protected _deactivatePortDevice (port: number, type: number, mode: number, format: number, callback?: () => void) { - this.send(Buffer.from([0x01, 0x02, port, type, mode, 0x01, 0x00, 0x00, 0x00, format, 0x00]), Consts.BLECharacteristic.WEDO2_PORT_TYPE_WRITE, callback); + public unsubscribe (portId: number, deviceType: number, mode: number) { + this.send(Buffer.from([0x01, 0x02, portId, deviceType, mode, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00]), Consts.BLECharacteristic.WEDO2_PORT_TYPE_WRITE); }