import { Device } from "./device" ; import { IDeviceInterface } from "../interfaces" ; import * as Consts from "../consts" ; class extends Device export class DuploTrainBaseSpeaker extends Device { constructor ( hub , portId ) { super ( hub , portId , { } , Consts . DeviceType . DUPLO_TRAIN_BASE_SPEAKER ) ; } method param { DuploTrainBaseSound } sound returns { Promise } public playSound ( sound ) { return new Promise < void > ( ( resolve ) => { this . subscribe ( Mode . SOUND ) ; this . writeDirect ( 0x01 , Buffer . from ( [ sound ] ) ) ; return resolve ( ) ; } ) ; } method param { number } tone returns { Promise } public playTone ( tone ) { this . subscribe ( Mode . TONE ) ; this . writeDirect ( 0x02 , Buffer . from ( [ tone ] ) ) ; } } export enum Mode { SOUND = 0x01 , TONE = 0x02 }