123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375 |
- // 枚举定义
- const EnumCmdEvent = {
- nextChannel: 'nextChannel',
- previousChannel: 'previousChannel',
- switchChannel: 'switchChannel',
- previousAlbum: 'previousAlbum',
- nextAlbum: 'nextAlbum',
- nextSong: 'nextSong',
- previousSong: 'previousSong',
- speed: 'speed',
- fastback: 'fastback',
- stopSpeed: 'stopSpeed',
- stopFastback: 'stopFastback',
- startRecord: 'startRecord',
- stopRecord: 'stopRecord',
- battery: 'battery',
- lowKwnSet: 'lowKwnSet',
- batteryEarphone: 'batteryEarphone',
- ctrlStatus: 'ctrlStatus',
- lowPowerOpen: 'lowPowerOpen',
- eq: 'eq',
- lowDelayMode: 'lowDelayMode',
- sleep: 'sleep',
- wake: 'wake',
- volume: 'volume',
- version: 'version',
- sim: 'sim',
- dsn: 'dsn',
- playInfo: 'playInfo',
- playStatus: 'playStatus',
- auth: 'auth',
- unbind: 'unbind',
- enableTTS: 'enableTTS',
- switchDeviceMode: 'switchDeviceMode',
- netModeAuto: 'netModeAuto',
- getDeviceInfo: 'getDeviceInfo',
- collectState: 'collectState',
- todayStep: 'todayStep',
- todayRates: 'todayRates',
- targetSteps: 'targetSteps',
- setTimeFormat: 'setTimeFormat',
- setNotDisturb: 'setNotDisturb',
- setQuickViewTime: 'setQuickViewTime',
- openPush: 'openPush',
- takeHandLight: 'takeHandLight',
- payId: 'payId',
- authSleepStatus: 'authSleepStatus',
- btMac: 'btMac'
- };
- // 枚举定义
- const EnumPlayStatus = {
- none: 'none',
- play: 'play',
- pause: 'pause',
- stop: 'stop',
- completed: 'completed',
- error: 'error',
- buffering: 'buffering', // APP自己定义的特殊处理中间状态
- };
- // 或者使用对象字面量
- const EnumSupplier = {
- shanJing: "ShanJing",
- jieLi: "JieLi",
- lingXin: "LingXin",
- qiXinWei: "QiXinWei"
- };
- // 设备操作类
- class CmdEvent {
- constructor({ cmdEvent }) {
- this.cmdEvent = cmdEvent;
- this.channelId = 1;
- this.wakeSwitch = null;
- this.wakeCycle = [0, 0, 0, 0, 0, 0, 0];
- this.ctrlStatus = [0, 0, 0];
- this.lowPowerOpen = null;
- this.wakeHour = null;
- this.wakeMinutes = null;
- this.sleepSwitch = null;
- this.sleepHour = null;
- this.sleepMinutes = null;
- this.kwh = 9;
- this.kwhLeft = 9;
- this.kwhRight = 9;
- this.kwhBox = 9;
- this.lowKwnSet = false;
- this.volume = 0;
- this.version = "1.0.0";
- this.dsn = null;
- this.playStatus = null;
- this.playInfo = null;
- this.authInfo = null;
- this.item = null;
- this.eSim = null;
- this.sim = null;
- this.simIndex = null;
- this.enableTTS = null;
- this.eqs = null;
- this.lowDelayMode = null;
- this.lowDelayModeOpen = null;
- this.netModeAuto = null;
- this.pauseSleep = null;
- this.collectStatus = null;
- this.audioInfoId = null;
- this.todayStep = null;
- this.todayRates = null;
- this.stepTarget = null;
- this.setTimeFormat = null;
- this.setQuickViewTime = null;
- this.setNotDisturb = null;
- this.openPush = null;
- this.takeHandLight = null;
- this.stepDistance = null;
- this.stepCalories = null;
- this.stepTime = null;
- this.payId = null;
- this.btMac = null;
- this.deviceMode = null;
- }
- static wake({ wakeSwitch, wakeCycle, wakeHour, wakeMinutes }) {
- const event = new CmdEvent({ cmdEvent: EnumCmdEvent.wake });
- event.wakeSwitch = wakeSwitch;
- event.wakeCycle = wakeCycle;
- event.wakeHour = wakeHour;
- event.wakeMinutes = wakeMinutes;
- return event;
- }
- static sim({ eSim, sim, simIndex }) {
- const event = new CmdEvent({ cmdEvent: EnumCmdEvent.sim });
- event.eSim = eSim;
- event.sim = sim;
- event.simIndex = simIndex;
- return event;
- }
- static sleep({ sleepSwitch, sleepHour, sleepMinutes }) {
- const event = new CmdEvent({ cmdEvent: EnumCmdEvent.sleep });
- event.sleepSwitch = sleepSwitch;
- event.sleepHour = sleepHour;
- event.sleepMinutes = sleepMinutes;
- return event;
- }
- static ctrlStatus({ ctrlStatus }) {
- const event = new CmdEvent({ cmdEvent: EnumCmdEvent.ctrlStatus });
- event.ctrlStatus = ctrlStatus;
- return event;
- }
- static switchChannel({ channelId }) {
- const event = new CmdEvent({ cmdEvent: EnumCmdEvent.switchChannel });
- event.channelId = channelId;
- return event;
- }
- static switchDeviceMode({ deviceMode }) {
- const event = new CmdEvent({ cmdEvent: EnumCmdEvent.switchDeviceMode });
- event.deviceMode = deviceMode;
- return event;
- }
- static enableTTS({ enableTTS }) {
- const event = new CmdEvent({ cmdEvent: EnumCmdEvent.enableTTS });
- event.enableTTS = enableTTS;
- return event;
- }
- static battery({ kwh }) {
- const event = new CmdEvent({ cmdEvent: EnumCmdEvent.battery });
- event.kwh = kwh;
- return event;
- }
- static queryLowKwn({ kwh }) {
- const event = new CmdEvent({ cmdEvent: EnumCmdEvent.lowKwnSet });
- event.kwh = kwh;
- return event;
- }
- static dsn({ dsn }) {
- const event = new CmdEvent({ cmdEvent: EnumCmdEvent.dsn });
- event.dsn = dsn;
- return event;
- }
- static getDeviceInfo() {
- return new CmdEvent({ cmdEvent: EnumCmdEvent.getDeviceInfo });
- }
- static todayStep({ todayStep, stepDistance, stepCalories, stepTime }) {
- const event = new CmdEvent({ cmdEvent: EnumCmdEvent.todayStep });
- event.todayStep = todayStep;
- event.stepDistance = stepDistance;
- event.stepCalories = stepCalories;
- event.stepTime = stepTime;
- return event;
- }
- static todaySport({ todayStep, stepDistance, stepCalories, stepTime }) {
- const event = new CmdEvent({ cmdEvent: EnumCmdEvent.todayStep });
- event.todayStep = todayStep;
- event.stepDistance = stepDistance;
- event.stepCalories = stepCalories;
- event.stepTime = stepTime;
- return event;
- }
- static todayRates({ todayRates }) {
- const event = new CmdEvent({ cmdEvent: EnumCmdEvent.todayRates });
- event.todayRates = todayRates;
- return event;
- }
- static pauseSleep({ pauseSleep }) {
- const event = new CmdEvent({ cmdEvent: EnumCmdEvent.authSleepStatus });
- event.pauseSleep = pauseSleep;
- return event;
- }
- static targetSteps({ stepTarget }) {
- const event = new CmdEvent({ cmdEvent: EnumCmdEvent.targetSteps });
- event.stepTarget = stepTarget;
- return event;
- }
- static setTimeFormat({ setTimeFormat }) {
- const event = new CmdEvent({ cmdEvent: EnumCmdEvent.setTimeFormat });
- event.setTimeFormat = setTimeFormat;
- return event;
- }
- static setNotDisturb({ setNotDisturb }) {
- const event = new CmdEvent({ cmdEvent: EnumCmdEvent.setNotDisturb });
- event.setNotDisturb = setNotDisturb;
- return event;
- }
- static setQuickViewTime({ setQuickViewTime }) {
- const event = new CmdEvent({ cmdEvent: EnumCmdEvent.setQuickViewTime });
- event.setQuickViewTime = setQuickViewTime;
- return event;
- }
- static openPush({ openPush }) {
- const event = new CmdEvent({ cmdEvent: EnumCmdEvent.openPush });
- event.openPush = openPush;
- return event;
- }
- static takeHandLight({ takeHandLight }) {
- const event = new CmdEvent({ cmdEvent: EnumCmdEvent.takeHandLight });
- event.takeHandLight = takeHandLight;
- return event;
- }
- static batteryEarphone({ kwh, kwhLeft, kwhRight, kwhBox }) {
- const event = new CmdEvent({ cmdEvent: EnumCmdEvent.batteryEarphone });
- event.kwh = kwh;
- event.kwhLeft = kwhLeft;
- event.kwhRight = kwhRight;
- event.kwhBox = kwhBox;
- return event;
- }
- static unbind({ item }) {
- const event = new CmdEvent({ cmdEvent: EnumCmdEvent.unbind });
- event.item = item;
- return event;
- }
- static auth({ authInfo }) {
- const event = new CmdEvent({ cmdEvent: EnumCmdEvent.auth });
- event.authInfo = authInfo;
- return event;
- }
- static eqs({ eqs }) {
- const event = new CmdEvent({ cmdEvent: EnumCmdEvent.eq });
- event.eqs = eqs;
- return event;
- }
- static lowDelayMode({ lowDelayMode, lowDelayModeOpen }) {
- const event = new CmdEvent({ cmdEvent: EnumCmdEvent.lowDelayMode });
- event.lowDelayMode = lowDelayMode;
- event.lowDelayModeOpen = lowDelayModeOpen;
- return event;
- }
- static lowPowerOpen({ lowPowerOpen }) {
- const event = new CmdEvent({ cmdEvent: EnumCmdEvent.lowPowerOpen });
- event.lowPowerOpen = lowPowerOpen;
- return event;
- }
- static volume({ volume }) {
- const event = new CmdEvent({ cmdEvent: EnumCmdEvent.volume });
- event.volume = volume;
- return event;
- }
- static version({ version }) {
- const event = new CmdEvent({ cmdEvent: EnumCmdEvent.version });
- event.version = version;
- return event;
- }
- static btMac({ btMac }) {
- const event = new CmdEvent({ cmdEvent: EnumCmdEvent.btMac });
- event.btMac = btMac;
- return event;
- }
- static netModeAuto({ netModeAuto }) {
- const event = new CmdEvent({ cmdEvent: EnumCmdEvent.netModeAuto });
- event.netModeAuto = netModeAuto;
- return event;
- }
- static playInfo({ playInfo }) {
- const event = new CmdEvent({ cmdEvent: EnumCmdEvent.playInfo });
- event.playInfo = playInfo;
- return event;
- }
- static payId({ payId }) {
- const event = new CmdEvent({ cmdEvent: EnumCmdEvent.payId });
- event.payId = payId;
- return event;
- }
- static collectState({ collectStatus, audioInfoId }) {
- const event = new CmdEvent({ cmdEvent: EnumCmdEvent.collectState });
- event.collectStatus = collectStatus;
- event.audioInfoId = audioInfoId;
- return event;
- }
- static playStatus({ playStatus }) {
- const event = new CmdEvent({ cmdEvent: EnumCmdEvent.playStatus });
- switch (playStatus) {
- case 1:
- event.playStatus = EnumPlayStatus.play;
- break;
- case 2:
- event.playStatus = EnumPlayStatus.pause;
- break;
- case 3:
- event.playStatus = EnumPlayStatus.stop;
- break;
- case 4:
- event.playStatus = EnumPlayStatus.completed;
- break;
- default:
- }
- return event
- }
- toString() {
- return `CmdEvent{cmdEvent: ${this.cmdEvent}, channelId: ${this.channelId}, wakeSwitch: ${this.wakeSwitch}, wakeCycle: ${this.wakeCycle}, wakeHour: ${this.wakeHour}, wakeMinutes: ${this.wakeMinutes}, sleepSwitch: ${this.sleepSwitch}, sleepHour: ${this.sleepHour}, sleepMinutes: ${this.sleepMinutes}, kwh: ${this.kwh}, volume: ${this.volume}, version: ${this.version}}`;
- }
- }
- module.exports = {
- CmdEvent,
- EnumCmdEvent,
- EnumPlayStatus,
- EnumSupplier
- };
|