Commit 6510e1fe authored by 曾思程's avatar 曾思程

加入了改号的命令

parent 9fdf6000
......@@ -86,6 +86,7 @@ declare class JensenType {
state: boolean,
seconds?: number
) => Promise<ReturnStruct['common']>;
writeSerialNumber: (sn: string) => Promise<ReturnStruct['common']>
}
......
......@@ -20,6 +20,7 @@ const SET_SETTINGS = 0x0c;
const GET_FILE_BLOCK = 0x0d;
const FACTORY_RESET = 0xf00b;
const TEST_SN_WRITE = 0xf007;
const RECORD_TEST_START = 0xf008; // 录音测试开始
const RECORD_TEST_END = 0xf009; // 录音测试结束
......@@ -825,6 +826,14 @@ Jensen.prototype.getFileBlock = async function (filename, length, ondata) {
return this.send(new Command(GET_FILE_BLOCK).body(data));
}
Jensen.prototype.writeSerialNumber = async function (sn) {
let data = [];
for (let i = 0; i < sn.length; i++) {
data.push(sn.charCodeAt(i));
}
return this.send(new Command(TEST_SN_WRITE).body(data));
}
const commonMessageParser = (msg) => {
return { result: msg.body[0] === 0x00 ? 'success' : 'failed' };
};
......@@ -964,5 +973,7 @@ Jensen.registerHandler(RECORD_TEST_START, commonMessageParser);
Jensen.registerHandler(RECORD_TEST_END, commonMessageParser);
Jensen.registerHandler(DEVICE_MSG_TEST, commonMessageParser);
Jensen.registerHandler(GET_FILE_BLOCK, commonMessageParser);
Jensen.registerHandler(TEST_SN_WRITE, commonMessageParser)
export { Jensen };
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