fix: add charging station status checkpoints to firmware update
[e-mobility-charging-stations-simulator.git] / src / charging-station / ocpp / OCPPServiceUtils.ts
index 9d410963ddd8dcf9210d10ae346ebc1f673acc6f..26b7a4ee5ccc4db42c48209eade339d08e2bf941 100644 (file)
@@ -24,10 +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 { Constants, FileUtils, Utils, logger } from '../../utils';
 
 export class OCPPServiceUtils {
   protected constructor() {
@@ -169,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,