fix: add charging station status checkpoints to firmware update
[e-mobility-charging-stations-simulator.git] / src / charging-station / ocpp / OCPPServiceUtils.ts
index 4b232033f70b1f71509e8034b4b6978a3a8194d8..26b7a4ee5ccc4db42c48209eade339d08e2bf941 100644 (file)
@@ -2,6 +2,7 @@ import fs from 'node:fs';
 
 import type { DefinedError, ErrorObject, JSONSchemaType } from 'ajv';
 
+import { type ChargingStation, ChargingStationConfigurationUtils } from '../../charging-station';
 import { BaseError } from '../../exception';
 import {
   ChargePointErrorCode,
@@ -23,12 +24,7 @@ import {
   StandardParametersKey,
   type StatusNotificationRequest,
 } from '../../types';
-import { Constants } from '../../utils/Constants';
-import { FileUtils } from '../../utils/FileUtils';
-import { logger } from '../../utils/Logger';
-import { Utils } from '../../utils/Utils';
-import type { ChargingStation } from '../ChargingStation';
-import { ChargingStationConfigurationUtils } from '../ChargingStationConfigurationUtils';
+import { Constants, FileUtils, Utils, logger } from '../../utils';
 
 export class OCPPServiceUtils {
   protected constructor() {
@@ -170,6 +166,14 @@ export class OCPPServiceUtils {
     }
   }
 
+  public static startHeartbeatInterval(chargingStation: ChargingStation, interval: number): void {
+    if (!chargingStation.heartbeatSetInterval) {
+      chargingStation.startHeartbeat();
+    } else if (chargingStation.getHeartbeatInterval() !== interval) {
+      chargingStation.restartHeartbeat();
+    }
+  }
+
   protected static parseJsonSchemaFile<T extends JsonType>(
     filePath: string,
     ocppVersion: OCPPVersion,