Commit b4133679 authored by martin hou's avatar martin hou

fix: debug

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