import { Device } from "./device" ; import { IDeviceInterface } from "../interfaces" ; import * as Consts from "../consts" ; class extends Device export class PiezoBuzzer extends Device { constructor ( hub , portId ) { super ( hub , portId , { } , Consts . DeviceType . PIEZO_BUZZER ) ; } method param { number } frequency param { number } time returns { Promise } public playTone ( frequency , time ) { return new Promise ( ( resolve ) => { const data = Buffer . from ( [ 0x05 , 0x02 , 0x04 , 0x00 , 0x00 , 0x00 , 0x00 ] ) ; data . writeUInt16LE ( frequency , 3 ) ; data . writeUInt16LE ( time , 5 ) ; this . send ( data , Consts . BLECharacteristic . WEDO2_MOTOR_VALUE_WRITE ) ; global . setTimeout ( resolve , time ) ; } ) ; } }