X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2Focpp%2FOCPPRequestService.ts;h=da8870292d0d4d3751a11992e473dc05f06b2de5;hb=6114e6f11b3fb12439d464e142fdf93866982b6c;hp=7b179c3fa973ce98855c454227d63b672da52926;hpb=c18084e22955bbbe514bb3ecef8818417407608d;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ocpp/OCPPRequestService.ts b/src/charging-station/ocpp/OCPPRequestService.ts index 7b179c3f..da887029 100644 --- a/src/charging-station/ocpp/OCPPRequestService.ts +++ b/src/charging-station/ocpp/OCPPRequestService.ts @@ -30,9 +30,8 @@ export default abstract class OCPPRequestService { skipBufferingOnError: false, triggerMessage: false }): 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.isInUnknownState() && (commandName === RequestCommand.BOOT_NOTIFICATION || commandName === IncomingRequestCommand.CHANGE_CONFIGURATION)) + if ((this.chargingStation.isInUnknownState() && commandName === RequestCommand.BOOT_NOTIFICATION) + || (!this.chargingStation.getOcppStrictCompliance() && this.chargingStation.isInUnknownState()) || this.chargingStation.isInAcceptedState() || (this.chargingStation.isInPendingState() && params.triggerMessage)) { // eslint-disable-next-line @typescript-eslint/no-this-alias const self = this; @@ -107,13 +106,12 @@ export default abstract class OCPPRequestService { }), Constants.OCPP_WEBSOCKET_TIMEOUT, new OCPPError(ErrorType.GENERIC_ERROR, `Timeout for message id '${messageId}'`, commandName, messageData?.details as JsonType ?? {}), () => { messageType === MessageType.CALL_MESSAGE && this.chargingStation.requests.delete(messageId); }); - } else { - throw new OCPPError(ErrorType.SECURITY_ERROR, 'Cannot send command payload if the charging station is in unknown state', commandName); } + throw new OCPPError(ErrorType.SECURITY_ERROR, `Cannot send command ${commandName} payload when the charging station is in ${this.chargingStation.getRegistrationStatus()} state on the central server`, commandName); } protected handleRequestError(commandName: RequestCommand, error: Error): void { - logger.error(this.chargingStation.logPrefix() + ' Request command ' + commandName + ' error: %j', error); + logger.error(this.chargingStation.logPrefix() + ' Request command %s error: %j', commandName, error); throw error; }