+ // eslint-disable-next-line class-methods-use-this
+ async _startHeartbeat(self) {
+ if (self._heartbeatInterval && !self._heartbeatSetInterval) {
+ logger.info(self._basicFormatLog() + ' Heartbeat started every ' + self._heartbeatInterval + 'ms');
+ self._heartbeatSetInterval = setInterval(() => {
+ try {
+ const payload = {
+ currentTime: new Date().toISOString(),
+ };
+ self.sendMessage(Utils.generateUUID(), payload, Constants.OCPP_JSON_CALL_MESSAGE, 'Heartbeat');
+ } catch (error) {
+ logger.error(self._basicFormatLog() + ' Send heartbeat error: ' + error);
+ }
+ }, self._heartbeatInterval);
+ } else {
+ logger.error(self._basicFormatLog() + ' Heartbeat interval undefined, not starting the heartbeat');
+ }
+ }
+