Commit fc068882 authored by martin hou's avatar martin hou

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

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