Handle missing interval in boot notification response.
authorJérôme Benoit <jerome.benoit@sap.com>
Thu, 14 Jan 2021 22:22:21 +0000 (23:22 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Thu, 14 Jan 2021 22:22:21 +0000 (23:22 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ChargingStation.ts
src/utils/Constants.ts

index dce900c758c224982e6fa2703c4ac8e1b53c06b3..5bf359b632f9c906923b7304daac47ebfedd28ea 100644 (file)
@@ -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));
     }
index 9beebf4f7e95830932d36d5411bfe5c6cfb1da38..7afe4cac1b5ba0ea973b0c2858be8dd208b6ea7e 100644 (file)
@@ -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