Improve changeConfiguration.
authorJérôme Benoit <jerome.benoit@sap.com>
Sun, 18 Oct 2020 13:58:00 +0000 (15:58 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Sun, 18 Oct 2020 13:58:00 +0000 (15:58 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/assets/station-templates/abb.station-template.json
src/charging-station/ChargingStation.js
src/utils/Constants.js

index 922ec8f19a078b590b329d23fc276b5e25580437..6faab07844774f38a1cc56cc30bf53f78a7ab41c 100644 (file)
@@ -35,7 +35,8 @@
         "key": "VendorKey",
         "readonly": false,
         "value": "VendorValue",
-        "visible": false
+        "visible": false,
+        "reboot": true
       }
     ]
   },
index abfd92638df099e900ff46977a5d573ba3b41368..a99e488740704589f7ea9925545076adba83513a 100644 (file)
@@ -649,12 +649,18 @@ class ChargingStation {
 
   async handleChangeConfiguration(commandPayload) {
     const keyToChange = this._getConfigurationKey(commandPayload.key);
-    if (keyToChange && !Utils.convertToBoolean(keyToChange.readonly)) {
+    if (!keyToChange) {
+      return {status: Constants.OCPP_ERROR_NOT_SUPPORTED};
+    } else if (keyToChange && Utils.convertToBoolean(keyToChange.readonly)) {
+      return Constants.OCPP_RESPONSE_REJECTED;
+    } else if (keyToChange && !Utils.convertToBoolean(keyToChange.readonly)) {
       const keyIndex = this._configuration.configurationKey.indexOf(keyToChange);
       this._configuration.configurationKey[keyIndex].value = commandPayload.value;
+      if (Utils.convertToBoolean(keyToChange.reboot)) {
+        return Constants.OCPP_RESPONSE_REBOOT_REQUIRED;
+      }
       return Constants.OCPP_RESPONSE_ACCEPTED;
     }
-    return Constants.OCPP_RESPONSE_REJECTED;
   }
 
   async handleRemoteStartTransaction(commandPayload) {
index b5b55cc330638e54e333184c2315da4920e60aa8..8873280f3629ba05093d3385a55595027ae1ee2a 100644 (file)
@@ -103,6 +103,7 @@ class Constants {
 
   static OCPP_RESPONSE_ACCEPTED = {status: 'Accepted'};
   static OCPP_RESPONSE_REJECTED = {status: 'Rejected'};
+  static OCPP_RESPONSE_REBOOT_REQUIRED = {status: 'RebootRequired'};
   static OCPP_SOCKET_TIMEOUT = 60000; // 60 sec
   static OCPP_JSON_CALL_MESSAGE = 2; // Client-to-Server
   static OCPP_JSON_CALL_RESULT_MESSAGE = 3; // Server-to-Client