Commit b4133679 authored by martin hou's avatar martin hou

fix: debug

parent 9c551795
......@@ -86,7 +86,7 @@ export function Home() {
const listFiles = async () => {
let fc = await jensen.getFileCount();
alert(fc?.count);
// alert(fc?.count);
let files = await jensen.listFiles();
setFiles(files)
}
......
......@@ -89,6 +89,7 @@ function Jensen(log, conn) {
let self = this;
this.data = {};
this.sqidx = new Date().getTime();
// 消息
this.decodeTimeout = 0;
this.timewait = 1;
......@@ -161,6 +162,10 @@ function Jensen(log, conn) {
return true;
}
this.sequence = function() {
return this.sqidx ++;
}
this.reconnect = async function () {
try
{
......@@ -441,10 +446,10 @@ function Jensen(log, conn) {
let handler = handlers[msg.id];
if (!handler) handler = Jensen.handlers[msg.id];
let r = handler(msg, self);
if (r) trigger(r, msg.id);
if (r) console.log('x111111111111'), trigger(r, msg.id);
} catch (e) {
console.error(e);
trigger(e);
console.log('x22222222222222'), trigger(e);
Logger.error('jensen', 'receive', pid + '-recv: ' + msg.id + ', seq: ' + msg.sequence + ', error: ' + String(e));
}
sendNext();
......@@ -459,9 +464,12 @@ function Jensen(log, conn) {
if (!handler) handler = Jensen.handlers[msgid];
handler(null, self);
} catch (e) {
console.log('x3333333333333333');
console.error(e);
trigger(e);
Logger.error('jensen', 'decode', 'decode error: ' + String(e));
}
console.log('x44444444444444444444'),
trigger(null, msgid);
blocks.length = 0;
break;
......@@ -657,7 +665,7 @@ Jensen.prototype.getBluetoothStatus = async function (seconds) {
};
Jensen.prototype.listFiles = async function () {
let tag = 'filelist-' + this.serialNumber + '-' + new Date().getTime();
let tag = 'filelist-' + this.serialNumber + '-' + this.sequence();
if (this[tag] != null) return null;
let fc = null;
......@@ -672,6 +680,7 @@ Jensen.prototype.listFiles = async function () {
// let tag = 'data_' + new Date().getTime();
this[tag] = [];
this.registerHandler(QUERY_FILE_LIST, (msg, jensen) => {
console.log('tag', tag);
if (msg.body.length == 0) {
jensen[tag] = null;
return [];
......
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