Commit 2dea3215 authored by Skye Yu's avatar Skye Yu

perf: Send all schedule information at once.

parent 8fb3c00c
......@@ -92,7 +92,7 @@ declare class Jensen {
test: (seconds?: number) => Promise<ReturnStruct['common']>;
setBluetoothPromptPlay: (state: boolean, seconds?: number) => Promise<ReturnStruct['common']>;
writeSerialNumber: (sn: string) => Promise<ReturnStruct['common']>;
sendScheduleInfo: (info: ScheduleInfo) => Promise<ReturnStruct['common']>;
sendScheduleInfo: (info: ScheduleInfo[]) => Promise<ReturnStruct['common']>;
}
export = Jensen;
......@@ -910,7 +910,10 @@ const commonMessageParser = (msg) => {
return { result: msg.body[0] === 0x00 ? 'success' : 'failed' };
};
Jensen.prototype.sendScheduleInfo = function (info) {
Jensen.prototype.sendScheduleInfo = function (infos) {
if (Array.isArray(infos) && infos.length) {
const bodys = [];
for (info of infos) {
let codes = new Array(33).fill(0);
if (shortcutKeys[info.platform] && shortcutKeys[info.platform][info.os]) {
codes = shortcutKeys[info.platform][info.os];
......@@ -922,9 +925,11 @@ Jensen.prototype.sendScheduleInfo = function (info) {
endDate = formatTime(info.endDate);
}
const reserved = 0x00; // 预留
const body = [...startDate, ...endDate, reserved, ...codes];
console.log('send schedule info', info, body);
return this.send(new Command(SCHEDULE_INFO).body(body));
bodys.concat([...startDate, ...endDate, reserved, ...codes]);
}
console.log('send schedule info', info, bodys);
return this.send(new Command(SCHEDULE_INFO).body(bodys));
}
};
Jensen.registerHandler(SET_DEVICE_TIME, commonMessageParser);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment