Skip to content

Commit

Permalink
fix a few items
Browse files Browse the repository at this point in the history
  • Loading branch information
benbrown committed Nov 23, 2024
1 parent 8d5532f commit eebf0b6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/adapters/serialConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class SerialConnection extends MeshDevice {
* through a transform stream (https://stackoverflow.com/questions/71262432) */
private pipePromise?: Promise<void>;

/* 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<typeof setInterval> | undefined;

/**
Expand Down Expand Up @@ -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");
}
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
6 changes: 5 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down

0 comments on commit eebf0b6

Please sign in to comment.