Relax OCPP commands acceptance while the charging station is in unknown
authorJérôme Benoit <jerome.benoit@sap.com>
Mon, 7 Feb 2022 19:44:21 +0000 (20:44 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Mon, 7 Feb 2022 19:44:21 +0000 (20:44 +0100)
state

Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts
src/charging-station/ocpp/OCPPRequestService.ts

index 03a06960400c1e7ff6f24490afaf76536b803930..72e4d316d69f7f08d2bbe4489cd264d433fb10cc 100644 (file)
@@ -52,8 +52,8 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
       && (commandName === OCPP16IncomingRequestCommand.REMOTE_START_TRANSACTION || commandName === OCPP16IncomingRequestCommand.REMOTE_STOP_TRANSACTION)) {
       throw new OCPPError(ErrorType.SECURITY_ERROR, `${commandName} cannot be issued to handle request payload ${JSON.stringify(commandPayload, null, 2)} while charging station is in pending state`, commandName);
     }
-    // FIXME: Add template tunable for accepting incoming ChangeConfiguration request while in unknown state
-    if (this.chargingStation.isRegistered() || (this.chargingStation.isInUnknownState() && commandName === OCPP16IncomingRequestCommand.CHANGE_CONFIGURATION)) {
+    // FIXME: Add template tunable for accepting incoming configuration requests while in unknown state
+    if (this.chargingStation.isRegistered() || (this.chargingStation.isInUnknownState() && (commandName === OCPP16IncomingRequestCommand.GET_CONFIGURATION || commandName === OCPP16IncomingRequestCommand.CHANGE_CONFIGURATION || commandName === OCPP16IncomingRequestCommand.CHANGE_AVAILABILITY || commandName === OCPP16IncomingRequestCommand.TRIGGER_MESSAGE))) {
       if (this.incomingRequestHandlers.has(commandName)) {
         try {
           // Call the method to build the result
index 2ec7424b1c3e658472f4d51a3bffb125d43984e8..666ee577dec6da25f5043a2e0d8eb116d3ddf79f 100644 (file)
@@ -32,8 +32,8 @@ export default abstract class OCPPRequestService {
       }): Promise<JsonType | OCPPError | string> {
     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);
-    // FIXME: Add template tunable for accepting incoming ChangeConfiguration request while in unknown state
-    } else if ((this.chargingStation.isInUnknownState() && (commandName === RequestCommand.BOOT_NOTIFICATION || commandName === IncomingRequestCommand.CHANGE_CONFIGURATION))
+    // FIXME: Add template tunable for accepting incoming configuration requests while in unknown state
+    } else if ((this.chargingStation.isInUnknownState() && (commandName === RequestCommand.BOOT_NOTIFICATION || commandName === IncomingRequestCommand.GET_CONFIGURATION || commandName === IncomingRequestCommand.CHANGE_CONFIGURATION || commandName === IncomingRequestCommand.CHANGE_AVAILABILITY || commandName === IncomingRequestCommand.TRIGGER_MESSAGE))
       || this.chargingStation.isInAcceptedState() || (this.chargingStation.isInPendingState() && params.triggerMessage)) {
       // eslint-disable-next-line @typescript-eslint/no-this-alias
       const self = this;