X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=inline;f=src%2Fcharging-station%2FChargingStation.js;h=52d54958fa4e0ad003de9de88465becd944a2c35;hb=0bbcb3dc3d1b75955b816452fc0050d401e96fca;hp=b0a461fadd6f8269af2c902f727dccbecffc40a7;hpb=72766a82a1372713a48d9e7143a0348d7fd56a29;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ChargingStation.js b/src/charging-station/ChargingStation.js index b0a461fa..52d54958 100644 --- a/src/charging-station/ChargingStation.js +++ b/src/charging-station/ChargingStation.js @@ -172,6 +172,14 @@ class ChargingStation { onOpen() { logger.info(`${this._basicFormatLog()} Is connected to server through ${this._url}`); + if (!this._heartbeatInterval) { + // Send BootNotification + try { + this.sendMessage(Utils.generateUUID(), this._bootNotificationMessage, Constants.OCPP_JSON_CALL_MESSAGE, 'BootNotification'); + } catch (error) { + logger.error(this._basicFormatLog() + ' Send boot notification error: ' + error); + } + } if (this._isSocketRestart) { this._basicStartMessageSequence(); if (this._messageQueue.length > 0) { @@ -181,13 +189,6 @@ class ChargingStation { } }); } - } else { - // At first start, send BootNotification - try { - this.sendMessage(Utils.generateUUID(), this._bootNotificationMessage, Constants.OCPP_JSON_CALL_MESSAGE, 'BootNotification'); - } catch (error) { - logger.error(this._basicFormatLog() + ' Send boot notification error: ' + error); - } } this._autoReconnectRetryCount = 0; this._isSocketRestart = false; @@ -286,7 +287,6 @@ class ChargingStation { // 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 = { @@ -297,6 +297,7 @@ class ChargingStation { logger.error(self._basicFormatLog() + ' Send heartbeat error: ' + error); } }, self._heartbeatInterval); + logger.info(self._basicFormatLog() + ' Heartbeat started every ' + self._heartbeatInterval + 'ms'); } else { logger.error(self._basicFormatLog() + ' Heartbeat interval undefined, not starting the heartbeat'); }