Commit 2989ee45 authored by martin hou's avatar martin hou

feat: 增加错误日志输出/增加对reconnect的兼容处理

parent d16340ea
...@@ -162,8 +162,9 @@ function Jensen(log, conn) { ...@@ -162,8 +162,9 @@ function Jensen(log, conn) {
this.reconnect = async function () { this.reconnect = async function () {
try try
{ {
if (device && device.opened) device.close(); await device.close();
device.open(); await device.open();
ready = false;
await setup(); await setup();
return true; return true;
} }
...@@ -386,6 +387,7 @@ function Jensen(log, conn) { ...@@ -386,6 +387,7 @@ function Jensen(log, conn) {
}; };
const tryDecode = function () { const tryDecode = function () {
if (!current) return;
// 一个容器,比单独任意一个小包要大一点儿,好像还差一点儿 // 一个容器,比单独任意一个小包要大一点儿,好像还差一点儿
let stime = new Date(); let stime = new Date();
let buff = new ArrayBuffer(RECV_BUFF_SIZE * 2); let buff = new ArrayBuffer(RECV_BUFF_SIZE * 2);
...@@ -407,6 +409,7 @@ function Jensen(log, conn) { ...@@ -407,6 +409,7 @@ function Jensen(log, conn) {
try { try {
rst = decodeMessage(bview, startIndex, buffLength); rst = decodeMessage(bview, startIndex, buffLength);
} catch (e) { } catch (e) {
Logger.error('jensen', 'decode', String(e));
crash = true; crash = true;
break; break;
} }
...@@ -964,6 +967,10 @@ Jensen.prototype.getFile = async function (filename, length, ondata, onprogress) ...@@ -964,6 +967,10 @@ Jensen.prototype.getFile = async function (filename, length, ondata, onprogress)
this.send(new Command(TRANSFER_FILE).body(fname)); this.send(new Command(TRANSFER_FILE).body(fname));
}; };
Jensen.prototype.getAndDecode = async function () {
// 版本兼容
}
Jensen.prototype.requestFirmwareUpgrade = async function (versionNumber, fileSize, seconds) { Jensen.prototype.requestFirmwareUpgrade = async function (versionNumber, fileSize, seconds) {
let data = []; let data = [];
data[0] = (versionNumber >> 24) & 0xff; data[0] = (versionNumber >> 24) & 0xff;
......
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