From: Jérôme Benoit Date: Mon, 7 Feb 2022 10:16:59 +0000 (+0100) Subject: Fix charging station initial registration at boot notification X-Git-Tag: v1.1.45~3 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=73c4266dacc6883a6089ed86725e4c19842cdad8;p=e-mobility-charging-stations-simulator.git Fix charging station initial registration at boot notification Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 99e8f5ee..48833337 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -123,6 +123,10 @@ export default class ChargingStation { return this?.wsConnection?.readyState === OPEN; } + public isInUnknownState(): boolean { + return Utils.isNullOrUndefined(this?.bootNotificationResponse?.status); + } + public isInPendingState(): boolean { return this?.bootNotificationResponse?.status === RegistrationStatus.PENDING; } @@ -136,7 +140,7 @@ export default class ChargingStation { } public isRegistered(): boolean { - return this.isInAcceptedState() || this.isInPendingState(); + return !this.isInUnknownState() && (this.isInAcceptedState() || this.isInPendingState()); } public isChargingStationAvailable(): boolean { diff --git a/src/charging-station/ocpp/OCPPRequestService.ts b/src/charging-station/ocpp/OCPPRequestService.ts index 14cab283..af116c4e 100644 --- a/src/charging-station/ocpp/OCPPRequestService.ts +++ b/src/charging-station/ocpp/OCPPRequestService.ts @@ -32,7 +32,8 @@ export default abstract class OCPPRequestService { }): Promise { if (this.chargingStation.isInRejectedState() || (this.chargingStation.isInPendingState() && !params.triggerMessage)) { throw new OCPPError(ErrorType.SECURITY_ERROR, 'Cannot send command payload if the charging station is not in accepted state', commandName); - } else if (this.chargingStation.isInAcceptedState() || (this.chargingStation.isInPendingState() && params.triggerMessage)) { + } else if ((this.chargingStation.isInUnknownState() && commandName === RequestCommand.BOOT_NOTIFICATION) + || this.chargingStation.isInAcceptedState() || (this.chargingStation.isInPendingState() && params.triggerMessage)) { // eslint-disable-next-line @typescript-eslint/no-this-alias const self = this; // Send a message through wsConnection