Merge branch 'feature/devices' of github.com:nathankellenicki/node-poweredup into feature/devices
This commit is contained in:
commit
9f087e3e1a
@ -107,11 +107,15 @@ export class Device extends EventEmitter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public unsubscribe (mode: number) {
|
||||||
|
this._ensureConnected();
|
||||||
|
}
|
||||||
|
|
||||||
public receive (message: Buffer) {
|
public receive (message: Buffer) {
|
||||||
this.emitGlobal("receive", { message });
|
this.emitGlobal("receive", { message });
|
||||||
}
|
}
|
||||||
|
|
||||||
public emitGlobal (event: string, ...args: any) {
|
public emitGlobal (event: string, ...args: any[]) {
|
||||||
this.emit(event, ...args);
|
this.emit(event, ...args);
|
||||||
if (this.hub.listenerCount(event) > 0) {
|
if (this.hub.listenerCount(event) > 0) {
|
||||||
this.hub.emit(event, this, ...args);
|
this.hub.emit(event, this, ...args);
|
||||||
|
@ -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) {
|
protected _attachDevice (device: Device) {
|
||||||
this._attachedDevices[device.portId] = device;
|
this._attachedDevices[device.portId] = device;
|
||||||
/**
|
/**
|
||||||
|
@ -141,8 +141,8 @@ export class WeDo2SmartHub extends BaseHub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected _deactivatePortDevice (port: number, type: number, mode: number, format: number, callback?: () => void) {
|
public unsubscribe (portId: number, deviceType: number, mode: number) {
|
||||||
this.send(Buffer.from([0x01, 0x02, port, type, mode, 0x01, 0x00, 0x00, 0x00, format, 0x00]), Consts.BLECharacteristic.WEDO2_PORT_TYPE_WRITE, callback);
|
this.send(Buffer.from([0x01, 0x02, portId, deviceType, mode, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00]), Consts.BLECharacteristic.WEDO2_PORT_TYPE_WRITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user