Commit fc068882 authored by martin hou's avatar martin hou

feat: 增加initialize方法用于连接初始化

parent 898c9a67
...@@ -101,6 +101,7 @@ export type Logger = { ...@@ -101,6 +101,7 @@ export type Logger = {
declare class Jensen { declare class Jensen {
constructor(log?: Logger, conn?: USBDevice); constructor(log?: Logger, conn?: USBDevice);
init: () => Promise<boolean>; init: () => Promise<boolean>;
initialize: () => Promise<boolean>;
connect: () => Promise<void>; connect: () => Promise<void>;
onconnect: () => void; onconnect: () => void;
disconnect: () => void; disconnect: () => void;
......
...@@ -149,10 +149,13 @@ async function Jensen(log, conn) { ...@@ -149,10 +149,13 @@ async function Jensen(log, conn) {
} }
}; };
if (conn) this.initialize = async function() {
{ if (conn)
if (!conn.opened) conn.open(); {
await setup(); if (!conn.opened) conn.open();
await setup();
}
return true;
} }
this.reconnect = async function () { this.reconnect = async function () {
......
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