Commit 69b779a9 authored by Skye Yu's avatar Skye Yu

update jensen api

parent 716901bc
......@@ -16,6 +16,7 @@ const SET_SETTINGS = 0x0c;
const READ_CARD_INFO = 0x10;
const FORMAT_CARD = 0x11;
const GET_RECORDING_FILE = 0x12;
const GET_FILE_BLOCK = 0x0d;
const FACTORY_RESET = 0xf00b;
const RECORD_TEST_START = 0xf008; // 录音测试开始
......@@ -771,8 +772,13 @@ Jensen.prototype.setAutoPlay = function (enable, seconds) {
};
Jensen.prototype.setNotification = function (enable, seconds) {
if (this.versionNumber < 327714) return { result: false };
return this.send(new Command(SET_SETTINGS).body([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, enable ? 1 : 2]), seconds);
return this.send(new Command(SET_SETTINGS).body([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, enable ? 1 : 2], 0, 0, 0, 0), seconds);
};
Jensen.prototype.setBluetoothPromptPlay = function(enable, seconds)
{
return this.send(new Command(SET_SETTINGS).body([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, enable ? 1 : 2]), seconds);
}
Jensen.prototype.getCardInfo = function (seconds) {
if (this.versionNumber < 327733) return null;
return this.send(new Command(READ_CARD_INFO), seconds);
......@@ -793,6 +799,30 @@ Jensen.prototype.recordTestEnd = async function (type, seconds) {
return this.send(new Command(0xf009).body([type]), seconds);
};
Jensen.prototype.test = async function (seconds) {
return this.send(new Command(DEVICE_MSG_TEST), seconds);
};
Jensen.prototype.getFileBlock = async function(filename, length, ondata) {
if (typeof(length) != 'number') throw new Error('parameter `length` required');
if (length <= 0) throw new Error('parameter `length` must greater than zero');
if (this.fileLength > 0) return null;
let data = [];
data.push((length >> 24) & 0xff);
data.push((length >> 16) & 0xff);
data.push((length >> 8) & 0xff);
data.push((length >> 0) & 0xff);
for (let i = 0; i < filename.length; i++) data.push(filename.charCodeAt(i));
this.onFileRecvHandler = ondata;
this.fileLength = length;
this.fileReadBytes = 0;
return this.send(new Command(GET_FILE_BLOCK).body(data));
}
const commonMessageParser = (msg) => {
return { result: msg.body[0] == 0x00 ? 'success' : 'failed' };
};
......@@ -928,5 +958,7 @@ Jensen.registerHandler(GET_RECORDING_FILE, (msg) => {
});
Jensen.registerHandler(RECORD_TEST_START, commonMessageParser);
Jensen.registerHandler(RECORD_TEST_END, commonMessageParser);
Jensen.registerHandler(DEVICE_MSG_TEST, commonMessageParser);
Jensen.registerHandler(GET_FILE_BLOCK, 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