diff --git a/src/adapters/serialConnection.ts b/src/adapters/serialConnection.ts index 9e2b492..13a402b 100644 --- a/src/adapters/serialConnection.ts +++ b/src/adapters/serialConnection.ts @@ -25,7 +25,7 @@ export class SerialConnection extends MeshDevice { * through a transform stream (https://stackoverflow.com/questions/71262432) */ private pipePromise?: Promise; - /* Reference for the heartbeat ping interval so it can be canceled on disconnect. */ + /* Reference for the heartbeat ping interval so it can be canceled on disconnect. */ private heartbeatInterval?: ReturnType | undefined; /** @@ -161,9 +161,9 @@ export class SerialConnection extends MeshDevice { // The firmware requires at least one ping per 15 minutes, so this should be more than enough. this.heartbeatInterval = setInterval(() => { this.heartbeat().catch((err) => { - console.error('Heartbeat error', err); + console.error("Heartbeat error", err); }); - }, 60*1000); + }, 60 * 1000); } else { console.log("not readable or writable"); } @@ -193,11 +193,11 @@ export class SerialConnection extends MeshDevice { if (this.port?.readable) { await this.port?.close(); } - + // stop the interval when disconnecting. if (this.heartbeatInterval) { clearInterval(this.heartbeatInterval); - this.heartbeatInterval = undefined; + this.heartbeatInterval = undefined; } // ------- this.updateDeviceStatus(Types.DeviceStatusEnum.DeviceDisconnected); diff --git a/src/index.ts b/src/index.ts index 2e94149..8743e05 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,3 +5,8 @@ export * from "./meshDevice.ts"; export * as Protobuf from "@meshtastic/protobufs"; export * as Types from "./types.ts"; export * as Utils from "./utils/index.ts"; +export { + create as createProtobuf, + fromBinary, + toBinary, +} from "@bufbuild/protobuf"; diff --git a/src/types.ts b/src/types.ts index e1edca1..25bb0ca 100644 --- a/src/types.ts +++ b/src/types.ts @@ -145,7 +145,11 @@ export enum ChannelNumber { Admin = 7, } -export type ConnectionType = BleConnection | HttpConnection | NodeSerialConnection | SerialConnection; +export type ConnectionType = + | BleConnection + | HttpConnection + | NodeSerialConnection + | SerialConnection; export type ConnectionTypeName = "ble" | "http" | "serial";