Commit fdfb03b7 authored by Skye's avatar Skye

feat: send schedule info api

parent 55ef423c
import { Jensen as Jen } from "./src/jensen";
import { Logger } from "./src/utils/utils";
import { Jensen as Jen } from './src/jensen';
import { Logger } from './src/utils/utils';
export type DeviceInfo = {
sn: string;
......@@ -8,7 +8,7 @@ export type DeviceInfo = {
};
export type ReturnStruct = {
common: { result: "failed" | "success" };
common: { result: 'failed' | 'success' };
};
export type FileInfo = {
......@@ -24,10 +24,8 @@ export type FileInfo = {
export type ScheduleInfo = {
startDate: Date;
endDate: Date;
keyAnswer?: string;
keyHangup?: string;
keyReject?: string;
keyMicMute?: string;
os: 'Windows' | 'Linux' | 'Mac';
platform: string;
};
declare class JensenType {
......@@ -39,33 +37,20 @@ declare class JensenType {
getDeviceInfo: (time?: number) => Promise<DeviceInfo>;
listFiles: (time?: number) => Promise<FileInfo[]>;
tryconnect: (disableOnConnect?: boolean) => Promise<boolean>;
getFile: (
fileName: string,
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"]>;
getFile: (fileName: string, 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: (
vn: number,
length: number,
time?: number,
time?: number
) => Promise<{
result: "accepted" | "fail";
result: 'accepted' | 'fail';
}>;
beginBNC: (time?: number) => Promise<ReturnStruct["common"]>;
endBNC: (time?: number) => Promise<ReturnStruct["common"]>;
setTime: (date: Date, timeout?: number) => Promise<ReturnStruct["common"]>;
beginBNC: (time?: number) => Promise<ReturnStruct['common']>;
endBNC: (time?: number) => Promise<ReturnStruct['common']>;
setTime: (date: Date, timeout?: number) => Promise<ReturnStruct['common']>;
deleteFile: (fileName: string) => Promise<{ result: string }>;
uploadFirmware: (
data: number[],
seconds?: number,
onProgress?: (cur: number, total: number) => void,
) => Promise<ReturnStruct["common"]>;
uploadFirmware: (data: number[], seconds?: number, onProgress?: (cur: number, total: number) => void) => Promise<ReturnStruct['common']>;
getTime: (time?: number) => Promise<{
time: string;
}>;
......@@ -74,19 +59,10 @@ declare class JensenType {
autoPlay: boolean;
notification?: boolean;
} | null>;
setAutoRecord: (
enable: boolean,
time?: number,
) => Promise<ReturnStruct["common"]>;
setAutoPlay: (
enable: boolean,
time?: number,
) => Promise<ReturnStruct["common"]>;
setAutoRecord: (enable: boolean, time?: number) => Promise<ReturnStruct['common']>;
setAutoPlay: (enable: boolean, time?: number) => Promise<ReturnStruct['common']>;
isConnected: () => boolean;
setNotification: (
state: boolean,
time?: number,
) => Promise<ReturnStruct["common"]>;
setNotification: (state: boolean, time?: number) => Promise<ReturnStruct['common']>;
ondisconnect?: Function;
isStopConnectionCheck: boolean;
getRecordingFile: () => Promise<{
......@@ -94,29 +70,18 @@ declare class JensenType {
createTime: string;
createDate: string;
}>;
getCardInfo: (
seconds?: number,
) => Promise<{ used: number; capacity: number; status: string }>;
formatCard: (seconds?: number) => Promise<ReturnStruct["common"]>;
factoryReset: (seconds?: number) => Promise<ReturnStruct["common"]>;
restoreFactorySettings: (seconds?: number) => Promise<ReturnStruct["common"]>;
getCardInfo: (seconds?: number) => Promise<{ used: number; capacity: number; status: string }>;
formatCard: (seconds?: number) => Promise<ReturnStruct['common']>;
factoryReset: (seconds?: number) => Promise<ReturnStruct['common']>;
restoreFactorySettings: (seconds?: number) => Promise<ReturnStruct['common']>;
getModel: () => string;
getFileCount: (seconds?: number) => Promise<{ count: number } | null>;
recordTestStart: (
type: number,
seconds?: number,
) => Promise<ReturnStruct["common"]>;
recordTestEnd: (
type: number,
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"]>;
recordTestStart: (type: number, seconds?: number) => Promise<ReturnStruct['common']>;
recordTestEnd: (type: number, 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
......
{
"name": "jensen",
"version": "1.1.3",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "jensen",
"version": "1.1.3",
"version": "1.0.0",
"license": "ISC",
"devDependencies": {
"prettier": "^3.3.3"
......
This diff is collapsed.
const Level = {
debug: "debug",
info: "info",
error: "error",
debug: 'debug',
info: 'info',
error: 'error'
};
export const Logger = {
......@@ -22,7 +22,7 @@ export const Logger = {
module,
procedure,
message: String(message),
time: new Date().getTime(),
time: new Date().getTime()
};
this.messages.push(log);
if (this.consoleOutput) {
......@@ -33,22 +33,20 @@ export const Logger = {
_print(log) {
let time = new Date(log.time);
console.info(
"[" +
(log.level === "error" ? "x" : "*") +
"][" +
'[' +
(log.level === 'error' ? 'x' : '*') +
'][' +
time.toLocaleString() +
"](" +
'](' +
log.module +
" - " +
' - ' +
log.procedure +
") " +
log.message,
') ' +
log.message
);
},
filter(module, procedure) {
return this.messages.filter(
(i) => i.module === module && i.procedure === procedure,
);
return this.messages.filter((i) => i.module === module && i.procedure === procedure);
},
enableConsoleOutput() {
this.consoleOutput = true;
......@@ -71,25 +69,250 @@ export const Logger = {
}
return true;
});
},
}
};
export const getTimeStr = (date: Date) => {
let str =
date.getFullYear() +
"-0" +
'-0' +
(date.getMonth() + 1) +
"-0" +
'-0' +
date.getDate() +
"-0" +
'-0' +
date.getHours() +
"-0" +
'-0' +
date.getMinutes() +
"-0" +
'-0' +
date.getSeconds();
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",
);
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');
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