From: Jérôme Benoit Date: Thu, 14 Jan 2021 22:22:21 +0000 (+0100) Subject: Handle missing interval in boot notification response. X-Git-Tag: v1.0.1-0~145 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=c55b9bc2299d35c3950f450f8a221e1666f9eca0;p=e-mobility-charging-stations-simulator.git Handle missing interval in boot notification response. Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index dce900c7..5bf359b6 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -661,7 +661,7 @@ export default class ChargingStation { this._bootNotificationResponse = await this.sendBootNotification(); if (!this._isRegistered()) { registrationRetryCount++; - await Utils.sleep(this._bootNotificationResponse.interval * 1000); + await Utils.sleep(this._bootNotificationResponse?.interval ? this._bootNotificationResponse.interval * 1000 : Constants.OCPP_DEFAULT_BOOT_NOTIFICATION_INTERVAL); } } while (!this._isRegistered() && (registrationRetryCount <= this._getRegistrationMaxRetries() || this._getRegistrationMaxRetries() === -1)); } diff --git a/src/utils/Constants.ts b/src/utils/Constants.ts index 9beebf4f..7afe4cac 100644 --- a/src/utils/Constants.ts +++ b/src/utils/Constants.ts @@ -27,6 +27,7 @@ export default class Constants { static readonly OCPP_VERSION_16 = '1.6'; static readonly OCPP_VERSION_20 = '2.0'; + static readonly OCPP_DEFAULT_BOOT_NOTIFICATION_INTERVAL = 60000; // Ms static readonly OCPP_ERROR_TIMEOUT = 60000; // 60 sec static readonly CHARGING_STATION_DEFAULT_RESET_TIME = 60000; // Ms