Skip to content

Commit

Permalink
Merge pull request #77 from p9malino26/auto-refresh
Browse files Browse the repository at this point in the history
auto-refresh from radio at interval
  • Loading branch information
sachaw authored Dec 11, 2023
2 parents 4912930 + 8836dce commit 77c8f86
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/adapters/bleConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export class BleConnection extends MeshDevice {
/** Short Description */
private fromNumCharacteristic: BluetoothRemoteGATTCharacteristic | undefined;

private timerUpdateFromRadio: NodeJS.Timeout | null = null;

constructor(configId?: number) {
super(configId);

Expand Down Expand Up @@ -183,13 +185,18 @@ export class BleConnection extends MeshDevice {
void this.configure().catch(() => {
// TODO: FIX, workaround for `wantConfigId` not getting acks.
});


this.timerUpdateFromRadio = setInterval(() => this.readFromRadio(), 1000);
}

/** Disconnects from the Meshtastic device */
public disconnect(): void {
this.device?.gatt?.disconnect();
this.updateDeviceStatus(Types.DeviceStatusEnum.DEVICE_DISCONNECTED);
this.complete();
clearInterval(this.timerUpdateFromRadio!);
this.timerUpdateFromRadio = null;
}

/**
Expand Down

0 comments on commit 77c8f86

Please sign in to comment.