From eebf0b675435a62fbb8fb58057f5cd2702e0c520 Mon Sep 17 00:00:00 2001 From: Ben Brown Date: Fri, 22 Nov 2024 19:56:28 -0600 Subject: [PATCH] fix a few items --- src/adapters/serialConnection.ts | 10 +++++----- src/index.ts | 5 +++++ src/types.ts | 6 +++++- 3 files changed, 15 insertions(+), 6 deletions(-) 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";