Allow incoming ChangeConfiguration requests before the registration on
authorJérôme Benoit <jerome.benoit@sap.com>
Mon, 7 Feb 2022 13:36:16 +0000 (14:36 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Mon, 7 Feb 2022 13:36:16 +0000 (14:36 +0100)
OCPP server

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 4988a9ef491f6187f62916fa5ae7fb7e6ef24b96..03a06960400c1e7ff6f24490afaf76536b803930 100644 (file)
@@ -52,7 +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);
     }
-    if (this.chargingStation.isRegistered()) {
+    // FIXME: Add template tunable for accepting incoming ChangeConfiguration request while in unknown state
+    if (this.chargingStation.isRegistered() || (this.chargingStation.isInUnknownState() && commandName === OCPP16IncomingRequestCommand.CHANGE_CONFIGURATION)) {
       if (this.incomingRequestHandlers.has(commandName)) {
         try {
           // Call the method to build the result
index af116c4ec92acb366230c54fb1cdd4c181a584fa..7b179c3fa973ce98855c454227d63b672da52926 100644 (file)
@@ -32,7 +32,7 @@ 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);
-    } else if ((this.chargingStation.isInUnknownState() && commandName === RequestCommand.BOOT_NOTIFICATION)
+    } else if ((this.chargingStation.isInUnknownState() && (commandName === RequestCommand.BOOT_NOTIFICATION || commandName === IncomingRequestCommand.CHANGE_CONFIGURATION))
       || this.chargingStation.isInAcceptedState() || (this.chargingStation.isInPendingState() && params.triggerMessage)) {
       // eslint-disable-next-line @typescript-eslint/no-this-alias
       const self = this;