Commit fdfb03b7 authored by Skye's avatar Skye

feat: send schedule info api

parent 55ef423c
import { Jensen as Jen } from "./src/jensen"; import { Jensen as Jen } from './src/jensen';
import { Logger } from "./src/utils/utils"; import { Logger } from './src/utils/utils';
export type DeviceInfo = { export type DeviceInfo = {
sn: string; sn: string;
...@@ -8,7 +8,7 @@ export type DeviceInfo = { ...@@ -8,7 +8,7 @@ export type DeviceInfo = {
}; };
export type ReturnStruct = { export type ReturnStruct = {
common: { result: "failed" | "success" }; common: { result: 'failed' | 'success' };
}; };
export type FileInfo = { export type FileInfo = {
...@@ -24,10 +24,8 @@ export type FileInfo = { ...@@ -24,10 +24,8 @@ export type FileInfo = {
export type ScheduleInfo = { export type ScheduleInfo = {
startDate: Date; startDate: Date;
endDate: Date; endDate: Date;
keyAnswer?: string; os: 'Windows' | 'Linux' | 'Mac';
keyHangup?: string; platform: string;
keyReject?: string;
keyMicMute?: string;
}; };
declare class JensenType { declare class JensenType {
...@@ -39,33 +37,20 @@ declare class JensenType { ...@@ -39,33 +37,20 @@ declare class JensenType {
getDeviceInfo: (time?: number) => Promise<DeviceInfo>; getDeviceInfo: (time?: number) => Promise<DeviceInfo>;
listFiles: (time?: number) => Promise<FileInfo[]>; listFiles: (time?: number) => Promise<FileInfo[]>;
tryconnect: (disableOnConnect?: boolean) => Promise<boolean>; tryconnect: (disableOnConnect?: boolean) => Promise<boolean>;
getFile: ( getFile: (fileName: string, length: number, on?: (msg: Uint8Array | 'fail') => void, onprogress?: (size: number) => void) => void;
fileName: string, getFileBlock: (fileName: string, length: number, on?: (msg: Uint8Array | 'fail') => void) => Promise<ReturnStruct['common']>;
length: number,
on?: (msg: Uint8Array | "fail") => void,
onprogress?: (size: number) => void,
) => void;
getFileBlock: (
fileName: string,
length: number,
on?: (msg: Uint8Array | "fail") => void,
) => Promise<ReturnStruct["common"]>;
requestFirmwareUpgrade: ( requestFirmwareUpgrade: (
vn: number, vn: number,
length: number, length: number,
time?: number, time?: number
) => Promise<{ ) => Promise<{
result: "accepted" | "fail"; result: 'accepted' | 'fail';
}>; }>;
beginBNC: (time?: number) => Promise<ReturnStruct["common"]>; beginBNC: (time?: number) => Promise<ReturnStruct['common']>;
endBNC: (time?: number) => Promise<ReturnStruct["common"]>; endBNC: (time?: number) => Promise<ReturnStruct['common']>;
setTime: (date: Date, timeout?: number) => Promise<ReturnStruct["common"]>; setTime: (date: Date, timeout?: number) => Promise<ReturnStruct['common']>;
deleteFile: (fileName: string) => Promise<{ result: string }>; deleteFile: (fileName: string) => Promise<{ result: string }>;
uploadFirmware: ( uploadFirmware: (data: number[], seconds?: number, onProgress?: (cur: number, total: number) => void) => Promise<ReturnStruct['common']>;
data: number[],
seconds?: number,
onProgress?: (cur: number, total: number) => void,
) => Promise<ReturnStruct["common"]>;
getTime: (time?: number) => Promise<{ getTime: (time?: number) => Promise<{
time: string; time: string;
}>; }>;
...@@ -74,19 +59,10 @@ declare class JensenType { ...@@ -74,19 +59,10 @@ declare class JensenType {
autoPlay: boolean; autoPlay: boolean;
notification?: boolean; notification?: boolean;
} | null>; } | null>;
setAutoRecord: ( setAutoRecord: (enable: boolean, time?: number) => Promise<ReturnStruct['common']>;
enable: boolean, setAutoPlay: (enable: boolean, time?: number) => Promise<ReturnStruct['common']>;
time?: number,
) => Promise<ReturnStruct["common"]>;
setAutoPlay: (
enable: boolean,
time?: number,
) => Promise<ReturnStruct["common"]>;
isConnected: () => boolean; isConnected: () => boolean;
setNotification: ( setNotification: (state: boolean, time?: number) => Promise<ReturnStruct['common']>;
state: boolean,
time?: number,
) => Promise<ReturnStruct["common"]>;
ondisconnect?: Function; ondisconnect?: Function;
isStopConnectionCheck: boolean; isStopConnectionCheck: boolean;
getRecordingFile: () => Promise<{ getRecordingFile: () => Promise<{
...@@ -94,29 +70,18 @@ declare class JensenType { ...@@ -94,29 +70,18 @@ declare class JensenType {
createTime: string; createTime: string;
createDate: string; createDate: string;
}>; }>;
getCardInfo: ( getCardInfo: (seconds?: number) => Promise<{ used: number; capacity: number; status: string }>;
seconds?: number, formatCard: (seconds?: number) => Promise<ReturnStruct['common']>;
) => Promise<{ used: number; capacity: number; status: string }>; factoryReset: (seconds?: number) => Promise<ReturnStruct['common']>;
formatCard: (seconds?: number) => Promise<ReturnStruct["common"]>; restoreFactorySettings: (seconds?: number) => Promise<ReturnStruct['common']>;
factoryReset: (seconds?: number) => Promise<ReturnStruct["common"]>;
restoreFactorySettings: (seconds?: number) => Promise<ReturnStruct["common"]>;
getModel: () => string; getModel: () => string;
getFileCount: (seconds?: number) => Promise<{ count: number } | null>; getFileCount: (seconds?: number) => Promise<{ count: number } | null>;
recordTestStart: ( recordTestStart: (type: number, seconds?: number) => Promise<ReturnStruct['common']>;
type: number, recordTestEnd: (type: number, seconds?: number) => Promise<ReturnStruct['common']>;
seconds?: number, test: (seconds?: number) => Promise<ReturnStruct['common']>;
) => Promise<ReturnStruct["common"]>; setBluetoothPromptPlay: (state: boolean, seconds?: number) => Promise<ReturnStruct['common']>;
recordTestEnd: ( writeSerialNumber: (sn: string) => Promise<ReturnStruct['common']>;
type: number, sendScheduleInfo: (info: ScheduleInfo) => Promise<ReturnStruct['common']>;
seconds?: number,
) => Promise<ReturnStruct["common"]>;
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"]>;
} }
//@ts-ignore //@ts-ignore
......
{ {
"name": "jensen", "name": "jensen",
"version": "1.1.3", "version": "1.0.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "jensen", "name": "jensen",
"version": "1.1.3", "version": "1.0.0",
"license": "ISC", "license": "ISC",
"devDependencies": { "devDependencies": {
"prettier": "^3.3.3" "prettier": "^3.3.3"
......
This diff is collapsed.
const Level = { const Level = {
debug: "debug", debug: 'debug',
info: "info", info: 'info',
error: "error", error: 'error'
}; };
export const Logger = { export const Logger = {
...@@ -22,7 +22,7 @@ export const Logger = { ...@@ -22,7 +22,7 @@ export const Logger = {
module, module,
procedure, procedure,
message: String(message), message: String(message),
time: new Date().getTime(), time: new Date().getTime()
}; };
this.messages.push(log); this.messages.push(log);
if (this.consoleOutput) { if (this.consoleOutput) {
...@@ -33,22 +33,20 @@ export const Logger = { ...@@ -33,22 +33,20 @@ export const Logger = {
_print(log) { _print(log) {
let time = new Date(log.time); let time = new Date(log.time);
console.info( console.info(
"[" + '[' +
(log.level === "error" ? "x" : "*") + (log.level === 'error' ? 'x' : '*') +
"][" + '][' +
time.toLocaleString() + time.toLocaleString() +
"](" + '](' +
log.module + log.module +
" - " + ' - ' +
log.procedure + log.procedure +
") " + ') ' +
log.message, log.message
); );
}, },
filter(module, procedure) { filter(module, procedure) {
return this.messages.filter( return this.messages.filter((i) => i.module === module && i.procedure === procedure);
(i) => i.module === module && i.procedure === procedure,
);
}, },
enableConsoleOutput() { enableConsoleOutput() {
this.consoleOutput = true; this.consoleOutput = true;
...@@ -71,25 +69,250 @@ export const Logger = { ...@@ -71,25 +69,250 @@ export const Logger = {
} }
return true; return true;
}); });
}, }
}; };
export const getTimeStr = (date: Date) => { export const getTimeStr = (date: Date) => {
let str = let str =
date.getFullYear() + date.getFullYear() +
"-0" + '-0' +
(date.getMonth() + 1) + (date.getMonth() + 1) +
"-0" + '-0' +
date.getDate() + date.getDate() +
"-0" + '-0' +
date.getHours() + date.getHours() +
"-0" + '-0' +
date.getMinutes() + date.getMinutes() +
"-0" + '-0' +
date.getSeconds(); date.getSeconds();
str = str.replace( str = str.replace(/(\d{4})\-0*(\d{2})\-0*(\d{2})\-0*(\d{2})\-0*(\d{2})\-0*(\d{2})/gi, '$1$2$3$4$5$6');
/(\d{4})\-0*(\d{2})\-0*(\d{2})\-0*(\d{2})\-0*(\d{2})\-0*(\d{2})/gi,
"$1$2$3$4$5$6",
);
return str; return str;
}; };
const keyMap: { [key: string]: number } = {
A: 0x04,
B: 0x05,
C: 0x06,
D: 0x07,
E: 0x08,
F: 0x09,
G: 0x0a,
H: 0x0b,
I: 0x0c,
J: 0x0d,
K: 0x0e,
L: 0x0f,
M: 0x10,
N: 0x11,
O: 0x12,
P: 0x13,
Q: 0x14,
R: 0x15,
S: 0x16,
T: 0x17,
U: 0x18,
V: 0x19,
W: 0x1a,
X: 0x1b,
Y: 0x1c,
Z: 0x1b,
ENTER: 0x28,
ESCAPE: 0x29,
SPACE: 0x2c
};
const HotKeyBuilder = {
control: false,
shift: false,
alt: false,
guiKey: false,
keys: [],
withControl: () => {
HotKeyBuilder.control = true;
return HotKeyBuilder;
},
withShift: () => {
HotKeyBuilder.shift = true;
return HotKeyBuilder;
},
withAlt: () => {
HotKeyBuilder.alt = true;
return HotKeyBuilder;
},
withGuiKey: () => {
HotKeyBuilder.guiKey = true;
return HotKeyBuilder;
},
withKey: (key: string) => {
if (HotKeyBuilder.keys.length >= 2) throw new Error('exceed max key bindings');
HotKeyBuilder.keys.push(HotKeyBuilder.__mapping(key));
return HotKeyBuilder;
},
__mapping: (key: string) => {
return keyMap[key];
},
build: () => {
let key1 = 0;
if (HotKeyBuilder.control) key1 |= 0x01 << 0;
if (HotKeyBuilder.shift) key1 |= 0x01 << 1;
if (HotKeyBuilder.alt) key1 |= 0x01 << 2;
if (HotKeyBuilder.guiKey) key1 |= 0x01 << 3;
let codes = [
0x03,
key1,
HotKeyBuilder.keys.length ? HotKeyBuilder.keys[0] : 0x00,
HotKeyBuilder.keys.length > 1 ? HotKeyBuilder.keys[1] : 0x00,
0x00,
0x00,
0x00,
0x00
];
HotKeyBuilder.control = false;
HotKeyBuilder.shift = false;
HotKeyBuilder.alt = false;
HotKeyBuilder.guiKey = false;
HotKeyBuilder.keys = [];
return codes;
}
};
const enterKeyCode = (answer: 0 | 1 = 0, hangup: 0 | 1 = 0, reject: 0 | 1 = 0, micMute: 0 | 1 = 0) => {
let code = 0;
if (answer) code |= 0x01 << 0;
if (hangup) code |= 0x01 << 1;
if (reject) code |= 0x01 << 2;
if (micMute) code |= 0x01 << 3;
return code;
};
const emptyCodes = [0, 0, 0, 0, 0, 0, 0, 0];
export const shortcutKeys = {
Zoom: {
Windows: [
enterKeyCode(0, 1),
...emptyCodes,
HotKeyBuilder.withAlt().withKey('Q').build(),
...emptyCodes,
HotKeyBuilder.withAlt().withKey('A').build()
],
Mac: [
enterKeyCode(0, 1),
...emptyCodes,
HotKeyBuilder.withGuiKey().withKey('W').build(),
...emptyCodes,
HotKeyBuilder.withGuiKey().withShift().withKey('A').build()
],
Linux: [enterKeyCode(), ...emptyCodes, ...emptyCodes, ...emptyCodes, ...emptyCodes]
},
Teams: {
Windows: [
enterKeyCode(),
HotKeyBuilder.withControl().withShift().withKey('A').build(),
HotKeyBuilder.withControl().withShift().withKey('H').build(),
HotKeyBuilder.withControl().withShift().withKey('D').build(),
HotKeyBuilder.withControl().withShift().withKey('M').build()
],
Mac: [
enterKeyCode(),
HotKeyBuilder.withGuiKey().withShift().withKey('A').build(),
HotKeyBuilder.withGuiKey().withShift().withKey('H').build(),
HotKeyBuilder.withGuiKey().withShift().withKey('D').build(),
HotKeyBuilder.withGuiKey().withShift().withKey('M').build()
],
Linux: [enterKeyCode(), ...emptyCodes, ...emptyCodes, ...emptyCodes, ...emptyCodes]
},
'Google Meetings': {
Windows: [enterKeyCode(), ...emptyCodes, ...emptyCodes, ...emptyCodes, HotKeyBuilder.withControl().withKey('D').build()],
Mac: [enterKeyCode(), ...emptyCodes, ...emptyCodes, ...emptyCodes, HotKeyBuilder.withGuiKey().withKey('D').build()],
Linux: [enterKeyCode(), ...emptyCodes, ...emptyCodes, ...emptyCodes, ...emptyCodes]
},
Webex: {
Windows: [
enterKeyCode(),
HotKeyBuilder.withControl().withShift().withKey('C').build(),
HotKeyBuilder.withControl().withKey('L').build(),
HotKeyBuilder.withControl().withKey('D').build(),
HotKeyBuilder.withControl().withKey('M').build()
],
Mac: [
enterKeyCode(),
HotKeyBuilder.withControl().withShift().withKey('C').build(),
HotKeyBuilder.withGuiKey().withKey('L').build(),
HotKeyBuilder.withGuiKey().withShift().withKey('D').build(),
HotKeyBuilder.withGuiKey().withShift().withKey('M').build()
],
Linux: [enterKeyCode(), ...emptyCodes, ...emptyCodes, ...emptyCodes, ...emptyCodes]
},
Feishu: {
Windows: [enterKeyCode(), ...emptyCodes, ...emptyCodes, ...emptyCodes, HotKeyBuilder.withControl().withShift().withKey('D').build()],
Mac: [enterKeyCode(), ...emptyCodes, ...emptyCodes, ...emptyCodes, HotKeyBuilder.withGuiKey().withShift().withKey('D').build()],
Linux: [enterKeyCode(), ...emptyCodes, ...emptyCodes, ...emptyCodes, ...emptyCodes]
},
Lark: {
Windows: [enterKeyCode(), ...emptyCodes, ...emptyCodes, ...emptyCodes, HotKeyBuilder.withControl().withShift().withKey('D').build()],
Mac: [enterKeyCode(), ...emptyCodes, ...emptyCodes, ...emptyCodes, HotKeyBuilder.withGuiKey().withShift().withKey('D').build()],
Linux: [enterKeyCode(), ...emptyCodes, ...emptyCodes, ...emptyCodes, ...emptyCodes]
},
WeChat: {
Windows: [enterKeyCode(), ...emptyCodes, ...emptyCodes, ...emptyCodes, ...emptyCodes],
Mac: [enterKeyCode(), ...emptyCodes, ...emptyCodes, ...emptyCodes, ...emptyCodes],
Linux: [enterKeyCode(), ...emptyCodes, ...emptyCodes, ...emptyCodes, ...emptyCodes]
},
Line: {
Windows: [
enterKeyCode(0, 1, 1),
...emptyCodes,
HotKeyBuilder.withKey('ESCAPE').build(),
HotKeyBuilder.withKey('ESCAPE').build(),
HotKeyBuilder.withControl().withShift().withKey('A').build()
],
Mac: [
enterKeyCode(0, 1, 1),
...emptyCodes,
HotKeyBuilder.withKey('ESCAPE').build(),
HotKeyBuilder.withKey('ESCAPE').build(),
HotKeyBuilder.withGuiKey().withShift().withKey('A').build()
],
Linux: [enterKeyCode(), ...emptyCodes, ...emptyCodes, ...emptyCodes, ...emptyCodes]
},
WhatsApp: {
Windows: [enterKeyCode(), ...emptyCodes, ...emptyCodes, ...emptyCodes, ...emptyCodes],
Mac: [
enterKeyCode(),
...emptyCodes,
HotKeyBuilder.withGuiKey().withKey('W').build(),
HotKeyBuilder.withGuiKey().withKey('W').build(),
HotKeyBuilder.withGuiKey().withShift().withKey('M').build()
],
Linux: [enterKeyCode(), ...emptyCodes, ...emptyCodes, ...emptyCodes, ...emptyCodes]
},
Slack: {
Windows: [
enterKeyCode(),
...emptyCodes,
...emptyCodes,
...emptyCodes,
HotKeyBuilder.withControl().withShift().withKey('SPACE').build()
],
Mac: [enterKeyCode(), ...emptyCodes, ...emptyCodes, ...emptyCodes, HotKeyBuilder.withGuiKey().withShift().withKey('SPACE').build()],
Linux: [enterKeyCode(), ...emptyCodes, ...emptyCodes, ...emptyCodes, ...emptyCodes]
},
Discord: {
Windows: [
enterKeyCode(),
HotKeyBuilder.withControl().withKey('ENTER').build(),
...emptyCodes,
HotKeyBuilder.withKey('ESCAPE').build(),
HotKeyBuilder.withControl().withShift().withKey('M').build()
],
Mac: [
enterKeyCode(),
HotKeyBuilder.withGuiKey().withKey('ENTER').build(),
...emptyCodes,
HotKeyBuilder.withGuiKey().withKey('ESCAPE').build(),
HotKeyBuilder.withGuiKey().withShift().withKey('M').build()
],
Linux: [enterKeyCode(), ...emptyCodes, ...emptyCodes, ...emptyCodes, ...emptyCodes]
}
};
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