From c55b9bc2299d35c3950f450f8a221e1666f9eca0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Thu, 14 Jan 2021 23:22:21 +0100 Subject: [PATCH] Handle missing interval in boot notification response. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/charging-station/ChargingStation.ts | 2 +- src/utils/Constants.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) 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 -- 2.34.1